http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java index 6aa0f50..31d7a47 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java @@ -106,8 +106,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { protected Class resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException { if (System.getSecurityManager() == null) { return resolveClass0(desc); - } - else { + } else { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() { @Override @@ -115,8 +114,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { return resolveClass0(desc); } }); - } - catch (PrivilegedActionException e) { + } catch (PrivilegedActionException e) { throw unwrapException(e); } } @@ -126,8 +124,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { protected Class resolveProxyClass(final String[] interfaces) throws IOException, ClassNotFoundException { if (System.getSecurityManager() == null) { return resolveProxyClass0(interfaces); - } - else { + } else { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() { @Override @@ -135,8 +132,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { return resolveProxyClass0(interfaces); } }); - } - catch (PrivilegedActionException e) { + } catch (PrivilegedActionException e) { throw unwrapException(e); } } @@ -157,8 +153,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { } return checkSecurity(clazz); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { return checkSecurity(super.resolveClass(desc)); } } @@ -176,8 +171,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { if (nonPublicLoader != cl.getClassLoader()) { throw new IllegalAccessError("conflicting non-public interface class loaders"); } - } - else { + } else { nonPublicLoader = cl.getClassLoader(); hasNonPublicInterface = true; } @@ -186,8 +180,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { } try { return checkSecurity(Proxy.getProxyClass(hasNonPublicInterface ? nonPublicLoader : latestLoader, classObjs)); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new ClassNotFoundException(null, e); } } @@ -196,17 +189,13 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { Throwable c = e.getCause(); if (c instanceof IOException) { throw (IOException) c; - } - else if (c instanceof ClassNotFoundException) { + } else if (c instanceof ClassNotFoundException) { throw (ClassNotFoundException) c; - } - else if (c instanceof RuntimeException) { + } else if (c instanceof RuntimeException) { throw (RuntimeException) c; - } - else if (c instanceof Error) { + } else if (c instanceof Error) { throw (Error) c; - } - else { + } else { throw new RuntimeException(c); } } @@ -225,8 +214,8 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { if (!target.isPrimitive()) { if (!isTrustedType(target)) { throw new ClassNotFoundException("Forbidden " + clazz + "! " + - "This class is not trusted to be deserialized under the current configuration. " + - "Please refer to the documentation for more information on how to configure trusted classes."); + "This class is not trusted to be deserialized under the current configuration. " + + "Please refer to the documentation for more information on how to configure trusted classes."); } } @@ -247,8 +236,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { for (String blackListEntry : blackList) { if (CATCH_ALL_WILDCARD.equals(blackListEntry)) { return false; - } - else if (isClassOrPackageMatch(className, blackListEntry)) { + } else if (isClassOrPackageMatch(className, blackListEntry)) { return false; } } @@ -256,8 +244,7 @@ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { for (String whiteListEntry : whiteList) { if (CATCH_ALL_WILDCARD.equals(whiteListEntry)) { return true; - } - else if (isClassOrPackageMatch(className, whiteListEntry)) { + } else if (isClassOrPackageMatch(className, whiteListEntry)) { return true; } }
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/OrderedExecutorFactory.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/OrderedExecutorFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/OrderedExecutorFactory.java index d80d7bd..609af8e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/OrderedExecutorFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/OrderedExecutorFactory.java @@ -78,7 +78,6 @@ public final class OrderedExecutorFactory implements ExecutorFactory { this.delegate = delegate; } - @Override public void execute(Runnable command) { tasks.add(command); @@ -101,20 +100,17 @@ public final class OrderedExecutorFactory implements ExecutorFactory { while (task != null) { try { task.run(); - } - catch (ActiveMQInterruptedException e) { + } catch (ActiveMQInterruptedException e) { // This could happen during shutdowns. Nothing to be concerned about here logger.debug("Interrupted Thread", e); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.caughtunexpectedThrowable(t); } task = tasks.poll(); } //set state back to not running. stateUpdater.set(OrderedExecutor.this, STATE_NOT_RUNNING); - } - else { + } else { return; } //we loop again based on tasks not being empty. Otherwise there is a window where the state is running, http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/PriorityLinkedListImpl.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/PriorityLinkedListImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/PriorityLinkedListImpl.java index 06b2432..427a927 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/PriorityLinkedListImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/PriorityLinkedListImpl.java @@ -49,8 +49,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> { lastPriority = priority; if (lastReset == Integer.MAX_VALUE) { lastReset = 0; - } - else { + } else { lastReset++; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java index 90994fb..b4fe581 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.utils; -import org.apache.activemq.artemis.core.security.Role; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.activemq.artemis.core.security.Role; + public class SecurityFormatter { public static Set<Role> createSecurity(String sendRoles, http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SizeFormatterUtil.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SizeFormatterUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SizeFormatterUtil.java index 71698b4..0214374 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SizeFormatterUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SizeFormatterUtil.java @@ -36,12 +36,10 @@ public class SizeFormatterUtil { if (s > SizeFormatterUtil.oneGiB) { s /= SizeFormatterUtil.oneGiB; suffix = "GiB"; - } - else if (s > SizeFormatterUtil.oneMiB) { + } else if (s > SizeFormatterUtil.oneMiB) { s /= SizeFormatterUtil.oneMiB; suffix = "MiB"; - } - else if (s > SizeFormatterUtil.oneKiB) { + } else if (s > SizeFormatterUtil.oneKiB) { s /= SizeFormatterUtil.oneKiB; suffix = "kiB"; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java index 17228c2..070f91e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SoftValueHashMap.java @@ -128,8 +128,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen if (value != null) { value.used(); return value.get(); - } - else { + } else { return null; } } @@ -148,8 +147,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen newRef.used(); if (oldRef != null) { return oldRef.get(); - } - else { + } else { return null; } } @@ -190,8 +188,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen if (k > 0) { return 1; - } - else if (k < 0) { + } else if (k < 0) { return -1; } @@ -199,11 +196,9 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen if (k > 0) { return 1; - } - else if (k < 0) { + } else if (k < 0) { return -1; - } - else { + } else { return 0; } } @@ -219,8 +214,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen AggregatedSoftReference ref = mapDelegate.remove(key); if (ref != null) { return ref.get(); - } - else { + } else { return null; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/StringUtil.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/StringUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/StringUtil.java index 1b40209..ac4d641 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/StringUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/StringUtil.java @@ -25,6 +25,7 @@ public class StringUtil { /** * Convert a list of Strings into a single String + * * @param strList the string list * @param delimit the delimiter used to separate each string entry in the list * @return the converted string @@ -44,6 +45,7 @@ public class StringUtil { /** * Convert a String into a list of String + * * @param strList the String * @param delimit used to separate items within the string. * @return the string list http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TimeAndCounterIDGenerator.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TimeAndCounterIDGenerator.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TimeAndCounterIDGenerator.java index 96678f7..f6e4cac 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TimeAndCounterIDGenerator.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TimeAndCounterIDGenerator.java @@ -74,8 +74,7 @@ public class TimeAndCounterIDGenerator implements IDGenerator { wrapped = true; - } - else { + } else { // Else.. no worry... we will just accept the new time portion being added // This time-mark would have been generated some time ago, so this is ok. // tmMark is just a cache to validate the MaxIDs, so there is no need to make it atomic (synchronized) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TokenBucketLimiterImpl.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TokenBucketLimiterImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TokenBucketLimiterImpl.java index 699ccac..ed11e4f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TokenBucketLimiterImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/TokenBucketLimiterImpl.java @@ -65,12 +65,10 @@ public class TokenBucketLimiterImpl implements TokenBucketLimiter { while (!check()) { if (spin) { Thread.yield(); - } - else { + } else { try { Thread.sleep(1); - } - catch (Exception e) { + } catch (Exception e) { // Ignore } } @@ -96,8 +94,7 @@ public class TokenBucketLimiterImpl implements TokenBucketLimiter { tokens--; return true; - } - else { + } else { return false; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java index a0efdb5..22d274d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java @@ -56,8 +56,7 @@ public final class VersionLoader { return System.getProperty(VersionLoader.VERSION_PROP_FILE_KEY); } }); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); PROP_FILE_NAME = null; } @@ -67,8 +66,7 @@ public final class VersionLoader { } VersionLoader.versions = VersionLoader.load(); - } - catch (Throwable e) { + } catch (Throwable e) { VersionLoader.versions = null; ActiveMQClientLogger.LOGGER.error(e.getMessage(), e); } @@ -131,19 +129,16 @@ public final class VersionLoader { }); return definedVersions.toArray(new Version[incrementingVersions.length]); - } - catch (IOException e) { + } catch (IOException e) { // if we get here then the messaging hasn't been built properly and the version.properties is skewed in some // way throw new RuntimeException("unable to load " + VersionLoader.PROP_FILE_NAME, e); } - } - finally { + } finally { try { if (in != null) in.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -168,8 +163,7 @@ public final class VersionLoader { if (cursor > 1) { to = Integer.parseInt(token.substring(1, cursor)); } - } - else if (Character.isDigit(firstChar)) { + } else if (Character.isDigit(firstChar)) { for (; cursor < token.length() && Character.isDigit(token.charAt(cursor)); cursor++) { // do nothing } @@ -178,14 +172,12 @@ public final class VersionLoader { if (cursor == token.length()) { // just "n" pattern to = from; - } - else if (token.charAt(cursor) == '-') { + } else if (token.charAt(cursor) == '-') { cursor++; if (cursor == token.length()) { // "n-" pattern to = Integer.MAX_VALUE; - } - else { + } else { // "n-n" pattern to = Integer.parseInt(token.substring(cursor)); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java index 7a492c4..39b0657 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java @@ -121,12 +121,10 @@ public final class XMLUtil { if (children.getLength() == 0) { if ((textContent = XMLUtil.getTextContent(n)) != null && !"".equals(textContent)) { sb.append(textContent).append("</").append(name).append('>'); - } - else { + } else { sb.append("/>").append('\n'); } - } - else { + } else { sb.append('>').append('\n'); boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { @@ -303,8 +301,7 @@ public final class XMLUtil { try { return Long.parseLong(value); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw ActiveMQClientMessageBundle.BUNDLE.mustBeLong(elem, value); } } @@ -314,8 +311,7 @@ public final class XMLUtil { try { return Integer.parseInt(value); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw ActiveMQClientMessageBundle.BUNDLE.mustBeInteger(elem, value); } } @@ -325,8 +321,7 @@ public final class XMLUtil { try { return Boolean.parseBoolean(value); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw ActiveMQClientMessageBundle.BUNDLE.mustBeBoolean(elem, value); } } @@ -336,8 +331,7 @@ public final class XMLUtil { try { return Double.parseDouble(value); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw ActiveMQClientMessageBundle.BUNDLE.mustBeDouble(elem, value); } } @@ -351,8 +345,7 @@ public final class XMLUtil { // validate the DOM tree try { validator.validate(new DOMSource(node)); - } - catch (SAXException e) { + } catch (SAXException e) { ActiveMQClientLogger.LOGGER.errorOnXMLTransformInvalidConf(e); throw new IllegalStateException("Invalid configuration", e); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java index 75b871d..ad6363e 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java @@ -86,8 +86,7 @@ public class ClientThreadPoolsTest { try { inUse.countDown(); neverLeave.await(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); neverLeave.countDown(); } @@ -103,11 +102,9 @@ public class ClientThreadPoolsTest { public void testInjectPools() throws Exception { ActiveMQClient.clearThreadPools(); - ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1, 1, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<Runnable>()); + ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); - ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = (ScheduledThreadPoolExecutor)Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); + ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); ActiveMQClient.injectPools(poolExecutor, scheduledThreadPoolExecutor); @@ -121,15 +118,13 @@ public class ClientThreadPoolsTest { try { inUse.countDown(); neverLeave.await(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); neverLeave.countDown(); } } }); - Assert.assertTrue(inUse.await(10, TimeUnit.SECONDS)); poolExecutor.shutdownNow(); scheduledThreadPoolExecutor.shutdownNow(); @@ -185,7 +180,6 @@ public class ClientThreadPoolsTest { final CountDownLatch latchTotal = new CountDownLatch(expectedMax * 3); // we will schedule 3 * max, so all runnables should execute final AtomicInteger errors = new AtomicInteger(0); - // Set this to true if you need to debug why executions are not being performed. final boolean debugExecutions = false; @@ -202,11 +196,9 @@ public class ClientThreadPoolsTest { doneMax.countDown(); latch.await(); latchTotal.countDown(); - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); - } - finally { + } finally { if (debugExecutions) { System.out.println("done " + localI); } @@ -219,7 +211,6 @@ public class ClientThreadPoolsTest { latch.countDown(); Assert.assertTrue(latchTotal.await(5, TimeUnit.SECONDS)); - ScheduledThreadPoolExecutor scheduledThreadPool = (ScheduledThreadPoolExecutor) scheduledThreadPoolField.get(serverLocator); assertEquals(expectedMax, threadPool.getMaximumPoolSize()); @@ -232,7 +223,7 @@ public class ClientThreadPoolsTest { ServerLocator serverLocator = new ServerLocatorImpl(false); ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, 1, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); - ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(1); + ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(1); serverLocator.setThreadPools(threadPool, scheduledThreadPool); Field threadPoolField = ServerLocatorImpl.class.getDeclaredField("threadPool"); @@ -260,5 +251,4 @@ public class ClientThreadPoolsTest { ActiveMQClient.clearThreadPools(); } - } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java index 180ca6c..2873bab 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.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-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java index 9f0d29c..1b7a479 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.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, @@ -36,7 +36,6 @@ public class TransportConfigurationTest { Assert.assertEquals(configuration, configuration2); Assert.assertEquals(configuration.hashCode(), configuration2.hashCode()); - HashMap<String, Object> configMap1 = new HashMap<>(); configMap1.put("host", "localhost"); HashMap<String, Object> configMap2 = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfoTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfoTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfoTest.java index f477879..392231b 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfoTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfoTest.java @@ -30,27 +30,27 @@ public class AddressSettingsInfoTest { @Test public void shouldLoadFromJSON() { String json = "{\n" + - "\"addressFullMessagePolicy\":\"fullPolicy\",\n" + - "\"maxSizeBytes\":500,\n" + - "\"pageSizeBytes\":200,\n" + - "\"pageCacheMaxSize\":3,\n" + - "\"maxDeliveryAttempts\":3,\n" + - "\"redeliveryDelay\":70000,\n" + - "\"redeliveryMultiplier\":1.5,\n" + - "\"maxRedeliveryDelay\":100000,\n" + - "\"DLA\":\"deadLettersGoHere\",\n" + - "\"expiryAddress\":\"\",\n" + - "\"lastValueQueue\":true,\n" + - "\"redistributionDelay\":10004,\n" + - "\"sendToDLAOnNoRoute\":true,\n" + - "\"slowConsumerThreshold\":200,\n" + - "\"slowConsumerCheckPeriod\":300,\n" + - "\"slowConsumerPolicy\":\"retire\",\n" + - "\"autoCreateJmsQueues\":true,\n" + - "\"autoDeleteJmsQueues\":false,\n" + - "\"autoCreateJmsTopics\":true,\n" + - "\"autoDeleteJmsTopics\":false\n" + - "}"; + "\"addressFullMessagePolicy\":\"fullPolicy\",\n" + + "\"maxSizeBytes\":500,\n" + + "\"pageSizeBytes\":200,\n" + + "\"pageCacheMaxSize\":3,\n" + + "\"maxDeliveryAttempts\":3,\n" + + "\"redeliveryDelay\":70000,\n" + + "\"redeliveryMultiplier\":1.5,\n" + + "\"maxRedeliveryDelay\":100000,\n" + + "\"DLA\":\"deadLettersGoHere\",\n" + + "\"expiryAddress\":\"\",\n" + + "\"lastValueQueue\":true,\n" + + "\"redistributionDelay\":10004,\n" + + "\"sendToDLAOnNoRoute\":true,\n" + + "\"slowConsumerThreshold\":200,\n" + + "\"slowConsumerCheckPeriod\":300,\n" + + "\"slowConsumerPolicy\":\"retire\",\n" + + "\"autoCreateJmsQueues\":true,\n" + + "\"autoDeleteJmsQueues\":false,\n" + + "\"autoCreateJmsTopics\":true,\n" + + "\"autoDeleteJmsTopics\":false\n" + + "}"; AddressSettingsInfo addressSettingsInfo = AddressSettingsInfo.from(json); assertEquals("fullPolicy", addressSettingsInfo.getAddressFullMessagePolicy()); assertEquals(500L, addressSettingsInfo.getMaxSizeBytes()); @@ -74,4 +74,4 @@ public class AddressSettingsInfoTest { assertFalse(addressSettingsInfo.isAutoDeleteJmsTopics()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/RandomUtil.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/RandomUtil.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/RandomUtil.java index b47e216..a8a6205 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/RandomUtil.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/RandomUtil.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.tests.util; import javax.transaction.xa.Xid; + import org.apache.activemq.artemis.core.transaction.impl.XidImpl; public class RandomUtil extends org.apache.activemq.artemis.utils.RandomUtil { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/SilentTestCase.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/SilentTestCase.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/SilentTestCase.java index 5508fc4..aa0669e 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/SilentTestCase.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/util/SilentTestCase.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.tests.util; -import org.junit.Before; -import org.junit.After; - import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; /** * Test case that hijacks sys-out and sys-err. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/CompressionUtilTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/CompressionUtilTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/CompressionUtilTest.java index e864822..ff2474a 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/CompressionUtilTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/CompressionUtilTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.util; -import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; @@ -25,11 +23,11 @@ import java.util.ArrayList; import java.util.concurrent.atomic.AtomicLong; import java.util.zip.Deflater; -import org.junit.Assert; - import org.apache.activemq.artemis.utils.DeflaterReader; import org.apache.activemq.artemis.utils.InflaterReader; import org.apache.activemq.artemis.utils.InflaterWriter; +import org.junit.Assert; +import org.junit.Test; public class CompressionUtilTest extends Assert { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/StringUtilTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/StringUtilTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/StringUtilTest.java index 76f3ec1..324e24d 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/StringUtilTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/StringUtilTest.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.util; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.utils.StringUtil; import org.junit.Assert; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; - public class StringUtilTest extends Assert { @Test http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java index 671261e..c2ec02d 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.util; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.utils.ConcurrentHashSet; import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator; import org.junit.Assert; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class TimeAndCounterIDGeneratorTest extends Assert { // Constants ----------------------------------------------------- @@ -108,8 +108,7 @@ public class TimeAndCounterIDGeneratorTest extends Assert { hashSet.add(value); } - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -154,8 +153,7 @@ public class TimeAndCounterIDGeneratorTest extends Assert { // This is simulating a situation where we generated more than 268 million messages on the same time interval seq.generateID(); Assert.fail("It was supposed to throw an exception, as the counter was set to explode on this test"); - } - catch (Exception e) { + } catch (Exception e) { } seq = new TimeAndCounterIDGenerator(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java index f2feeac..c7dcdaf 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java @@ -16,12 +16,10 @@ */ package org.apache.activemq.artemis.util; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.tests.util.SilentTestCase; import org.apache.activemq.artemis.utils.XMLUtil; +import org.junit.Assert; +import org.junit.Test; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -123,8 +121,7 @@ public class XMLUtilTest extends SilentTestCase { try { XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2)); Assert.fail("this should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // expected } } @@ -161,8 +158,7 @@ public class XMLUtilTest extends SilentTestCase { try { XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2)); Assert.fail("this should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // OK e.printStackTrace(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-dto/pom.xml ---------------------------------------------------------------------- diff --git a/artemis-dto/pom.xml b/artemis-dto/pom.xml index ef39754..2b67fb6 100644 --- a/artemis-dto/pom.xml +++ b/artemis-dto/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -28,7 +29,7 @@ <name>ActiveMQ Artemis DTO</name> <properties> - <activemq.basedir>${project.basedir}/..</activemq.basedir> + <activemq.basedir>${project.basedir}/..</activemq.basedir> </properties> <dependencies> @@ -40,151 +41,153 @@ </dependencies> <build> - <resources> - <resource> - <directory>target/schema</directory> - <includes> - <include>**/*</include> - </includes> - </resource> - <resource> - <directory>src/main/resources</directory> - <includes> - <include>**/*</include> - </includes> - <filtering>true</filtering> - </resource> - </resources> + <resources> + <resource> + <directory>target/schema</directory> + <includes> + <include>**/*</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.7</version> - <executions> - <execution> - <phase>generate-resources</phase> - <configuration> - <target> - <taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask" /> - <mkdir dir="${project.build.directory}/schema/org.apache.activemq/dto" /> - <echo message="Generating XSD to: ${project.build.directory}/schema/org.apache.activemq/dto" /> - <schemagen srcdir="${basedir}/.." destdir="${project.build.directory}/schema/org.apache.activemq/dto" includeantruntime="false"> - <schema namespace="http://activemq.org/schema" file="activemq.xsd" /> - <classpath refid="maven.compile.classpath" /> - <include name="**/package-info.java" /> - <include name="**/*DTO.java" /> - <exclude name="**/.git/**" /> - <exclude name="**/.svn/**" /> - </schemagen> - <copy todir="${project.build.directory}/classes"> - <fileset dir="${project.build.directory}/schema" /> - </copy> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.7</version> + <executions> + <execution> + <phase>generate-resources</phase> + <configuration> + <target> + <taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask"/> + <mkdir dir="${project.build.directory}/schema/org.apache.activemq/dto"/> + <echo message="Generating XSD to: ${project.build.directory}/schema/org.apache.activemq/dto"/> + <schemagen srcdir="${basedir}/.." + destdir="${project.build.directory}/schema/org.apache.activemq/dto" + includeantruntime="false"> + <schema namespace="http://activemq.org/schema" file="activemq.xsd"/> + <classpath refid="maven.compile.classpath"/> + <include name="**/package-info.java"/> + <include name="**/*DTO.java"/> + <exclude name="**/.git/**"/> + <exclude name="**/.svn/**"/> + </schemagen> + <copy todir="${project.build.directory}/classes"> + <fileset dir="${project.build.directory}/schema"/> + </copy> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.2.7</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.2.7</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-jxc</artifactId> + <version>2.2.7</version> + </dependency> + </dependencies> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <versionRange>[1.7,)</versionRange> + <goals> + <goal>run</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore/> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <profiles> + <profile> + <id>jdk-1.5</id> + <activation> + <jdk>1.5</jdk> + </activation> <dependencies> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> - <version>2.2.7</version> + <version>${jaxb-api-version}</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> - <version>2.2.7</version> - </dependency> - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-jxc</artifactId> - <version>2.2.7</version> + <version>${jaxb-version}</version> </dependency> </dependencies> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <versionRange>[1.7,)</versionRange> - <goals> - <goal>run</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - - <profiles> - <profile> - <id>jdk-1.5</id> - <activation> - <jdk>1.5</jdk> - </activation> - <dependencies> - <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - <version>${jaxb-api-version}</version> - </dependency> - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> - <version>${jaxb-version}</version> - </dependency> - </dependencies> - </profile> + </profile> - <profile> - <id>ibmjdk</id> - <activation> - <file> - <exists>${java.home}/../lib/tools.jar</exists> - </file> - </activation> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <dependencies> - <dependency> - <groupId>com.sun</groupId> - <artifactId>tools</artifactId> - <!--the real JDK version could be 1.5 or 1.6--> - <version>1.5.0</version> - <scope>system</scope> - <optional>true</optional> - <systemPath>${java.home}/../lib/tools.jar</systemPath> - </dependency> - </dependencies> - </plugin> - </plugins> - </pluginManagement> - </build> - </profile> + <profile> + <id>ibmjdk</id> + <activation> + <file> + <exists>${java.home}/../lib/tools.jar</exists> + </file> + </activation> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <dependencies> + <dependency> + <groupId>com.sun</groupId> + <artifactId>tools</artifactId> + <!--the real JDK version could be 1.5 or 1.6--> + <version>1.5.0</version> + <scope>system</scope> + <optional>true</optional> + <systemPath>${java.home}/../lib/tools.jar</systemPath> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> + </profile> </profiles> </project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java ---------------------------------------------------------------------- diff --git a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java index fa0ff9a..1af8542 100644 --- a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java +++ b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java @@ -63,8 +63,7 @@ public class XmlUtil { String property = props.getProperty(group); if (property != null) { str = matcher.replaceFirst(Matcher.quoteReplacement(property)); - } - else { + } else { start = matcher.end(); } } @@ -79,8 +78,13 @@ public class XmlUtil { return decode(clazz, configuration, null, null); } - /** We offer parameters for artemisInstance and artemisHome as they could be coming from the CLI or Maven Plugin */ - public static <T> T decode(Class<T> clazz, File configuration, String artemisHome, String artemisInstance) throws Exception { + /** + * We offer parameters for artemisInstance and artemisHome as they could be coming from the CLI or Maven Plugin + */ + public static <T> T decode(Class<T> clazz, + File configuration, + String artemisHome, + String artemisInstance) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance("org.apache.activemq.artemis.dto"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/package-info.java ---------------------------------------------------------------------- diff --git a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/package-info.java b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/package-info.java index 8f98eec..0a8b297 100644 --- a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/package-info.java +++ b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/package-info.java @@ -18,6 +18,6 @@ * The JAXB POJOs for the XML configuration of ActiveMQ Artemis broker */ @javax.xml.bind.annotation.XmlSchema( - namespace = "http://activemq.org/schema", - elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) + namespace = "http://activemq.org/schema", + elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.apache.activemq.artemis.dto; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/pom.xml ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/pom.xml b/artemis-jdbc-store/pom.xml index 2e0c8c0..3de4f85 100644 --- a/artemis-jdbc-store/pom.xml +++ b/artemis-jdbc-store/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java index 43b94e0..0098328 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.jdbc.store; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; @@ -23,8 +24,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import javax.sql.DataSource; - import org.apache.activemq.artemis.jdbc.store.drivers.derby.DerbySQLProvider; import org.apache.activemq.artemis.jdbc.store.drivers.mysql.MySQLSQLProvider; import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSQLProvider; @@ -37,6 +36,7 @@ import org.jboss.logging.Logger; public class JDBCUtils { private static final Logger logger = Logger.getLogger(JDBCUtils.class); + public static Driver getDriver(String className) throws Exception { try { @@ -49,18 +49,15 @@ public class JDBCUtils { public void run() { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - catch (Exception e) { + } catch (Exception e) { } } }); } return driver; - } - catch (ClassNotFoundException cnfe) { + } catch (ClassNotFoundException cnfe) { throw new RuntimeException("Could not find class: " + className); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Unable to instantiate driver class: ", e); } } @@ -78,8 +75,7 @@ public class JDBCUtils { } } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); } @@ -90,16 +86,13 @@ public class JDBCUtils { if (driverClass.contains("derby")) { logger.tracef("getSQLProvider Returning Derby SQL provider for driver::%s, tableName::%s", driverClass, tableName); factory = new DerbySQLProvider.Factory(); - } - else if (driverClass.contains("postgres")) { + } else if (driverClass.contains("postgres")) { logger.tracef("getSQLProvider Returning postgres SQL provider for driver::%s, tableName::%s", driverClass, tableName); factory = new PostgresSQLProvider.Factory(); - } - else if (driverClass.contains("mysql")) { + } else if (driverClass.contains("mysql")) { logger.tracef("getSQLProvider Returning mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName); factory = new MySQLSQLProvider.Factory(); - } - else { + } else { logger.tracef("getSQLProvider Returning generic SQL provider for driver::%s, tableName::%s", driverClass, tableName); factory = new GenericSQLProvider.Factory(); } @@ -123,8 +116,7 @@ public class JDBCUtils { if (provider instanceof PostgresSQLProvider) { dbDriver = new PostgresSequentialSequentialFileDriver(); dbDriver.setDataSource(dataSource); - } - else { + } else { dbDriver = new JDBCSequentialFileFactoryDriver(tableName, dataSource, provider); } return dbDriver; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java index 9ab28de..b277523 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java @@ -16,14 +16,13 @@ */ package org.apache.activemq.artemis.jdbc.store.drivers; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.Driver; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; -import javax.sql.DataSource; - import org.apache.activemq.artemis.jdbc.store.JDBCUtils; import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider; import org.apache.activemq.artemis.journal.ActiveMQJournalLogger; @@ -82,13 +81,11 @@ public abstract class AbstractJDBCDriver { protected void connect() throws Exception { if (dataSource != null) { connection = dataSource.getConnection(); - } - else { + } else { try { dbDriver = JDBCUtils.getDriver(jdbcDriverClass); connection = dbDriver.connect(jdbcConnectionUrl, new Properties()); - } - catch (SQLException e) { + } catch (SQLException e) { ActiveMQJournalLogger.LOGGER.error("Unable to connect to database using URL: " + jdbcConnectionUrl); throw new RuntimeException("Error connecting to database", e); } @@ -102,8 +99,7 @@ public abstract class AbstractJDBCDriver { statement.executeUpdate("DROP TABLE " + sqlProvider.getTableName()); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java index 7a32fcf..7b2ab1f 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java @@ -64,9 +64,10 @@ public class MySQLSQLProvider extends GenericSQLProvider { } public static class Factory implements SQLProvider.Factory { + @Override public SQLProvider create(String tableName) { return new MySQLSQLProvider(tableName); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java index d69cff9..254fa86 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java @@ -53,7 +53,6 @@ public class PostgresSQLProvider extends GenericSQLProvider { public static class Factory implements SQLProvider.Factory { - @Override public SQLProvider create(String tableName) { return new PostgresSQLProvider(tableName); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java index 4d42d7f..db74c05 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java @@ -20,8 +20,8 @@ import java.nio.ByteBuffer; import java.sql.ResultSet; import java.sql.SQLException; -import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver; import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile; +import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver; import org.postgresql.PGConnection; import org.postgresql.largeobject.LargeObject; import org.postgresql.largeobject.LargeObjectManager; @@ -52,8 +52,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa file.setId(keys.getInt(1)); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -69,8 +68,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa file.setWritePosition(getPostGresLargeObjectSize(file)); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -89,8 +87,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa largeObject.write(data); largeObject.close(); connection.commit(); - } - catch (Exception e) { + } catch (Exception e) { connection.rollback(); throw e; } @@ -108,7 +105,8 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa int readLength = (int) calculateReadLength(largeObject.size(), bytes.remaining(), file.position()); if (readLength > 0) { - if (file.position() > 0) largeObject.seek((int) file.position()); + if (file.position() > 0) + largeObject.seek((int) file.position()); byte[] data = largeObject.read(readLength); bytes.put(data); } @@ -117,8 +115,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa connection.commit(); return readLength; - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -134,8 +131,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa file.addMetaData(POSTGRES_OID_KEY, rs.getLong(1)); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -158,8 +154,7 @@ public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFa size = largeObject.size(); largeObject.close(); connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java index 19e9b69..8408991 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java @@ -140,8 +140,7 @@ public class JDBCSequentialFile implements SequentialFile { dbDriver.deleteFile(this); } } - } - catch (SQLException e) { + } catch (SQLException e) { throw new ActiveMQException(ActiveMQExceptionType.IO_ERROR, e.getMessage(), e); } } @@ -155,8 +154,7 @@ public class JDBCSequentialFile implements SequentialFile { callback.done(); return noBytes; } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); if (callback != null) callback.onError(-1, e.getMessage()); @@ -226,12 +224,10 @@ public class JDBCSequentialFile implements SequentialFile { try { scheduleWrite(bytes, waitIOCallback); waitIOCallback.waitCompletion(); - } - catch (Exception e) { + } catch (Exception e) { waitIOCallback.onError(-1, e.getMessage()); } - } - else { + } else { scheduleWrite(bytes, callback); } @@ -252,8 +248,7 @@ public class JDBCSequentialFile implements SequentialFile { if (callback != null) callback.done(); return read; - } - catch (Exception e) { + } catch (Exception e) { if (callback != null) callback.onError(-1, e.getMessage()); e.printStackTrace(); @@ -294,8 +289,7 @@ public class JDBCSequentialFile implements SequentialFile { try { callback.waitCompletion(); - } - catch (Exception e) { + } catch (Exception e) { throw new IOException(e); } } @@ -317,8 +311,7 @@ public class JDBCSequentialFile implements SequentialFile { try { JDBCSequentialFile clone = new JDBCSequentialFile(fileFactory, filename, executor, dbDriver, writeLock); return clone; - } - catch (Exception e) { + } catch (Exception e) { logger.error("Error cloning file: " + filename, e); return null; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java index 48d03bf..8078417 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.jdbc.store.file; +import javax.sql.DataSource; import java.io.File; import java.nio.ByteBuffer; import java.sql.SQLException; @@ -25,8 +26,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import javax.sql.DataSource; - import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; @@ -70,8 +69,7 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM dbDriver.start(); started = true; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.error("Could not start file factory, unable to connect to database"); started = false; } @@ -81,8 +79,7 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM public synchronized void stop() { try { dbDriver.stop(); - } - catch (SQLException e) { + } catch (SQLException e) { ActiveMQJournalLogger.LOGGER.error("Error stopping file factory, unable to close db connection"); } started = false; @@ -97,8 +94,7 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM JDBCSequentialFile file = new JDBCSequentialFile(this, fileName, executor, dbDriver, fileLocks.get(fileName)); files.add(file); return file; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.error("Could not create file", e); } return null; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java index 0ae0335..2110173 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.jdbc.store.file; +import javax.sql.DataSource; import java.nio.ByteBuffer; import java.sql.Blob; import java.sql.PreparedStatement; @@ -25,8 +26,6 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import javax.sql.DataSource; - import org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver; import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider; @@ -84,8 +83,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { } } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -103,8 +101,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { int fileId = fileExists(file); if (fileId < 0) { createFile(file); - } - else { + } else { file.setId(fileId); loadFile(file); } @@ -124,8 +121,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { int id = rs.next() ? rs.getInt(1) : -1; connection.commit(); return id; - } - catch (Exception e) { + } catch (Exception e) { connection.rollback(); throw e; } @@ -146,8 +142,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { file.setWritePosition((int) rs.getBlob(1).length()); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -171,8 +166,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { file.setId(keys.getInt(1)); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -192,8 +186,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { renameFile.setInt(2, file.getId()); renameFile.executeUpdate(); connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -211,8 +204,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { deleteFile.setInt(1, file.getId()); deleteFile.executeUpdate(); connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -234,8 +226,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { appendToLargeObject.executeUpdate(); connection.commit(); return data.length; - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -262,8 +253,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { } connection.commit(); return readLength; - } - catch (Throwable e) { + } catch (Throwable e) { connection.rollback(); throw e; } @@ -283,8 +273,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { copyFileRecord.setInt(2, fileTo.getId()); copyFileRecord.executeUpdate(); connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -301,8 +290,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { statement.executeUpdate(sqlProvider.getDropFileTableSQL()); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); throw e; } @@ -312,8 +300,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { long bytesRemaining = objectLength - readPosition; if (bytesRemaining > bufferSpace) { return bufferSpace; - } - else { + } else { return bytesRemaining; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java index 924fdc8..ef45fe0 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.jdbc.store.journal; +import javax.sql.DataSource; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -29,8 +30,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.sql.DataSource; - import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.IOCompletion; @@ -49,7 +48,6 @@ import org.jboss.logging.Logger; public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { - private static final Logger logger = Logger.getLogger(JDBCJournalImpl.class); // Sync Delay in ms @@ -85,14 +83,22 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { // Sequence ID for journal records private final AtomicLong seq = new AtomicLong(0); - public JDBCJournalImpl(DataSource dataSource, SQLProvider provider, String tableName, ScheduledExecutorService scheduledExecutorService, Executor completeExecutor) { + public JDBCJournalImpl(DataSource dataSource, + SQLProvider provider, + String tableName, + ScheduledExecutorService scheduledExecutorService, + Executor completeExecutor) { super(dataSource, provider); records = new ArrayList<>(); this.scheduledExecutorService = scheduledExecutorService; this.completeExecutor = completeExecutor; } - public JDBCJournalImpl(String jdbcUrl, String jdbcDriverClass, SQLProvider sqlProvider, ScheduledExecutorService scheduledExecutorService, Executor completeExecutor) { + public JDBCJournalImpl(String jdbcUrl, + String jdbcDriverClass, + SQLProvider sqlProvider, + ScheduledExecutorService scheduledExecutorService, + Executor completeExecutor) { super(sqlProvider, jdbcUrl, jdbcDriverClass); records = new ArrayList<>(); this.scheduledExecutorService = scheduledExecutorService; @@ -190,8 +196,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { break; } } - } - catch (SQLException e) { + } catch (SQLException e) { executeCallbacks(recordRef, success); return 0; } @@ -205,16 +210,14 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { connection.commit(); success = true; - } - catch (SQLException e) { + } catch (SQLException e) { performRollback(recordRef); } try { if (success) cleanupTxRecords(deletedRecords, committedTransactions); - } - catch (SQLException e) { + } catch (SQLException e) { e.printStackTrace(); } @@ -271,8 +274,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { transactions.remove(txH.transactionID); } } - } - catch (Exception sqlE) { + } catch (Exception sqlE) { ActiveMQJournalLogger.LOGGER.error("Error performing rollback", sqlE); } } @@ -326,12 +328,10 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { RecordInfo info = new RecordInfo(record.getId(), record.getRecordType(), new byte[0], record.isUpdate(), record.getCompactCount()); if (record.getRecordType() == JDBCJournalRecord.DELETE_RECORD_TX) { txHolder.recordsToDelete.add(info); - } - else { + } else { txHolder.recordInfos.add(info); } - } - else { + } else { txHolder.prepared = true; } } @@ -344,12 +344,10 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { RecordInfo info = new RecordInfo(record.getTxId(), record.getRecordType(), new byte[0], record.isUpdate(), record.getCompactCount()); if (record.getRecordType() == JDBCJournalRecord.DELETE_RECORD_TX) { txHolder.recordsToDelete.remove(info); - } - else { + } else { txHolder.recordInfos.remove(info); } - } - else { + } else { txHolder.prepared = false; } } @@ -670,8 +668,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { try (ResultSet rs = countJournalRecords.executeQuery()) { rs.next(); count = rs.getInt(1); - } - catch (SQLException e) { + } catch (SQLException e) { return -1; } return count; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java index 4678425..cd8a411 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalReaderCallback.java @@ -106,8 +106,7 @@ public class JDBCJournalReaderCallback implements JournalReaderCallback { for (RecordInfo txRecord : tx.recordInfos) { if (txRecord.isUpdate) { loadManager.updateRecord(txRecord); - } - else { + } else { loadManager.addRecord(txRecord); } } @@ -132,8 +131,7 @@ public class JDBCJournalReaderCallback implements JournalReaderCallback { if ((!transaction.prepared && !transaction.committed) || transaction.invalid) { ActiveMQJournalLogger.LOGGER.uncomittedTxFound(transaction.transactionID); loadManager.failedTransaction(transaction.transactionID, transaction.recordInfos, transaction.recordsToDelete); - } - else if (!transaction.committed) { + } else if (!transaction.committed) { PreparedTransactionInfo info = new PreparedTransactionInfo(transaction.transactionID, transaction.extraData); info.getRecords().addAll(transaction.recordInfos); info.getRecordsToDelete().addAll(transaction.recordsToDelete); @@ -145,4 +143,4 @@ public class JDBCJournalReaderCallback implements JournalReaderCallback { public Map<Long, TransactionHolder> getTransactions() { return loadTransactions; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java index 2d31a8f..3b570a0 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java @@ -115,13 +115,11 @@ public class JDBCJournalRecord { } public static String insertRecordsSQL(String tableName) { - return "INSERT INTO " + tableName + "(id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords,seq) " - + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; + return "INSERT INTO " + tableName + "(id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords,seq) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; } public static String selectRecordsSQL(String tableName) { - return "SELECT id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords,seq " - + "FROM " + tableName + " ORDER BY seq ASC"; + return "SELECT id,recordType,compactCount,txId,userRecordType,variableSize,record,txDataSize,txData,txCheckNoRecords,seq " + "FROM " + tableName + " ORDER BY seq ASC"; } public static String deleteRecordsSQL(String tableName) { @@ -136,8 +134,7 @@ public class JDBCJournalRecord { if (ioCompletion != null) { if (success) { ioCompletion.done(); - } - else { + } else { ioCompletion.onError(1, "DATABASE TRANSACTION FAILED"); } } @@ -157,8 +154,7 @@ public class JDBCJournalRecord { try { record.read(recordBytes); txData.read(txDataBytes); - } - catch (IOException e) { + } catch (IOException e) { ActiveMQJournalLogger.LOGGER.error("Error occurred whilst reading Journal Record", e); } @@ -347,4 +343,4 @@ public class JDBCJournalRecord { public long getSeq() { return seq; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java index 0f354bc..1fae83a 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/sql/SQLProvider.java @@ -59,6 +59,7 @@ public interface SQLProvider { boolean closeConnectionOnShutdown(); interface Factory { + SQLProvider create(String tableName); } }
