Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1E5F2200BBA for ; Fri, 30 Sep 2016 17:26:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1D269160AE5; Fri, 30 Sep 2016 15:26:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C2DB4160AF1 for ; Fri, 30 Sep 2016 17:26:07 +0200 (CEST) Received: (qmail 90707 invoked by uid 500); 30 Sep 2016 15:26:06 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 87120 invoked by uid 99); 30 Sep 2016 15:26:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Sep 2016 15:26:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 99302DFF03; Fri, 30 Sep 2016 15:26:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: martyntaylor@apache.org To: commits@activemq.apache.org Date: Fri, 30 Sep 2016 15:26:48 -0000 Message-Id: <6e297a920a224feaad0424c37dc617d1@git.apache.org> In-Reply-To: <5ac6d0226a5f467aa1c95175e44ed5d6@git.apache.org> References: <5ac6d0226a5f467aa1c95175e44ed5d6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [48/52] [partial] activemq-artemis git commit: ARTEMIS-765 Improve Checkstyle archived-at: Fri, 30 Sep 2016 15:26:11 -0000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java index 8379fdf..dbcc8a5 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java @@ -7,7 +7,6 @@ * don't have to match it up with any other open source license &em; just use it. You can rename the files, move the * Java packages, whatever you want. If your lawyers say you have to have a license, contact me, and I'll make a special * release to you under whatever reasonable license you desire: MIT, BSD, GPL, whatever." - * */ package org.apache.activemq.artemis.utils; @@ -313,11 +312,9 @@ public class Base64 { private static byte[] getAlphabet(final int options) { if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) { return Base64._URL_SAFE_ALPHABET; - } - else if ((options & Base64.ORDERED) == Base64.ORDERED) { + } else if ((options & Base64.ORDERED) == Base64.ORDERED) { return Base64._ORDERED_ALPHABET; - } - else { + } else { return Base64._STANDARD_ALPHABET; } @@ -333,11 +330,9 @@ public class Base64 { private static byte[] getDecodabet(final int options) { if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) { return Base64._URL_SAFE_DECODABET; - } - else if ((options & Base64.ORDERED) == Base64.ORDERED) { + } else if ((options & Base64.ORDERED) == Base64.ORDERED) { return Base64._ORDERED_DECODABET; - } - else { + } else { return Base64._STANDARD_DECODABET; } @@ -359,18 +354,15 @@ public class Base64 { public static final void main(final String[] args) { if (args.length < 3) { Base64.usage("Not enough arguments."); - } // end if: args.length < 3 - else { + } else { // end if: args.length < 3 String flag = args[0]; String infile = args[1]; String outfile = args[2]; if (flag.equals("-e")) { Base64.encodeFileToFile(infile, outfile); - } // end if: encode - else if (flag.equals("-d")) { + } else if (flag.equals("-d")) { // end if: encode Base64.decodeFileToFile(infile, outfile); - } // end else if: decode - else { + } else { // end else if: decode Base64.usage("Unknown flag: " + flag); } // end else } // end else @@ -540,37 +532,31 @@ public class Base64 { if (gzip == Base64.GZIP) { gzos = new java.util.zip.GZIPOutputStream(b64os); oos = new java.io.ObjectOutputStream(gzos); - } // end if: gzip - else { + // end if: gzip + } else { oos = new java.io.ObjectOutputStream(b64os); } oos.writeObject(serializableObject); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { e.printStackTrace(); return null; - } // end catch - finally { + } finally { try { oos.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { gzos.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { b64os.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { baos.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -670,35 +656,28 @@ public class Base64 { gzos.write(source, off, len); gzos.close(); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { e.printStackTrace(); return null; - } // end catch - finally { + } finally { try { gzos.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { b64os.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { baos.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally // Return value according to relevant encoding. return new String(baos.toByteArray(), Base64.PREFERRED_ENCODING); - } // end if: compress + } else { // Else, don't compress. Better not to use streams at all then. - // Else, don't compress. Better not to use streams at all then. - else { // Convert option to boolean in way that code likes it. boolean breakLines = dontBreakLines == 0; @@ -775,10 +754,10 @@ public class Base64 { destination[destOffset] = (byte) (outBuff >>> 16); return 1; - } + } else if (source[srcOffset + 3] == Base64.EQUALS_SIGN) { + + // Example: DkL= - // Example: DkL= - else if (source[srcOffset + 3] == Base64.EQUALS_SIGN) { // Two ways to do the same thing. Don't know which way I like best. // int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) @@ -789,10 +768,8 @@ public class Base64 { destination[destOffset] = (byte) (outBuff >>> 16); destination[destOffset + 1] = (byte) (outBuff >>> 8); return 2; - } - - // Example: DkLE - else { + } else { + // Example: DkLE try { // Two ways to do the same thing. Don't know which way I like best. // int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) @@ -808,8 +785,7 @@ public class Base64 { destination[destOffset + 2] = (byte) outBuff; return 3; - } - catch (Exception e) { + } catch (Exception e) { System.out.println("" + source[srcOffset] + ": " + DECODABET[source[srcOffset]]); System.out.println("" + source[srcOffset + 1] + ": " + DECODABET[source[srcOffset + 1]]); System.out.println("" + source[srcOffset + 2] + ": " + DECODABET[source[srcOffset + 2]]); @@ -862,8 +838,7 @@ public class Base64 { } // end if: equals sign or better - } // end if: white space, equals sign or better - else { + } else { System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)"); return null; } // end else: @@ -926,25 +901,20 @@ public class Base64 { // No error? Get new bytes. bytes = baos.toByteArray(); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { // Just return originally-decoded bytes - } // end catch - finally { + } finally { try { baos.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { gzis.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { bais.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -975,25 +945,20 @@ public class Base64 { ois = new java.io.ObjectInputStream(bais); obj = ois.readObject(); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { e.printStackTrace(); obj = null; - } // end catch - catch (java.lang.ClassNotFoundException e) { + } catch (java.lang.ClassNotFoundException e) { e.printStackTrace(); obj = null; - } // end catch - finally { + } finally { try { bais.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { ois.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -1015,16 +980,13 @@ public class Base64 { bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.ENCODE); bos.write(dataToEncode); success = true; - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { success = false; - } // end catch: IOException - finally { + } finally { try { bos.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -1046,15 +1008,12 @@ public class Base64 { bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.DECODE); bos.write(dataToDecode.getBytes(Base64.PREFERRED_ENCODING)); success = true; - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { success = false; - } // end catch: IOException - finally { + } finally { try { bos.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -1098,17 +1057,14 @@ public class Base64 { decodedData = new byte[length]; System.arraycopy(buffer, 0, decodedData, 0, length); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { System.err.println("Error decoding from file " + filename); - } // end catch: IOException - finally { + } finally { try { if (bis != null) { bis.close(); } - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -1145,15 +1101,12 @@ public class Base64 { // Save in a variable to return encodedData = new String(buffer, 0, length, Base64.PREFERRED_ENCODING); - } // end try - catch (java.io.IOException e) { + } catch (java.io.IOException e) { System.err.println("Error encoding from file " + filename); - } // end catch: IOException - finally { + } finally { try { bis.close(); - } - catch (Exception e) { + } catch (Exception e) { } } // end finally @@ -1181,20 +1134,16 @@ public class Base64 { out.write(buffer, 0, read); } // end while: through file success = true; - } - catch (java.io.IOException exc) { + } catch (java.io.IOException exc) { exc.printStackTrace(); - } - finally { + } finally { try { in.close(); - } - catch (Exception exc) { + } catch (Exception exc) { } try { out.close(); - } - catch (Exception exc) { + } catch (Exception exc) { } } // end finally @@ -1222,20 +1171,16 @@ public class Base64 { out.write(buffer, 0, read); } // end while: through file success = true; - } - catch (java.io.IOException exc) { + } catch (java.io.IOException exc) { exc.printStackTrace(); - } - finally { + } finally { try { in.close(); - } - catch (Exception exc) { + } catch (Exception exc) { } try { out.close(); - } - catch (Exception exc) { + } catch (Exception exc) { } } // end finally @@ -1341,8 +1286,7 @@ public class Base64 { numBinaryBytes++; } // end if: not end of stream - } // end try: read - catch (java.io.IOException e) { + } catch (java.io.IOException e) { // Only a problem if we got no data at all. if (i == 0) { throw e; @@ -1355,14 +1299,10 @@ public class Base64 { Base64.encode3to4(b3, 0, numBinaryBytes, buffer, 0, options); position = 0; numSigBytes = 4; - } // end if: got data - else { + } else { return -1; } - } // end if: encoding - - // Else decoding - else { + } else { // Else decoding byte[] b4 = new byte[4]; int i = 0; for (i = 0; i < 4; i++) { @@ -1382,11 +1322,9 @@ public class Base64 { if (i == 4) { numSigBytes = Base64.decode4to3(b4, 0, buffer, 0, options); position = 0; - } // end if: got four characters - else if (i == 0) { + } else if (i == 0) { return -1; - } - else { + } else { // Must have broken out from above. throw new java.io.IOException("Improperly padded Base64 input."); } @@ -1404,8 +1342,7 @@ public class Base64 { if (encode && breakLines && lineLength >= Base64.MAX_LINE_LENGTH) { lineLength = 0; return '\n'; - } // end if - else { + } else { lineLength++; // This isn't important when decoding // but throwing an extra "if" seems // just as wasteful. @@ -1419,8 +1356,7 @@ public class Base64 { return b & 0xFF; // This is how you "cast" a byte that's // intended to be unsigned. } // end else - } // end if: position >= 0 - else { + } else { // When JDK1.4 is more accepted, use an assertion here. throw new java.io.IOException("Error in Base64 code reading stream."); } @@ -1450,11 +1386,9 @@ public class Base64 { if (b >= 0) { dest[off + i] = (byte) b; - } - else if (i == 0) { + } else if (i == 0) { return -1; - } - else { + } else { break; // Out of 'for' loop } } // end for: each byte read @@ -1576,11 +1510,10 @@ public class Base64 { } // end if: end of line position = 0; - } // end if: enough to output - } // end if: encoding + } + } else { + // Else, Decoding - // Else, Decoding - else { // Meaningful Base64 character? if (decodabet[theByte & 0x7f] > Base64.WHITE_SPACE_ENC) { buffer[position++] = (byte) theByte; @@ -1590,8 +1523,7 @@ public class Base64 { // out.write( Base64.decode4to3( buffer ) ); position = 0; } // end if: enough to output - } // end if: meaningful base64 character - else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC) { + } else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC) { throw new java.io.IOException("Invalid character in Base64 data."); } } // end else: decoding @@ -1632,8 +1564,7 @@ public class Base64 { if (encode) { out.write(Base64.encode3to4(b4, buffer, position, options)); position = 0; - } // end if: encoding - else { + } else { throw new java.io.IOException("Base64 input not properly padded."); } } // end if: buffer partially full http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java index c678941..c9143f5 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java @@ -39,8 +39,7 @@ public class ByteUtil { try { logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } @@ -48,7 +47,6 @@ public class ByteUtil { } } - public static String formatGroup(String str, int groupSize, int lineBreak) { StringBuffer buffer = new StringBuffer(); @@ -64,8 +62,7 @@ public class ByteUtil { buffer.append(" "); } buffer.append(Integer.toString(line) + " */ \""); - } - else if ((i + groupSize) % groupSize == 0 && str.length() - i > groupSize) { + } else if ((i + groupSize) % groupSize == 0 && str.length() - i > groupSize) { buffer.append("\" + \""); } } @@ -79,8 +76,7 @@ public class ByteUtil { public static String maxString(String value, int size) { if (value.length() < size) { return value; - } - else { + } else { return value.substring(0, size / 2) + " ... " + value.substring(value.length() - size / 2); } } @@ -138,7 +134,6 @@ public class ByteUtil { return buffer.array(); } - public static String readLine(ActiveMQBuffer buffer) { StringBuilder sb = new StringBuilder(""); char c = buffer.readChar(); @@ -154,8 +149,7 @@ public class ByteUtil { if (buffer.hasArray()) { byte[] array = buffer.array(); System.arraycopy(array, buffer.arrayOffset() + buffer.position(), ret, 0, ret.length); - } - else { + } else { buffer.slice().get(ret); } return ret; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CertificateUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CertificateUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CertificateUtil.java index 5e96687..1c16567 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CertificateUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CertificateUtil.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -25,20 +25,15 @@ import io.netty.channel.ChannelHandler; import io.netty.handler.ssl.SslHandler; public class CertificateUtil { + public static X509Certificate[] getCertsFromChannel(Channel channel) { X509Certificate[] certificates = null; - ChannelHandler channelHandler = channel - .pipeline() - .get("ssl"); + ChannelHandler channelHandler = channel.pipeline().get("ssl"); if (channelHandler != null && channelHandler instanceof SslHandler) { SslHandler sslHandler = (SslHandler) channelHandler; try { - certificates = sslHandler - .engine() - .getSession() - .getPeerCertificateChain(); - } - catch (SSLPeerUnverifiedException e) { + certificates = sslHandler.engine().getSession().getPeerCertificateChain(); + } catch (SSLPeerUnverifiedException e) { // ignore } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java index 707635e..e27ce0c 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java @@ -34,8 +34,7 @@ public final class ClassloadingUtil { try { Class clazz = loader.loadClass(className); return clazz.newInstance(); - } - catch (Throwable t) { + } catch (Throwable t) { if (t instanceof InstantiationException) { System.out.println(INSTANTIATION_EXCEPTION_MESSAGE); } @@ -45,14 +44,11 @@ public final class ClassloadingUtil { try { return loader.loadClass(className).newInstance(); - } - catch (InstantiationException e) { + } catch (InstantiationException e) { throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new IllegalStateException(e); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } @@ -67,8 +63,7 @@ public final class ClassloadingUtil { } Class clazz = loader.loadClass(className); return clazz.getConstructor(parametersType).newInstance(objs); - } - catch (Throwable t) { + } catch (Throwable t) { if (t instanceof InstantiationException) { System.out.println(INSTANTIATION_EXCEPTION_MESSAGE); } @@ -78,14 +73,11 @@ public final class ClassloadingUtil { try { return loader.loadClass(className).newInstance(); - } - catch (InstantiationException e) { + } catch (InstantiationException e) { throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new IllegalStateException(e); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } @@ -97,8 +89,7 @@ public final class ClassloadingUtil { URL resource = loader.getResource(resourceName); if (resource != null) return resource; - } - catch (Throwable t) { + } catch (Throwable t) { } loader = Thread.currentThread().getContextClassLoader(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentUtil.java index 80397c6..db1608e 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentUtil.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java index 9234136..02bec5f 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java @@ -16,16 +16,15 @@ */ package org.apache.activemq.artemis.utils; -import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.Map; - import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Map; /** * A DefaultSensitiveDataCodec http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java index 70b9c83..2dda85f 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java @@ -75,8 +75,7 @@ public class FactoryFinder { if (loader != null) { try { clazz = loader.loadClass(className); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { // ignore } } @@ -108,12 +107,10 @@ public class FactoryFinder { Properties properties = new Properties(); properties.load(reader); return properties; - } - finally { + } finally { try { reader.close(); - } - catch (Exception e) { + } catch (Exception e) { } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java index 76b6db4..00a0e30 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -41,13 +41,11 @@ public class FileUtil { public static void makeExec(File file) throws IOException { try { Files.setPosixFilePermissions(file.toPath(), new HashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, OTHERS_READ, OTHERS_EXECUTE))); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { // Our best effort was not good enough :) } } - public static final boolean deleteDirectory(final File directory) { if (directory.isDirectory()) { String[] files = directory.list(); @@ -56,8 +54,7 @@ public class FileUtil { while (files == null && (attempts < num)) { try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } files = directory.list(); attempts++; @@ -65,8 +62,7 @@ public class FileUtil { if (files == null) { logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath()); - } - else { + } else { for (String file : files) { File f = new File(directory, file); if (!deleteDirectory(f)) { @@ -79,5 +75,4 @@ public class FileUtil { return directory.delete(); } - } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/IPV6Util.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/IPV6Util.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/IPV6Util.java index 15af6e2..395eeeb 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/IPV6Util.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/IPV6Util.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -43,4 +43,4 @@ public class IPV6Util { return host; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java index 6be5e05..2ef0daa 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java @@ -55,8 +55,7 @@ public class PasswordMaskingUtil { try { Class clazz = loader.loadClass(codecClassName); return (SensitiveDataCodec) clazz.newInstance(); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQUtilBundle.BUNDLE.errorCreatingCodec(e, codecClassName); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PendingTask.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PendingTask.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PendingTask.java index fade097..a41318a 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PendingTask.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PendingTask.java @@ -17,9 +17,11 @@ package org.apache.activemq.artemis.utils; -/** This is similar to a Runnable, except that we throw exceptions. - * In certain places we need to complete tasks after deliveries, - * and this will take care of those situations. */ +/** + * This is similar to a Runnable, except that we throw exceptions. + * In certain places we need to complete tasks after deliveries, + * and this will take care of those situations. + */ public abstract class PendingTask { public abstract void run() throws Exception; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/RandomUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/RandomUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/RandomUtil.java index 8aabd1b..1691df1 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/RandomUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/RandomUtil.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java index 9507cb8..3f971fd 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java @@ -50,8 +50,7 @@ public class ReferenceCounterUtil implements ReferenceCounter { if (value == 0) { if (executor != null) { executor.execute(runnable); - } - else { + } else { runnable.run(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SelectorTranslator.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SelectorTranslator.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SelectorTranslator.java index 5515926..637cdff 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SelectorTranslator.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SelectorTranslator.java @@ -100,8 +100,7 @@ public class SelectorTranslator { matchPos = 0; } - } - else { + } else { matchPos = 0; } } @@ -126,8 +125,7 @@ public class SelectorTranslator { } return buff.toString(); - } - else { + } else { return input; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/StringEscapeUtils.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/StringEscapeUtils.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/StringEscapeUtils.java index ecff4da..db18e30 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/StringEscapeUtils.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/StringEscapeUtils.java @@ -20,6 +20,7 @@ package org.apache.activemq.artemis.utils; public abstract class StringEscapeUtils { + /** * Adapted from commons lang StringEscapeUtils, escapes a string * @@ -38,14 +39,11 @@ public abstract class StringEscapeUtils { // handle unicode if (ch > 0xfff) { stringBuilder.append("\\u").append(hex(ch)); - } - else if (ch > 0xff) { + } else if (ch > 0xff) { stringBuilder.append("\\u0").append(hex(ch)); - } - else if (ch > 0x7f) { + } else if (ch > 0x7f) { stringBuilder.append("\\u00").append(hex(ch)); - } - else if (ch < 32) { + } else if (ch < 32) { switch (ch) { case '\b': stringBuilder.append('\\').append('b'); @@ -62,17 +60,15 @@ public abstract class StringEscapeUtils { case '\r': stringBuilder.append('\\').append('r'); break; - default : + default: if (ch > 0xf) { stringBuilder.append("\\u00").append(hex(ch)); - } - else { + } else { stringBuilder.append("\\u000").append(hex(ch)); } break; } - } - else { + } else { switch (ch) { case '\'': stringBuilder.append('\\').append('\''); @@ -86,7 +82,7 @@ public abstract class StringEscapeUtils { case '/': stringBuilder.append('\\').append('/'); break; - default : + default: stringBuilder.append(ch); break; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java index eeb5783..56cec48 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java @@ -154,11 +154,9 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Boolean.valueOf(null); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { return (Boolean) value; - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Boolean.valueOf(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -168,11 +166,9 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Byte.valueOf(null); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return (Byte) value; - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Byte.parseByte(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -194,8 +190,7 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return null; - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { return (byte[]) value; } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -205,14 +200,11 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Double.valueOf(null); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { return ((Float) value).doubleValue(); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { return (Double) value; - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Double.parseDouble(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -222,17 +214,13 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Integer.valueOf(null); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { return (Integer) value; - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return ((Byte) value).intValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return ((Short) value).intValue(); - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Integer.parseInt(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -242,20 +230,15 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Long.valueOf(null); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { return (Long) value; - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return ((Byte) value).longValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return ((Short) value).longValue(); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { return ((Integer) value).longValue(); - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Long.parseLong(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -265,14 +248,11 @@ public final class TypedProperties { Object value = doGetProperty(key); if (value == null) { return Short.valueOf(null); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return ((Byte) value).shortValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return (Short) value; - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { return Short.parseShort(((SimpleString) value).toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -300,29 +280,21 @@ public final class TypedProperties { if (value instanceof SimpleString) { return (SimpleString) value; - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { return new SimpleString(value.toString()); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { return new SimpleString(value.toString()); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return new SimpleString(value.toString()); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return new SimpleString(value.toString()); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { return new SimpleString(value.toString()); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { return new SimpleString(value.toString()); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { return new SimpleString(value.toString()); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { return new SimpleString(value.toString()); } throw new ActiveMQPropertyConversionException("Invalid conversion: " + key); @@ -336,8 +308,7 @@ public final class TypedProperties { if (size == 0) { return false; - } - else { + } else { return properties.containsKey(key); } } @@ -345,8 +316,7 @@ public final class TypedProperties { public Set getPropertyNames() { if (size == 0) { return Collections.emptySet(); - } - else { + } else { return properties.keySet(); } } @@ -356,8 +326,7 @@ public final class TypedProperties { if (b == DataConstants.NULL) { properties = null; - } - else { + } else { int numHeaders = buffer.readInt(); properties = new HashMap<>(numHeaders); @@ -440,8 +409,7 @@ public final class TypedProperties { public synchronized void encode(final ActiveMQBuffer buffer) { if (properties == null) { buffer.writeByte(DataConstants.NULL); - } - else { + } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeInt(properties.size()); @@ -460,8 +428,7 @@ public final class TypedProperties { public int getEncodeSize() { if (properties == null) { return DataConstants.SIZE_BYTE; - } - else { + } else { return DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + size; } } @@ -491,8 +458,7 @@ public final class TypedProperties { if (theValue == null) { sb.append("NULL-value"); - } - else if (theValue instanceof byte[]) { + } else if (theValue instanceof byte[]) { sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte[]) theValue, 2), 150) + ")"); if (iterItem.getKey().toString().startsWith("_AMQ_ROUTE_TO")) { @@ -506,14 +472,12 @@ public final class TypedProperties { sb.append(","); } } - } - catch (Throwable e) { + } catch (Throwable e) { sb.append("error-converting-longs=" + e.getMessage()); } sb.append("]"); } - } - else { + } else { sb.append(theValue.toString()); } @@ -542,8 +506,7 @@ public final class TypedProperties { PropertyValue oldValue = properties.put(key, value); if (oldValue != null) { size += value.encodeSize() - oldValue.encodeSize(); - } - else { + } else { size += SimpleString.sizeofString(key) + value.encodeSize(); } } @@ -557,8 +520,7 @@ public final class TypedProperties { if (val == null) { return null; - } - else { + } else { size -= SimpleString.sizeofString(key) + val.encodeSize(); return val.getValue(); @@ -574,8 +536,7 @@ public final class TypedProperties { if (val == null) { return null; - } - else { + } else { return val.getValue(); } } @@ -924,8 +885,7 @@ public final class TypedProperties { Object val = entry.getValue().getValue(); if (val instanceof SimpleString) { m.put(entry.getKey().toString(), ((SimpleString) val).toString()); - } - else { + } else { m.put(entry.getKey().toString(), val); } } @@ -942,41 +902,29 @@ public final class TypedProperties { public static void setObjectProperty(final SimpleString key, final Object value, final TypedProperties properties) { if (value == null) { properties.putNullValue(key); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { properties.putBooleanProperty(key, (Boolean) value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { properties.putByteProperty(key, (Byte) value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { properties.putCharProperty(key, (Character) value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { properties.putShortProperty(key, (Short) value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { properties.putIntProperty(key, (Integer) value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { properties.putLongProperty(key, (Long) value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { properties.putFloatProperty(key, (Float) value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { properties.putDoubleProperty(key, (Double) value); - } - else if (value instanceof String) { + } else if (value instanceof String) { properties.putSimpleStringProperty(key, new SimpleString((String) value)); - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { properties.putSimpleStringProperty(key, (SimpleString) value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { properties.putBytesProperty(key, (byte[]) value); - } - else { + } else { throw new ActiveMQPropertyConversionException(value.getClass() + " is not a valid property type"); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java index 5af507e..e75395b 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java @@ -61,8 +61,7 @@ public final class UTF8Util { buffer.byteBuffer[byteLocation] = (byte) buffer.charBuffer[byteLocation]; } out.writeBytes(buffer.byteBuffer, 0, len); - } - else { + } else { if (UTF8Util.isTrace) { // This message is too verbose for debug, that's why we are using trace here ActiveMQUtilLogger.LOGGER.trace("Saving string with utfSize=" + len + " stringSize=" + str.length()); @@ -76,13 +75,11 @@ public final class UTF8Util { char charAtPos = buffer.charBuffer[i]; if (charAtPos >= 1 && charAtPos < 0x7f) { buffer.byteBuffer[charCount++] = (byte) charAtPos; - } - else if (charAtPos >= 0x800) { + } else if (charAtPos >= 0x800) { buffer.byteBuffer[charCount++] = (byte) (0xE0 | charAtPos >> 12 & 0x0F); buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 6 & 0x3F); buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F); - } - else { + } else { buffer.byteBuffer[charCount++] = (byte) (0xC0 | charAtPos >> 6 & 0x1F); buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F); } @@ -120,8 +117,7 @@ public final class UTF8Util { if (byte1 > 0 && byte1 <= 0x7F) { buffer.charBuffer[charCount++] = (char) byte1; - } - else { + } else { int c = byte1 & 0xff; switch (c >> 4) { case 0xc: @@ -151,8 +147,7 @@ public final class UTF8Util { value = new StringUtilBuffer(); softReference = new SoftReference<>(value); UTF8Util.currenBuffer.set(softReference); - } - else { + } else { value = softReference.get(); } @@ -188,11 +183,9 @@ public final class UTF8Util { if (c >= 1 && c < 0x7f) { calculatedLen++; - } - else if (c >= 0x800) { + } else if (c >= 0x800) { calculatedLen += 3; - } - else { + } else { calculatedLen += 2; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java index 342bf5d..1d84fea 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java @@ -140,8 +140,7 @@ public final class UUID { if (shift > 16) { result ^= curr << shift | curr >>> 32 - shift; - } - else { + } else { result ^= curr << shift; } } @@ -155,8 +154,7 @@ public final class UUID { // Let's not accept hash 0 as it indicates 'not hashed yet': if (result == 0) { mHashCode = -1; - } - else { + } else { mHashCode = result; } } @@ -220,8 +218,7 @@ public final class UUID { int c2Bytes = Character.digit(c2, 16); data[dataIdx++] = (byte) ((c1Bytes << 4) + c2Bytes); } - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new IllegalArgumentException(e); } return data; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java index 111d8f0..c111617 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java @@ -135,8 +135,7 @@ public final class UUIDGenerator { // check if we have enough security permissions to create and shutdown an executor ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); executor.shutdownNow(); - } - catch (Throwable t) { + } catch (Throwable t) { // not enough security permission return null; } @@ -156,8 +155,7 @@ public final class UUIDGenerator { return address; } return null; - } - catch (Exception e) { + } catch (Exception e) { return null; } } @@ -179,8 +177,7 @@ public final class UUIDGenerator { if (address == null) { return java.util.UUID.randomUUID().toString(); - } - else { + } else { return generateTimeBasedUUID(address).toString(); } } @@ -192,8 +189,7 @@ public final class UUIDGenerator { if (bytes.length > 0 && bytes.length <= 6) { if (bytes.length == 6) { return bytes; - } - else { + } else { // pad with zeroes to have a 6-byte array byte[] paddedAddress = new byte[6]; System.arraycopy(bytes, 0, paddedAddress, 0, bytes.length); @@ -256,8 +252,7 @@ public final class UUIDGenerator { ifaces.add(networkInterfaces.nextElement()); } return ifaces; - } - catch (SocketException e) { + } catch (SocketException e) { return Collections.emptyList(); } } @@ -300,11 +295,9 @@ public final class UUIDGenerator { // we wait 5 seconds to get the first matching hardware address. After that, we give up and return null byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS); return address; - } - catch (Exception e) { + } catch (Exception e) { return null; - } - finally { + } finally { executor.shutdownNow(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java index b60174f..a8e5301 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java @@ -179,8 +179,7 @@ public class UUIDTimer { */ if (mClockCounter < UUIDTimer.kClockMultiplier) { // yup, still have room systime = mLastUsedTimestamp; - } - else { // nope, have to roll over to next value and maybe wait + } else { // nope, have to roll over to next value and maybe wait long actDiff = mLastUsedTimestamp - systime; long origTime = systime; systime = mLastUsedTimestamp + 1L; @@ -205,8 +204,7 @@ public class UUIDTimer { UUIDTimer.slowDown(origTime, actDiff); } } - } - else { + } else { /* * Clock has advanced normally; just need to make sure counter is reset * to a low value (need not be 0; good to leave a small residual to @@ -271,14 +269,11 @@ public class UUIDTimer { if (ratio < 2L) { // 200 msecs or less delay = 1L; - } - else if (ratio < 10L) { // 1 second or less + } else if (ratio < 10L) { // 1 second or less delay = 2L; - } - else if (ratio < 600L) { // 1 minute or less + } else if (ratio < 600L) { // 1 minute or less delay = 3L; - } - else { + } else { delay = 5L; } // Logger.logWarning("Need to wait for "+delay+" milliseconds; virtual @@ -288,8 +283,7 @@ public class UUIDTimer { do { try { Thread.sleep(delay); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { } delay = 1L; /* http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java index 4985c65..70b36ab 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/BeanSupport.java @@ -62,7 +62,7 @@ public class BeanSupport { return obj; } - public static

P setData( P obj, Map data) throws Exception { + public static

P setData(P obj, Map data) throws Exception { synchronized (beanUtils) { beanUtils.populate(obj, data); } @@ -86,8 +86,7 @@ public class BeanSupport { for (Map.Entry entry : query.entrySet()) { if (allowableProperties.contains(entry.getKey())) { properties.put(entry.getKey(), entry.getValue()); - } - else { + } else { extraProps.put(entry.getKey(), entry.getValue()); } } @@ -136,7 +135,6 @@ public class BeanSupport { (type == String.class); } - public static String decodeURI(String value) throws UnsupportedEncodingException { return URLDecoder.decode(value, "UTF-8"); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java index d0e70f4..7df9131 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java @@ -29,6 +29,7 @@ import org.apache.commons.beanutils.IntrospectionContext; import org.jboss.logging.Logger; public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBeanIntrospector { + static Logger logger = Logger.getLogger(FluentPropertyBeanIntrospectorWithIgnores.class); private static ConcurrentHashSet> ignores = new ConcurrentHashSet<>(); @@ -56,12 +57,10 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); - } - else if (pd.getWriteMethod() == null) { + } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } - } - catch (IntrospectionException e) { + } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java index 1e54b5f..bc62dd2 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java @@ -73,7 +73,6 @@ public class URIFactory { schemaFactory.populateObject(uri, bean); } - public void populateObject(String uri, T bean) throws Exception { populateObject(new URI(uri), bean); } @@ -106,8 +105,7 @@ public class URIFactory { if (factoryQuery != null && factoryQuery.length() > 0) { if (connectorURIS[0].contains("?")) { builder.append("&").append(factoryQuery.substring(1)); - } - else { + } else { builder.append(factoryQuery); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java index 9751659..49a84c1 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java @@ -60,8 +60,7 @@ public abstract class URISchema { URIFactory factory = getFactory(); if (factory == null) { return null; - } - else { + } else { return factory.getDefaultURI(); } } @@ -112,8 +111,7 @@ public abstract class URISchema { String name = BeanSupport.decodeURI(parameter.substring(0, p)); String value = BeanSupport.decodeURI(parameter.substring(p + 1)); rc.put(name, value); - } - else { + } else { if (!parameter.trim().isEmpty()) { rc.put(parameter, null); } @@ -127,8 +125,7 @@ public abstract class URISchema { } } return rc; - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java index a95f810..ac02f8f 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java @@ -6,7 +6,7 @@ * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -83,8 +83,7 @@ public class URISupport { if (host != null && host.length() != 0) { sb.append(host); - } - else { + } else { sb.append('('); for (int i = 0; i < components.length; i++) { if (i != 0) { @@ -127,8 +126,7 @@ public class URISupport { parseParameters(rc, uri.split(";")); } return rc; - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } } @@ -141,8 +139,7 @@ public class URISupport { String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8"); String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8"); rc.put(name, value); - } - else { + } else { rc.put(parameter, null); } } @@ -161,8 +158,7 @@ public class URISupport { public static Map parseParameters(URI uri) throws URISyntaxException { if (!isCompositeURI(uri)) { return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(), "?")); - } - else { + } else { CompositeData data = URISupport.parseComposite(uri); Map parameters = new HashMap<>(); parameters.putAll(data.getParameters()); @@ -317,8 +313,7 @@ public class URISupport { char current = array[index]; if (current == '(') { depth++; - } - else if (current == ')') { + } else if (current == ')') { if (--depth == 0) { break; } @@ -366,8 +361,7 @@ public class URISupport { componentString = ssp.substring(initialParen + 1, p); params = ssp.substring(p + 1).trim(); - } - else { + } else { componentString = ssp; params = ""; } @@ -384,8 +378,7 @@ public class URISupport { rc.path = stripPrefix(params.substring(0, p), "/"); } rc.parameters = parseQuery(params.substring(p + 1)); - } - else { + } else { if (params.length() > 0) { rc.path = stripPrefix(params, "/"); } @@ -479,8 +472,7 @@ public class URISupport { for (String key : keys) { if (first) { first = false; - } - else { + } else { rc.append("&"); } String value = (String) options.get(key); @@ -489,12 +481,10 @@ public class URISupport { rc.append(URLEncoder.encode(value, "UTF-8")); } return rc.toString(); - } - else { + } else { return ""; } - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java index b4b7daf..438f38e 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java @@ -34,10 +34,11 @@ import org.junit.Test; public class ActiveMQScheduledComponentTest { @Rule - public ThreadLeakCheckRule rule = new ThreadLeakCheckRule(); + public ThreadLeakCheckRule rule = new ThreadLeakCheckRule(); ScheduledExecutorService scheduledExecutorService; ExecutorService executorService; + @Before public void before() { scheduledExecutorService = new ScheduledThreadPoolExecutor(5); @@ -54,15 +55,13 @@ public class ActiveMQScheduledComponentTest { public void testAccumulation() throws Exception { final AtomicInteger count = new AtomicInteger(0); - final ActiveMQScheduledComponent local = new ActiveMQScheduledComponent(scheduledExecutorService, executorService, 100, TimeUnit.MILLISECONDS, false) { @Override public void run() { if (count.get() == 0) { try { Thread.sleep(800); - } - catch (Exception e) { + } catch (Exception e) { } } count.incrementAndGet(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ConcurrentHashSetTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ConcurrentHashSetTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ConcurrentHashSetTest.java index 6bc4fde..4055801 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ConcurrentHashSetTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ConcurrentHashSetTest.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.utils; +import java.util.Iterator; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.Iterator; - public class ConcurrentHashSetTest extends Assert { // Constants ----------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java index a45886e..ed91860 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.utils; -import org.junit.Test; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.Pair; +import org.junit.Assert; +import org.junit.Test; public class PairTest extends Assert { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java index 0616f57..865afff 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java @@ -75,8 +75,7 @@ public class ReferenceCounterTest extends Assert { if (executor == null) { ref = new ReferenceCounterUtil(runner); - } - else { + } else { ref = new ReferenceCounterUtil(runner, executor); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java index b2c3bf6..80dfb01 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java @@ -34,6 +34,7 @@ import org.junit.rules.ExternalResource; * This is useful to make sure you won't have leaking threads between tests */ public class ThreadLeakCheckRule extends ExternalResource { + private static Logger log = Logger.getLogger(ThreadLeakCheckRule.class); private static Set knownThreads = new HashSet<>(); @@ -79,26 +80,22 @@ public class ThreadLeakCheckRule extends ExternalResource { forceGC(); try { Thread.sleep(500); - } - catch (Throwable e) { + } catch (Throwable e) { } } } if (failed) { Assert.fail("Thread leaked"); - } - else if (failedOnce) { + } else if (failedOnce) { System.out.println("******************** Threads cleared after retries ********************"); System.out.println(); } - } - else { + } else { enabled = true; } - } - finally { + } finally { // clearing just to help GC previousThreads = null; } @@ -125,16 +122,14 @@ public class ThreadLeakCheckRule extends ExternalResource { System.runFinalization(); try { finalized.await(100, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } if (dumbReference.get() != null) { failedGCCalls++; log.info("It seems that GC is disabled at your VM"); - } - else { + } else { // a success would reset the count failedGCCalls = 0; } @@ -154,8 +149,7 @@ public class ThreadLeakCheckRule extends ExternalResource { System.gc(); try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } @@ -175,7 +169,6 @@ public class ThreadLeakCheckRule extends ExternalResource { if (postThreads != null && previousThreads != null && postThreads.size() > previousThreads.size()) { - for (Thread aliveThread : postThreads.keySet()) { if (aliveThread.isAlive() && !isExpectedThread(aliveThread) && !previousThreads.containsKey(aliveThread)) { if (!failedThread) { @@ -197,11 +190,9 @@ public class ThreadLeakCheckRule extends ExternalResource { } } - return failedThread; } - /** * if it's an expected thread... we will just move along ignoring it * @@ -216,50 +207,39 @@ public class ThreadLeakCheckRule extends ExternalResource { if (threadName.contains("SunPKCS11")) { return true; - } - else if (threadName.contains("Attach Listener")) { + } else if (threadName.contains("Attach Listener")) { return true; - } - else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) { + } else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) { return true; - } - else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("ClassCache Reaper")) { + } else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("ClassCache Reaper")) { return true; - } - else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) { + } else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) { return true; - } - else if (threadName.contains("globalEventExecutor")) { + } else if (threadName.contains("globalEventExecutor")) { return true; - } - else if (threadName.contains("threadDeathWatcher")) { + } else if (threadName.contains("threadDeathWatcher")) { return true; - } - else if (threadName.contains("netty-threads")) { + } else if (threadName.contains("netty-threads")) { // This is ok as we use EventLoopGroup.shutdownGracefully() which will shutdown things with a bit of delay // if the EventLoop's are still busy. return true; - } - else if (threadName.contains("threadDeathWatcher")) { + } else if (threadName.contains("threadDeathWatcher")) { //another netty thread return true; - } - else if (threadName.contains("Abandoned connection cleanup thread")) { + } else if (threadName.contains("Abandoned connection cleanup thread")) { // MySQL Engine checks for abandoned connections return true; - } - else if (threadName.contains("hawtdispatch")) { + } else if (threadName.contains("hawtdispatch")) { // Static workers used by MQTT client. return true; - } - else { + } else { for (StackTraceElement element : thread.getStackTrace()) { if (element.getClassName().contains("org.jboss.byteman.agent.TransformListener")) { return true; } } - for (String known: knownThreads) { + for (String known : knownThreads) { if (threadName.contains(known)) { return true; } @@ -269,7 +249,6 @@ public class ThreadLeakCheckRule extends ExternalResource { } } - protected static class DumbReference { private CountDownLatch finalized; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesConversionTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesConversionTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesConversionTest.java index ff5d32d..cec3959 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesConversionTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesConversionTest.java @@ -61,8 +61,7 @@ public class TypedPropertiesConversionTest { props.putByteProperty(key, RandomUtil.randomByte()); props.getBooleanProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } Assert.assertFalse(props.getBooleanProperty(unknownKey)); @@ -80,15 +79,13 @@ public class TypedPropertiesConversionTest { props.putByteProperty(key, RandomUtil.randomByte()); props.getCharProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getCharProperty(unknownKey); Assert.fail(); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { } } @@ -107,15 +104,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getByteProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getByteProperty(unknownKey); Assert.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -138,15 +133,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getIntProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getIntProperty(unknownKey); Assert.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -177,15 +170,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getLongProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getLongProperty(unknownKey); Assert.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -204,15 +195,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getDoubleProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getDoubleProperty(unknownKey); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -232,15 +221,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getFloatProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getFloatProperty(unknownKey); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -264,15 +251,13 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getShortProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } try { props.getShortProperty(unknownKey); Assert.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -294,8 +279,7 @@ public class TypedPropertiesConversionTest { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getBytesProperty(key); Assert.fail(); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { } Assert.assertNull(props.getBytesProperty(unknownKey)); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java index 48c7630..8013e96 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java @@ -41,8 +41,7 @@ public class TypedPropertiesTest { byte[] expectedBytes = (byte[]) expectedValue; byte[] actualBytes = (byte[]) actualValue; Assert.assertArrayEquals(expectedBytes, actualBytes); - } - else { + } else { Assert.assertEquals(expectedValue, actualValue); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java index 5a22405..379868e 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java @@ -63,13 +63,11 @@ public class URIParserTest { myFruit.setFluentName("apples&bananas with &host=3344"); URI uri = parser.createSchema("fruit", myFruit); - Fruit newFruit = (Fruit)parser.newObject(uri, "something"); + Fruit newFruit = (Fruit) parser.newObject(uri, "something"); Assert.assertEquals(myFruit.getHost(), newFruit.getHost()); Assert.assertEquals(myFruit.getFluentName(), newFruit.getFluentName()); - - } /**