ARTEMIS-765 Improve Checkstyle
diff --git a/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java b/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
index df4c61b..8049a97 100644
--- a/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
+++ b/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
@@ -67,12 +67,10 @@
if (getNativeVersion() != EXPECTED_NATIVE_VERSION) {
NativeLogger.LOGGER.incompatibleNativeLibrary();
return false;
- }
- else {
+ } else {
return true;
}
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
NativeLogger.LOGGER.debug(name + " -> error loading the native library", e);
return false;
}
@@ -93,8 +91,7 @@
}
});
break;
- }
- else {
+ } else {
NativeLogger.LOGGER.debug("Library " + library + " not found!");
}
}
@@ -161,16 +158,14 @@
try {
contexts.incrementAndGet();
this.ioContext = newContext(queueSize);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw e;
}
this.queueSize = queueSize;
totalMaxIO.addAndGet(queueSize);
if (useSemaphore) {
this.ioSpace = new Semaphore(queueSize);
- }
- else {
+ } else {
this.ioSpace = null;
}
}
@@ -197,8 +192,7 @@
if (ioSpace != null) {
ioSpace.acquire();
}
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e.getMessage(), e);
}
@@ -217,8 +211,7 @@
if (ioSpace != null) {
ioSpace.acquire();
}
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e.getMessage(), e);
}
@@ -238,8 +231,7 @@
if (ioSpace != null) {
try {
ioSpace.tryAcquire(queueSize, 10, TimeUnit.SECONDS);
- }
- catch (Exception e) {
+ } catch (Exception e) {
NativeLogger.LOGGER.error(e);
}
}
diff --git a/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java b/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java
index 92a6733..43d80ea 100644
--- a/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java
+++ b/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java
@@ -121,8 +121,7 @@
public void fill(long size) {
try {
LibaioContext.fill(fd, size);
- }
- catch (OutOfMemoryError e) {
+ } catch (OutOfMemoryError e) {
NativeLogger.LOGGER.debug("Didn't have enough memory to allocate " + size + " bytes in memory, using simple fallocate");
LibaioContext.fallocate(fd, size);
}
diff --git a/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java b/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java
index 2205103..afde2fc 100644
--- a/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java
+++ b/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -42,8 +42,7 @@
synchronized (lock) {
if (available <= 0) {
return null;
- }
- else {
+ } else {
Callback retValue = (Callback) pool[get];
pool[get] = null;
if (retValue == null) {
diff --git a/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java b/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java
index 6785d78..bed9da3 100644
--- a/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java
+++ b/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -14,13 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.artemis.jlibaio.test;
import java.util.HashSet;
-import org.apache.activemq.artemis.jlibaio.util.CallbackCache;
import org.apache.activemq.artemis.jlibaio.SubmitInfo;
+import org.apache.activemq.artemis.jlibaio.util.CallbackCache;
import org.junit.Assert;
import org.junit.Test;
diff --git a/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java b/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java
index fec742c..7f98f0d 100644
--- a/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java
+++ b/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java
@@ -53,19 +53,16 @@
try {
parent.mkdirs();
-
boolean failed = false;
try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) {
fileDescriptor.fallocate(4 * 1024);
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
failed = true;
}
Assume.assumeFalse("There is not enough support to libaio", failed);
- }
- finally {
+ } finally {
file.delete();
}
}
@@ -218,8 +215,7 @@
file.close();
}
- }
- finally {
+ } finally {
LibaioContext.freeBuffer(buffer);
}
}
@@ -270,8 +266,7 @@
for (int i = 0; i < 512; i++) {
Assert.assertEquals('B', buffer.get());
}
- }
- finally {
+ } finally {
LibaioContext.freeBuffer(buffer);
fileDescriptor.close();
}
@@ -330,8 +325,7 @@
for (int i = 0; i < BUFFER_SIZE; i++) {
Assert.assertEquals('B', buffer.get());
}
- }
- finally {
+ } finally {
fileDescriptor.close();
}
}
@@ -372,8 +366,7 @@
for (int i = 0; i < BUFFER_SIZE; i++) {
Assert.assertEquals('@', buffer.get());
}
- }
- finally {
+ } finally {
LibaioContext.freeBuffer(buffer);
fileDescriptor.close();
}
@@ -432,8 +425,7 @@
callback = null;
TestInfo.checkLeaks();
- }
- finally {
+ } finally {
fileDescriptor.close();
}
}
@@ -470,8 +462,7 @@
}
TestInfo.checkLeaks();
- }
- finally {
+ } finally {
LibaioContext.freeBuffer(bufferWrite);
}
}
@@ -501,8 +492,7 @@
boolean failed = false;
try {
LibaioContext.freeBuffer(null);
- }
- catch (Exception expected) {
+ } catch (Exception expected) {
failed = true;
}
@@ -546,8 +536,7 @@
try {
// There is no space for a queue this huge, the native layer should throw the exception
LibaioContext newController = new LibaioContext(Integer.MAX_VALUE, false);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
exceptionThrown = true;
}
@@ -557,8 +546,7 @@
try {
// this should throw an exception, we shouldn't be able to open a directory!
control.openFile(temporaryFolder.getRoot(), true);
- }
- catch (IOException expected) {
+ } catch (IOException expected) {
exceptionThrown = true;
}
@@ -570,8 +558,7 @@
fileDescriptor.close();
try {
fileDescriptor.close();
- }
- catch (IOException expected) {
+ } catch (IOException expected) {
exceptionThrown = true;
}
@@ -593,8 +580,7 @@
boolean ex = false;
try {
fileDescriptor.write(0, 512, buffer, new TestInfo());
- }
- catch (Exception e) {
+ } catch (Exception e) {
ex = true;
}
@@ -623,8 +609,7 @@
exceptionThrown = false;
try {
LibaioContext.newAlignedBuffer(300, 512);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
exceptionThrown = true;
}
@@ -633,14 +618,12 @@
exceptionThrown = false;
try {
LibaioContext.newAlignedBuffer(-512, 512);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
- }
- finally {
+ } finally {
LibaioContext.freeBuffer(buffer);
}
}
diff --git a/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java b/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java
index 6c7d69b..c04bff4 100644
--- a/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java
+++ b/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -48,7 +48,8 @@
@Test
public void testRepeatOpenCloseContext() throws Exception {
ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512);
- for (int i = 0; i < 512; i++) buffer.put((byte)'x');
+ for (int i = 0; i < 512; i++)
+ buffer.put((byte) 'x');
for (int i = 0; i < 10; i++) {
System.out.println("#test " + i);
@@ -75,8 +76,7 @@
insideMethod.countDown();
try {
awaitInside.await();
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
System.out.println("done");
@@ -98,17 +98,16 @@
awaitInside.countDown();
control.close();
-
t.join();
}
-
}
@Test
public void testRepeatOpenCloseContext2() throws Exception {
ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512);
- for (int i = 0; i < 512; i++) buffer.put((byte)'x');
+ for (int i = 0; i < 512; i++)
+ buffer.put((byte) 'x');
for (int i = 0; i < 10; i++) {
System.out.println("#test " + i);
@@ -135,8 +134,7 @@
insideMethod.countDown();
try {
awaitInside.await(100, TimeUnit.MILLISECONDS);
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
}
System.out.println("done");
@@ -162,7 +160,6 @@
t.join();
}
-
}
@Test
@@ -173,7 +170,6 @@
control.close();
control.poll();
-
control2.close();
control2.poll();