diff --git a/artemis-boot/src/main/java/org/apache/activemq/artemis/boot/Artemis.java b/artemis-boot/src/main/java/org/apache/activemq/artemis/boot/Artemis.java index bc2910df41..5847a8bdbe 100644 --- a/artemis-boot/src/main/java/org/apache/activemq/artemis/boot/Artemis.java +++ b/artemis-boot/src/main/java/org/apache/activemq/artemis/boot/Artemis.java @@ -45,14 +45,17 @@ public class Artemis { execute(fileHome, fileInstance, args); } - - /** This is a good method for booting an embedded command */ + /** + * This is a good method for booting an embedded command + */ public static Object execute(File artemisHome, File artemisInstance, List args) throws Throwable { return execute(artemisHome, artemisInstance, args.toArray(new String[args.size()])); } - /** This is a good method for booting an embedded command */ - public static Object execute(File fileHome, File fileInstance, String ... args) throws Throwable { + /** + * This is a good method for booting an embedded command + */ + public static Object execute(File fileHome, File fileInstance, String... args) throws Throwable { ArrayList dirs = new ArrayList<>(); if (fileHome != null) { dirs.add(new File(fileHome, "lib")); @@ -61,7 +64,6 @@ public class Artemis { dirs.add(new File(fileInstance, "lib")); } - ArrayList urls = new ArrayList<>(); // Without the etc on the config, things like JGroups configuration wouldn't be loaded @@ -118,13 +120,12 @@ public class Artemis { Thread.currentThread().setContextClassLoader(loader); Class clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis"); Method method = clazz.getMethod("execute", File.class, File.class, args.getClass()); + try { return method.invoke(null, fileHome, fileInstance, args); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { throw e.getTargetException(); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(originalCL); } @@ -141,8 +142,7 @@ public class Artemis { private static void add(ArrayList urls, File file) { try { urls.add(file.toURI().toURL()); - } - catch (MalformedURLException e) { + } catch (MalformedURLException e) { e.printStackTrace(); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java index bd64b3302c..16dcd03f0b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java @@ -24,17 +24,17 @@ import java.util.List; import io.airlift.airline.Cli; import org.apache.activemq.artemis.cli.commands.Action; import org.apache.activemq.artemis.cli.commands.ActionContext; -import org.apache.activemq.artemis.cli.commands.messages.Browse; -import org.apache.activemq.artemis.cli.commands.messages.Consumer; import org.apache.activemq.artemis.cli.commands.Create; -import org.apache.activemq.artemis.cli.commands.destination.CreateDestination; -import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination; import org.apache.activemq.artemis.cli.commands.HelpAction; -import org.apache.activemq.artemis.cli.commands.destination.HelpDestination; import org.apache.activemq.artemis.cli.commands.Kill; -import org.apache.activemq.artemis.cli.commands.messages.Producer; import org.apache.activemq.artemis.cli.commands.Run; import org.apache.activemq.artemis.cli.commands.Stop; +import org.apache.activemq.artemis.cli.commands.destination.CreateDestination; +import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination; +import org.apache.activemq.artemis.cli.commands.destination.HelpDestination; +import org.apache.activemq.artemis.cli.commands.messages.Browse; +import org.apache.activemq.artemis.cli.commands.messages.Consumer; +import org.apache.activemq.artemis.cli.commands.messages.Producer; import org.apache.activemq.artemis.cli.commands.tools.CompactJournal; import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal; import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal; @@ -73,25 +73,21 @@ public class Artemis { public static Object execute(File artemisHome, File artemisInstance, String... args) throws Exception { try { return internalExecute(artemisHome, artemisInstance, args); - } - catch (ConfigurationException configException) { + } catch (ConfigurationException configException) { System.err.println(configException.getMessage()); System.out.println(); System.out.println("Configuration should be specified as 'scheme:location'. Default configuration is 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'"); return configException; - } - catch (CLIException cliException) { + } catch (CLIException cliException) { System.err.println(cliException.getMessage()); return cliException; - } - catch (NullPointerException e) { + } catch (NullPointerException e) { // Yeah.. I really meant System.err.. // this is the CLI and System.out and System.err are common places for interacting with the user // this is a programming error that must be visualized and corrected e.printStackTrace(); return e; - } - catch (RuntimeException re) { + } catch (RuntimeException re) { System.err.println(re.getMessage()); System.out.println(); @@ -102,8 +98,10 @@ public class Artemis { } } - /** This method is used to validate exception returns. - * Useful on test cases */ + /** + * This method is used to validate exception returns. + * Useful on test cases + */ public static Object internalExecute(File artemisHome, File artemisInstance, String[] args) throws Exception { Action action = builder(artemisInstance).build().parse(args); action.setHomeValues(artemisHome, artemisInstance); @@ -122,22 +120,16 @@ public class Artemis { private static Cli.CliBuilder builder(File artemisInstance) { String instance = artemisInstance != null ? artemisInstance.getAbsolutePath() : System.getProperty("artemis.instance"); - Cli.CliBuilder builder = Cli.builder("artemis").withDescription("ActiveMQ Artemis Command Line") - .withCommand(HelpAction.class) - .withCommand(Producer.class) - .withCommand(Consumer.class) - .withCommand(Browse.class) - .withDefaultCommand(HelpAction.class); + Cli.CliBuilder builder = Cli.builder("artemis").withDescription("ActiveMQ Artemis Command Line").withCommand(HelpAction.class).withCommand(Producer.class).withCommand(Consumer.class).withCommand(Browse.class).withDefaultCommand(HelpAction.class); builder.withGroup("destination").withDescription("Destination tools group (create|delete) (example ./artemis destination create)"). - withDefaultCommand(HelpDestination.class).withCommands(CreateDestination.class, DeleteDestination.class); + withDefaultCommand(HelpDestination.class).withCommands(CreateDestination.class, DeleteDestination.class); if (instance != null) { builder.withGroup("data").withDescription("data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)"). withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class, XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class, CompactJournal.class); builder = builder.withCommands(Run.class, Stop.class, Kill.class); - } - else { + } else { builder.withGroup("data").withDescription("data tools group (print) (example ./artemis data print)"). withDefaultCommand(HelpData.class).withCommands(PrintData.class); builder = builder.withCommand(Create.class); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/CLIException.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/CLIException.java index 247d6ef420..20a4106998 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/CLIException.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/CLIException.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, @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.cli; -public class CLIException extends Exception { +public class CLIException extends Exception { public CLIException(String message) { super(message); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java index 1fd183c0e3..1df83934fe 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java @@ -72,7 +72,6 @@ public abstract class Configurable extends ActionAbstract { } } - protected FileConfiguration getFileConfiguration() throws Exception { if (fileConfiguration == null) { if (getBrokerInstance() == null) { @@ -84,8 +83,7 @@ public abstract class Configurable extends ActionAbstract { fileConfiguration.setLargeMessagesDirectory(defaultLocation + "/largemessages"); fileConfiguration.setPagingDirectory(defaultLocation + "/paging"); fileConfiguration.setBrokerInstance(new File(".")); - } - else { + } else { fileConfiguration = new FileConfiguration(); FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration(); @@ -97,7 +95,6 @@ public abstract class Configurable extends ActionAbstract { } } - return fileConfiguration; } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index c99bc786c8..62de0efa5f 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -500,8 +500,7 @@ public class Create extends InputAbstract { if (!created) { throw new RuntimeException(String.format("Unable to create the path '%s'.", directory)); } - } - else if (!directory.canWrite()) { + } else if (!directory.canWrite()) { throw new RuntimeException(String.format("The path '%s' is not writable.", directory)); } } @@ -533,16 +532,14 @@ public class Create extends InputAbstract { if (replicated) { clustered = true; filters.put("${replicated.settings}", applyFilters(readTextFile(ETC_REPLICATED_SETTINGS_TXT), filters)); - } - else { + } else { filters.put("${replicated.settings}", ""); } if (sharedStore) { clustered = true; filters.put("${shared-store.settings}", applyFilters(readTextFile(ETC_SHARED_STORE_SETTINGS_TXT), filters)); - } - else { + } else { filters.put("${shared-store.settings}", ""); } @@ -551,8 +548,7 @@ public class Create extends InputAbstract { if (IS_WINDOWS || !supportsLibaio()) { aio = false; filters.put("${journal.settings}", "NIO"); - } - else { + } else { aio = true; filters.put("${journal.settings}", "ASYNCIO"); } @@ -567,8 +563,7 @@ public class Create extends InputAbstract { extraWebAttr += " clientAuth=\"true\" trustStorePath=\"" + sslTrust + "\" trustStorePassword=\"" + sslTrustPassword + "\""; } filters.put("${extra.web.attributes}", extraWebAttr); - } - else { + } else { filters.put("${web.protocol}", "http"); filters.put("${extra.web.attributes}", ""); } @@ -601,8 +596,7 @@ public class Create extends InputAbstract { filters.put("${cluster.settings}", applyFilters(readTextFile(ETC_CLUSTER_SETTINGS_TXT), filters)); filters.put("${cluster-user}", getClusterUser()); filters.put("${cluster-password}", getClusterPassword()); - } - else { + } else { if (name == null) { name = getHost(); } @@ -643,8 +637,7 @@ public class Create extends InputAbstract { if (isAllowAnonymous()) { write(ETC_LOGIN_CONFIG_WITH_GUEST, filters, false); new File(directory, ETC_LOGIN_CONFIG_WITH_GUEST).renameTo(new File(directory, ETC_LOGIN_CONFIG)); - } - else { + } else { write(ETC_LOGIN_CONFIG_WITHOUT_GUEST, filters, false); new File(directory, ETC_LOGIN_CONFIG_WITHOUT_GUEST).renameTo(new File(directory, ETC_LOGIN_CONFIG)); } @@ -670,36 +663,31 @@ public class Create extends InputAbstract { if (noWeb) { filters.put("${bootstrap-web-settings}", ""); - } - else { + } else { filters.put("${bootstrap-web-settings}", applyFilters(readTextFile(ETC_BOOTSTRAP_WEB_SETTINGS_TXT), filters)); } if (noAmqpAcceptor) { filters.put("${amqp-acceptor}", ""); - } - else { + } else { filters.put("${amqp-acceptor}", applyFilters(readTextFile(ETC_AMQP_ACCEPTOR_TXT), filters)); } if (noMqttAcceptor) { filters.put("${mqtt-acceptor}", ""); - } - else { + } else { filters.put("${mqtt-acceptor}", applyFilters(readTextFile(ETC_MQTT_ACCEPTOR_TXT), filters)); } if (noStompAcceptor) { filters.put("${stomp-acceptor}", ""); - } - else { + } else { filters.put("${stomp-acceptor}", applyFilters(readTextFile(ETC_STOMP_ACCEPTOR_TXT), filters)); } if (noHornetQAcceptor) { filters.put("${hornetq-acceptor}", ""); - } - else { + } else { filters.put("${hornetq-acceptor}", applyFilters(readTextFile(ETC_HORNETQ_ACCEPTOR_TXT), filters)); } @@ -782,8 +770,7 @@ public class Create extends InputAbstract { private void performAutoTune(HashMap filters, boolean aio, File dataFolder) { if (noAutoTune) { filters.put("${journal-buffer.settings}", ""); - } - else { + } else { try { int writes = 250; System.out.println(""); @@ -804,8 +791,7 @@ public class Create extends InputAbstract { filters.put("${journal-buffer.settings}", applyFilters(readTextFile(ETC_JOURNAL_BUFFER_SETTINGS), syncFilter)); - } - catch (Exception e) { + } catch (Exception e) { filters.put("${journal-buffer.settings}", ""); e.printStackTrace(); System.err.println("Couldn't perform sync calculation, using default values"); @@ -817,20 +803,17 @@ public class Create extends InputAbstract { if (forceLibaio) { // forcing libaio return true; - } - else if (forceNIO) { + } else if (forceNIO) { // forcing NIO return false; - } - else if (LibaioContext.isLoaded()) { + } else if (LibaioContext.isLoaded()) { try (LibaioContext context = new LibaioContext(1, true)) { File tmpFile = new File(directory, "validateAIO.bin"); boolean supportsLibaio = true; try { LibaioFile file = context.openFile(tmpFile, true); file.close(); - } - catch (Exception e) { + } catch (Exception e) { supportsLibaio = false; } tmpFile.delete(); @@ -839,8 +822,7 @@ public class Create extends InputAbstract { } return supportsLibaio; } - } - else { + } else { return false; } } @@ -852,8 +834,7 @@ public class Create extends InputAbstract { private String[] getQueueList() { if (queues == null) { return new String[0]; - } - else { + } else { return queues.split(","); } } @@ -861,8 +842,7 @@ public class Create extends InputAbstract { private String[] getTopicList() { if (topics == null) { return new String[0]; - } - else { + } else { return topics.split(","); } } @@ -874,8 +854,7 @@ public class Create extends InputAbstract { private String path(File value, boolean unixPaths) throws IOException { if (unixPaths && IS_CYGWIN) { return value.getCanonicalPath(); - } - else { + } else { return value.getCanonicalPath(); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java index a499d4e370..5625c9ddc5 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java @@ -50,8 +50,7 @@ public class InputAbstract extends ActionAbstract { inputStr = scanner.nextLine(); if (inputStr.trim().equals("")) { System.out.println("Invalid Entry!"); - } - else { + } else { valid = true; } } while (!valid); @@ -74,8 +73,7 @@ public class InputAbstract extends ActionAbstract { if (inputStr.trim().equals("")) { System.out.println("Invalid Entry!"); - } - else { + } else { valid = true; } } while (!valid); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java index 359a564909..ff07106bea 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java @@ -127,8 +127,7 @@ public class Run extends LockAbstract { try { System.err.println("Halting by user request"); fileKill.delete(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } Runtime.getRuntime().halt(0); } @@ -136,13 +135,11 @@ public class Run extends LockAbstract { try { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } timer.cancel(); - } - finally { + } finally { System.out.println("Server stopped!"); System.out.flush(); latchRunning.countDown(); @@ -159,8 +156,7 @@ public class Run extends LockAbstract { public void run() { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java index 985ef14655..a0ae4bf75d 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java @@ -17,6 +17,8 @@ package org.apache.activemq.artemis.cli.commands.destination; +import javax.jms.Message; + import io.airlift.airline.Command; import io.airlift.airline.Option; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -24,8 +26,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; import org.apache.activemq.artemis.cli.commands.ActionContext; -import javax.jms.Message; - @Command(name = "create", description = "create a queue or topic") public class CreateDestination extends DestinationAction { @@ -47,14 +47,11 @@ public class CreateDestination extends DestinationAction { if (JMS_QUEUE.equals(destType)) { createJmsQueue(context); - } - else if (CORE_QUEUE.equals(destType)) { + } else if (CORE_QUEUE.equals(destType)) { createCoreQueue(context); - } - else if (JMS_TOPIC.equals(destType)) { + } else if (JMS_TOPIC.equals(destType)) { createJmsTopic(context); - } - else { + } else { throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE); } return null; @@ -72,8 +69,7 @@ public class CreateDestination extends DestinationAction { boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class); if (result) { context.out.println("Topic " + getName() + " created successfully."); - } - else { + } else { context.err.println("Failed to create topic " + getName() + "."); } } @@ -128,8 +124,7 @@ public class CreateDestination extends DestinationAction { boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class); if (result) { context.out.println("Jms queue " + getName() + " created successfully."); - } - else { + } else { context.err.println("Failed to create jms queue " + getName() + "."); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java index 9b2bc49957..eeb050611d 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java @@ -17,6 +17,8 @@ package org.apache.activemq.artemis.cli.commands.destination; +import javax.jms.Message; + import io.airlift.airline.Command; import io.airlift.airline.Option; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -24,8 +26,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; import org.apache.activemq.artemis.cli.commands.ActionContext; -import javax.jms.Message; - @Command(name = "delete", description = "delete a queue or topic") public class DeleteDestination extends DestinationAction { @@ -38,14 +38,11 @@ public class DeleteDestination extends DestinationAction { if (JMS_QUEUE.equals(destType)) { deleteJmsQueue(context); - } - else if (CORE_QUEUE.equals(destType)) { + } else if (CORE_QUEUE.equals(destType)) { deleteCoreQueue(context); - } - else if (JMS_TOPIC.equals(destType)) { + } else if (JMS_TOPIC.equals(destType)) { deleteJmsTopic(context); - } - else { + } else { throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE); } return null; @@ -63,8 +60,7 @@ public class DeleteDestination extends DestinationAction { boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class); if (result) { context.out.println("Topic " + getName() + " deleted successfully."); - } - else { + } else { context.err.println("Failed to delete topic " + getName()); } } @@ -89,8 +85,7 @@ public class DeleteDestination extends DestinationAction { boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class); if (result) { context.out.println("Jms queue " + getName() + " deleted successfully."); - } - else { + } else { context.err.println("Failed to delete queue " + getName()); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java index ffce4d465b..c128fc5c9c 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.cli.commands.destination; +import javax.jms.Message; +import javax.jms.Queue; +import javax.jms.QueueRequestor; +import javax.jms.Session; + import io.airlift.airline.Option; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -32,11 +37,6 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnection; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQSession; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueRequestor; -import javax.jms.Session; - public abstract class DestinationAction extends InputAbstract { public static final String JMS_QUEUE = "jms-queue"; @@ -58,7 +58,10 @@ public abstract class DestinationAction extends InputAbstract { @Option(name = "--name", description = "destination name") String name; - public static void performJmsManagement(String brokerURL, String user, String password, ManagementCallback cb) throws Exception { + public static void performJmsManagement(String brokerURL, + String user, + String password, + ManagementCallback cb) throws Exception { try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURL, user, password); ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection(); @@ -79,15 +82,16 @@ public abstract class DestinationAction extends InputAbstract { if (result) { cb.requestSuccessful(reply); - } - else { + } else { cb.requestFailed(reply); } } } - public static void performCoreManagement(String brokerURL, String user, String password, ManagementCallback cb) throws Exception { - + public static void performCoreManagement(String brokerURL, + String user, + String password, + ManagementCallback cb) throws Exception { try (ServerLocator locator = ServerLocatorImpl.newLocator(brokerURL); ClientSessionFactory sessionFactory = locator.createSessionFactory(); @@ -102,8 +106,7 @@ public abstract class DestinationAction extends InputAbstract { if (ManagementHelper.hasOperationSucceeded(reply)) { cb.requestSuccessful(reply); - } - else { + } else { cb.requestFailed(reply); } } @@ -130,6 +133,7 @@ public abstract class DestinationAction extends InputAbstract { } public interface ManagementCallback { + void setUpInvocation(T message) throws Exception; void requestSuccessful(T reply) throws Exception; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java index b9d9d73403..3455520f4a 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java @@ -17,14 +17,14 @@ package org.apache.activemq.artemis.cli.commands.destination; -import io.airlift.airline.Help; -import org.apache.activemq.artemis.cli.commands.Action; -import org.apache.activemq.artemis.cli.commands.ActionContext; - import java.io.File; import java.util.ArrayList; import java.util.List; +import io.airlift.airline.Help; +import org.apache.activemq.artemis.cli.commands.Action; +import org.apache.activemq.artemis.cli.commands.ActionContext; + public class HelpDestination extends Help implements Action { @Override diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java index dbd091351e..3149708e81 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java @@ -17,6 +17,10 @@ package org.apache.activemq.artemis.cli.commands.messages; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Session; + import io.airlift.airline.Command; import io.airlift.airline.Option; import org.apache.activemq.artemis.cli.commands.ActionContext; @@ -24,10 +28,6 @@ import org.apache.activemq.artemis.cli.commands.util.ConsumerThread; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Session; - @Command(name = "browser", description = "It will send consume messages from an instance") public class Browse extends DestAbstract { @@ -49,8 +49,7 @@ public class Browse extends DestAbstract { Session session; if (txBatchSize > 0) { session = connection.createSession(true, Session.SESSION_TRANSACTED); - } - else { + } else { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } threadsArray[i] = new ConsumerThread(session, dest, i); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java index dee847569b..71bf40cf2f 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java @@ -58,8 +58,7 @@ public class Consumer extends DestAbstract { Session session; if (txBatchSize > 0) { session = connection.createSession(true, Session.SESSION_TRANSACTED); - } - else { + } else { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } threadsArray[i] = new ConsumerThread(session, dest, i); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java index ea3b088dad..1f6a4b1921 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java @@ -59,8 +59,7 @@ public class Producer extends DestAbstract { Session session; if (txBatchSize > 0) { session = connection.createSession(true, Session.SESSION_TRANSACTED); - } - else { + } else { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } threadsArray[i] = new ProducerThread(session, dest, i); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java index a638963fda..2959828e1d 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java @@ -38,8 +38,7 @@ public final class CompactJournal extends LockAbstract { compactJournal(new File(getBinding()), "activemq-bindings", "bindings", 2, 1048576, null); System.out.println("Compactation succeeded for " + getBinding()); - } - catch (Exception e) { + } catch (Exception e) { treatError(e, "data", "compact"); } return null; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/DecodeJournal.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/DecodeJournal.java index e39b055930..b392f6ffb0 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/DecodeJournal.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/DecodeJournal.java @@ -62,8 +62,7 @@ public class DecodeJournal extends LockAbstract { directory = getFileConfiguration().getJournalDirectory(); } importJournal(directory, prefix, suffix, 2, size, input); - } - catch (Exception e) { + } catch (Exception e) { treatError(e, "data", "decode"); } @@ -145,41 +144,35 @@ public class DecodeJournal extends LockAbstract { if (operation.equals("AddRecord")) { RecordInfo info = parseRecord(lineProperties); journal.appendAddRecord(info.id, info.userRecordType, info.data, false); - } - else if (operation.equals("AddRecordTX")) { + } else if (operation.equals("AddRecordTX")) { long txID = parseLong("txID", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); counter.incrementAndGet(); RecordInfo info = parseRecord(lineProperties); journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data); - } - else if (operation.equals("AddRecordTX")) { + } else if (operation.equals("AddRecordTX")) { long txID = parseLong("txID", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); counter.incrementAndGet(); RecordInfo info = parseRecord(lineProperties); journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data); - } - else if (operation.equals("UpdateTX")) { + } else if (operation.equals("UpdateTX")) { long txID = parseLong("txID", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); counter.incrementAndGet(); RecordInfo info = parseRecord(lineProperties); journal.appendUpdateRecordTransactional(txID, info.id, info.userRecordType, info.data); - } - else if (operation.equals("Update")) { + } else if (operation.equals("Update")) { RecordInfo info = parseRecord(lineProperties); journal.appendUpdateRecord(info.id, info.userRecordType, info.data, false); - } - else if (operation.equals("DeleteRecord")) { + } else if (operation.equals("DeleteRecord")) { long id = parseLong("id", lineProperties); // If not found it means the append/update records were reclaimed already if (journalRecords.get(id) != null) { journal.appendDeleteRecord(id, false); } - } - else if (operation.equals("DeleteRecordTX")) { + } else if (operation.equals("DeleteRecordTX")) { long txID = parseLong("txID", lineProperties); long id = parseLong("id", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); @@ -189,8 +182,7 @@ public class DecodeJournal extends LockAbstract { if (journalRecords.get(id) != null) { journal.appendDeleteRecordTransactional(txID, id); } - } - else if (operation.equals("Prepare")) { + } else if (operation.equals("Prepare")) { long txID = parseLong("txID", lineProperties); int numberOfRecords = parseInt("numberOfRecords", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); @@ -198,8 +190,7 @@ public class DecodeJournal extends LockAbstract { if (counter.get() == numberOfRecords) { journal.appendPrepareRecord(txID, data, false); - } - else { + } else { System.err.println("Transaction " + txID + " at line " + lineNumber + @@ -208,15 +199,13 @@ public class DecodeJournal extends LockAbstract { " while the import only had " + counter); } - } - else if (operation.equals("Commit")) { + } else if (operation.equals("Commit")) { long txID = parseLong("txID", lineProperties); int numberOfRecords = parseInt("numberOfRecords", lineProperties); AtomicInteger counter = getCounter(txID, txCounters); if (counter.get() == numberOfRecords) { journal.appendCommitRecord(txID, false); - } - else { + } else { System.err.println("Transaction " + txID + " at line " + lineNumber + @@ -225,16 +214,13 @@ public class DecodeJournal extends LockAbstract { " while the import only had " + counter); } - } - else if (operation.equals("Rollback")) { + } else if (operation.equals("Rollback")) { long txID = parseLong("txID", lineProperties); journal.appendRollbackRecord(txID, false); - } - else { + } else { System.err.println("Invalid operation " + operation + " at line " + lineNumber); } - } - catch (Exception ex) { + } catch (Exception ex) { System.err.println("Error at line " + lineNumber + ", operation=" + operation + " msg = " + ex.getMessage()); } } @@ -317,8 +303,7 @@ public class DecodeJournal extends LockAbstract { String[] tuple = el.split("@"); if (tuple.length == 2) { properties.put(tuple[0], tuple[1]); - } - else { + } else { properties.put(tuple[0], tuple[0]); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/EncodeJournal.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/EncodeJournal.java index d34b4ca273..e5fd80cea7 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/EncodeJournal.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/EncodeJournal.java @@ -57,8 +57,7 @@ public class EncodeJournal extends LockAbstract { } exportJournal(directory, prefix, suffix, 2, size); - } - catch (Exception e) { + } catch (Exception e) { treatError(e, "data", "encode"); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/LockAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/LockAbstract.java index 2089d3e005..602b55a47b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/LockAbstract.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/LockAbstract.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, @@ -26,7 +26,8 @@ import org.apache.activemq.artemis.cli.CLIException; import org.apache.activemq.artemis.cli.commands.Action; import org.apache.activemq.artemis.cli.commands.ActionContext; -public abstract class LockAbstract extends DataAbstract implements Action { +public abstract class LockAbstract extends DataAbstract implements Action { + // There should be one lock per VM // These will be locked as long as the VM is running private static RandomAccessFile serverLockFile = null; @@ -35,9 +36,8 @@ public abstract class LockAbstract extends DataAbstract implements Action { protected File getLockPlace() throws Exception { String brokerInstance = getBrokerInstance(); if (brokerInstance != null) { - return new File(new File(brokerInstance),"lock"); - } - else { + return new File(new File(brokerInstance), "lock"); + } else { return null; } } @@ -53,8 +53,7 @@ public abstract class LockAbstract extends DataAbstract implements Action { serverLockLock.close(); serverLockLock = null; } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -65,15 +64,13 @@ public abstract class LockAbstract extends DataAbstract implements Action { if (getBrokerInstance() == null) { System.err.println("Warning: You are running a data tool outside of any broker instance. Modifying data on a running server might break the server's data"); System.err.println(); - } - else { + } else { lockCLI(getLockPlace()); } return null; } - protected void lockCLI(File lockPlace) throws Exception { if (lockPlace != null) { lockPlace.mkdirs(); @@ -87,12 +84,10 @@ public abstract class LockAbstract extends DataAbstract implements Action { throw new CLIException("Error: There is another process using the server at " + lockPlace + ". Cannot start the process!"); } serverLockLock = lock; - } - catch (OverlappingFileLockException e) { + } catch (OverlappingFileLockException e) { throw new CLIException("Error: There is another process using the server at " + lockPlace + ". Cannot start the process!"); } } } - } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/OptionalLocking.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/OptionalLocking.java index 5a536564a0..7169ba4e81 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/OptionalLocking.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/OptionalLocking.java @@ -21,7 +21,9 @@ import java.io.File; import io.airlift.airline.Option; -/** This is for commands where --f on ignoring lock could be valid. */ +/** + * This is for commands where --f on ignoring lock could be valid. + */ public class OptionalLocking extends LockAbstract { @Option(name = "--f", description = "This will allow certain tools like print-data to be performed ignoring any running servers. WARNING: Changing data concurrently with a running broker may damage your data. Be careful with this option.") diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java index 9b273b2a3b..408aef5f41 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java @@ -65,8 +65,7 @@ public class PrintData extends OptionalLocking { super.execute(context); try { printData(new File(getBinding()), new File(getJournal()), new File(getPaging())); - } - catch (Exception e) { + } catch (Exception e) { treatError(e, "data", "print"); } return null; @@ -87,8 +86,7 @@ public class PrintData extends OptionalLocking { System.out.println("Server's ID=" + fileLock.getNodeId().toString()); System.out.println("********************************************"); fileLock.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -99,8 +97,7 @@ public class PrintData extends OptionalLocking { try { DescribeJournal.describeBindingsJournal(bindingsDirectory); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -112,8 +109,7 @@ public class PrintData extends OptionalLocking { DescribeJournal describeJournal = null; try { describeJournal = DescribeJournal.describeMessagesJournal(messagesDirectory); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return; } @@ -125,8 +121,7 @@ public class PrintData extends OptionalLocking { System.out.println("********************************************"); printPages(pagingDirectory, describeJournal); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return; } @@ -218,8 +213,7 @@ public class PrintData extends OptionalLocking { } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -248,8 +242,7 @@ public class PrintData extends OptionalLocking { } set.add(encoding.position); - } - else if (record.userRecordType == JournalRecordIds.PAGE_CURSOR_COMPLETE) { + } else if (record.userRecordType == JournalRecordIds.PAGE_CURSOR_COMPLETE) { CursorAckRecordEncoding encoding = new CursorAckRecordEncoding(); encoding.decode(buff); @@ -259,15 +252,13 @@ public class PrintData extends OptionalLocking { if (!cursorInfo.getCompletePages(queueID).add(pageNR)) { System.err.println("Page " + pageNR + " has been already set as complete on queue " + queueID); } - } - else if (record.userRecordType == JournalRecordIds.PAGE_TRANSACTION) { + } else if (record.userRecordType == JournalRecordIds.PAGE_TRANSACTION) { if (record.isUpdate) { PageUpdateTXEncoding pageUpdate = new PageUpdateTXEncoding(); pageUpdate.decode(buff); cursorInfo.getPgTXs().add(pageUpdate.pageTX); - } - else { + } else { PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl(); pageTransactionInfo.decode(buff); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java index 05f1fb5616..a0e6c1e87a 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java @@ -66,12 +66,12 @@ import org.apache.activemq.artemis.core.paging.impl.Page; import org.apache.activemq.artemis.core.paging.impl.PageTransactionInfoImpl; import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl; import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO; +import org.apache.activemq.artemis.core.persistence.impl.journal.AckDescribe; import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal; import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.MessageDescribe; import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.ReferenceDescribe; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; -import org.apache.activemq.artemis.core.persistence.impl.journal.AckDescribe; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.CursorAckRecordEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageUpdateTXEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentQueueBindingEncoding; @@ -130,8 +130,7 @@ public final class XmlDataExporter extends OptionalLocking { try { process(context.out, getBinding(), getJournal(), getPaging(), getLargeMessages()); - } - catch (Exception e) { + } catch (Exception e) { treatError(e, "data", "exp"); } return null; @@ -236,26 +235,21 @@ public final class XmlDataExporter extends OptionalLocking { Object o = DescribeJournal.newObjectEncoding(info, storageManager); if (info.getUserRecordType() == JournalRecordIds.ADD_MESSAGE) { messages.put(info.id, ((MessageDescribe) o).getMsg()); - } - else if (info.getUserRecordType() == JournalRecordIds.ADD_LARGE_MESSAGE) { + } else if (info.getUserRecordType() == JournalRecordIds.ADD_LARGE_MESSAGE) { messages.put(info.id, ((MessageDescribe) o).getMsg()); - } - else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) { + } else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) { ReferenceDescribe ref = (ReferenceDescribe) o; HashMap map = messageRefs.get(info.id); if (map == null) { HashMap newMap = new HashMap<>(); newMap.put(ref.refEncoding.queueID, ref); messageRefs.put(info.id, newMap); - } - else { + } else { map.put(ref.refEncoding.queueID, ref); } - } - else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { + } else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { acks.add(info); - } - else if (info.userRecordType == JournalRecordIds.ACKNOWLEDGE_CURSOR) { + } else if (info.userRecordType == JournalRecordIds.ACKNOWLEDGE_CURSOR) { CursorAckRecordEncoding encoding = new CursorAckRecordEncoding(); encoding.decode(buff); @@ -267,15 +261,13 @@ public final class XmlDataExporter extends OptionalLocking { } set.add(encoding.position); - } - else if (info.userRecordType == JournalRecordIds.PAGE_TRANSACTION) { + } else if (info.userRecordType == JournalRecordIds.PAGE_TRANSACTION) { if (info.isUpdate) { PageUpdateTXEncoding pageUpdate = new PageUpdateTXEncoding(); pageUpdate.decode(buff); pgTXs.add(pageUpdate.pageTX); - } - else { + } else { PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl(); pageTransactionInfo.decode(buff); @@ -336,15 +328,13 @@ public final class XmlDataExporter extends OptionalLocking { cf.setId(id); ActiveMQServerLogger.LOGGER.info("Found JMS connection factory: " + cf.getName()); jmsConnectionFactories.put(cf.getName(), cf); - } - else if (rec == JMSJournalStorageManagerImpl.DESTINATION_RECORD) { + } else if (rec == JMSJournalStorageManagerImpl.DESTINATION_RECORD) { PersistedDestination destination = new PersistedDestination(); destination.decode(buffer); destination.setId(id); ActiveMQServerLogger.LOGGER.info("Found JMS destination: " + destination.getName()); jmsDestinations.put(new Pair<>(destination.getType(), destination.getName()), destination); - } - else if (rec == JMSJournalStorageManagerImpl.BINDING_RECORD) { + } else if (rec == JMSJournalStorageManagerImpl.BINDING_RECORD) { PersistedBindings jndi = new PersistedBindings(); jndi.decode(buffer); jndi.setId(id); @@ -355,8 +345,7 @@ public final class XmlDataExporter extends OptionalLocking { } ActiveMQServerLogger.LOGGER.info("Found JMS JNDI binding data for " + jndi.getType() + " " + jndi.getName() + ": " + builder.toString()); jmsJNDI.put(key, jndi); - } - else { + } else { throw new IllegalStateException("Invalid record type " + rec); } @@ -401,8 +390,7 @@ public final class XmlDataExporter extends OptionalLocking { xmlWriter.writeEndDocument(); xmlWriter.flush(); xmlWriter.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -745,13 +733,11 @@ public final class XmlDataExporter extends OptionalLocking { pageId++; } - } - else { + } else { ActiveMQServerLogger.LOGGER.debug("Page store was null"); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -771,8 +757,7 @@ public final class XmlDataExporter extends OptionalLocking { if (message.isLargeMessage()) { printLargeMessageBody((LargeServerMessage) message); - } - else { + } else { int size = message.getEndOfBodyPosition() - message.getBodyBuffer().readerIndex(); byte[] buffer = new byte[size]; message.getBodyBuffer().readBytes(buffer); @@ -796,8 +781,7 @@ public final class XmlDataExporter extends OptionalLocking { Long remainder = bodySize - totalBytesWritten; if (remainder >= LARGE_MESSAGE_CHUNK_SIZE) { bufferSize = LARGE_MESSAGE_CHUNK_SIZE; - } - else { + } else { bufferSize = remainder; } ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(bufferSize.intValue()); @@ -806,16 +790,13 @@ public final class XmlDataExporter extends OptionalLocking { totalBytesWritten += bufferSize; } encoder.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); - } - finally { + } finally { if (encoder != null) { try { encoder.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } } @@ -839,39 +820,29 @@ public final class XmlDataExporter extends OptionalLocking { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_NAME, key.toString()); if (value instanceof byte[]) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, encode((byte[]) value)); - } - else { + } else { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, value == null ? XmlDataConstants.NULL : value.toString()); } if (value instanceof Boolean) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BOOLEAN); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BYTE); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_SHORT); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_INTEGER); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_LONG); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_FLOAT); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_DOUBLE); - } - else if (value instanceof String) { + } else if (value instanceof String) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_STRING); - } - else if (value instanceof SimpleString) { + } else if (value instanceof SimpleString) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_TYPE, XmlDataConstants.PROPERTY_TYPE_BYTES); } } @@ -887,17 +858,13 @@ public final class XmlDataExporter extends OptionalLocking { String prettyType = XmlDataConstants.DEFAULT_TYPE_PRETTY; if (rawType == Message.BYTES_TYPE) { prettyType = XmlDataConstants.BYTES_TYPE_PRETTY; - } - else if (rawType == Message.MAP_TYPE) { + } else if (rawType == Message.MAP_TYPE) { prettyType = XmlDataConstants.MAP_TYPE_PRETTY; - } - else if (rawType == Message.OBJECT_TYPE) { + } else if (rawType == Message.OBJECT_TYPE) { prettyType = XmlDataConstants.OBJECT_TYPE_PRETTY; - } - else if (rawType == Message.STREAM_TYPE) { + } else if (rawType == Message.STREAM_TYPE) { prettyType = XmlDataConstants.STREAM_TYPE_PRETTY; - } - else if (rawType == Message.TEXT_TYPE) { + } else if (rawType == Message.TEXT_TYPE) { prettyType = XmlDataConstants.TEXT_TYPE_PRETTY; } xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_TYPE, prettyType); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java index f73a1b1d5e..f0b8c3c20a 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java @@ -161,8 +161,7 @@ public final class XmlDataImporter extends ActionAbstract { this.session = session; if (managementSession != null) { this.managementSession = managementSession; - } - else { + } else { this.managementSession = session; } localSession = false; @@ -182,8 +181,7 @@ public final class XmlDataImporter extends ActionAbstract { if (user != null || password != null) { session = sf.createSession(user, password, false, !transactional, true, false, 0); managementSession = sf.createSession(user, password, false, true, true, false, 0); - } - else { + } else { session = sf.createSession(false, !transactional, true); managementSession = sf.createSession(false, true, true); } @@ -201,14 +199,11 @@ public final class XmlDataImporter extends ActionAbstract { if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { if (XmlDataConstants.BINDINGS_CHILD.equals(reader.getLocalName())) { bindQueue(); - } - else if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName())) { + } else if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName())) { processMessage(); - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName())) { createJmsConnectionFactories(); - } - else if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName())) { createJmsDestinations(); } } @@ -218,8 +213,7 @@ public final class XmlDataImporter extends ActionAbstract { if (!session.isAutoCommitSends()) { session.commit(); } - } - finally { + } finally { // if the session was created in our constructor then close it (otherwise the caller will close it) if (localSession) { session.close(); @@ -270,11 +264,9 @@ public final class XmlDataImporter extends ActionAbstract { case XMLStreamConstants.START_ELEMENT: if (XmlDataConstants.MESSAGE_BODY.equals(reader.getLocalName())) { processMessageBody(message); - } - else if (XmlDataConstants.PROPERTIES_CHILD.equals(reader.getLocalName())) { + } else if (XmlDataConstants.PROPERTIES_CHILD.equals(reader.getLocalName())) { processMessageProperties(message); - } - else if (XmlDataConstants.QUEUES_CHILD.equals(reader.getLocalName())) { + } else if (XmlDataConstants.QUEUES_CHILD.equals(reader.getLocalName())) { processMessageQueues(queues); } break; @@ -330,8 +322,7 @@ public final class XmlDataImporter extends ActionAbstract { if (queueIDs.containsKey(queue)) { queueID = queueIDs.get(queue); - } - else { + } else { // Get the ID of the queues involved so the message can be routed properly. This is done because we cannot // send directly to a queue, we have to send to an address instead but not all the queues related to the // address may need the message @@ -474,8 +465,7 @@ public final class XmlDataImporter extends ActionAbstract { FileInputStream fileInputStream = new FileInputStream(tempFileName); BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream); ((ClientMessage) message).setBodyInputStream(bufferedInput); - } - else { + } else { getMessageBodyBytes(new MessageBodyBytesProcessor() { @Override public void processBodyBytes(byte[] bytes) throws IOException { @@ -502,15 +492,13 @@ public final class XmlDataImporter extends ActionAbstract { currentEventType = reader.getEventType(); if (currentEventType == XMLStreamConstants.END_ELEMENT) { break; - } + } else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) { /* when we hit a whitespace CHARACTERS event we know that the entire CDATA is complete so decode, pass back to * the processor, and reset the cdata for the next event(s) */ - else if (currentEventType == XMLStreamConstants.CHARACTERS && reader.isWhiteSpace() && cdata.length() > 0) { processor.processBodyBytes(decode(cdata.toString())); cdata.setLength(0); - } - else { + } else { cdata.append(new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()).trim()); } reader.next(); @@ -544,8 +532,7 @@ public final class XmlDataImporter extends ActionAbstract { if (logger.isDebugEnabled()) { logger.debug("Binding queue(name=" + queueName + ", address=" + address + ", filter=" + filter + ")"); } - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Binding " + queueName + " already exists so won't re-bind."); } @@ -651,210 +638,175 @@ public final class XmlDataImporter extends ActionAbstract { if (logger.isDebugEnabled()) { logger.debug("JMS connection factory callFailoverTimeout: " + callFailoverTimeout); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_TIMEOUT.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_TIMEOUT.equals(reader.getLocalName())) { callTimeout = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory callTimeout: " + callTimeout); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD.equals(reader.getLocalName())) { clientFailureCheckPeriod = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory clientFailureCheckPeriod: " + clientFailureCheckPeriod); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_ID.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_ID.equals(reader.getLocalName())) { clientId = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory clientId: " + clientId); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE.equals(reader.getLocalName())) { confirmationWindowSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory confirmationWindowSize: " + confirmationWindowSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTION_TTL.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTION_TTL.equals(reader.getLocalName())) { connectionTtl = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory connectionTtl: " + connectionTtl); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName())) { connectors = getConnectors(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory getLocalName: " + connectors); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE.equals(reader.getLocalName())) { consumerMaxRate = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory consumerMaxRate: " + consumerMaxRate); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE.equals(reader.getLocalName())) { consumerWindowSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory consumerWindowSize: " + consumerWindowSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME.equals(reader.getLocalName())) { discoveryGroupName = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory discoveryGroupName: " + discoveryGroupName); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE.equals(reader.getLocalName())) { dupsOkBatchSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory dupsOkBatchSize: " + dupsOkBatchSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_GROUP_ID.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_GROUP_ID.equals(reader.getLocalName())) { groupId = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory groupId: " + groupId); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME.equals(reader.getLocalName())) { loadBalancingPolicyClassName = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory loadBalancingPolicyClassName: " + loadBalancingPolicyClassName); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL.equals(reader.getLocalName())) { maxRetryInterval = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory maxRetryInterval: " + maxRetryInterval); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE.equals(reader.getLocalName())) { minLargeMessageSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory minLargeMessageSize: " + minLargeMessageSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_NAME.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_NAME.equals(reader.getLocalName())) { name = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory name: " + name); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE.equals(reader.getLocalName())) { producerMaxRate = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory producerMaxRate: " + producerMaxRate); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE.equals(reader.getLocalName())) { producerWindowSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory producerWindowSize: " + producerWindowSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS.equals(reader.getLocalName())) { reconnectAttempts = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory reconnectAttempts: " + reconnectAttempts); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL.equals(reader.getLocalName())) { retryInterval = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory retryInterval: " + retryInterval); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER.equals(reader.getLocalName())) { retryIntervalMultiplier = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory retryIntervalMultiplier: " + retryIntervalMultiplier); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) { scheduledThreadMaxPoolSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory scheduledThreadMaxPoolSize: " + scheduledThreadMaxPoolSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName())) { threadMaxPoolSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory threadMaxPoolSize: " + threadMaxPoolSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE.equals(reader.getLocalName())) { transactionBatchSize = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory transactionBatchSize: " + transactionBatchSize); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TYPE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TYPE.equals(reader.getLocalName())) { type = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory type: " + type); } - } - else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) { entries = getEntries(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory entries: " + entries); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_AUTO_GROUP.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_AUTO_GROUP.equals(reader.getLocalName())) { autoGroup = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory autoGroup: " + autoGroup); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE.equals(reader.getLocalName())) { blockOnAcknowledge = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory blockOnAcknowledge: " + blockOnAcknowledge); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND.equals(reader.getLocalName())) { blockOnDurableSend = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory blockOnDurableSend: " + blockOnDurableSend); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND.equals(reader.getLocalName())) { blockOnNonDurableSend = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory blockOnNonDurableSend: " + blockOnNonDurableSend); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT.equals(reader.getLocalName())) { cacheLargeMessagesClient = reader.getElementText(); ActiveMQServerLogger.LOGGER.info("JMS connection factory " + name + " cacheLargeMessagesClient: " + cacheLargeMessagesClient); - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES.equals(reader.getLocalName())) { compressLargeMessages = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory compressLargeMessages: " + compressLargeMessages); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION.equals(reader.getLocalName())) { failoverOnInitialConnection = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory failoverOnInitialConnection: " + failoverOnInitialConnection); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_HA.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_HA.equals(reader.getLocalName())) { ha = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory ha: " + ha); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PREACKNOWLEDGE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PREACKNOWLEDGE.equals(reader.getLocalName())) { preacknowledge = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory preacknowledge: " + preacknowledge); } - } - else if (XmlDataConstants.JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS.equals(reader.getLocalName())) { useGlobalPools = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS connection factory useGlobalPools: " + useGlobalPools); @@ -883,8 +835,7 @@ public final class XmlDataImporter extends ActionAbstract { if (logger.isDebugEnabled()) { logger.debug("Created connection factory " + name); } - } - else { + } else { ActiveMQServerLogger.LOGGER.error("Problem creating " + name); } @@ -907,20 +858,17 @@ public final class XmlDataImporter extends ActionAbstract { if (logger.isDebugEnabled()) { logger.debug("JMS destination name: " + name); } - } - else if (XmlDataConstants.JMS_DESTINATION_SELECTOR.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_DESTINATION_SELECTOR.equals(reader.getLocalName())) { selector = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS destination selector: " + selector); } - } - else if (XmlDataConstants.JMS_DESTINATION_TYPE.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_DESTINATION_TYPE.equals(reader.getLocalName())) { type = reader.getElementText(); if (logger.isDebugEnabled()) { logger.debug("JMS destination type: " + type); } - } - else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) { + } else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) { entries = getEntries(); } break; @@ -940,8 +888,7 @@ public final class XmlDataImporter extends ActionAbstract { ClientMessage managementMessage = managementSession.createMessage(false); if ("Queue".equals(type)) { ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createQueue", name, entries, selector); - } - else if ("Topic".equals(type)) { + } else if ("Topic".equals(type)) { ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createTopic", name, entries); } managementSession.start(); @@ -950,8 +897,7 @@ public final class XmlDataImporter extends ActionAbstract { if (logger.isDebugEnabled()) { logger.debug("Created " + type.toLowerCase() + " " + name); } - } - else { + } else { ActiveMQServerLogger.LOGGER.error("Problem creating " + name); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ConsumerThread.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ConsumerThread.java index fea2f3e039..fc635186c8 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ConsumerThread.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ConsumerThread.java @@ -60,8 +60,7 @@ public class ConsumerThread extends Thread { public void run() { if (browse) { browse(); - } - else { + } else { consume(); } } @@ -74,8 +73,7 @@ public class ConsumerThread extends Thread { try { if (filter != null) { consumer = session.createBrowser((Queue) destination, filter); - } - else { + } else { consumer = session.createBrowser((Queue) destination); } Enumeration enumBrowse = consumer.getEnumeration(); @@ -99,8 +97,7 @@ public class ConsumerThread extends Thread { if (received >= messageCount) { break; } - } - else { + } else { break; } @@ -111,11 +108,9 @@ public class ConsumerThread extends Thread { } consumer.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (finished != null) { finished.countDown(); } @@ -123,8 +118,7 @@ public class ConsumerThread extends Thread { System.out.println(threadName + " Consumed: " + this.getReceived() + " messages"); try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -142,16 +136,13 @@ public class ConsumerThread extends Thread { if (durable && destination instanceof Topic) { if (filter != null) { consumer = session.createDurableSubscriber((Topic) destination, getName(), filter, false); - } - else { + } else { consumer = session.createDurableSubscriber((Topic) destination, getName()); } - } - else { + } else { if (filter != null) { consumer = session.createConsumer(destination, filter); - } - else { + } else { consumer = session.createConsumer(destination); } } @@ -169,8 +160,7 @@ public class ConsumerThread extends Thread { System.out.println("Message:" + msg); } received++; - } - else { + } else { if (breakOnNull) { break; } @@ -181,8 +171,7 @@ public class ConsumerThread extends Thread { System.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } - } - else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { + } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { if (batchSize > 0 && received > 0 && received % batchSize == 0) { System.out.println("Acknowledging last " + batchSize + " messages; messages so far = " + received); msg.acknowledge(); @@ -196,14 +185,11 @@ public class ConsumerThread extends Thread { try { session.commit(); + } catch (Throwable ignored) { } - catch (Throwable ignored) { - } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (finished != null) { finished.countDown(); } @@ -211,8 +197,7 @@ public class ConsumerThread extends Thread { System.out.println(threadName + " Consumed: " + this.getReceived() + " messages"); try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java index aaf08d3edc..67cef6723f 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java @@ -84,8 +84,7 @@ public class ProducerThread extends Thread { sendMessage(producer, threadName); sentCount.incrementAndGet(); } - } - else { + } else { for (sentCount.set(0); sentCount.get() < messageCount && running; sentCount.incrementAndGet()) { paused.await(); sendMessage(producer, threadName); @@ -94,8 +93,7 @@ public class ProducerThread extends Thread { try { session.commit(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } System.out.println(threadName + " Produced: " + this.getSentCount() + " messages"); @@ -104,19 +102,16 @@ public class ProducerThread extends Thread { System.out.println(threadName + " Elapsed time in second : " + elapsed + " s"); System.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (finished != null) { finished.countDown(); } if (producer != null) { try { producer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -154,20 +149,16 @@ public class ProducerThread extends Thread { if (payload != null) { answer = session.createBytesMessage(); ((BytesMessage) answer).writeBytes(payload); - } - else { + } else { if (textMessageSize > 0) { if (messageText == null) { messageText = readInputStream(getClass().getResourceAsStream("demo.txt"), textMessageSize, i); } - } - else if (payloadUrl != null) { + } else if (payloadUrl != null) { messageText = readInputStream(new URL(payloadUrl).openStream(), -1, i); - } - else if (message != null) { + } else if (message != null) { messageText = message; - } - else { + } else { messageText = createDefaultMessage(i); } answer = session.createTextMessage(messageText); @@ -186,8 +177,7 @@ public class ProducerThread extends Thread { char[] buffer; if (size > 0) { buffer = new char[size]; - } - else { + } else { buffer = new char[1024]; } int count; @@ -198,8 +188,7 @@ public class ProducerThread extends Thread { break; } return builder.toString(); - } - catch (IOException ioe) { + } catch (IOException ioe) { return createDefaultMessage(messageNumber); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.java index e3799d90a1..468eabf7ff 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.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, @@ -122,22 +122,18 @@ public class SyncCalculation { } return totalTime; - } - finally { + } finally { try { file.close(); - } - catch (Exception e) { + } catch (Exception e) { } try { file.delete(); - } - catch (Exception e) { + } catch (Exception e) { } try { factory.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -160,8 +156,7 @@ public class SyncCalculation { ((AIOSequentialFileFactory) factory).disableBufferReuse(); return factory; - } - else { + } else { SequentialFileFactory factory = new NIOSequentialFileFactory(datafolder, 1); factory.start(); return factory; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java index 86c66af49d..5e4acf4df9 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java @@ -70,8 +70,7 @@ public class ProcessBuilder { String[] newArgs; if (IS_WINDOWS) { newArgs = rebuildArgs(args, "cmd", "/c", "artemis.cmd"); - } - else { + } else { newArgs = rebuildArgs(args, "./artemis"); } @@ -147,14 +146,12 @@ public class ProcessBuilder { if (print) { if (sendToErr) { System.err.println(logName + "-err:" + line); - } - else { + } else { System.out.println(logName + "-out:" + line); } } } - } - catch (IOException e) { + } catch (IOException e) { // ok, stream closed } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/package-info.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/package-info.java index d902bbd290..b4826af377 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/package-info.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/package-info.java @@ -15,5 +15,7 @@ * limitations under the License. */ -/** Contains useful classes for spawning process from client classes */ +/** + * Contains useful classes for spawning process from client classes + */ package org.apache.activemq.artemis.cli.process; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java index 29d83c459f..54567fd7a6 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java @@ -33,7 +33,9 @@ public class BrokerFactory { return createBrokerConfiguration(configURI, null, null); } - public static BrokerDTO createBrokerConfiguration(URI configURI, String artemisHome, String artemisInstance) throws Exception { + public static BrokerDTO createBrokerConfiguration(URI configURI, + String artemisHome, + String artemisInstance) throws Exception { if (configURI.getScheme() == null) { throw new ConfigurationException("Invalid configuration URI, no scheme specified: " + configURI); } @@ -42,20 +44,20 @@ public class BrokerFactory { try { FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/"); factory = (BrokerFactoryHandler) finder.newInstance(configURI.getScheme()); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme()); } return factory.createBroker(configURI, artemisHome, artemisInstance); } - public static BrokerDTO createBrokerConfiguration(String configuration) throws Exception { return createBrokerConfiguration(new URI(configuration), null, null); } - public static BrokerDTO createBrokerConfiguration(String configuration, String artemisHome, String artemisInstance) throws Exception { + public static BrokerDTO createBrokerConfiguration(String configuration, + String artemisHome, + String artemisInstance) throws Exception { return createBrokerConfiguration(new URI(configuration), artemisHome, artemisInstance); } @@ -75,8 +77,7 @@ public class BrokerFactory { try { FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/server/"); handler = (BrokerHandler) finder.newInstance(configURI.getScheme()); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme()); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java index 189ccddf0e..2c1cba3470 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.factory; -import org.apache.activemq.artemis.dto.BrokerDTO; - import java.net.URI; +import org.apache.activemq.artemis.dto.BrokerDTO; + public interface BrokerFactoryHandler { BrokerDTO createBroker(URI brokerURI) throws Exception; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java index dc677e094a..9f0c489ac9 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java @@ -22,6 +22,7 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; public class JaasSecurityHandler implements SecurityHandler { + @Override public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) throws Exception { JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java index c4223087c1..4b7102988b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.factory; +import javax.xml.bind.annotation.XmlRootElement; + import org.apache.activemq.artemis.dto.SecurityDTO; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.utils.FactoryFinder; -import javax.xml.bind.annotation.XmlRootElement; - public class SecurityManagerFactory { public static ActiveMQSecurityManager create(SecurityDTO config) throws Exception { @@ -29,8 +29,7 @@ public class SecurityManagerFactory { FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/"); SecurityHandler securityHandler = (SecurityHandler) finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name()); return securityHandler.createSecurityManager(config); - } - else { + } else { throw new Exception("No security manager configured!"); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java index a84343b176..272e46dc14 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.factory; +import java.io.File; +import java.net.URI; + import org.apache.activemq.artemis.cli.ConfigurationException; import org.apache.activemq.artemis.dto.BrokerDTO; import org.apache.activemq.artemis.dto.XmlUtil; -import java.io.File; -import java.net.URI; - public class XmlBrokerFactoryHandler implements BrokerFactoryHandler { @Override diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java index 494101ec16..8da0480e9f 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java @@ -23,5 +23,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; * A Broker os a set of ActiveMQComponents that create a Server, for instance core and jms. */ public interface Broker extends ActiveMQComponent { + ActiveMQServer getServer(); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java index b120cc7b7d..82224b9025 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.integration; +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.Map; + import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQComponent; @@ -25,10 +29,6 @@ import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; -import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.Map; - public class FileBroker implements Broker { private final String configurationUrl; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java index d036f1dd58..fa443b5c1b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.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, @@ -45,8 +45,7 @@ public class ServerUtil { ProcessBuilder builder = null; if (IS_WINDOWS) { builder = new ProcessBuilder("cmd", "/c", "artemis.cmd", "run"); - } - else { + } else { builder = new ProcessBuilder("./artemis", "run"); } @@ -86,8 +85,7 @@ public class ServerUtil { try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) { cf.createConnection().close(); System.out.println("server " + uri + " started"); - } - catch (Exception e) { + } catch (Exception e) { System.out.println("awaiting server " + uri + " start at "); Thread.sleep(500); continue; @@ -160,14 +158,12 @@ public class ServerUtil { if (print) { if (sendToErr) { System.err.println(logName + "-err:" + line); - } - else { + } else { System.out.println(logName + "-out:" + line); } } } - } - catch (IOException e) { + } catch (IOException e) { // ok, stream closed } } diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java index 969138f503..58e91bdf47 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java @@ -80,8 +80,7 @@ public class ArtemisTest { if (original == null) { System.clearProperty("java.security.auth.login.config"); - } - else { + } else { System.setProperty("java.security.auth.login.config", original); } @@ -97,8 +96,7 @@ public class ArtemisTest { public void invalidPathDoesntThrowException() { if (isWindows()) { testCli("create", "zzzzz:/rawr", "--silent"); - } - else { + } else { testCli("create", "/rawr", "--silent"); } } @@ -132,7 +130,7 @@ public class ArtemisTest { File bootstrapFile = new File(new File(instance1, "etc"), "bootstrap.xml"); Assert.assertTrue(bootstrapFile.exists()); Document config = parseXml(bootstrapFile); - Element webElem = (Element)config.getElementsByTagName("web").item(0); + Element webElem = (Element) config.getElementsByTagName("web").item(0); String bindAttr = webElem.getAttribute("bind"); String bindStr = "http://localhost:" + Create.HTTP_PORT; @@ -151,7 +149,7 @@ public class ArtemisTest { bootstrapFile = new File(new File(instance2, "etc"), "bootstrap.xml"); Assert.assertTrue(bootstrapFile.exists()); config = parseXml(bootstrapFile); - webElem = (Element)config.getElementsByTagName("web").item(0); + webElem = (Element) config.getElementsByTagName("web").item(0); bindAttr = webElem.getAttribute("bind"); bindStr = "https://localhost:" + Create.HTTP_PORT; @@ -168,9 +166,7 @@ public class ArtemisTest { //instance3: https with clientAuth File instance3 = new File(temporaryFolder.getRoot(), "instance3"); - Artemis.main("create", instance3.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore", - "--ssl-key-password", "password1", - "--use-client-auth", "--ssl-trust", "etc/truststore", "--ssl-trust-password", "password2"); + Artemis.main("create", instance3.getAbsolutePath(), "--silent", "--ssl-key", "etc/keystore", "--ssl-key-password", "password1", "--use-client-auth", "--ssl-trust", "etc/truststore", "--ssl-trust-password", "password2"); bootstrapFile = new File(new File(instance3, "etc"), "bootstrap.xml"); Assert.assertTrue(bootstrapFile.exists()); @@ -179,7 +175,7 @@ public class ArtemisTest { System.out.println("confg: " + cfgText); config = parseXml(bootstrapFile); - webElem = (Element)config.getElementsByTagName("web").item(0); + webElem = (Element) config.getElementsByTagName("web").item(0); bindAttr = webElem.getAttribute("bind"); bindStr = "https://localhost:" + Create.HTTP_PORT; @@ -227,8 +223,7 @@ public class ArtemisTest { try { Artemis.internalExecute("data", "print"); Assert.fail("Exception expected"); - } - catch (CLIException expected) { + } catch (CLIException expected) { } Artemis.internalExecute("data", "print", "--f"); @@ -268,8 +263,7 @@ public class ArtemisTest { // Checking it was acked before Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("consumer", "--txt-size", "50", "--verbose", "--break-on-null", "--receive-timeout", "100", "--user", "admin", "--password", "admin")); - } - finally { + } finally { stopServer(); } } @@ -287,8 +281,7 @@ public class ArtemisTest { try { Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("producer", "--message-count", "100")); Assert.assertEquals(Integer.valueOf(100), Artemis.internalExecute("consumer", "--message-count", "100")); - } - finally { + } finally { stopServer(); } } @@ -296,8 +289,7 @@ public class ArtemisTest { private void testCli(String... args) { try { Artemis.main(args); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); Assert.fail("Exception caught " + e.getMessage()); } diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java index 7e34ccdf29..baef0fe3a2 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java @@ -60,8 +60,7 @@ public class FileBrokerTest { Assert.assertNotNull(activeMQServer); Assert.assertTrue(activeMQServer.isStarted()); Assert.assertTrue(broker.isStarted()); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -82,8 +81,7 @@ public class FileBrokerTest { Assert.assertNotNull(activeMQServer); Assert.assertTrue(activeMQServer.isStarted()); Assert.assertTrue(broker.isStarted()); - } - finally { + } finally { assert broker != null; broker.stop(); } @@ -124,13 +122,11 @@ public class FileBrokerTest { try { producer.send(session.createMessage(true)); fail("Should throw a security exception"); - } - catch (Exception e) { + } catch (Exception e) { } locator.close(); - } - finally { + } finally { assert broker != null; broker.stop(); if (path != null) { diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/ArtemisConstants.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/ArtemisConstants.java index 4e3602c627..35bcec0163 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/ArtemisConstants.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/ArtemisConstants.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, @@ -18,6 +18,7 @@ package org.apache.activemq.artemis; public class ArtemisConstants { + public static final int DEFAULT_JOURNAL_BUFFER_SIZE_AIO = 490 * 1024; public static final int DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO = (int) (1000000000d / 2000); public static final int DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO = (int) (1000000000d / 300); diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java index b3e130f25a..392974c285 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java @@ -44,8 +44,7 @@ public final class Pair implements Serializable { if (hash == -1) { if (a == null && b == null) { return super.hashCode(); - } - else { + } else { hash = (a == null ? 0 : a.hashCode()) + 37 * (b == null ? 0 : b.hashCode()); } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java index 70cf4cf5be..b4a02ea40c 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java @@ -122,8 +122,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl if (end < start || start < 0 || end > len) { throw new IndexOutOfBoundsException(); - } - else { + } else { int newlen = end - start << 1; byte[] bytes = new byte[newlen]; @@ -217,8 +216,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl } return true; - } - else { + } else { return false; } } @@ -270,8 +268,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl if (all == null) { return new SimpleString[]{this}; - } - else { + } else { // Adding the last one byte[] bytes = new byte[data.length - lasPos]; System.arraycopy(data, lasPos, bytes, 0, bytes.length); @@ -366,8 +363,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; - } - else { + } else { return 1 + str.sizeof(); } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java index aea98670a3..60262f809b 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java @@ -35,7 +35,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { public static ByteBuf unwrap(ByteBuf buffer) { ByteBuf parent; while ((parent = buffer.unwrap()) != null && parent != buffer) { // this last part is just in case the semantic - // ever changes where unwrap is returning itself + // ever changes where unwrap is returning itself buffer = parent; } @@ -49,8 +49,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { public ChannelBufferWrapper(final ByteBuf buffer, boolean releasable) { if (!releasable) { this.buffer = Unpooled.unreleasableBuffer(buffer); - } - else { + } else { this.buffer = buffer; } this.releasable = releasable; @@ -105,11 +104,9 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { chars[i] = (char) buffer.readShort(); } return new String(chars); - } - else if (len < 0xfff) { + } else if (len < 0xfff) { return readUTF(); - } - else { + } else { return readSimpleStringInternal().toString(); } } @@ -128,8 +125,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { public void writeNullableSimpleString(final SimpleString val) { if (val == null) { buffer.writeByte(DataConstants.NULL); - } - else { + } else { buffer.writeByte(DataConstants.NOT_NULL); writeSimpleStringInternal(val); } @@ -139,8 +135,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { public void writeNullableString(final String val) { if (val == null) { buffer.writeByte(DataConstants.NULL); - } - else { + } else { buffer.writeByte(DataConstants.NOT_NULL); writeStringInternal(val); } @@ -172,12 +167,10 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { for (int i = 0; i < val.length(); i++) { buffer.writeShort((short) val.charAt(i)); } - } - else if (length < 0xfff) { + } else if (length < 0xfff) { // Store as UTF - this is quicker than char by char for most strings writeUTF(val); - } - else { + } else { // Store as SimpleString, since can't store utf > 0xffff in length writeSimpleStringInternal(new SimpleString(val)); } @@ -609,23 +602,28 @@ public class ChannelBufferWrapper implements ActiveMQBuffer { buffer.writeShort(value); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b) throws IOException { readBytes(b); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b, int off, int len) throws IOException { readBytes(b, off, len); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public String readLine() throws IOException { return ByteUtil.readLine(this); } - } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java index efa0cabef6..d62a7443dd 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java @@ -25,10 +25,11 @@ import java.util.concurrent.atomic.AtomicInteger; import org.jboss.logging.Logger; -/** This is for components with a scheduled at a fixed rate. */ +/** + * This is for components with a scheduled at a fixed rate. + */ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, Runnable { - private static final Logger logger = Logger.getLogger(ActiveMQScheduledComponent.class); private final ScheduledExecutorService scheduledExecutorService; private long period; @@ -69,8 +70,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R } if (period >= 0) { future = scheduledExecutorService.scheduleWithFixedDelay(runForScheduler, period, period, timeUnit); - } - else { + } else { logger.tracef("did not start scheduled executor on %s because period was configured as %d", this, period); } } @@ -79,8 +79,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R int value = delayed.incrementAndGet(); if (value > 10) { delayed.decrementAndGet(); - } - else { + } else { // We only schedule up to 10 periods upfront. // this is to avoid a window where a current one would be running and a next one is coming. // in theory just 2 would be enough. I'm using 10 as a precaution here. @@ -124,7 +123,6 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R return future != null; } - // this will restart the schedulped component upon changes private void restartIfNeeded() { if (isStarted()) { diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java index 664470a071..91744c3901 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java @@ -17,10 +17,10 @@ package org.apache.activemq.artemis.logs; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 20 diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java index d7d9214b8f..ac89fc2927 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java @@ -71,19 +71,19 @@ public class AssertionLoggerHandler extends ExtHandler { return false; } - public static boolean findText(long mstimeout, String ... text) { + public static boolean findText(long mstimeout, String... text) { long timeMax = System.currentTimeMillis() + mstimeout; do { if (findText(text)) { return true; } - } - while (timeMax > System.currentTimeMillis()); + } while (timeMax > System.currentTimeMillis()); return false; } + /** * Find a line that contains the parameters passed as an argument * @@ -105,8 +105,7 @@ public class AssertionLoggerHandler extends ExtHandler { if (!found) { break; } - } - else { + } else { break; } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java index 3a4de3e53e..130a6d87fa 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java @@ -41,8 +41,8 @@ public final class ActiveMQThreadFactory implements ThreadFactory { * new threads if a security manager is installed. * * @param groupName the name of the thread group to assign threads to by default - * @param daemon whether the created threads should be daemon threads - * @param tccl the context class loader of newly created threads + * @param daemon whether the created threads should be daemon threads + * @param tccl the context class loader of newly created threads */ public ActiveMQThreadFactory(final String groupName, final boolean daemon, final ClassLoader tccl) { group = new ThreadGroup(groupName + "-" + System.identityHashCode(this)); @@ -61,8 +61,7 @@ public final class ActiveMQThreadFactory implements ThreadFactory { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); - } - else { + } else { return createThread(command); } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java index 8471dace66..a87b18aa6a 100755 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java @@ -41,8 +41,10 @@ import java.util.concurrent.atomic.AtomicInteger; * executor is not limited. Only the offer method checks the configured limit. */ public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor { + @SuppressWarnings("serial") private static class ThreadPoolQueue extends LinkedBlockingQueue { + private ActiveMQThreadPoolExecutor executor = null; public void setExecutor(ActiveMQThreadPoolExecutor executor) { @@ -75,7 +77,12 @@ public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor { } // private constructor is needed to inject 'this' into the ThreadPoolQueue instance - private ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, TimeUnit keepUnits, ThreadPoolQueue myQueue, ThreadFactory factory) { + private ActiveMQThreadPoolExecutor(int coreSize, + int maxSize, + long keep, + TimeUnit keepUnits, + ThreadPoolQueue myQueue, + ThreadFactory factory) { super(coreSize, Integer.MAX_VALUE, keep, keepUnits, myQueue, factory); maxPoolSize = maxSize; myQueue.setExecutor(this); 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 8379fdf71e..dbcc8a521a 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 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 c6789411d6..c9143f52be 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; 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 5e96687f72..1c16567273 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 } } 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 707635eff5..e27ce0cca7 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(); 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 80397c6c3e..db1608e347 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, 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 9234136d14..02bec5f1ca 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 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 70b9c83488..2dda85fdf1 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) { } } } 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 76b6db46de..00a0e3084a 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(); } - } 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 15af6e2a58..395eeeb481 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 +} 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 6be5e054cc..2ef0daabae 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); } } 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 fade097661..a41318a06a 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; 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 8aabd1b1b9..1691df1bdf 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, 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 9507cb8860..3f971fdea5 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(); } } 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 55159266de..637cdffe71 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; } } 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 ecff4da0da..db18e30f75 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; } 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 eeb5783c7d..56cec48e79 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"); } } 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 5af507e397..e75395b30b 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; } } 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 342bf5dee9..1d84fea906 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; 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 111d8f03cc..c111617471 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(); } } 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 b60174fad9..a8e5301757 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; /* 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 4985c651e1..70b36aba4c 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"); } 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 d0e70f41d4..7df9131255 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); } } 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 1e54b5f24c..bc62dd2e02 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); } } 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 9751659e69..49a84c1126 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); } } 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 a95f810982..ac02f8f1c2 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); } } 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 b4b7daf767..438f38eb26 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(); 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 6bc4fde842..4055801c4a 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 ----------------------------------------------------- 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 a45886ecaf..ed91860bba 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 { 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 0616f57b7c..865afffd21 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); } 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 b2c3bf6a07..80dfb01f9c 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; 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 ff5d32d474..cec395969b 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)); 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 48c763042d..8013e9609b 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); } } 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 5a224053a5..379868ef1f 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()); - - } /** diff --git a/artemis-core-client/pom.xml b/artemis-core-client/pom.xml index e986738503..d4f9739f66 100644 --- a/artemis-core-client/pom.xml +++ b/artemis-core-client/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -93,7 +94,8 @@ 512m false true - org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java index 4ba732960e..e07493f99c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java @@ -526,7 +526,9 @@ public final class ActiveMQDefaultConfiguration { return DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS; } - /** The default Cluster address for the Cluster connection*/ + /** + * The default Cluster address for the Cluster connection + */ public static String getDefaultClusterAddress() { return DEFAULT_CLUSTER_ADDRESS; } @@ -733,6 +735,7 @@ public final class ActiveMQDefaultConfiguration { /** * How many journal files can be resued + * * @return */ public static int getDefaultJournalPoolFiles() { @@ -1060,14 +1063,14 @@ public final class ActiveMQDefaultConfiguration { /** * if we have to start as a replicated server this is the delay to wait before fail-back occurs - * @deprecated use getDefaultInitialReplicationSyncTimeout() + * + * @deprecated use getDefaultInitialReplicationSyncTimeout() */ @Deprecated public static long getDefaultFailbackDelay() { return 5000; } - /** * Will this backup server come live on a normal server shutdown */ @@ -1151,7 +1154,9 @@ public final class ActiveMQDefaultConfiguration { return DEFAULT_CONFIGURATION_FILE_REFRESH_PERIOD; } - /** The default global max size. -1 = no global max size. */ + /** + * The default global max size. -1 = no global max size. + */ public static long getDefaultMaxGlobalSize() { return DEFAULT_GLOBAL_MAX_SIZE; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/BroadcastGroupConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/BroadcastGroupConfiguration.java index 095deb0a28..168d840b01 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/BroadcastGroupConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/BroadcastGroupConfiguration.java @@ -101,20 +101,17 @@ public final class BroadcastGroupConfiguration implements Serializable { if (connectorInfos == null) { if (other.connectorInfos != null) return false; - } - else if (!connectorInfos.equals(other.connectorInfos)) + } else if (!connectorInfos.equals(other.connectorInfos)) return false; if (endpointFactory == null) { if (other.endpointFactory != null) return false; - } - else if (!endpointFactory.equals(other.endpointFactory)) + } else if (!endpointFactory.equals(other.endpointFactory)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java index 27aa9b4889..c4809f6bf3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/FilterConstants.java @@ -72,7 +72,6 @@ public final class FilterConstants { */ public static final SimpleString ACTIVEMQ_PREFIX = new SimpleString("AMQ"); - private FilterConstants() { // Utility class } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java index 79c7e144a7..64878083f1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java @@ -16,12 +16,13 @@ */ package org.apache.activemq.artemis.api.core; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.jgroups.JChannelManager; import org.apache.activemq.artemis.api.core.jgroups.JChannelWrapper; import org.apache.activemq.artemis.api.core.jgroups.JGroupsReceiver; import org.jboss.logging.Logger; import org.jgroups.JChannel; -import java.util.concurrent.TimeUnit; /** * This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups. @@ -49,7 +50,8 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { @Override public void broadcast(final byte[] data) throws Exception { - if (logger.isTraceEnabled()) logger.trace("Broadcasting: BroadCastOpened=" + broadcastOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) + logger.trace("Broadcasting: BroadCastOpened=" + broadcastOpened + ", channelOPen=" + channel.getChannel().isOpen()); if (broadcastOpened) { org.jgroups.Message msg = new org.jgroups.Message(); @@ -61,22 +63,22 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { @Override public byte[] receiveBroadcast() throws Exception { - if (logger.isTraceEnabled()) logger.trace("Receiving Broadcast: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) + logger.trace("Receiving Broadcast: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); if (clientOpened) { return receiver.receiveBroadcast(); - } - else { + } else { return null; } } @Override public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception { - if (logger.isTraceEnabled()) logger.trace("Receiving Broadcast2: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) + logger.trace("Receiving Broadcast2: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); if (clientOpened) { return receiver.receiveBroadcast(time, unit); - } - else { + } else { return null; } } @@ -115,8 +117,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { public synchronized void close(boolean isBroadcast) throws Exception { if (isBroadcast) { broadcastOpened = false; - } - else { + } else { channel.removeReceiver(receiver); clientOpened = false; } @@ -126,6 +127,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { /** * Closes the channel used in this JGroups Broadcast. * Can be overridden by implementations that use an externally managed channel. + * * @param channel */ protected synchronized void internalCloseChannel(JChannelWrapper channel) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsChannelBroadcastEndpoint.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsChannelBroadcastEndpoint.java index 96cfee64c7..2317169f33 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsChannelBroadcastEndpoint.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsChannelBroadcastEndpoint.java @@ -29,7 +29,7 @@ public class JGroupsChannelBroadcastEndpoint extends JGroupsBroadcastEndpoint { private final JChannel jChannel; - public JGroupsChannelBroadcastEndpoint(JChannelManager manager, JChannel jChannel, final String channelName) { + public JGroupsChannelBroadcastEndpoint(JChannelManager manager, JChannel jChannel, final String channelName) { super(manager, channelName); this.jChannel = jChannel; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpoint.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpoint.java index be903d37df..d5f8011014 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpoint.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpoint.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.api.core; +import java.net.URL; + import org.apache.activemq.artemis.api.core.jgroups.JChannelManager; import org.jgroups.JChannel; -import java.net.URL; - /** * This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups. */ @@ -28,7 +28,9 @@ public final class JGroupsFileBroadcastEndpoint extends JGroupsBroadcastEndpoint private String file; - public JGroupsFileBroadcastEndpoint(final JChannelManager manager, final String file, final String channelName) throws Exception { + public JGroupsFileBroadcastEndpoint(final JChannelManager manager, + final String file, + final String channelName) throws Exception { super(manager, channelName); this.file = file; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpointFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpointFactory.java index f560c71a58..5aaae0c1bb 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpointFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsFileBroadcastEndpointFactory.java @@ -16,7 +16,6 @@ */ package org.apache.activemq.artemis.api.core; - import org.apache.activemq.artemis.api.core.jgroups.JChannelManager; public class JGroupsFileBroadcastEndpointFactory implements BroadcastEndpointFactory { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsPropertiesBroadcastEndpoint.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsPropertiesBroadcastEndpoint.java index d10400a476..bd29a1f5e0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsPropertiesBroadcastEndpoint.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsPropertiesBroadcastEndpoint.java @@ -23,11 +23,13 @@ import org.jgroups.conf.PlainConfigurator; /** * This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups. */ -public final class JGroupsPropertiesBroadcastEndpoint extends JGroupsBroadcastEndpoint { +public final class JGroupsPropertiesBroadcastEndpoint extends JGroupsBroadcastEndpoint { private String properties; - public JGroupsPropertiesBroadcastEndpoint(final JChannelManager manager, final String properties, final String channelName) throws Exception { + public JGroupsPropertiesBroadcastEndpoint(final JChannelManager manager, + final String properties, + final String channelName) throws Exception { super(manager, channelName); this.properties = properties; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java index 6c47a2811f..a8463c4825 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.api.core; -import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; -import org.apache.activemq.artemis.utils.Base64; -import org.apache.activemq.artemis.utils.JsonLoader; -import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -import org.apache.activemq.artemis.utils.StringEscapeUtils; - import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; @@ -39,7 +33,14 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; +import org.apache.activemq.artemis.utils.Base64; +import org.apache.activemq.artemis.utils.JsonLoader; +import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; +import org.apache.activemq.artemis.utils.StringEscapeUtils; + public final class JsonUtil { + public static JsonArray toJSONArray(final Object[] array) throws Exception { JsonArrayBuilder jsonArray = JsonLoader.createArrayBuilder(); @@ -58,15 +59,13 @@ public final class JsonUtil { if (val.getClass().isArray()) { JsonArray objectArray = toJSONArray((Object[]) val); jsonObject.add(key, objectArray); - } - else { + } else { addToObject(key, val, jsonObject); } } } jsonArray.add(jsonObject); - } - else { + } else { if (parameter != null) { Class clz = parameter.getClass(); @@ -82,16 +81,13 @@ public final class JsonUtil { JsonObjectBuilder jsonObject = JsonLoader.createObjectBuilder(); jsonObject.add(CompositeData.class.getName(), innerJsonArray); jsonArray.add(jsonObject); - } - else { + } else { jsonArray.add(toJSONArray(innerArray)); } - } - else { + } else { addToArray(parameter, jsonArray); } - } - else { + } else { jsonArray.addNull(); } } @@ -109,8 +105,7 @@ public final class JsonUtil { Object[] inner = fromJsonArray((JsonArray) val); array[i] = inner; - } - else if (val instanceof JsonObject) { + } else if (val instanceof JsonObject) { JsonObject jsonObject = (JsonObject) val; Map map = new HashMap<>(); @@ -122,26 +117,20 @@ public final class JsonUtil { if (innerVal instanceof JsonArray) { innerVal = fromJsonArray(((JsonArray) innerVal)); - } - else if (innerVal instanceof JsonString) { - innerVal = ((JsonString)innerVal).getString(); - } - else if (innerVal == JsonValue.FALSE) { + } else if (innerVal instanceof JsonString) { + innerVal = ((JsonString) innerVal).getString(); + } else if (innerVal == JsonValue.FALSE) { innerVal = Boolean.FALSE; - } - else if (innerVal == JsonValue.TRUE) { + } else if (innerVal == JsonValue.TRUE) { innerVal = Boolean.TRUE; - } - else if (innerVal instanceof JsonNumber) { - JsonNumber jsonNumber = (JsonNumber)innerVal; + } else if (innerVal instanceof JsonNumber) { + JsonNumber jsonNumber = (JsonNumber) innerVal; if (jsonNumber.isIntegral()) { innerVal = jsonNumber.longValue(); - } - else { + } else { innerVal = jsonNumber.doubleValue(); } - } - else if (innerVal instanceof JsonObject) { + } else if (innerVal instanceof JsonObject) { Map innerMap = new HashMap<>(); JsonObject o = (JsonObject) innerVal; Set innerKeys = o.keySet(); @@ -154,7 +143,7 @@ public final class JsonUtil { Object[] data = (Object[]) innerVal; CompositeData[] cds = new CompositeData[data.length]; for (int i1 = 0; i1 < data.length; i1++) { - String dataConverted = convertJsonValue(data[i1], String.class).toString(); + String dataConverted = convertJsonValue(data[i1], String.class).toString(); ObjectInputStreamWithClassLoader ois = new ObjectInputStreamWithClassLoader(new ByteArrayInputStream(Base64.decode(dataConverted))); ois.setWhiteList("java.util,java.lang,javax.management"); cds[i1] = (CompositeDataSupport) ois.readObject(); @@ -166,30 +155,23 @@ public final class JsonUtil { } array[i] = map; - } - else if (val instanceof JsonString) { - array[i] = ((JsonString)val).getString(); - } - else if (val == JsonValue.FALSE) { + } else if (val instanceof JsonString) { + array[i] = ((JsonString) val).getString(); + } else if (val == JsonValue.FALSE) { array[i] = Boolean.FALSE; - } - else if (val == JsonValue.TRUE) { + } else if (val == JsonValue.TRUE) { array[i] = Boolean.TRUE; - } - else if (val instanceof JsonNumber) { - JsonNumber jsonNumber = (JsonNumber)val; + } else if (val instanceof JsonNumber) { + JsonNumber jsonNumber = (JsonNumber) val; if (jsonNumber.isIntegral()) { array[i] = jsonNumber.longValue(); - } - else { + } else { array[i] = jsonNumber.doubleValue(); } - } - else { + } else { if (val == JsonValue.NULL) { array[i] = null; - } - else { + } else { array[i] = val; } } @@ -205,36 +187,26 @@ public final class JsonUtil { public static void addToObject(final String key, final Object param, final JsonObjectBuilder jsonObjectBuilder) { if (param instanceof Integer) { jsonObjectBuilder.add(key, (Integer) param); - } - else if (param instanceof Long) { + } else if (param instanceof Long) { jsonObjectBuilder.add(key, (Long) param); - } - else if (param instanceof Double) { + } else if (param instanceof Double) { jsonObjectBuilder.add(key, (Double) param); - } - else if (param instanceof String) { + } else if (param instanceof String) { jsonObjectBuilder.add(key, (String) param); - } - else if (param instanceof Boolean) { + } else if (param instanceof Boolean) { jsonObjectBuilder.add(key, (Boolean) param); - } - else if (param instanceof Map) { - JsonObject mapObject = toJsonObject((Map) param); + } else if (param instanceof Map) { + JsonObject mapObject = toJsonObject((Map) param); jsonObjectBuilder.add(key, mapObject); - } - else if (param instanceof Short) { + } else if (param instanceof Short) { jsonObjectBuilder.add(key, (Short) param); - } - else if (param instanceof Byte) { + } else if (param instanceof Byte) { jsonObjectBuilder.add(key, ((Byte) param).shortValue()); - } - else if (param instanceof SimpleString) { + } else if (param instanceof SimpleString) { jsonObjectBuilder.add(key, param.toString()); - } - else if (param == null) { + } else if (param == null) { jsonObjectBuilder.addNull(key); - } - else { + } else { throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName()); } } @@ -242,33 +214,24 @@ public final class JsonUtil { public static void addToArray(final Object param, final JsonArrayBuilder jsonArrayBuilder) { if (param instanceof Integer) { jsonArrayBuilder.add((Integer) param); - } - else if (param instanceof Long) { + } else if (param instanceof Long) { jsonArrayBuilder.add((Long) param); - } - else if (param instanceof Double) { + } else if (param instanceof Double) { jsonArrayBuilder.add((Double) param); - } - else if (param instanceof String) { + } else if (param instanceof String) { jsonArrayBuilder.add((String) param); - } - else if (param instanceof Boolean) { + } else if (param instanceof Boolean) { jsonArrayBuilder.add((Boolean) param); - } - else if (param instanceof Map) { - JsonObject mapObject = toJsonObject((Map) param); + } else if (param instanceof Map) { + JsonObject mapObject = toJsonObject((Map) param); jsonArrayBuilder.add(mapObject); - } - else if (param instanceof Short) { + } else if (param instanceof Short) { jsonArrayBuilder.add((Short) param); - } - else if (param instanceof Byte) { + } else if (param instanceof Byte) { jsonArrayBuilder.add(((Byte) param).shortValue()); - } - else if (param == null) { + } else if (param == null) { jsonArrayBuilder.addNull(); - } - else { + } else { throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName()); } } @@ -307,75 +270,59 @@ public final class JsonUtil { if (desiredType == null || desiredType == Long.class || desiredType == Long.TYPE) { return number.longValue(); - } - else if (desiredType == Integer.class || desiredType == Integer.TYPE) { + } else if (desiredType == Integer.class || desiredType == Integer.TYPE) { return number.intValue(); - } - else if (desiredType == Double.class || desiredType == Double.TYPE) { + } else if (desiredType == Double.class || desiredType == Double.TYPE) { return number.doubleValue(); - } - else { + } else { return number.longValue(); } - } - else if (jsonValue instanceof JsonString) { + } else if (jsonValue instanceof JsonString) { return ((JsonString) jsonValue).getString(); - } - else if (jsonValue instanceof JsonValue) { + } else if (jsonValue instanceof JsonValue) { if (jsonValue == JsonValue.TRUE) { return true; - } - else if (jsonValue == JsonValue.FALSE) { + } else if (jsonValue == JsonValue.FALSE) { return false; - } - else { + } else { return jsonValue.toString(); } - } - else if (jsonValue instanceof Number) { - Number jsonNumber = (Number)jsonValue; + } else if (jsonValue instanceof Number) { + Number jsonNumber = (Number) jsonValue; if (desiredType == Integer.TYPE || desiredType == Integer.class) { - return jsonNumber.intValue(); - } - else if (desiredType == Long.TYPE || desiredType == Long.class) { + return jsonNumber.intValue(); + } else if (desiredType == Long.TYPE || desiredType == Long.class) { return jsonNumber.longValue(); - } - else if (desiredType == Double.TYPE || desiredType == Double.class) { + } else if (desiredType == Double.TYPE || desiredType == Double.class) { return jsonNumber.doubleValue(); - } - else if (desiredType == Short.TYPE || desiredType == Short.class) { + } else if (desiredType == Short.TYPE || desiredType == Short.class) { return jsonNumber.shortValue(); - } - else { + } else { return jsonValue; } - } - else if (jsonValue instanceof Object[]) { + } else if (jsonValue instanceof Object[]) { Object[] array = (Object[]) jsonValue; for (int i = 0; i < array.length; i++) { array[i] = convertJsonValue(array[i], desiredType); } return array; - } - else { + } else { return jsonValue; } } - - private JsonUtil() { } private static class NullableJsonString implements JsonValue, JsonString { + private final String value; private String escape; NullableJsonString(String value) { if (value == null || value.length() == 0) { this.value = null; - } - else { + } else { this.value = value; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java index 01db007939..1ea9309661 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java @@ -53,7 +53,8 @@ public interface Message { /** * the actual time the message was expired. - * * * */ + * * * + */ SimpleString HDR_ACTUAL_EXPIRY_TIME = new SimpleString("_AMQ_ACTUAL_EXPIRY"); /** @@ -585,7 +586,6 @@ public interface Message { */ Map toMap(); - /** * @return Returns the message properties in Map form, useful when encoding to JSON */ diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java index 288ace1bb7..3b0359f795 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.api.core; +import javax.json.JsonObject; import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -26,8 +27,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.utils.JsonLoader; import org.apache.activemq.artemis.utils.UUIDGenerator; -import javax.json.JsonObject; - /** * A TransportConfiguration is used by a client to specify connections to a server and its backup if * one exists. @@ -65,12 +64,7 @@ public class TransportConfiguration implements Serializable { private static final byte TYPE_STRING = 3; public JsonObject toJson() { - return JsonLoader.createObjectBuilder() - .add("name", name) - .add("factoryClassName", factoryClassName) - .add("params", JsonUtil.toJsonObject(params)) - .add("extraProps", JsonUtil.toJsonObject(extraProps)) - .build(); + return JsonLoader.createObjectBuilder().add("name", name).add("factoryClassName", factoryClassName).add("params", JsonUtil.toJsonObject(params)).add("extraProps", JsonUtil.toJsonObject(extraProps)).build(); } /** @@ -114,18 +108,20 @@ public class TransportConfiguration implements Serializable { * Creates a TransportConfiguration with a specific name providing the class name of the {@link org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory} * and any parameters needed. * - * @param className The class name of the ConnectorFactory - * @param params The parameters needed by the ConnectorFactory - * @param name The name of this TransportConfiguration - * @param extraProps The extra properties that specific to protocols + * @param className The class name of the ConnectorFactory + * @param params The parameters needed by the ConnectorFactory + * @param name The name of this TransportConfiguration + * @param extraProps The extra properties that specific to protocols */ - public TransportConfiguration(final String className, final Map params, final String name, final Map extraProps) { + public TransportConfiguration(final String className, + final Map params, + final String name, + final Map extraProps) { factoryClassName = className; if (params == null || params.isEmpty()) { this.params = TransportConfigurationUtil.getDefaults(className); - } - else { + } else { this.params = params; } @@ -134,7 +130,7 @@ public class TransportConfiguration implements Serializable { } public TransportConfiguration newTransportConfig(String newName) { - return new TransportConfiguration(factoryClassName, params, newName); + return new TransportConfiguration(factoryClassName, params, newName); } /** @@ -236,14 +232,11 @@ public class TransportConfiguration implements Serializable { public boolean isEquivalent(TransportConfiguration otherConfig) { if (this.getFactoryClassName().equals(otherConfig.getFactoryClassName())) { return true; - } - else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) { + } else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) { return true; - } - else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) { + } else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) { return true; - } - else { + } else { return false; } } @@ -271,8 +264,7 @@ public class TransportConfiguration implements Serializable { String val; if (key.equals(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME) || key.equals(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME)) { val = "****"; - } - else { + } else { val = entry.getValue() == null ? "null" : entry.getValue().toString(); } @@ -307,20 +299,16 @@ public class TransportConfiguration implements Serializable { if (val instanceof Boolean) { buffer.writeByte(TransportConfiguration.TYPE_BOOLEAN); buffer.writeBoolean((Boolean) val); - } - else if (val instanceof Integer) { + } else if (val instanceof Integer) { buffer.writeByte(TransportConfiguration.TYPE_INT); buffer.writeInt((Integer) val); - } - else if (val instanceof Long) { + } else if (val instanceof Long) { buffer.writeByte(TransportConfiguration.TYPE_LONG); buffer.writeLong((Long) val); - } - else if (val instanceof String) { + } else if (val instanceof String) { buffer.writeByte(TransportConfiguration.TYPE_STRING); buffer.writeString((String) val); - } - else { + } else { throw ActiveMQClientMessageBundle.BUNDLE.invalidEncodeType(val); } } @@ -364,8 +352,7 @@ public class TransportConfiguration implements Serializable { if (num > 0) { params = new HashMap<>(); } - } - else { + } else { params.clear(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java index e5cc1ffc39..c257ade482 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java @@ -150,12 +150,10 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto while (open) { try { receivingSocket.receive(packet); - } - // TODO: Do we need this? - catch (InterruptedIOException e) { + } catch (InterruptedIOException e) { + // TODO: Do we need this? continue; - } - catch (IOException e) { + } catch (IOException e) { if (open) { ActiveMQClientLogger.LOGGER.warn(this + " getting exception when receiving broadcasting.", e); } @@ -176,8 +174,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto public void openBroadcaster() throws Exception { if (localBindPort != -1) { broadcastingSocket = new DatagramSocket(localBindPort, localAddress); - } - else { + } else { if (localAddress != null) { for (int i = 0; i < 100; i++) { int nextPort = RandomUtil.randomInterval(3000, 4000); @@ -185,8 +182,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto broadcastingSocket = new DatagramSocket(nextPort, localAddress); ActiveMQClientLogger.LOGGER.broadcastGroupBindError(localAddress.toString() + ":" + nextPort); break; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.broadcastGroupBindErrorRetry(localAddress.toString() + ":" + nextPort, e); } } @@ -205,14 +201,12 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto if (checkForLinux() || checkForSolaris() || checkForHp()) { try { receivingSocket = new MulticastSocket(new InetSocketAddress(groupAddress, groupPort)); - } - catch (IOException e) { + } catch (IOException e) { ActiveMQClientLogger.LOGGER.ioDiscoveryError(groupAddress.getHostAddress(), groupAddress instanceof Inet4Address ? "IPv4" : "IPv6"); receivingSocket = new MulticastSocket(groupPort); } - } - else { + } else { receivingSocket = new MulticastSocket(groupPort); } @@ -267,8 +261,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto tmp = defaultValue; } return tmp; - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.warn(t); return defaultValue; } @@ -279,8 +272,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto try { return Integer.parseInt(value); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.warn(t.getMessage(), t); return Integer.parseInt(defaultValue); } @@ -308,8 +300,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto if (groupAddress == null) { if (other.groupAddress != null) return false; - } - else if (!groupAddress.equals(other.groupAddress)) + } else if (!groupAddress.equals(other.groupAddress)) return false; if (groupPort != other.groupPort) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java index b6615bea05..0ad80fcb08 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java @@ -144,7 +144,6 @@ public final class ActiveMQClient { private static ScheduledExecutorService globalScheduledThreadPool; - static { initializeGlobalThreadPoolProperties(); } @@ -153,7 +152,6 @@ public final class ActiveMQClient { clearThreadPools(10, TimeUnit.SECONDS); } - public static synchronized void clearThreadPools(long time, TimeUnit unit) { if (injectedPools) { @@ -170,11 +168,9 @@ public final class ActiveMQClient { globalThreadPool.shutdownNow(); ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client globalThreadPool in less than 10 seconds, interrupting it now"); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); - } - finally { + } finally { globalThreadPool = null; } } @@ -186,18 +182,19 @@ public final class ActiveMQClient { globalScheduledThreadPool.shutdownNow(); ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client scheduled in less than 10 seconds, interrupting it now"); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); - } - finally { + } finally { globalScheduledThreadPool = null; } } } - /** Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call. */ - public static synchronized void injectPools(ExecutorService globalThreadPool, ScheduledExecutorService scheduledThreadPool) { + /** + * Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call. + */ + public static synchronized void injectPools(ExecutorService globalThreadPool, + ScheduledExecutorService scheduledThreadPool) { if (globalThreadPool == null || scheduledThreadPool == null) throw new IllegalArgumentException("thread pools must not be null"); @@ -220,8 +217,7 @@ public final class ActiveMQClient { if (globalThreadPoolSize == -1) { globalThreadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), factory); - } - else { + } else { globalThreadPool = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.globalThreadPoolSize, 60L, TimeUnit.SECONDS, factory); } } @@ -237,7 +233,7 @@ public final class ActiveMQClient { } }); - globalScheduledThreadPool = new ScheduledThreadPoolExecutor(ActiveMQClient.globalScheduledThreadPoolSize, factory); + globalScheduledThreadPool = new ScheduledThreadPoolExecutor(ActiveMQClient.globalScheduledThreadPoolSize, factory); } return globalScheduledThreadPool; } @@ -279,7 +275,8 @@ public final class ActiveMQClient { */ public static void setGlobalThreadPoolProperties(int globalThreadMaxPoolSize, int globalScheduledThreadPoolSize) { - if (globalThreadMaxPoolSize < 2 && globalThreadMaxPoolSize != -1) globalThreadMaxPoolSize = 2; + if (globalThreadMaxPoolSize < 2 && globalThreadMaxPoolSize != -1) + globalThreadMaxPoolSize = 2; ActiveMQClient.globalScheduledThreadPoolSize = globalScheduledThreadPoolSize; ActiveMQClient.globalThreadPoolSize = globalThreadMaxPoolSize; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java index d2f58a6114..e87d36584f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java @@ -20,8 +20,8 @@ import java.io.InputStream; import java.io.OutputStream; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.SimpleString; /** * A ClientMessage represents a message sent and/or received by ActiveMQ Artemis. diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/TopologyMember.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/TopologyMember.java index 4247b4328a..1ea039e81c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/TopologyMember.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/TopologyMember.java @@ -92,6 +92,5 @@ public interface TopologyMember { */ boolean isMember(TransportConfiguration configuration); - String toURI(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java index 58694b601e..388cf347a4 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java @@ -42,8 +42,7 @@ public final class RoundRobinConnectionLoadBalancingPolicy implements Connection pos = RandomUtil.randomInterval(0, max); first = false; - } - else { + } else { pos++; if (pos >= max) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java index e83a33dd8e..5baec23c0f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java @@ -31,6 +31,7 @@ import org.jgroups.ReceiverAdapter; * will be disconnected. */ public class JChannelWrapper { + private static final Logger logger = Logger.getLogger(JChannelWrapper.class); private boolean connected = false; @@ -46,7 +47,6 @@ public class JChannelWrapper { this.channel = channel; this.manager = manager; - if (logger.isTraceEnabled() && channel.getReceiver() != null) { logger.trace(this + "The channel already had a receiver previously!!!! == " + channel.getReceiver(), new Exception("trace")); } @@ -83,7 +83,8 @@ public class JChannelWrapper { public synchronized void close(boolean closeWrappedChannel) { refCount--; - if (logger.isTraceEnabled()) logger.trace(this + "::RefCount-- " + refCount + " on channel " + channelName, new Exception("Trace")); + if (logger.isTraceEnabled()) + logger.trace(this + "::RefCount-- " + refCount + " on channel " + channelName, new Exception("Trace")); if (refCount == 0) { if (closeWrappedChannel) { closeChannel(); @@ -102,7 +103,8 @@ public class JChannelWrapper { } public void removeReceiver(JGroupsReceiver receiver) { - if (logger.isTraceEnabled()) logger.trace(this + "::removeReceiver: " + receiver + " on " + channelName, new Exception("Trace")); + if (logger.isTraceEnabled()) + logger.trace(this + "::removeReceiver: " + receiver + " on " + channelName, new Exception("Trace")); synchronized (receivers) { receivers.remove(receiver); } @@ -127,13 +129,15 @@ public class JChannelWrapper { public void addReceiver(JGroupsReceiver jGroupsReceiver) { synchronized (receivers) { - if (logger.isTraceEnabled()) logger.trace(this + "::Add Receiver: " + jGroupsReceiver + " on " + channelName); + if (logger.isTraceEnabled()) + logger.trace(this + "::Add Receiver: " + jGroupsReceiver + " on " + channelName); receivers.add(jGroupsReceiver); } } public void send(org.jgroups.Message msg) throws Exception { - if (logger.isTraceEnabled()) logger.trace(this + "::Sending JGroups Message: Open=" + channel.isOpen() + " on channel " + channelName + " msg=" + msg); + if (logger.isTraceEnabled()) + logger.trace(this + "::Sending JGroups Message: Open=" + channel.isOpen() + " on channel " + channelName + " msg=" + msg); if (!manager.isLoopbackMessages()) { msg.setTransientFlag(Message.TransientFlag.DONT_LOOPBACK); } @@ -142,7 +146,8 @@ public class JChannelWrapper { public JChannelWrapper addRef() { this.refCount++; - if (logger.isTraceEnabled()) logger.trace(this + "::RefCount++ = " + refCount + " on channel " + channelName); + if (logger.isTraceEnabled()) + logger.trace(this + "::RefCount++ = " + refCount + " on channel " + channelName); return this; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java index c49caf0abd..e11456958b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java @@ -36,7 +36,8 @@ public class JGroupsReceiver extends ReceiverAdapter { @Override public void receive(org.jgroups.Message msg) { - if (logger.isTraceEnabled()) logger.trace("sending message " + msg); + if (logger.isTraceEnabled()) + logger.trace("sending message " + msg); dequeue.add(msg.getBuffer()); } @@ -52,8 +53,7 @@ public class JGroupsReceiver extends ReceiverAdapter { private void logBytes(String methodName, byte[] bytes) { if (bytes != null) { logger.trace(methodName + "::" + bytes.length + " bytes"); - } - else { + } else { logger.trace(methodName + ":: no bytes"); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java index 062ba46cfe..b182470e9e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.api.core.management; -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + // XXX no javadocs public final class AddressSettingsInfo { @@ -67,19 +67,7 @@ public final class AddressSettingsInfo { public static AddressSettingsInfo from(final String jsonString) { JsonObject object = JsonUtil.readJsonObject(jsonString); - return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"), - object.getJsonNumber("maxSizeBytes").longValue(), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"), - object.getInt("maxDeliveryAttempts"), - object.getJsonNumber("redeliveryDelay").longValue(), - object.getJsonNumber("redeliveryMultiplier").doubleValue(), - object.getJsonNumber("maxRedeliveryDelay").longValue(), - object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"), - object.getJsonNumber("redistributionDelay").longValue(), object.getBoolean("sendToDLAOnNoRoute"), - object.getJsonNumber("slowConsumerThreshold").longValue(), - object.getJsonNumber("slowConsumerCheckPeriod").longValue(), - object.getString("slowConsumerPolicy"), object.getBoolean("autoCreateJmsQueues"), - object.getBoolean("autoDeleteJmsQueues"), object.getBoolean("autoCreateJmsTopics"), - object.getBoolean("autoDeleteJmsTopics")); + return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"), object.getJsonNumber("maxSizeBytes").longValue(), object.getInt("pageSizeBytes"), object.getInt("pageCacheMaxSize"), object.getInt("maxDeliveryAttempts"), object.getJsonNumber("redeliveryDelay").longValue(), object.getJsonNumber("redeliveryMultiplier").doubleValue(), object.getJsonNumber("maxRedeliveryDelay").longValue(), object.getString("DLA"), object.getString("expiryAddress"), object.getBoolean("lastValueQueue"), object.getJsonNumber("redistributionDelay").longValue(), object.getBoolean("sendToDLAOnNoRoute"), object.getJsonNumber("slowConsumerThreshold").longValue(), object.getJsonNumber("slowConsumerCheckPeriod").longValue(), object.getString("slowConsumerPolicy"), object.getBoolean("autoCreateJmsQueues"), object.getBoolean("autoDeleteJmsQueues"), object.getBoolean("autoCreateJmsTopics"), object.getBoolean("autoDeleteJmsTopics")); } // Constructors -------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Attribute.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Attribute.java index 9682dd9bb7..824b2f72b4 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Attribute.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Attribute.java @@ -30,5 +30,6 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Attribute { + String desc() default ""; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java index 16fa90730b..4cb124b6c9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.api.core.management; -import org.apache.activemq.artemis.api.core.JsonUtil; -import org.apache.activemq.artemis.utils.JsonLoader; - import javax.json.JsonArray; import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; +import org.apache.activemq.artemis.api.core.JsonUtil; +import org.apache.activemq.artemis.utils.JsonLoader; + /** * Helper class to create Java Objects from the * JSON serialization returned by {@link QueueControl#listMessageCounterHistory()}. @@ -44,9 +44,7 @@ public final class DayCounterInfo { for (int c : info.getCounters()) { counter.add(c); } - JsonObjectBuilder dci = JsonLoader.createObjectBuilder() - .add("date", info.getDate()) - .add("counters", counter); + JsonObjectBuilder dci = JsonLoader.createObjectBuilder().add("date", info.getDate()).add("counters", counter); counters.add(dci); } json.add("dayCounters", counters); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java index 78405b0ecf..40211c1524 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.api.core.management; +import javax.json.JsonArray; + import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import javax.json.JsonArray; - /** * Helper class to use ActiveMQ Artemis Core messages to manage server resources. */ @@ -130,8 +130,7 @@ public final class ManagementHelper { JsonArray jsonArray = JsonUtil.toJSONArray(parameters); paramString = jsonArray.toString(); - } - else { + } else { paramString = null; } @@ -149,8 +148,7 @@ public final class ManagementHelper { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); - } - else { + } else { return null; } } @@ -181,8 +179,7 @@ public final class ManagementHelper { JsonArray jsonArray = JsonUtil.toJSONArray(new Object[]{result}); resultString = jsonArray.toString(); - } - else { + } else { resultString = null; } @@ -202,8 +199,7 @@ public final class ManagementHelper { if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); - } - else { + } else { return null; } } @@ -218,19 +214,18 @@ public final class ManagementHelper { return getResult(message, null); } - /** - * Returns the result of an operation invocation or an attribute value. - *
- * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. - * and the result will be a String corresponding to the server exception. - */ + /** + * Returns the result of an operation invocation or an attribute value. + *
+ * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. + * and the result will be a String corresponding to the server exception. + */ public static Object getResult(final Message message, Class desiredType) throws Exception { Object[] res = ManagementHelper.getResults(message); if (res != null) { return JsonUtil.convertJsonValue(res[0], desiredType); - } - else { + } else { return null; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java index fd3d718444..ef7b4837c3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java @@ -18,8 +18,8 @@ package org.apache.activemq.artemis.api.core.management; import javax.management.ObjectName; -import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.api.core.SimpleString; /** * Helper class to build ObjectNames for ActiveMQ Artemis resources. @@ -50,8 +50,7 @@ public final class ObjectNameBuilder { public static ObjectNameBuilder create(final String domain) { if (domain == null) { return new ObjectNameBuilder(ActiveMQDefaultConfiguration.getDefaultJmxDomain(), null, false); - } - else { + } else { return new ObjectNameBuilder(domain, null, false); } } @@ -59,8 +58,7 @@ public final class ObjectNameBuilder { public static ObjectNameBuilder create(final String domain, String brokerName) { if (domain == null) { return new ObjectNameBuilder(ActiveMQDefaultConfiguration.getDefaultJmxDomain(), brokerName, true); - } - else { + } else { return new ObjectNameBuilder(domain, brokerName, true); } } @@ -68,8 +66,7 @@ public final class ObjectNameBuilder { public static ObjectNameBuilder create(final String domain, String brokerName, boolean jmxUseBrokerName) { if (domain == null) { return new ObjectNameBuilder(ActiveMQDefaultConfiguration.getDefaultJmxDomain(), brokerName, jmxUseBrokerName); - } - else { + } else { return new ObjectNameBuilder(domain, brokerName, jmxUseBrokerName); } } @@ -197,8 +194,7 @@ public final class ObjectNameBuilder { private String getBrokerProperties() { if (jmxUseBrokerName && brokerName != null) { return String.format("type=Broker,brokerName=%s,", ObjectName.quote(brokerName)); - } - else { + } else { return ""; } } @@ -206,8 +202,7 @@ public final class ObjectNameBuilder { private String getObjectType() { if (jmxUseBrokerName && brokerName != null) { return "serviceType"; - } - else { + } else { return "type"; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Operation.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Operation.java index 5495f5a81c..9e03b11f1d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Operation.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/Operation.java @@ -16,14 +16,13 @@ */ package org.apache.activemq.artemis.api.core.management; +import javax.management.MBeanOperationInfo; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.management.MBeanOperationInfo; - /** * Info for a MBean Operation. *

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java index 60957ad03b..0a74d1c4a4 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java @@ -246,7 +246,6 @@ public interface QueueControl { @Operation(desc = "Remove the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION) boolean expireMessage(@Parameter(name = "messageID", desc = "A message ID") long messageID) throws Exception; - /** * Retries the message corresponding to the given messageID to the original queue. * This is appropriate on dead messages on Dead letter queues only. @@ -336,14 +335,13 @@ public interface QueueControl { int sendMessagesToDeadLetterAddress(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filterStr) throws Exception; /** - * - * @param headers the message headers and properties to set. Can only - * container Strings maped to primitive types. - * @param body the text to send + * @param headers the message headers and properties to set. Can only + * container Strings maped to primitive types. + * @param body the text to send * @param userID * @param durable - *@param user - * @param password @return + * @param user + * @param password @return * @throws Exception */ @Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION) @@ -355,7 +353,6 @@ public interface QueueControl { @Parameter(name = "user", desc = "The user to authenticate with") String user, @Parameter(name = "password", desc = "The users password to authenticate with") String password) throws Exception; - /** * Changes the message's priority corresponding to the specified message ID to the specified priority. * diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java index 01be093525..d3fc9dbc8f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.api.core.management; -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonArray; import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + /** * Helper class to create Java Objects from the * JSON serialization returned by {@link AddressControl#getRolesAsJSON()}. @@ -54,10 +54,7 @@ public final class RoleInfo { RoleInfo[] roles = new RoleInfo[array.size()]; for (int i = 0; i < array.size(); i++) { JsonObject r = array.getJsonObject(i); - RoleInfo role = new RoleInfo(r.getString("name"), r.getBoolean("send"), - r.getBoolean("consume"), r.getBoolean("createDurableQueue"), - r.getBoolean("deleteDurableQueue"), r.getBoolean("createNonDurableQueue"), - r.getBoolean("deleteNonDurableQueue"), r.getBoolean("manage"), r.getBoolean("browse")); + RoleInfo role = new RoleInfo(r.getString("name"), r.getBoolean("send"), r.getBoolean("consume"), r.getBoolean("createDurableQueue"), r.getBoolean("deleteDurableQueue"), r.getBoolean("createNonDurableQueue"), r.getBoolean("deleteNonDurableQueue"), r.getBoolean("manage"), r.getBoolean("browse")); roles[i] = role; } return roles; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java index 08f51ae356..4a4a9a3683 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java @@ -32,10 +32,10 @@ import org.apache.activemq.artemis.api.core.ActiveMQTransactionRolledBackExcepti import org.apache.activemq.artemis.api.core.ActiveMQUnBlockedException; import org.apache.activemq.artemis.core.cluster.DiscoveryGroup; import org.apache.activemq.artemis.spi.core.remoting.Connection; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; import org.w3c.dom.Node; /** diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java index 42168e9f61..f937c405e5 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java @@ -253,14 +253,13 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } } - if ( m != null) { + if (m != null) { session.workDone(); } try { wait(toWait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } @@ -287,8 +286,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { deliveryForced = false; toWait = timeout == 0 ? Long.MAX_VALUE : timeout; continue; - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> failedOver, but m != null, being " + m); } @@ -324,8 +322,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } return null; - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + "::Ignored force delivery answer as it belonged to another call"); } @@ -349,8 +346,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (toWait > 0) { continue; - } - else { + } else { return null; } } @@ -364,8 +360,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } return m; - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + "::Returning null"); } @@ -373,8 +368,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { return null; } } - } - finally { + } finally { receiverThread = null; } } @@ -439,9 +433,8 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { // if no previous handler existed queue up messages for delivery if (handler != null && noPreviousHandler) { requeueExecutors(); - } - // if unsetting a previous handler may be in onMessage so wait for completion - else if (handler == null && !noPreviousHandler) { + } else if (handler == null && !noPreviousHandler) { + // if unsetting a previous handler may be in onMessage so wait for completion waitForOnMessageToComplete(true); } @@ -480,8 +473,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { public void cleanUp() { try { doCleanUp(false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQClientLogger.LOGGER.warn("problem cleaning up: " + this); } } @@ -574,8 +566,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (message.getBooleanProperty(Message.HDR_LARGE_COMPRESSED)) { handleCompressedMessage(message); - } - else { + } else { handleRegularMessage(message); } } @@ -602,8 +593,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (!stopped) { queueExecutor(); } - } - else { + } else { notify(); } } @@ -673,8 +663,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (clientLargeMessage.isCompressed()) { clientLargeMessage.setLargeMessageController(new CompressedLargeMessageControllerImpl(currentLargeMessageController)); - } - else { + } else { clientLargeMessage.setLargeMessageController(currentLargeMessageController); } @@ -693,8 +682,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { logger.trace(this + "::Sending back credits for largeController = null " + flowControlSize); } flowControl(flowControlSize, false); - } - else { + } else { currentLargeMessageController.addPacket(chunk, flowControlSize, isContinues); } } @@ -716,8 +704,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } flowControlBeforeConsumption(message); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorClearingMessages(e); } } @@ -726,8 +713,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { try { resetLargeMessageController(); - } - catch (Throwable e) { + } catch (Throwable e) { // nothing that could be done here ActiveMQClientLogger.LOGGER.errorClearingMessages(e); } @@ -763,8 +749,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (ackIndividually) { individualAcknowledge(message); - } - else { + } else { ackBytes += message.getEncodeSize(); @@ -777,8 +762,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { logger.trace(this + ":: acknowledge acking " + cmi); } doAck(cmi); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + ":: acknowledge setting lastAckedMessage = " + cmi); } @@ -832,8 +816,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (credits > 0) { sendCredits(credits); } - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Sending " + messageBytes + " from flow-control"); } @@ -875,8 +858,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { // However when starting a slow consumer, we have to guarantee the credit was sent before we can perform any // operations like forceDelivery pendingFlowControl.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // will just ignore and forward the ignored Thread.currentThread().interrupt(); } @@ -897,8 +879,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { try { latch.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -928,8 +909,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { public void run() { try { sessionContext.sendConsumerCredits(ClientConsumerImpl.this, credits); - } - finally { + } finally { pendingFlowControl.countDown(); } } @@ -1019,8 +999,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { onMessageThread = Thread.currentThread(); try { theHandler.onMessage(message); - } - finally { + } finally { try { AccessController.doPrivileged(new PrivilegedAction() { @Override @@ -1029,8 +1008,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { return null; } }); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); } @@ -1044,8 +1022,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (message.isLargeMessage()) { message.discardBody(); } - } - else { + } else { session.expire(this, message); } @@ -1105,8 +1082,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (sendCloseMessage) { sessionContext.closeConsumer(this); } - } - catch (Throwable t) { + } catch (Throwable t) { // Consumer close should always return without exception } @@ -1146,8 +1122,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { public void run() { try { callOnMessage(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.onMessageError(e); lastException = e; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java index b30df3f40a..c3cbceb041 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java @@ -61,8 +61,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C public int getEncodeSize() { if (bodyBuffer != null) { return super.getEncodeSize(); - } - else { + } else { return DataConstants.SIZE_INT + DataConstants.SIZE_INT + getHeadersAndPropertiesEncodeSize(); } } @@ -90,8 +89,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C try { checkBuffer(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e.getMessage(), e); } @@ -113,8 +111,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C if (bodyBuffer != null) { // The body was rebuilt on the client, so we need to behave as a regular message on this case super.saveToOutputStream(out); - } - else { + } else { largeMessageController.saveBuffer(out); } } @@ -123,8 +120,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C public ClientLargeMessageImpl setOutputStream(final OutputStream out) throws ActiveMQException { if (bodyBuffer != null) { super.setOutputStream(out); - } - else { + } else { largeMessageController.setOutputStream(out); } @@ -135,8 +131,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C public boolean waitOutputStreamCompletion(final long timeMilliseconds) throws ActiveMQException { if (bodyBuffer != null) { return super.waitOutputStreamCompletion(timeMilliseconds); - } - else { + } else { return largeMessageController.waitCompletion(timeMilliseconds); } } @@ -145,8 +140,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C public void discardBody() { if (bodyBuffer != null) { super.discardBody(); - } - else { + } else { largeMessageController.discardUnusedPackets(); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java index a6a2231a8d..7bf8eb7b4e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java @@ -151,8 +151,7 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter getBodyBuffer().readBytes(readBuffer); out.write(readBuffer); out.flush(); - } - catch (IOException e) { + } catch (IOException e) { throw ActiveMQClientMessageBundle.BUNDLE.errorSavingBody(e); } } @@ -334,8 +333,7 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter public long getLargeBodySize() { if (isLargeMessage()) { return getBodyBuffer().writerIndex(); - } - else { + } else { return getBodyBuffer().writerIndex() - BODY_OFFSET; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditManagerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditManagerImpl.java index 32ada4ffde..80b255ffd2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditManagerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditManagerImpl.java @@ -47,8 +47,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana SessionContext context) { if (windowSize == -1) { return ClientProducerCreditsNoFlowControl.instance; - } - else { + } else { boolean needInit = false; ClientProducerCredits credits; @@ -68,8 +67,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana // Remove from anon credits (if there) unReferencedCredits.remove(address); - } - else { + } else { addToUnReferencedCache(address, credits); } } @@ -171,7 +169,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana static ClientProducerCreditsNoFlowControl instance = new ClientProducerCreditsNoFlowControl(); @Override - public void acquireCredits(int credits) { + public void acquireCredits(int credits) { } @Override diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditsImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditsImpl.java index 70fda674e6..75543fd9ec 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditsImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerCreditsImpl.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.core.client.impl; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -23,9 +26,6 @@ import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; import org.apache.activemq.artemis.spi.core.remoting.SessionContext; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; - public class ClientProducerCreditsImpl implements ClientProducerCredits { private final Semaphore semaphore; @@ -94,12 +94,10 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits { // better getting a "null" string than a NPE ActiveMQClientLogger.LOGGER.outOfCreditOnFlowControl("" + address); } - } - catch (InterruptedException interrupted) { + } catch (InterruptedException interrupted) { Thread.currentThread().interrupt(); throw new ActiveMQInterruptedException(interrupted); - } - finally { + } finally { this.blocked = false; } } @@ -210,4 +208,4 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits { private void requestCredits(final int credits) { session.sendProducerCreditsMessage(credits, address); } -} \ No newline at end of file +} diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java index baa59f577d..fddd4de5e8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java @@ -30,8 +30,8 @@ import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; import org.apache.activemq.artemis.core.message.BodyEncoder; import org.apache.activemq.artemis.core.message.impl.MessageInternal; import org.apache.activemq.artemis.spi.core.remoting.SessionContext; -import org.apache.activemq.artemis.utils.DeflaterReader; import org.apache.activemq.artemis.utils.ActiveMQBufferInputStream; +import org.apache.activemq.artemis.utils.DeflaterReader; import org.apache.activemq.artemis.utils.TokenBucketLimiter; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.jboss.logging.Logger; @@ -92,8 +92,7 @@ public class ClientProducerImpl implements ClientProducerInternal { if (autoGroup) { this.groupID = UUIDGenerator.getInstance().generateSimpleStringUUID(); - } - else { + } else { this.groupID = groupID; } @@ -101,8 +100,7 @@ public class ClientProducerImpl implements ClientProducerInternal { if (address != null) { producerCredits = session.getCredits(address, false); - } - else { + } else { producerCredits = null; } } @@ -141,8 +139,7 @@ public class ClientProducerImpl implements ClientProducerInternal { boolean confirmationWindowEnabled = session.isConfirmationWindowEnabled(); if (confirmationWindowEnabled) { doSend(address1, message, handler, true); - } - else { + } else { doSend(address1, message, null, true); if (handler != null) { session.scheduleConfirmation(handler, message); @@ -231,15 +228,13 @@ public class ClientProducerImpl implements ClientProducerInternal { if (sessionContext.supportsLargeMessage() && (msgI.getBodyInputStream() != null || msgI.isLargeMessage() || msgI.getBodyBuffer().writerIndex() > minLargeMessageSize && !msgI.isServerMessage())) { isLarge = true; - } - else { + } else { isLarge = false; } if (!isLarge) { session.setAddress(msg, sendingAddress); - } - else { + } else { msg.setAddress(sendingAddress); } @@ -264,12 +259,10 @@ public class ClientProducerImpl implements ClientProducerInternal { if (isLarge) { largeMessageSend(sendBlocking, msgI, theCredits, handler); - } - else { + } else { sendRegularMessage(sendingAddress, msgI, sendBlocking, theCredits, handler); } - } - finally { + } finally { session.endCall(); } } @@ -330,11 +323,9 @@ public class ClientProducerImpl implements ClientProducerInternal { if (msgI.isServerMessage()) { largeMessageSendServer(sendBlocking, msgI, credits, handler); - } - else if ((input = msgI.getBodyInputStream()) != null) { + } else if ((input = msgI.getBodyInputStream()) != null) { largeMessageSendStreamed(sendBlocking, msgI, input, credits, handler); - } - else { + } else { largeMessageSendBuffered(sendBlocking, msgI, credits, handler); } } @@ -391,8 +382,7 @@ public class ClientProducerImpl implements ClientProducerInternal { credits.acquireCredits(creditsUsed); } - } - finally { + } finally { context.close(); } } @@ -443,7 +433,6 @@ public class ClientProducerImpl implements ClientProducerInternal { boolean headerSent = false; - int reconnectID = sessionContext.getReconnectID(); while (!lastPacket) { byte[] buff = new byte[minLargeMessageSize]; @@ -457,8 +446,7 @@ public class ClientProducerImpl implements ClientProducerInternal { try { numberOfBytesRead = input.read(buff, pos, wanted); - } - catch (IOException e) { + } catch (IOException e) { throw ActiveMQClientMessageBundle.BUNDLE.errorReadingBody(e); } @@ -494,8 +482,7 @@ public class ClientProducerImpl implements ClientProducerInternal { msgI.getBodyBuffer().writeBytes(buff, 0, pos); sendRegularMessage(msgI.getAddress(), msgI, sendBlocking, credits, handler); return; - } - else { + } else { if (!headerSent) { headerSent = true; sendInitialLargeMessageHeader(msgI, credits); @@ -503,8 +490,7 @@ public class ClientProducerImpl implements ClientProducerInternal { int creditsSent = sessionContext.sendLargeMessageChunk(msgI, messageSize.get(), sendBlocking, true, buff, reconnectID, handler); credits.acquireCredits(creditsSent); } - } - else { + } else { if (!headerSent) { headerSent = true; sendInitialLargeMessageHeader(msgI, credits); @@ -517,8 +503,7 @@ public class ClientProducerImpl implements ClientProducerInternal { try { input.close(); - } - catch (IOException e) { + } catch (IOException e) { throw ActiveMQClientMessageBundle.BUNDLE.errorClosingLargeMessage(e); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java index 88a20e1e14..d781fff131 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java @@ -189,8 +189,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C connectionTTL == ActiveMQClient.DEFAULT_CONNECTION_TTL) { this.clientFailureCheckPeriod = ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM; this.connectionTTL = ActiveMQClient.DEFAULT_CONNECTION_TTL_INVM; - } - else { + } else { this.clientFailureCheckPeriod = clientFailureCheckPeriod; this.connectionTTL = connectionTTL; @@ -269,14 +268,13 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C logger.debug("Setting up backup config = " + backUp + " for live = " + live); } backupConfig = backUp; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("ClientSessionFactoryImpl received backup update for live/backup pair = " + live + - " / " + - backUp + - " but it didn't belong to " + - connectorConfig); + " / " + + backUp + + " but it didn't belong to " + + connectorConfig); } } } @@ -444,8 +442,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C session.close(); else session.cleanUp(false); - } - catch (Exception e1) { + } catch (Exception e1) { ActiveMQClientLogger.LOGGER.unableToCloseSession(e1); } } @@ -475,8 +472,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C public boolean waitForTopology(long timeout, TimeUnit unit) { try { return latchFinalTopology.await(timeout, unit); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); return false; @@ -506,12 +502,10 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C String scaleDownTargetNodeID) { try { failoverOrReconnect(connectionID, me, scaleDownTargetNodeID); - } - catch (ActiveMQInterruptedException e1) { + } catch (ActiveMQInterruptedException e1) { // this is just a debug, since an interrupt is an expected event (in case of a shutdown) logger.debug(e1.getMessage(), e1); - } - catch (Throwable t) { + } catch (Throwable t) { //for anything else just close so clients are un blocked close(); throw t; @@ -532,7 +526,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C for (ClientSessionInternal session : sessions) { SessionContext context = session.getSessionContext(); if (context instanceof ActiveMQSessionContext) { - ActiveMQSessionContext sessionContext = (ActiveMQSessionContext)context; + ActiveMQSessionContext sessionContext = (ActiveMQSessionContext) context; if (sessionContext.isKilled()) { setReconnectAttempts(0); } @@ -607,8 +601,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (localConnector != null) { try { localConnector.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { // no-op } } @@ -627,8 +620,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C callFailoverListeners(FailoverEventType.FAILOVER_COMPLETED); } } - } - else { + } else { RemotingConnection connectionToDestory = connection; if (connectionToDestory != null) { connectionToDestory.destroy(); @@ -643,8 +635,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C callFailoverListeners(FailoverEventType.FAILOVER_FAILED); callSessionFailureListeners(me, true, false, scaleDownTargetNodeID); } - } - finally { + } finally { localFailoverLock.unlock(); } @@ -659,8 +650,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C for (ClientSessionInternal session : sessionsToClose) { try { session.cleanUp(true); - } - catch (Exception cause) { + } catch (Exception cause) { ActiveMQClientLogger.LOGGER.failedToCleanupSession(cause); } } @@ -708,12 +698,10 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C try { if (afterReconnect) { listener.connectionFailed(me, failedOver, scaleDownTargetNodeID); - } - else { + } else { listener.beforeReconnect(me); } - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -728,8 +716,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C for (final FailoverEventListener listener : listenersClone) { try { listener.failoverEvent(type); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -789,10 +776,10 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C return; if (logger.isTraceEnabled()) { logger.trace("getConnectionWithRetry::" + reconnectAttempts + - " with retryInterval = " + - retryInterval + - " multiplier = " + - retryIntervalMultiplier, new Exception("trace")); + " with retryInterval = " + + retryInterval + + " multiplier = " + + retryIntervalMultiplier, new Exception("trace")); } long interval = retryInterval; @@ -809,8 +796,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C logger.debug("Reconnection successful"); } return; - } - else { + } else { // Failed to get connection if (reconnectAttempts != 0) { @@ -832,8 +818,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (clientProtocolManager.waitOnLatch(interval)) { return; } - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { throw new ActiveMQInterruptedException(createTrace); } @@ -845,8 +830,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C } interval = newInterval; - } - else { + } else { logger.debug("Could not connect to any server. Didn't have reconnection configured on the ClientSessionFactory"); return; } @@ -876,8 +860,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C try { connectionInUse.destroy(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } connection = null; @@ -886,8 +869,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (connectorInUse != null) { connectorInUse.close(); } - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } connector = null; @@ -904,8 +886,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (connection != null) { // a connection already exists, so returning the same one return connection; - } - else { + } else { RemotingConnection connection = establishNewConnection(); this.connection = connection; @@ -920,8 +901,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C this.connection = null; return null; } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { connection.destroy(); this.connection = null; return null; @@ -939,8 +919,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C } clientProtocolManager.sendSubscribeTopology(serverLocator.isClusterConnection()); } - } - else { + } else { logger.debug("serverLocator@" + System.identityHashCode(serverLocator + " had no topology")); } @@ -959,10 +938,9 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C // To make sure the first ping will be sent pingRunnable.send(); - } - // send a ping every time we create a new remoting connection - // to set up its TTL on the server side - else { + } else { + // send a ping every time we create a new remoting connection + // to set up its TTL on the server side pingRunnable.run(); } } @@ -1015,12 +993,10 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C CLOSE_RUNNABLES.add(this); if (scaleDownTargetNodeID == null) { conn.fail(ActiveMQClientMessageBundle.BUNDLE.disconnected()); - } - else { + } else { conn.fail(ActiveMQClientMessageBundle.BUNDLE.disconnected(), scaleDownTargetNodeID); } - } - finally { + } finally { CLOSE_RUNNABLES.remove(this); } @@ -1065,8 +1041,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C try { connector.close(); - } - catch (Throwable t) { + } catch (Throwable t) { } } @@ -1092,10 +1067,10 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C try { if (logger.isDebugEnabled()) { logger.debug("Trying to connect with connector = " + connectorFactory + - ", parameters = " + - connectorConfig.getParams() + - " connector = " + - connector); + ", parameters = " + + connectorConfig.getParams() + + " connector = " + + connector); } Connector liveConnector = createConnector(connectorFactory, connectorConfig); @@ -1103,8 +1078,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if ((transportConnection = openTransportConnection(liveConnector)) != null) { // if we can't connect the connect method will return null, hence we have to try the backup connector = liveConnector; - } - else if (backupConfig != null) { + } else if (backupConfig != null) { if (logger.isDebugEnabled()) { logger.debug("Trying backup config = " + backupConfig); } @@ -1127,16 +1101,14 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C connectorConfig = backupConfig; backupConfig = null; connectorFactory = backupConnectorFactory; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Backup is not active."); } } } - } - catch (Exception cause) { + } catch (Exception cause) { // Sanity catch for badly behaved remoting plugins ActiveMQClientLogger.LOGGER.createConnectorException(cause); @@ -1144,16 +1116,14 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (transportConnection != null) { try { transportConnection.close(); - } - catch (Throwable t) { + } catch (Throwable t) { } } if (connector != null) { try { connector.close(); - } - catch (Throwable t) { + } catch (Throwable t) { } } @@ -1173,8 +1143,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (theConn != null && connectionID.equals(theConn.getID())) { theConn.bufferReceived(connectionID, buffer); - } - else { + } else { logger.debug("TheConn == null on ClientSessionFactoryImpl::DelegatingBufferHandler, ignoring packet"); } } @@ -1262,8 +1231,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C }); return; - } - else { + } else { lastCheck = now; } } @@ -1331,11 +1299,11 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (logger.isTraceEnabled()) { logger.trace("Disconnect being called on client:" + - " server locator = " + - serverLocator + - " notifying node " + - nodeID + - " as down", new Exception("trace")); + " server locator = " + + serverLocator + + " notifying node " + + nodeID + + " as down", new Exception("trace")); } serverLocator.notifyNodeDown(System.currentTimeMillis(), nodeID); @@ -1359,8 +1327,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C } serverLocator.notifyNodeUp(uniqueEventID, nodeID, backupGroupName, scaleDownGroupName, connectorPair, isLast); - } - finally { + } finally { if (isLast) { latchFinalTopology.countDown(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java index 8b0fc8ecba..de45066af3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java @@ -274,8 +274,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.createSharedQueue(address, queueName, filterString, durable); - } - finally { + } finally { endCall(); } @@ -328,8 +327,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.deleteQueue(queueName); - } - finally { + } finally { endCall(); } } @@ -346,8 +344,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { return sessionContext.queueQuery(queueName); - } - finally { + } finally { endCall(); } @@ -411,13 +408,11 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi return createConsumer(SimpleString.toSimpleString(queueName), null, browseOnly); } - @Override public boolean isWritable(ReadyListener callback) { return sessionContext.isWritable(callback); } - /** * Note, we DO NOT currently support direct consumers (i.e. consumers where delivery occurs on * the remoting thread). @@ -510,16 +505,14 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } try { sessionContext.simpleCommit(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.UNBLOCKED || rollbackOnly) { // The call to commit was unlocked on failover, we therefore rollback the tx, // and throw a transaction rolled back exception instead //or //if we have been set to rollbackonly then we have probably failed over and don't know if the tx has committed rollbackOnFailover(false); - } - else { + } else { throw e; } } @@ -753,8 +746,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.sendACK(false, blockOnAcknowledge, consumer, message); - } - finally { + } finally { endCall(); } } @@ -772,8 +764,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi try { sessionContext.sendACK(true, blockOnAcknowledge, consumer, message); - } - finally { + } finally { endCall(); } } @@ -859,8 +850,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi public void run() { try { consumer.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQClientLogger.LOGGER.unableToCloseConsumer(e); } } @@ -887,8 +877,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } inClose = true; sessionContext.sessionClose(); - } - catch (Throwable e) { + } catch (Throwable e) { // Session close should always return without exception // Note - we only log at trace @@ -1002,11 +991,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi sessionContext.returnBlocking(cause); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.failedToHandleFailover(t); - } - finally { + } finally { sessionContext.releaseCommunications(); } @@ -1053,13 +1040,11 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi logger.tracef("setAddress() Setting default address as %s", address); message.setAddress(address); - } - else { + } else { if (!address.equals(defaultAddress)) { logger.tracef("setAddress() setting non default address %s on message", address); message.setAddress(address); - } - else { + } else { logger.trace("setAddress() being set as null"); message.setAddress(null); } @@ -1074,7 +1059,6 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } } - @Override public void setPacketSize(final int packetSize) { if (packetSize > this.initialMessagePacketSize) { @@ -1149,8 +1133,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi if (rollbackOnly) { if (onePhase) { throw new XAException(XAException.XAER_RMFAIL); - } - else { + } else { ActiveMQClientLogger.LOGGER.commitAfterFailover(); } } @@ -1162,19 +1145,16 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi try { sessionContext.xaCommit(xid, onePhase); workDone = false; - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.failoverDuringCommit(); XAException xaException = null; if (onePhase) { //we must return XA_RMFAIL xaException = new XAException(XAException.XAER_RMFAIL); - } - else { + } else { // Any error on commit -> RETRY // We can't rollback a Prepared TX for definition xaException = new XAException(XAException.XA_RETRY); @@ -1182,8 +1162,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi xaException.initCause(t); throw xaException; - } - finally { + } finally { endCall(); } } @@ -1200,8 +1179,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi if (rollbackOnly) { try { rollback(false, false); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { logger.debug("Error on rollback during end call!", ignored); } throw new XAException(XAException.XAER_RMFAIL); @@ -1213,23 +1191,19 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.xaEnd(xid, flags); - } - finally { + } finally { endCall(); } - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.errorCallingEnd(t); // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); throw xaException; } - } - finally { + } finally { currentXID = null; } } @@ -1240,17 +1214,14 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.xaForget(xid); - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); throw xaException; - } - finally { + } finally { endCall(); } } @@ -1261,8 +1232,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi try { return sessionContext.recoverSessionTimeout(); - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1276,8 +1246,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi try { return sessionContext.configureTransactionTimeout(seconds); - } - catch (Throwable t) { + } catch (Throwable t) { markRollbackOnly(); // The TM will ignore any errors from here, if things are this screwed up we mark rollbackonly // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); @@ -1317,8 +1286,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } if (xares instanceof ClientSessionInternal) { return (ClientSessionInternal) xares; - } - else if (xares instanceof ActiveMQXAResource) { + } else if (xares instanceof ActiveMQXAResource) { return getSessionInternalFromXAResource(((ActiveMQXAResource) xares).getResource()); } return null; @@ -1341,25 +1309,21 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { return sessionContext.xaPrepare(xid); - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.UNBLOCKED) { // Unblocked on failover try { // will retry once after failover & unblock return sessionContext.xaPrepare(xid); - } - catch (Throwable t) { + } catch (Throwable t) { // ignore and rollback } ActiveMQClientLogger.LOGGER.failoverDuringPrepareRollingBack(); try { rollback(false); - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1377,16 +1341,14 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(e); throw xaException; - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQClientLogger.LOGGER.errorDuringPrepare(t); // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); throw xaException; - } - finally { + } finally { endCall(); } } @@ -1398,8 +1360,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi if ((flags & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) { try { return sessionContext.xaScan(); - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1434,19 +1395,16 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi try { sessionContext.xaRollback(xid, wasStarted); - } - finally { + } finally { if (wasStarted) { start(); } } workDone = false; - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.UNBLOCKED) { // Unblocked on failover throw new XAException(XAException.XA_RETRY); @@ -1456,8 +1414,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(e); throw xaException; - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1477,20 +1434,16 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi sessionContext.xaStart(xid, flags); this.currentXID = xid; - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // we can retry this only because we know for sure that no work would have been done if (e.getType() == ActiveMQExceptionType.UNBLOCKED) { try { sessionContext.xaStart(xid, flags); - } - catch (XAException xae) { + } catch (XAException xae) { throw xae; - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1502,8 +1455,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(e); throw xaException; - } - catch (Throwable t) { + } catch (Throwable t) { // This could occur if the TM interrupts the thread XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(t); @@ -1517,8 +1469,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi public void connectionFailed(final ActiveMQException me, boolean failedOver) { try { cleanUp(false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.failedToCleanupSession(e); } } @@ -1618,8 +1569,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi startCall(); try { sessionContext.createQueue(address, queueName, filterString, durable, temp); - } - finally { + } finally { endCall(); } } @@ -1739,24 +1689,18 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi private String convertTXFlag(final int flags) { if (flags == XAResource.TMSUSPEND) { return "SESS_XA_SUSPEND"; - } - else if (flags == XAResource.TMSUCCESS) { + } else if (flags == XAResource.TMSUCCESS) { return "TMSUCCESS"; - } - else if (flags == XAResource.TMFAIL) { + } else if (flags == XAResource.TMFAIL) { return "TMFAIL"; - } - else if (flags == XAResource.TMJOIN) { + } else if (flags == XAResource.TMJOIN) { return "TMJOIN"; - } - else if (flags == XAResource.TMRESUME) { + } else if (flags == XAResource.TMRESUME) { return "TMRESUME"; - } - else if (flags == XAResource.TMNOFLAGS) { + } else if (flags == XAResource.TMNOFLAGS) { // Don't need to flush since the previous end will have done this return "TMNOFLAGS"; - } - else { + } else { return "XAER_INVAL(" + flags + ")"; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionInternal.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionInternal.java index b082786054..ed636bd917 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionInternal.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionInternal.java @@ -88,7 +88,9 @@ public interface ClientSessionInternal extends ClientSession { ClientProducerCreditManager getProducerCreditManager(); - /** This will set the address at the message */ + /** + * This will set the address at the message + */ void setAddress(Message message, SimpleString address); void checkDefaultAddress(SimpleString address); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java index 0e826b5c36..24b7f1e96d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java @@ -102,8 +102,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } @@ -119,8 +118,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public byte readByte() { try { return getStream().readByte(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -340,8 +338,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public int readUnsignedByte() { try { return getStream().readUnsignedByte(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -350,8 +347,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public short readShort() { try { return getStream().readShort(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -360,8 +356,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public int readUnsignedShort() { try { return getStream().readUnsignedShort(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -370,8 +365,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public int readInt() { try { return getStream().readInt(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -385,8 +379,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll public long readLong() { try { return getStream().readLong(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -398,8 +391,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll if (nReadBytes < length) { ActiveMQClientLogger.LOGGER.compressedLargeMessageError(length, nReadBytes); } - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } @@ -445,33 +437,36 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll getStream().read(); } return length; - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } - - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b) throws IOException { readBytes(b); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b, int off, int len) throws IOException { readBytes(b, off, len); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override @SuppressWarnings("deprecation") public String readLine() throws IOException { return getStream().readLine(); } - @Override public void writeByte(final byte value) { throw new IllegalAccessError(OPERATION_NOT_SUPPORTED); @@ -568,8 +563,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll int b = readByte(); if (b == DataConstants.NULL) { return null; - } - else { + } else { return readSimpleString(); } } @@ -579,8 +573,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll int b = readByte(); if (b == DataConstants.NULL) { return null; - } - else { + } else { return readString(); } } @@ -603,11 +596,9 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll chars[i] = (char) readShort(); } return new String(chars); - } - else if (len < 0xfff) { + } else if (len < 0xfff) { return readUTF(); - } - else { + } else { return readSimpleString().toString(); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java index da4d6bd1ce..5a27f248e3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java @@ -122,8 +122,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { this.totalSize = totalSize; if (cachedFile == null) { fileCache = null; - } - else { + } else { fileCache = new FileCache(cachedFile); } this.bufferSize = bufferSize; @@ -142,8 +141,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { return; try { checkForPacket(totalSize - 1); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -177,18 +175,15 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (streamEnded) { outStream.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorAddingPacket(e); handledException = e; } - } - else { + } else { if (fileCache != null) { try { fileCache.cachePackage(chunk); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorAddingPacket(e); handledException = e; } @@ -201,8 +196,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (flowControlCredit != 0) { try { consumerInternal.flowControl(flowControlCredit, !isContinues); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorAddingPacket(e); handledException = e; } @@ -222,8 +216,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { try { consumerInternal.flowControl(totalSize, false); - } - catch (Exception ignored) { + } catch (Exception ignored) { // what else can we do here? ActiveMQClientLogger.LOGGER.errorCallingCancel(ignored); } @@ -300,24 +293,21 @@ public class LargeMessageControllerImpl implements LargeMessageController { // And we will check if no packets have arrived within readTimeout milliseconds if (timeWait != 0) { timeOut = System.currentTimeMillis() + timeWait; - } - else { + } else { timeOut = System.currentTimeMillis() + readTimeout; } while (!streamEnded && handledException == null) { try { this.wait(timeWait == 0 ? readTimeout : timeWait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } if (!streamEnded && handledException == null) { if (timeWait != 0 && System.currentTimeMillis() > timeOut) { throw ActiveMQClientMessageBundle.BUNDLE.timeoutOnLargeMessage(); - } - else if (System.currentTimeMillis() > timeOut && !packetAdded) { + } else if (System.currentTimeMillis() > timeOut && !packetAdded) { throw ActiveMQClientMessageBundle.BUNDLE.timeoutOnLargeMessage(); } } @@ -343,15 +333,13 @@ public class LargeMessageControllerImpl implements LargeMessageController { // instead to just where it was canceled. if (handledException instanceof ActiveMQLargeMessageInterruptedException) { nestedException = new ActiveMQLargeMessageInterruptedException(handledException.getMessage()); - } - else { + } else { nestedException = new ActiveMQException(((ActiveMQException) handledException).getType(), handledException.getMessage()); } nestedException.initCause(handledException); throw nestedException; - } - else { + } else { throw new ActiveMQException(ActiveMQExceptionType.LARGE_MESSAGE_ERROR_BODY, "Error on saving LargeMessageBufferImpl", handledException); } } @@ -379,8 +367,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (fileCache != null && index < packetPosition) { return fileCache.getByteFromCache(index); - } - else { + } else { return currentPacket.getChunk()[(int) (index - packetPosition)]; } } @@ -546,8 +533,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { public void readerIndex(final int readerIndex) { try { checkForPacket(readerIndex); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorReadingIndex(e); throw new RuntimeException(e.getMessage(), e); } @@ -573,8 +559,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { public void setIndex(final int readerIndex, final int writerIndex) { try { checkForPacket(readerIndex); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorSettingIndex(e); throw new RuntimeException(e.getMessage(), e); } @@ -601,8 +586,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (readableBytes > Integer.MAX_VALUE) { return Integer.MAX_VALUE; - } - else { + } else { return (int) (totalSize - readerIndex); } } @@ -621,8 +605,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { public void resetReaderIndex() { try { checkForPacket(0); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorReSettingIndex(e); throw new RuntimeException(e.getMessage(), e); } @@ -956,8 +939,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { int b = readByte(); if (b == DataConstants.NULL) { return null; - } - else { + } else { return readSimpleString(); } } @@ -967,8 +949,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { int b = readByte(); if (b == DataConstants.NULL) { return null; - } - else { + } else { return readString(); } } @@ -991,11 +972,9 @@ public class LargeMessageControllerImpl implements LargeMessageController { chars[i] = (char) readShort(); } return new String(chars); - } - else if (len < 0xfff) { + } else if (len < 0xfff) { return readUTF(); - } - else { + } else { return readSimpleString().toString(); } } @@ -1074,8 +1053,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { streamEnded = true; output.close(); } - } - catch (IOException e) { + } catch (IOException e) { throw ActiveMQClientMessageBundle.BUNDLE.errorWritingLargeMessage(e); } } @@ -1105,11 +1083,9 @@ public class LargeMessageControllerImpl implements LargeMessageController { packetPosition += sizeToAdd; packetLastPosition = packetPosition + currentPacket.getChunk().length; - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -1180,12 +1156,10 @@ public class LargeMessageControllerImpl implements LargeMessageController { readCachePositionEnd = readCachePositionStart + cachedChannel.read(readCache) - 1; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorReadingCache(e); throw new RuntimeException(e.getMessage(), e); - } - finally { + } finally { close(); } } @@ -1221,8 +1195,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (cachedChannel != null && cachedChannel.isOpen()) { try { cachedChannel.close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorClosingCache(e); } cachedChannel = null; @@ -1231,8 +1204,7 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (cachedRAFile != null) { try { cachedRAFile.close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorClosingCache(e); } cachedRAFile = null; @@ -1246,27 +1218,32 @@ public class LargeMessageControllerImpl implements LargeMessageController { if (cachedFile != null && cachedFile.exists()) { try { cachedFile.delete(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorFinalisingCache(e); } } } } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b) throws IOException { readBytes(b); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public void readFully(byte[] b, int off, int len) throws IOException { readBytes(b, off, len); } - /** from {@link java.io.DataInput} interface */ + /** + * from {@link java.io.DataInput} interface + */ @Override public String readLine() throws IOException { return ByteUtil.readLine(this); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java index 76ffdb9484..beb1b13517 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java @@ -220,13 +220,11 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery private synchronized void setThreadPools() { if (threadPool != null) { return; - } - else if (useGlobalPools) { + } else if (useGlobalPools) { threadPool = ActiveMQClient.getGlobalThreadPool(); scheduledThreadPool = ActiveMQClient.getGlobalScheduledThreadPool(); - } - else { + } else { this.shutdownPool = true; ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction() { @@ -238,8 +236,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (threadPoolMaxSize == -1) { threadPool = Executors.newCachedThreadPool(factory); - } - else { + } else { threadPool = new ActiveMQThreadPoolExecutor(0, threadPoolMaxSize, 60L, TimeUnit.SECONDS, factory); } @@ -255,9 +252,11 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } @Override - public synchronized boolean setThreadPools(ExecutorService threadPool, ScheduledExecutorService scheduledThreadPool) { + public synchronized boolean setThreadPools(ExecutorService threadPool, + ScheduledExecutorService scheduledThreadPool) { - if (threadPool == null || scheduledThreadPool == null) return false; + if (threadPool == null || scheduledThreadPool == null) + return false; if (this.threadPool == null && this.scheduledThreadPool == null) { useGlobalPools = false; @@ -265,8 +264,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery this.threadPool = threadPool; this.scheduledThreadPool = scheduledThreadPool; return true; - } - else { + } else { return false; } } @@ -305,8 +303,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery discoveryGroup.start(); } - } - catch (Exception e) { + } catch (Exception e) { state = null; throw ActiveMQClientMessageBundle.BUNDLE.failedToInitialiseSessionFactory(e); } @@ -401,8 +398,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery public static ServerLocator newLocator(String uri) { try { return newLocator(new URI(uri)); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -411,8 +407,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery try { ServerLocatorParser parser = new ServerLocatorParser(); return parser.newObject(uri, null); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -546,8 +541,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery Pair pair = usedTopology[pos]; return pair.getA(); - } - else { + } else { // Get from initialconnectors if (logger.isTraceEnabled()) { logger.trace("Selecting connector from initial connectors."); @@ -572,8 +566,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery public void run() { try { connect(); - } - catch (Exception e) { + } catch (Exception e) { if (!isClosed()) { ActiveMQClientLogger.LOGGER.errorConnectingToNodes(e); } @@ -627,8 +620,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (returnFactory != null) { addFactory(returnFactory); return returnFactory; - } - else { + } else { // wait for discovery group to get the list of initial connectors return (ClientSessionFactoryInternal) createSessionFactory(); } @@ -689,16 +681,14 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery try { try { factory.connect(reconnectAttempts, failoverOnInitialConnection); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { //we need to make sure is closed just for garbage collection factory.close(); throw e1; } addFactory(factory); return factory; - } - finally { + } finally { removeFromConnecting(factory); } } @@ -717,16 +707,14 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery try { try { factory.connect(reconnectAttempts, failoverOnInitialConnection); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { //we need to make sure is closed just for garbage collection factory.close(); throw e1; } addFactory(factory); return factory; - } - finally { + } finally { removeFromConnecting(factory); } } @@ -780,12 +768,10 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery try { addToConnecting(factory); factory.connect(initialConnectAttempts, failoverOnInitialConnection); - } - finally { + } finally { removeFromConnecting(factory); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { factory.close(); if (e.getType() == ActiveMQExceptionType.NOT_CONNECTED) { attempts++; @@ -800,8 +786,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } } retry = true; - } - else { + } else { throw e; } } @@ -1344,13 +1329,11 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery synchronized (this) { try { discoveryGroup.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.failedToStopDiscovery(e); } } - } - else { + } else { staticConnector.disconnect(); } @@ -1377,8 +1360,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery for (ClientSessionFactory factory : clonedFactory) { if (sendClose) { factory.close(); - } - else { + } else { factory.cleanup(); } } @@ -1391,8 +1373,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (!threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS)) { ActiveMQClientLogger.LOGGER.timedOutWaitingForTermination(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -1404,8 +1385,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (!scheduledThreadPool.awaitTermination(10000, TimeUnit.MILLISECONDS)) { ActiveMQClientLogger.LOGGER.timedOutWaitingForScheduledPoolTermination(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -1436,14 +1416,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (clusterConnection) { updateArraysAndPairs(); - } - else { + } else { if (topology.isEmpty()) { // Resetting the topology to its original condition as it was brand new receivedTopology = false; topologyArray = null; - } - else { + } else { updateArraysAndPairs(); if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null) { @@ -1551,16 +1529,14 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery public void run() { try { connect(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQClientLogger.LOGGER.errorConnectingToNodes(e); } } }; if (startExecutor != null) { startExecutor.execute(connectRunnable); - } - else { + } else { connectRunnable.run(); } } @@ -1667,8 +1643,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (clusterConnection && exception.getType() == ActiveMQExceptionType.DISCONNECTED) { try { ServerLocatorImpl.this.start(startExecutor); - } - catch (Exception e) { + } catch (Exception e) { // There isn't much to be done if this happens here ActiveMQClientLogger.LOGGER.errorStartingLocator(e); } @@ -1690,10 +1665,10 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery if (logger.isDebugEnabled()) { logger.debug("Returning " + csf + - " after " + - retryNumber + - " retries on StaticConnector " + - ServerLocatorImpl.this); + " after " + + retryNumber + + " retries on StaticConnector " + + ServerLocatorImpl.this); } return csf; @@ -1708,14 +1683,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery return null; } - } - catch (RejectedExecutionException e) { + } catch (RejectedExecutionException e) { if (isClosed() || skipWarnings) return null; logger.debug("Rejected execution", e); throw e; - } - catch (Exception e) { + } catch (Exception e) { if (isClosed() || skipWarnings) return null; ActiveMQClientLogger.LOGGER.errorConnectingToNodes(e); @@ -1795,14 +1768,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery try { factoryToUse.connect(1, false); - } - finally { + } finally { removeFromConnecting(factoryToUse); } } return factoryToUse; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { logger.debug(this + "::Exception on establish connector initial connection", e); return null; } @@ -1883,5 +1854,4 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } - } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java index 4e9230b6a8..096fd66c45 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java @@ -33,6 +33,7 @@ import org.apache.activemq.artemis.spi.core.remoting.Connector; import org.jboss.logging.Logger; public final class Topology { + private static final Logger logger = Logger.getLogger(Topology.class); private final Set topologyListeners; @@ -181,11 +182,11 @@ public final class Topology { Long deleteTme = getMapDelete().get(nodeId); if (deleteTme != null && uniqueEventID != 0 && uniqueEventID < deleteTme) { logger.debug("Update uniqueEvent=" + uniqueEventID + - ", nodeId=" + - nodeId + - ", memberInput=" + - memberInput + - " being rejected as there was a delete done after that"); + ", nodeId=" + + nodeId + + ", memberInput=" + + memberInput + + " being rejected as there was a delete done after that"); return false; } @@ -214,8 +215,8 @@ public final class Topology { if (logger.isTraceEnabled()) { logger.trace(this + "::updated currentMember=nodeID=" + nodeId + ", currentMember=" + - currentMember + ", memberInput=" + memberInput + "newMember=" + - newMember, new Exception("trace")); + currentMember + ", memberInput=" + memberInput + "newMember=" + + newMember, new Exception("trace")); } newMember.setUniqueEventID(uniqueEventID); @@ -254,17 +255,16 @@ public final class Topology { for (ClusterTopologyListener listener : copy) { if (logger.isTraceEnabled()) { logger.trace(Topology.this + " informing " + - listener + - " about node up = " + - nodeId + - " connector = " + - memberToSend.getConnector()); + listener + + " about node up = " + + nodeId + + " connector = " + + memberToSend.getConnector()); } try { listener.nodeUP(memberToSend, false); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.errorSendingTopology(e); } } @@ -293,8 +293,7 @@ public final class Topology { if (member.getUniqueEventID() > uniqueEventID) { logger.debug("The removeMember was issued before the node " + nodeId + " was started, ignoring call"); member = null; - } - else { + } else { getMapDelete().put(nodeId, uniqueEventID); member = topology.remove(nodeId); } @@ -303,12 +302,12 @@ public final class Topology { if (logger.isTraceEnabled()) { logger.trace("removeMember " + this + - " removing nodeID=" + - nodeId + - ", result=" + - member + - ", size = " + - topology.size(), new Exception("trace")); + " removing nodeID=" + + nodeId + + ", result=" + + member + + ", size = " + + topology.size(), new Exception("trace")); } if (member != null) { @@ -323,8 +322,7 @@ public final class Topology { } try { listener.nodeDown(uniqueEventID, nodeId); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorSendingTopologyNodedown(e); } } @@ -353,11 +351,11 @@ public final class Topology { for (Map.Entry entry : copy.entrySet()) { if (logger.isDebugEnabled()) { logger.debug(Topology.this + " sending " + - entry.getKey() + - " / " + - entry.getValue().getConnector() + - " to " + - listener); + entry.getKey() + + " / " + + entry.getValue().getConnector() + + " to " + + listener); } listener.nodeUP(entry.getValue(), ++count == copy.size()); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/TopologyMemberImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/TopologyMemberImpl.java index c646059ec6..cf62e17ec7 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/TopologyMemberImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/TopologyMemberImpl.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.core.client.impl; +import java.util.Map; + import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.TopologyMember; @@ -23,8 +25,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.utils.ConfigurationHelper; -import java.util.Map; - public final class TopologyMemberImpl implements TopologyMember { private static final long serialVersionUID = 1123652191795626133L; @@ -115,8 +115,7 @@ public final class TopologyMemberImpl implements TopologyMember { public boolean isMember(TransportConfiguration configuration) { if (getConnector().getA() != null && getConnector().getA().isSameParams(configuration) || getConnector().getB() != null && getConnector().getB().isSameParams(configuration)) { return true; - } - else { + } else { return false; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java index 4e9fce58da..7c40602de6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java @@ -150,8 +150,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { try { endpoint.close(false); - } - catch (Exception e1) { + } catch (Exception e1) { ActiveMQClientLogger.LOGGER.errorStoppingDiscoveryBroadcastEndpoint(endpoint, e1); } @@ -163,8 +162,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { ActiveMQClientLogger.LOGGER.timedOutStoppingDiscovery(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } @@ -176,8 +174,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorSendingNotifOnDiscoveryStop(e); } } @@ -207,8 +204,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { while (started && !received && (toWait > 0 || timeout == 0)) { try { waitLock.wait(toWait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } @@ -238,8 +234,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { if (currentUniqueID == null) { uniqueIDMap.put(originatingNodeID, uniqueID); - } - else { + } else { if (!currentUniqueID.equals(uniqueID)) { ActiveMQClientLogger.LOGGER.multipleServersBroadcastingSameNode(originatingNodeID); uniqueIDMap.put(originatingNodeID, uniqueID); @@ -266,12 +261,10 @@ public final class DiscoveryGroup implements ActiveMQComponent { } break; } - } - catch (Exception e) { + } catch (Exception e) { if (!started) { return; - } - else { + } else { ActiveMQClientLogger.LOGGER.errorReceivingPacketInDiscovery(e); } } @@ -332,8 +325,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { waitLock.notifyAll(); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.failedToReceiveDatagramInDiscovery(e); } } @@ -357,8 +349,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { for (DiscoveryListener listener : listeners) { try { listener.connectorsChanged(getDiscoveryEntries()); - } - catch (Throwable t) { + } catch (Throwable t) { // Catch it so exception doesn't prevent other listeners from running ActiveMQClientLogger.LOGGER.failedToCallListenerInDiscovery(t); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java index 10818fa266..921f97d5a8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java @@ -200,8 +200,7 @@ public abstract class MessageImpl implements MessageInternal { buffer.writeNullableSimpleString(address); if (userID == null) { buffer.writeByte(DataConstants.NULL); - } - else { + } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeBytes(userID.asBytes()); } @@ -221,8 +220,7 @@ public abstract class MessageImpl implements MessageInternal { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); - } - else { + } else { userID = null; } type = buffer.readByte(); @@ -449,7 +447,6 @@ public abstract class MessageImpl implements MessageInternal { tmpbodyBuffer.setMessage(this); this.bodyBuffer = tmpbodyBuffer; - } @Override @@ -804,8 +801,7 @@ public abstract class MessageImpl implements MessageInternal { if (str == null) { return null; - } - else { + } else { return str.toString(); } } @@ -916,8 +912,7 @@ public abstract class MessageImpl implements MessageInternal { bodyBuffer.readBytes(buffer2); bodyBuffer.readerIndex(readerIndex2); return "ServerMessage@" + Integer.toHexString(System.identityHashCode(this)) + "[writerIndex=" + buffer.writerIndex() + ",capacity=" + buffer.capacity() + ",bodyStart=" + getEndOfBodyPosition() + " buffer=" + ByteUtil.bytesToHex(buffer1, 1) + ", bodyBuffer=" + ByteUtil.bytesToHex(buffer2, 1); - } - else { + } else { return "ServerMessage@" + Integer.toHexString(System.identityHashCode(this)) + "[writerIndex=" + buffer.writerIndex() + ",capacity=" + buffer.capacity() + ",bodyStart=" + getEndOfBodyPosition() + " buffer=" + ByteUtil.bytesToHex(buffer1, 1); } @@ -955,8 +950,7 @@ public abstract class MessageImpl implements MessageInternal { if ((bodySize + 4) > buffer.capacity()) { buffer.setIndex(0, bodySize); buffer.writeInt(0); - } - else { + } else { buffer.setIndex(0, bodySize + DataConstants.SIZE_INT); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/ClientPacketDecoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/ClientPacketDecoder.java index a7930cba6b..206796d652 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/ClientPacketDecoder.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/ClientPacketDecoder.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.core.protocol; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_LARGE_MSG; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_MSG; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl; import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; @@ -27,6 +24,9 @@ import org.apache.activemq.artemis.core.protocol.core.impl.PacketDecoder; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveClientLargeMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_LARGE_MSG; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_MSG; + public class ClientPacketDecoder extends PacketDecoder { private static final long serialVersionUID = 6952614096979334582L; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/Channel.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/Channel.java index cf88d216ee..bb7b3817f6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/Channel.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/Channel.java @@ -42,6 +42,7 @@ public interface Channel { /** * This number increases every time the channel reconnects successfully. * This is used to guarantee the integrity of the channel on sequential commands such as large messages. + * * @return */ int getReconnectID(); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java index 30a0b7a05e..c79fc7079c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java @@ -30,8 +30,8 @@ import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.protocol.ClientPacketDecoder; @@ -55,8 +55,8 @@ import org.apache.activemq.artemis.core.version.Version; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager; import org.apache.activemq.artemis.spi.core.remoting.Connection; -import org.apache.activemq.artemis.spi.core.remoting.TopologyResponseHandler; import org.apache.activemq.artemis.spi.core.remoting.SessionContext; +import org.apache.activemq.artemis.spi.core.remoting.TopologyResponseHandler; import org.apache.activemq.artemis.utils.VersionLoader; import org.jboss.logging.Logger; @@ -139,8 +139,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { public Channel getChannel0() { if (connection == null) { return null; - } - else { + } else { return connection.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1); } } @@ -153,8 +152,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { public Channel getChannel1() { if (connection == null) { return null; - } - else { + } else { return connection.getChannel(1, -1); } } @@ -175,13 +173,11 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { } return lock; - } - finally { + } finally { localFailoverLock.unlock(); } // We can now release the failoverLock - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; } @@ -239,8 +235,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { for (Version clientVersion : VersionLoader.getClientVersions()) { try { return createSessionContext(clientVersion, name, username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge, minLargeMessageSize, confirmationWindowSize); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() != ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS) { throw e; } @@ -291,8 +286,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { try { // channel1 reference here has to go away response = (CreateSessionResponseMessage) getChannel1().sendBlocking(request, PacketImpl.CREATESESSION_RESP); - } - catch (ActiveMQException cause) { + } catch (ActiveMQException cause) { if (!isAlive()) throw cause; @@ -303,16 +297,14 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { retry = true; continue; - } - else { + } else { throw cause; } } sessionChannel = connection.getChannel(sessionChannelID, confirmationWindowSize); - } - catch (Throwable t) { + } catch (Throwable t) { if (lock != null) { lock.unlock(); lock = null; @@ -320,12 +312,10 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { if (t instanceof ActiveMQException) { throw (ActiveMQException) t; - } - else { + } else { throw ActiveMQClientMessageBundle.BUNDLE.failedToCreateSession(t); } - } - finally { + } finally { if (lock != null) { lock.unlock(); } @@ -354,9 +344,9 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { } protected SessionContext newSessionContext(String name, - int confirmationWindowSize, - Channel sessionChannel, - CreateSessionResponseMessage response) { + int confirmationWindowSize, + Channel sessionChannel, + CreateSessionResponseMessage response) { // these objects won't be null, otherwise it would keep retrying on the previous loop return new ActiveMQSessionContext(name, connection, sessionChannel, response.getServerVersion(), confirmationWindowSize); } @@ -378,8 +368,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { needToInterrupt = inCreateSession; exitLockLatch = inCreateSessionLatch; } - } - finally { + } finally { lock.unlock(); } @@ -395,8 +384,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { if (exitLockLatch != null) { exitLockLatch.await(500, TimeUnit.MILLISECONDS); } - } - catch (InterruptedException e1) { + } catch (InterruptedException e1) { throw new ActiveMQInterruptedException(e1); } } @@ -464,20 +452,16 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { if (topologyResponseHandler != null) topologyResponseHandler.nodeDisconnected(conn, nodeID == null ? null : nodeID.toString(), scaleDownTargetNodeID); - } - else if (type == PacketImpl.CLUSTER_TOPOLOGY) { + } else if (type == PacketImpl.CLUSTER_TOPOLOGY) { ClusterTopologyChangeMessage topMessage = (ClusterTopologyChangeMessage) packet; notifyTopologyChange(topMessage); - } - else if (type == PacketImpl.CLUSTER_TOPOLOGY_V2) { + } else if (type == PacketImpl.CLUSTER_TOPOLOGY_V2) { ClusterTopologyChangeMessage_V2 topMessage = (ClusterTopologyChangeMessage_V2) packet; notifyTopologyChange(topMessage); - } - else if (type == PacketImpl.CLUSTER_TOPOLOGY || type == PacketImpl.CLUSTER_TOPOLOGY_V2 || type == PacketImpl.CLUSTER_TOPOLOGY_V3) { + } else if (type == PacketImpl.CLUSTER_TOPOLOGY || type == PacketImpl.CLUSTER_TOPOLOGY_V2 || type == PacketImpl.CLUSTER_TOPOLOGY_V3) { ClusterTopologyChangeMessage topMessage = (ClusterTopologyChangeMessage) packet; notifyTopologyChange(topMessage); - } - else if (type == PacketImpl.CHECK_FOR_FAILOVER_REPLY) { + } else if (type == PacketImpl.CHECK_FOR_FAILOVER_REPLY) { System.out.println("Channel0Handler.handlePacket"); } } @@ -493,13 +477,11 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { eventUID = ((ClusterTopologyChangeMessage_V3) topMessage).getUniqueEventID(); backupGroupName = ((ClusterTopologyChangeMessage_V3) topMessage).getBackupGroupName(); scaleDownGroupName = ((ClusterTopologyChangeMessage_V3) topMessage).getScaleDownGroupName(); - } - else if (topMessage instanceof ClusterTopologyChangeMessage_V2) { + } else if (topMessage instanceof ClusterTopologyChangeMessage_V2) { eventUID = ((ClusterTopologyChangeMessage_V2) topMessage).getUniqueEventID(); backupGroupName = ((ClusterTopologyChangeMessage_V2) topMessage).getBackupGroupName(); scaleDownGroupName = null; - } - else { + } else { eventUID = System.currentTimeMillis(); backupGroupName = null; scaleDownGroupName = null; @@ -513,8 +495,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { if (topologyResponseHandler != null) { topologyResponseHandler.notifyNodeDown(eventUID, topMessage.getNodeID()); } - } - else { + } else { Pair transportConfig = topMessage.getPair(); if (transportConfig.getA() == null && transportConfig.getB() == null) { transportConfig = new Pair<>(conn.getTransportConnection().getConnectorConfig(), null); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java index 32f2d14a51..c03f76ceb8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java @@ -133,7 +133,6 @@ public class ActiveMQSessionContext extends SessionContext { this.name = name; } - protected int getConfirmationWindow() { return confirmationWindow; @@ -178,8 +177,7 @@ public class ActiveMQSessionContext extends SessionContext { if (packet.getType() == PacketImpl.SESS_SEND) { SessionSendMessage ssm = (SessionSendMessage) packet; callSendAck(ssm.getHandler(), ssm.getMessage()); - } - else if (packet.getType() == PacketImpl.SESS_SEND_CONTINUATION) { + } else if (packet.getType() == PacketImpl.SESS_SEND_CONTINUATION) { SessionSendContinuationMessage scm = (SessionSendContinuationMessage) packet; if (!scm.isContinues()) { callSendAck(scm.getHandler(), scm.getMessage()); @@ -190,8 +188,7 @@ public class ActiveMQSessionContext extends SessionContext { private void callSendAck(SendAcknowledgementHandler handler, final Message message) { if (handler != null) { handler.sendAcknowledged(message); - } - else if (sendAckHandler != null) { + } else if (sendAckHandler != null) { sendAckHandler.sendAcknowledged(message); } } @@ -363,14 +360,11 @@ public class ActiveMQSessionContext extends SessionContext { Packet packet; if (flags == XAResource.TMSUSPEND) { packet = new PacketImpl(PacketImpl.SESS_XA_SUSPEND); - } - else if (flags == XAResource.TMSUCCESS) { + } else if (flags == XAResource.TMSUCCESS) { packet = new SessionXAEndMessage(xid, false); - } - else if (flags == XAResource.TMFAIL) { + } else if (flags == XAResource.TMFAIL) { packet = new SessionXAEndMessage(xid, true); - } - else { + } else { throw new XAException(XAException.XAER_INVAL); } @@ -410,8 +404,7 @@ public class ActiveMQSessionContext extends SessionContext { if (sendBlocking) { sessionChannel.sendBlocking(packet, PacketImpl.NULL_RESPONSE); - } - else { + } else { sessionChannel.sendBatched(packet); } } @@ -439,8 +432,7 @@ public class ActiveMQSessionContext extends SessionContext { if (requiresResponse) { // When sending it blocking, only the last chunk will be blocking. sessionChannel.sendBlocking(chunkPacket, reconnectID, PacketImpl.NULL_RESPONSE); - } - else { + } else { sessionChannel.send(chunkPacket, reconnectID); } @@ -448,15 +440,19 @@ public class ActiveMQSessionContext extends SessionContext { } @Override - public int sendServerLargeMessageChunk(MessageInternal msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, SendAcknowledgementHandler messageHandler) throws ActiveMQException { + public int sendServerLargeMessageChunk(MessageInternal msgI, + long messageBodySize, + boolean sendBlocking, + boolean lastChunk, + byte[] chunk, + SendAcknowledgementHandler messageHandler) throws ActiveMQException { final boolean requiresResponse = lastChunk && sendBlocking; final SessionSendContinuationMessage chunkPacket = new SessionSendContinuationMessage(msgI, chunk, !lastChunk, requiresResponse, messageBodySize, messageHandler); if (requiresResponse) { // When sending it blocking, only the last chunk will be blocking. sessionChannel.sendBlocking(chunkPacket, PacketImpl.NULL_RESPONSE); - } - else { + } else { sessionChannel.send(chunkPacket); } @@ -471,15 +467,13 @@ public class ActiveMQSessionContext extends SessionContext { PacketImpl messagePacket; if (individual) { messagePacket = new SessionIndividualAcknowledgeMessage(getConsumerID(consumer), message.getMessageID(), block); - } - else { + } else { messagePacket = new SessionAcknowledgeMessage(getConsumerID(consumer), message.getMessageID(), block); } if (block) { sessionChannel.sendBlocking(messagePacket, PacketImpl.NULL_RESPONSE); - } - else { + } else { sessionChannel.sendBatched(messagePacket); } } @@ -513,8 +507,7 @@ public class ActiveMQSessionContext extends SessionContext { if (response.isError()) { throw new XAException(response.getResponseCode()); - } - else { + } else { return response.getResponseCode(); } } @@ -546,15 +539,12 @@ public class ActiveMQSessionContext extends SessionContext { Packet packet; if (flags == XAResource.TMJOIN) { packet = new SessionXAJoinMessage(xid); - } - else if (flags == XAResource.TMRESUME) { + } else if (flags == XAResource.TMRESUME) { packet = new SessionXAResumeMessage(xid); - } - else if (flags == XAResource.TMNOFLAGS) { + } else if (flags == XAResource.TMNOFLAGS) { // Don't need to flush since the previous end will have done this packet = new SessionXAStartMessage(xid); - } - else { + } else { throw new XAException(XAException.XAER_INVAL); } @@ -610,8 +600,7 @@ public class ActiveMQSessionContext extends SessionContext { sessionChannel.replayCommands(response.getLastConfirmedCommandID()); return true; - } - else { + } else { ActiveMQClientLogger.LOGGER.reconnectCreatingNewSession(sessionChannel.getID()); sessionChannel.clearCommands(); @@ -636,8 +625,7 @@ public class ActiveMQSessionContext extends SessionContext { try { getCreateChannel().sendBlocking(createRequest, PacketImpl.CREATESESSION_RESP); retry = false; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // the session was created while its server was starting, retry it: if (e.getType() == ActiveMQExceptionType.SESSION_CREATION_REJECTED) { ActiveMQClientLogger.LOGGER.retryCreateSessionSeverStarting(name); @@ -645,13 +633,11 @@ public class ActiveMQSessionContext extends SessionContext { // sleep a little bit to avoid spinning too much try { Thread.sleep(10); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw e; } - } - else { + } else { throw e; } } @@ -692,8 +678,7 @@ public class ActiveMQSessionContext extends SessionContext { SessionConsumerFlowCreditMessage packet = new SessionConsumerFlowCreditMessage(getConsumerID(consumerInternal), clientWindowSize); sendPacketWithoutLock(sessionChannel, packet); - } - else { + } else { // https://jira.jboss.org/browse/HORNETQ-522 SessionConsumerFlowCreditMessage packet = new SessionConsumerFlowCreditMessage(getConsumerID(consumerInternal), 1); sendPacketWithoutLock(sessionChannel, packet); @@ -830,8 +815,7 @@ public class ActiveMQSessionContext extends SessionContext { throw new IllegalStateException("Invalid packet: " + type); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.failedToHandlePacket(e); } @@ -859,20 +843,16 @@ public class ActiveMQSessionContext extends SessionContext { // No flow control - buffer can increase without bound! Only use with // caution for very fast consumers clientWindowSize = -1; - } - else if (windowSize == 0) { + } else if (windowSize == 0) { // Slow consumer - no buffering clientWindowSize = 0; - } - else if (windowSize == 1) { + } else if (windowSize == 1) { // Slow consumer = buffer 1 clientWindowSize = 1; - } - else if (windowSize > 1) { + } else if (windowSize > 1) { // Client window size is half server window size clientWindowSize = windowSize >> 1; - } - else { + } else { throw ActiveMQClientMessageBundle.BUNDLE.invalidWindowSize(windowSize); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java index 751dee013f..a51b7b9afe 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java @@ -43,6 +43,7 @@ import org.apache.activemq.artemis.utils.ConcurrentUtil; import org.jboss.logging.Logger; public final class ChannelImpl implements Channel { + private static final Logger logger = Logger.getLogger(ChannelImpl.class); public enum CHANNEL_ID { @@ -84,7 +85,9 @@ public final class ChannelImpl implements Channel { private volatile long id; - /** This is used in */ + /** + * This is used in + */ private final AtomicInteger reconnectID = new AtomicInteger(0); private ChannelHandler handler; @@ -135,8 +138,7 @@ public final class ChannelImpl implements Channel { if (confWindowSize != -1) { resendCache = new ConcurrentLinkedQueue<>(); - } - else { + } else { resendCache = null; } @@ -205,8 +207,7 @@ public final class ChannelImpl implements Channel { response = new ActiveMQExceptionMessage(ActiveMQClientMessageBundle.BUNDLE.unblockingACall(cause)); sendCondition.signal(); - } - finally { + } finally { lock.unlock(); } } @@ -245,12 +246,10 @@ public final class ChannelImpl implements Channel { while (failingOver) { failoverCondition.await(); } - } - else if (!ConcurrentUtil.await(failoverCondition, connection.getBlockingCallFailoverTimeout())) { + } else if (!ConcurrentUtil.await(failoverCondition, connection.getBlockingCallFailoverTimeout())) { logger.debug(timeoutMsg); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -285,8 +284,7 @@ public final class ChannelImpl implements Channel { if (resendCache != null && packet.isRequiresConfirmations()) { addResendPacket(packet); } - } - finally { + } finally { lock.unlock(); } @@ -321,7 +319,9 @@ public final class ChannelImpl implements Channel { * The expectedPacket will be used to filter out undesirable packets that would belong to previous calls. */ @Override - public Packet sendBlocking(final Packet packet, final int reconnectID, byte expectedPacket) throws ActiveMQException { + public Packet sendBlocking(final Packet packet, + final int reconnectID, + byte expectedPacket) throws ActiveMQException { String interceptionResult = invokeInterceptors(packet, interceptors, connection); if (interceptionResult != null) { @@ -371,8 +371,7 @@ public final class ChannelImpl implements Channel { while (!closed && (response == null || (response.getType() != PacketImpl.EXCEPTION && response.getType() != expectedPacket)) && toWait > 0) { try { sendCondition.await(toWait, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } @@ -404,8 +403,7 @@ public final class ChannelImpl implements Channel { throw e; } - } - finally { + } finally { lock.unlock(); } @@ -437,8 +435,7 @@ public final class ChannelImpl implements Channel { if (!callNext) { return interceptor.getClass().getName(); } - } - catch (final Throwable e) { + } catch (final Throwable e) { ActiveMQClientLogger.LOGGER.errorCallingInterceptor(e, interceptor); } } @@ -608,8 +605,7 @@ public final class ChannelImpl implements Channel { } return; - } - else { + } else { if (packet.isResponse()) { confirm(packet); @@ -618,12 +614,10 @@ public final class ChannelImpl implements Channel { try { response = packet; sendCondition.signal(); - } - finally { + } finally { lock.unlock(); } - } - else if (handler != null) { + } else if (handler != null) { handler.handlePacket(packet); } } @@ -648,8 +642,8 @@ public final class ChannelImpl implements Channel { if (logger.isTraceEnabled()) { logger.trace("ChannelImpl::clearUpTo lastReceived commandID=" + lastReceivedCommandID + - " first commandID=" + firstStoredCommandID + - " number to clear " + numberToClear); + " first commandID=" + firstStoredCommandID + + " number to clear " + numberToClear); } for (int i = 0; i < numberToClear; i++) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java index e04f3d0015..54c2022ab2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java @@ -16,76 +16,12 @@ */ package org.apache.activemq.artemis.core.protocol.core.impl; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY_V2; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY_V3; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATESESSION; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATESESSION_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT_V2; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT_CONSUMER; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.EXCEPTION; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.NULL_RESPONSE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.PACKETS_CONFIRMED; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.PING; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REATTACH_SESSION; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REATTACH_SESSION_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CHECK_FOR_FAILOVER; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ACKNOWLEDGE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ADD_METADATA; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ADD_METADATA2; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP_V2; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP_V3; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CLOSE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_COMMIT; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CONSUMER_CLOSE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CREATECONSUMER; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_EXPIRED; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_FLOWTOKEN; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_FORCE_CONSUMER_DELIVERY; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_INDIVIDUAL_ACKNOWLEDGE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_CREDITS; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_FAIL_CREDITS; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_REQUEST_CREDITS; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY_RESP_V2; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_CONTINUATION; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ROLLBACK; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_SEND_CONTINUATION; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_START; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_STOP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_UNIQUE_ADD_METADATA; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_COMMIT; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_END; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_FAILED; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_FORGET; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_GET_TIMEOUT; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_GET_TIMEOUT_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_INDOUBT_XIDS; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_INDOUBT_XIDS_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_JOIN; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_PREPARE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_RESUME; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_ROLLBACK; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SET_TIMEOUT; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SET_TIMEOUT_RESP; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_START; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SUSPEND; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SUBSCRIBE_TOPOLOGY; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SUBSCRIBE_TOPOLOGY_V2; - import java.io.Serializable; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; import org.apache.activemq.artemis.core.protocol.core.Packet; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CheckFailoverMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CheckFailoverReplyMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterTopologyChangeMessage; @@ -98,7 +34,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateShar import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectConsumerMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage_V2; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.PacketsConfirmedMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.Ping; @@ -147,6 +82,71 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAS import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SubscribeClusterTopologyUpdatesMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SubscribeClusterTopologyUpdatesMessageV2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CHECK_FOR_FAILOVER; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY_V2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_TOPOLOGY_V3; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATESESSION; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATESESSION_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT_CONSUMER; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT_V2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.EXCEPTION; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.NULL_RESPONSE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.PACKETS_CONFIRMED; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.PING; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REATTACH_SESSION; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REATTACH_SESSION_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ACKNOWLEDGE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ADD_METADATA; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ADD_METADATA2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP_V2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY_RESP_V3; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CLOSE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_COMMIT; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CONSUMER_CLOSE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_CREATECONSUMER; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_EXPIRED; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_FLOWTOKEN; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_FORCE_CONSUMER_DELIVERY; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_INDIVIDUAL_ACKNOWLEDGE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_CREDITS; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_FAIL_CREDITS; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_PRODUCER_REQUEST_CREDITS; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_QUEUEQUERY_RESP_V2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_RECEIVE_CONTINUATION; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ROLLBACK; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_SEND_CONTINUATION; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_START; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_STOP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_UNIQUE_ADD_METADATA; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_COMMIT; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_END; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_FAILED; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_FORGET; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_GET_TIMEOUT; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_GET_TIMEOUT_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_INDOUBT_XIDS; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_INDOUBT_XIDS_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_JOIN; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_PREPARE; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_RESUME; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_ROLLBACK; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SET_TIMEOUT; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SET_TIMEOUT_RESP; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_START; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_XA_SUSPEND; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SUBSCRIBE_TOPOLOGY; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SUBSCRIBE_TOPOLOGY_V2; + public abstract class PacketDecoder implements Serializable { public abstract Packet decode(final ActiveMQBuffer in); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java index 2a3522f951..8bd62ca4e6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java @@ -43,6 +43,7 @@ import org.apache.activemq.artemis.utils.SimpleIDGenerator; import org.jboss.logging.Logger; public class RemotingConnectionImpl extends AbstractRemotingConnection implements CoreRemotingConnection { + private static final Logger logger = Logger.getLogger(RemotingConnectionImpl.class); private final PacketDecoder packetDecoder; @@ -198,8 +199,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement try { transportConnection.forceClose(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); } @@ -247,8 +247,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement if (!criticalError) { removeAllChannels(); - } - else { + } else { // We can't hold a lock if a critical error is happening... // as other threads will be holding the lock while hanging on IO channels.clear(); @@ -265,8 +264,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement if (channel0.supports(PacketImpl.DISCONNECT_V2)) { disconnect = new DisconnectMessage_V2(nodeID, scaleDownNodeID); - } - else { + } else { disconnect = new DisconnectMessage(nodeID); } channel0.sendAndFlush(disconnect); @@ -358,8 +356,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement doBufferReceived(packet); super.bufferReceived(connectionID, buffer); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.errorDecodingPacket(e); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ActiveMQExceptionMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ActiveMQExceptionMessage.java index f99b46530e..da34d2e4a9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ActiveMQExceptionMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ActiveMQExceptionMessage.java @@ -93,8 +93,7 @@ public class ActiveMQExceptionMessage extends PacketImpl { if (other.exception != null) { return false; } - } - else if (!exception.equals(other.exception)) { + } else if (!exception.equals(other.exception)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage.java index b799f6e602..a441eee1ca 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage.java @@ -94,15 +94,13 @@ public class ClusterTopologyChangeMessage extends PacketImpl { if (pair.getA() != null) { buffer.writeBoolean(true); pair.getA().encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } if (pair.getB() != null) { buffer.writeBoolean(true); pair.getB().encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } buffer.writeBoolean(last); @@ -119,8 +117,7 @@ public class ClusterTopologyChangeMessage extends PacketImpl { if (hasLive) { a = new TransportConfiguration(); a.decode(buffer); - } - else { + } else { a = null; } boolean hasBackup = buffer.readBoolean(); @@ -128,8 +125,7 @@ public class ClusterTopologyChangeMessage extends PacketImpl { if (hasBackup) { b = new TransportConfiguration(); b.decode(buffer); - } - else { + } else { b = null; } pair = new Pair<>(a, b); @@ -181,16 +177,14 @@ public class ClusterTopologyChangeMessage extends PacketImpl { if (other.nodeID != null) { return false; } - } - else if (!nodeID.equals(other.nodeID)) { + } else if (!nodeID.equals(other.nodeID)) { return false; } if (pair == null) { if (other.pair != null) { return false; } - } - else if (!pair.equals(other.pair)) { + } else if (!pair.equals(other.pair)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V2.java index 7e0450acb2..3a381454d1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V2.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V2.java @@ -86,15 +86,13 @@ public class ClusterTopologyChangeMessage_V2 extends ClusterTopologyChangeMessag if (pair.getA() != null) { buffer.writeBoolean(true); pair.getA().encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } if (pair.getB() != null) { buffer.writeBoolean(true); pair.getB().encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } buffer.writeBoolean(last); @@ -113,8 +111,7 @@ public class ClusterTopologyChangeMessage_V2 extends ClusterTopologyChangeMessag if (hasLive) { a = new TransportConfiguration(); a.decode(buffer); - } - else { + } else { a = null; } boolean hasBackup = buffer.readBoolean(); @@ -122,8 +119,7 @@ public class ClusterTopologyChangeMessage_V2 extends ClusterTopologyChangeMessag if (hasBackup) { b = new TransportConfiguration(); b.decode(buffer); - } - else { + } else { b = null; } pair = new Pair<>(a, b); @@ -175,8 +171,7 @@ public class ClusterTopologyChangeMessage_V2 extends ClusterTopologyChangeMessag if (other.backupGroupName != null) { return false; } - } - else if (!backupGroupName.equals(other.backupGroupName)) { + } else if (!backupGroupName.equals(other.backupGroupName)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V3.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V3.java index d5ade55077..d371eb56cb 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V3.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ClusterTopologyChangeMessage_V3.java @@ -105,8 +105,7 @@ public class ClusterTopologyChangeMessage_V3 extends ClusterTopologyChangeMessag if (other.scaleDownGroupName != null) { return false; } - } - else if (!scaleDownGroupName.equals(other.scaleDownGroupName)) { + } else if (!scaleDownGroupName.equals(other.scaleDownGroupName)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage.java index 5f65fbe13e..e837d55ba0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage.java @@ -157,22 +157,19 @@ public class CreateQueueMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (durable != other.durable) return false; if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; if (requiresResponse != other.requiresResponse) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSessionMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSessionMessage.java index 57bae7c0cc..949645b5b1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSessionMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSessionMessage.java @@ -229,22 +229,19 @@ public class CreateSessionMessage extends PacketImpl { if (defaultAddress == null) { if (other.defaultAddress != null) return false; - } - else if (!defaultAddress.equals(other.defaultAddress)) + } else if (!defaultAddress.equals(other.defaultAddress)) return false; if (minLargeMessageSize != other.minLargeMessageSize) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (password == null) { if (other.password != null) return false; - } - else if (!password.equals(other.password)) + } else if (!password.equals(other.password)) return false; if (preAcknowledge != other.preAcknowledge) return false; @@ -253,8 +250,7 @@ public class CreateSessionMessage extends PacketImpl { if (username == null) { if (other.username != null) return false; - } - else if (!username.equals(other.username)) + } else if (!username.equals(other.username)) return false; if (version != other.version) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage.java index 9911490c1e..f8961028fd 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage.java @@ -138,20 +138,17 @@ public class CreateSharedQueueMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; if (durable != other.durable) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectConsumerWithKillMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectConsumerWithKillMessage.java index ce55bbdb0b..3663172a85 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectConsumerWithKillMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectConsumerWithKillMessage.java @@ -24,7 +24,7 @@ public class DisconnectConsumerWithKillMessage extends PacketImpl { private SimpleString nodeID; - public static final int VERSION_INTRODUCED = 128; + public static final int VERSION_INTRODUCED = 128; public DisconnectConsumerWithKillMessage(final SimpleString nodeID) { super(DISCONNECT_CONSUMER_KILL); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage.java index 13fdc08f6d..eb5f7ccf3b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage.java @@ -98,8 +98,7 @@ public class DisconnectMessage extends PacketImpl { if (other.nodeID != null) { return false; } - } - else if (!nodeID.equals(other.nodeID)) { + } else if (!nodeID.equals(other.nodeID)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage_V2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage_V2.java index 8d50ed1eb0..806c913353 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage_V2.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/DisconnectMessage_V2.java @@ -86,8 +86,7 @@ public class DisconnectMessage_V2 extends DisconnectMessage { if (other.scaleDownNodeID != null) { return false; } - } - else if (!scaleDownNodeID.equals(other.scaleDownNodeID)) { + } else if (!scaleDownNodeID.equals(other.scaleDownNodeID)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java index 72f3602daa..6a52a27376 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java @@ -40,5 +40,4 @@ public abstract class MessagePacket extends PacketImpl implements MessagePacketI return super.getParentString() + ", message=" + message; } - } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacketI.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacketI.java index ea1146f1a0..161274dd43 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacketI.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacketI.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, @@ -20,5 +20,6 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat; import org.apache.activemq.artemis.api.core.Message; public interface MessagePacketI { + Message getMessage(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReattachSessionMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReattachSessionMessage.java index 406347b82c..c0627718f6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReattachSessionMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReattachSessionMessage.java @@ -94,8 +94,7 @@ public class ReattachSessionMessage extends PacketImpl { if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessage.java index 76a28f8d86..1b3faedd5c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessage.java @@ -94,14 +94,12 @@ public class SessionAddMetaDataMessage extends PacketImpl { if (data == null) { if (other.data != null) return false; - } - else if (!data.equals(other.data)) + } else if (!data.equals(other.data)) return false; if (key == null) { if (other.key != null) return false; - } - else if (!key.equals(other.key)) + } else if (!key.equals(other.key)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessageV2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessageV2.java index eb16edaf32..5882fdc9a1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessageV2.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionAddMetaDataMessageV2.java @@ -119,14 +119,12 @@ public class SessionAddMetaDataMessageV2 extends PacketImpl { if (data == null) { if (other.data != null) return false; - } - else if (!data.equals(other.data)) + } else if (!data.equals(other.data)) return false; if (key == null) { if (other.key != null) return false; - } - else if (!key.equals(other.key)) + } else if (!key.equals(other.key)) return false; if (requiresConfirmation != other.requiresConfirmation) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryMessage.java index 6a901ae25c..0bb06e2f75 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryMessage.java @@ -76,8 +76,7 @@ public class SessionBindingQueryMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage.java index 410dac1dca..4cccfdc8e9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage.java @@ -112,8 +112,7 @@ public class SessionBindingQueryResponseMessage extends PacketImpl { if (queueNames == null) { if (other.queueNames != null) return false; - } - else if (!queueNames.equals(other.queueNames)) + } else if (!queueNames.equals(other.queueNames)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionContinuationMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionContinuationMessage.java index 135aac5a55..fcdd943457 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionContinuationMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionContinuationMessage.java @@ -49,8 +49,7 @@ public abstract class SessionContinuationMessage extends PacketImpl { public byte[] getBody() { if (size <= 0) { return new byte[0]; - } - else { + } else { return body; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionCreateConsumerMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionCreateConsumerMessage.java index 42ff65afc4..afff162a0f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionCreateConsumerMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionCreateConsumerMessage.java @@ -138,16 +138,14 @@ public class SessionCreateConsumerMessage extends PacketImpl { if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (id != other.id) return false; if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; if (requiresResponse != other.requiresResponse) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionDeleteQueueMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionDeleteQueueMessage.java index def97d8436..49344592ee 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionDeleteQueueMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionDeleteQueueMessage.java @@ -76,8 +76,7 @@ public class SessionDeleteQueueMessage extends PacketImpl { if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsFailMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsFailMessage.java index 6c194b8cc9..68259235b5 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsFailMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsFailMessage.java @@ -88,8 +88,7 @@ public class SessionProducerCreditsFailMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (credits != other.credits) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsMessage.java index d672b0ef93..d057ad1ccc 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionProducerCreditsMessage.java @@ -88,8 +88,7 @@ public class SessionProducerCreditsMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (credits != other.credits) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryMessage.java index 98ae9460e1..172f29fc80 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryMessage.java @@ -76,8 +76,7 @@ public class SessionQueueQueryMessage extends PacketImpl { if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java index e66b4eb155..b8313b2eae 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java @@ -187,8 +187,7 @@ public class SessionQueueQueryResponseMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (consumerCount != other.consumerCount) return false; @@ -199,16 +198,14 @@ public class SessionQueueQueryResponseMessage extends PacketImpl { if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (messageCount != other.messageCount) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (temporary != other.temporary) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveContinuationMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveContinuationMessage.java index 6748201a41..9141ae12b0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveContinuationMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveContinuationMessage.java @@ -80,8 +80,7 @@ public class SessionReceiveContinuationMessage extends SessionContinuationMessag if (size == -1) { // This packet was created by the LargeMessageController return 0; - } - else { + } else { return size; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java index 06805f08ea..64f96f9780 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java @@ -137,8 +137,7 @@ public class SessionReceiveLargeMessage extends PacketImpl implements MessagePac if (message == null) { if (other.message != null) return false; - } - else if (!message.equals(other.message)) + } else if (!message.equals(other.message)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionRequestProducerCreditsMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionRequestProducerCreditsMessage.java index 1627dfd967..fc495fee41 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionRequestProducerCreditsMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionRequestProducerCreditsMessage.java @@ -95,8 +95,7 @@ public class SessionRequestProducerCreditsMessage extends PacketImpl { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (credits != other.credits) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java index dc7e1f0b20..16fd073d83 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java @@ -145,8 +145,7 @@ public class SessionSendContinuationMessage extends SessionContinuationMessage { if (message == null) { if (other.message != null) return false; - } - else if (!message.equals(other.message)) + } else if (!message.equals(other.message)) return false; if (messageBodySize != other.messageBodySize) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java index 9154a7de0c..bf4290bcc2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java @@ -87,8 +87,7 @@ public class SessionSendLargeMessage extends PacketImpl implements MessagePacket if (largeMessage == null) { if (other.largeMessage != null) return false; - } - else if (!largeMessage.equals(other.largeMessage)) + } else if (!largeMessage.equals(other.largeMessage)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java index 4674ce0400..91d43a565b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java @@ -67,8 +67,7 @@ public class SessionSendMessage extends MessagePacket { if (connection == null) { // this is for unit tests only bufferWrite = buffer.copy(0, buffer.capacity()); - } - else { + } else { bufferWrite = connection.createTransportBuffer(buffer.writerIndex() + 1); // 1 for the requireResponse } bufferWrite.writeBytes(buffer, 0, buffer.writerIndex()); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAAfterFailedMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAAfterFailedMessage.java index 1727e42ef4..32f23a99ff 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAAfterFailedMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAAfterFailedMessage.java @@ -90,8 +90,7 @@ public class SessionXAAfterFailedMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXACommitMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXACommitMessage.java index 1e1ad764ee..29f7a3b973 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXACommitMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXACommitMessage.java @@ -87,8 +87,7 @@ public class SessionXACommitMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAEndMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAEndMessage.java index 5e99eb9eb1..991a1f922c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAEndMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAEndMessage.java @@ -88,8 +88,7 @@ public class SessionXAEndMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAForgetMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAForgetMessage.java index bbd110ef52..df9bf96acc 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAForgetMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAForgetMessage.java @@ -78,8 +78,7 @@ public class SessionXAForgetMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java index 08cd4a8c7d..09a8d89a68 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat; +import javax.transaction.xa.Xid; import java.util.ArrayList; import java.util.List; -import javax.transaction.xa.Xid; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; import org.apache.activemq.artemis.utils.XidCodecSupport; @@ -96,8 +95,7 @@ public class SessionXAGetInDoubtXidsResponseMessage extends PacketImpl { if (xids == null) { if (other.xids != null) return false; - } - else if (!xids.equals(other.xids)) + } else if (!xids.equals(other.xids)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAJoinMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAJoinMessage.java index 99ddf18f24..d31adcdc93 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAJoinMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAJoinMessage.java @@ -78,8 +78,7 @@ public class SessionXAJoinMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAPrepareMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAPrepareMessage.java index 24ef2eae72..d55747e457 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAPrepareMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAPrepareMessage.java @@ -78,8 +78,7 @@ public class SessionXAPrepareMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResponseMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResponseMessage.java index fa6c2961da..086b8511a6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResponseMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResponseMessage.java @@ -108,8 +108,7 @@ public class SessionXAResponseMessage extends PacketImpl { if (message == null) { if (other.message != null) return false; - } - else if (!message.equals(other.message)) + } else if (!message.equals(other.message)) return false; if (responseCode != other.responseCode) return false; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResumeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResumeMessage.java index fd801d4743..d88e8e322e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResumeMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAResumeMessage.java @@ -80,8 +80,7 @@ public class SessionXAResumeMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXARollbackMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXARollbackMessage.java index c42b7ae3d1..abfea74134 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXARollbackMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXARollbackMessage.java @@ -80,8 +80,7 @@ public class SessionXARollbackMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAStartMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAStartMessage.java index d0bff0aec1..d6a8e84d3f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAStartMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionXAStartMessage.java @@ -87,8 +87,7 @@ public class SessionXAStartMessage extends PacketImpl { if (xid == null) { if (other.xid != null) return false; - } - else if (!xid.equals(other.xid)) + } else if (!xid.equals(other.xid)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java index cfadcfa633..fe4cb3de4d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java @@ -50,8 +50,7 @@ public class TransportConfigurationUtil { if (object != null && object instanceof TransportConfigurationHelper) { DEFAULTS.put(className, ((TransportConfigurationHelper) object).getDefaults()); - } - else { + } else { DEFAULTS.put(className, EMPTY_HELPER); } } @@ -67,8 +66,7 @@ public class TransportConfigurationUtil { public Object run() { try { return ClassloadingUtil.newInstanceFromClassLoader(className); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { return null; } } @@ -90,8 +88,7 @@ public class TransportConfigurationUtil { String port1 = String.valueOf(tc1.getParams().get("port") != null ? tc1.getParams().get("port") : TransportConstants.DEFAULT_PORT); String port2 = String.valueOf(tc2.getParams().get("port") != null ? tc2.getParams().get("port") : TransportConstants.DEFAULT_PORT); return host1.equals(host2) && port1.equals(port2); - } - else if ("org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory".equals(tc1.getFactoryClassName())) { + } else if ("org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory".equals(tc1.getFactoryClassName())) { String serverId1 = tc1.getParams().get("serverId") != null ? tc1.getParams().get("serverId").toString() : "0"; String serverId2 = tc2.getParams().get("serverId") != null ? tc2.getParams().get("serverId").toString() : "0"; return serverId1.equals(serverId2); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java index c581a5a24b..93be28182c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java @@ -97,8 +97,7 @@ public class ActiveMQChannelHandler extends ChannelDuplexHandler { try { listener.connectionException(channelId(ctx.channel()), me); active = false; - } - catch (Exception ex) { + } catch (Exception ex) { ActiveMQClientLogger.LOGGER.errorCallingLifeCycleListener(ex); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java index a8c80c6b3f..0b307eff5d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java @@ -30,7 +30,6 @@ import io.netty.channel.ChannelPromise; import io.netty.channel.EventLoop; import io.netty.handler.ssl.SslHandler; import io.netty.util.concurrent.GenericFutureListener; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException; @@ -71,8 +70,10 @@ public class NettyConnection implements Connection { private boolean ready = true; - /** if {@link #isWritable(ReadyListener)} returns false, we add a callback - * here for when the connection (or Netty Channel) becomes available again. */ + /** + * if {@link #isWritable(ReadyListener)} returns false, we add a callback + * here for when the connection (or Netty Channel) becomes available again. + */ private final Deque readyListeners = new LinkedList<>(); // Static -------------------------------------------------------- @@ -131,7 +132,6 @@ public class NettyConnection implements Connection { break; } - if (readyToCall == null) { readyToCall = new LinkedList<>(); } @@ -145,8 +145,7 @@ public class NettyConnection implements Connection { for (ReadyListener readyListener : readyToCall) { try { readyListener.readyForWriting(); - } - catch (Throwable logOnly) { + } catch (Throwable logOnly) { ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly); } } @@ -158,8 +157,7 @@ public class NettyConnection implements Connection { if (channel != null) { try { channel.close(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); } } @@ -196,8 +194,7 @@ public class NettyConnection implements Connection { //if we are in an event loop we need to close the channel after the writes have finished if (!inEventLoop) { closeSSLAndChannel(sslHandler, channel, false); - } - else { + } else { eventLoop.execute(new Runnable() { @Override public void run() { @@ -236,8 +233,7 @@ public class NettyConnection implements Connection { batchBuffer = createTransportBuffer(BATCHING_BUFFER_SIZE); } - } - finally { + } finally { writeLock.release(); } } @@ -276,15 +272,13 @@ public class NettyConnection implements Connection { // If the batch buffer is full or it's flush param or not batched then flush the buffer buffer = batchBuffer; - } - else { + } else { return; } if (!batched || flush) { batchBuffer = null; - } - else { + } else { // Create a new buffer batchBuffer = ActiveMQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE); @@ -297,8 +291,7 @@ public class NettyConnection implements Connection { final ChannelPromise promise; if (flush || futureListener != null) { promise = channel.newPromise(); - } - else { + } else { promise = channel.voidPromise(); } @@ -307,12 +300,10 @@ public class NettyConnection implements Connection { if (!inEventLoop) { if (futureListener != null) { channel.writeAndFlush(buf, promise).addListener(futureListener); - } - else { + } else { channel.writeAndFlush(buf, promise); } - } - else { + } else { // create a task which will be picked up by the eventloop and trigger the write. // This is mainly needed as this method is triggered by different threads for the same channel. // if we not do this we may produce out of order writes. @@ -321,8 +312,7 @@ public class NettyConnection implements Connection { public void run() { if (futureListener != null) { channel.writeAndFlush(buf, promise).addListener(futureListener); - } - else { + } else { channel.writeAndFlush(buf, promise); } } @@ -342,18 +332,15 @@ public class NettyConnection implements Connection { } break; - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } } - } - finally { + } finally { writeLock.release(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -390,8 +377,7 @@ public class NettyConnection implements Connection { public TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); - } - else { + } else { return null; } } @@ -427,12 +413,10 @@ public class NettyConnection implements Connection { if (!inEventLoop && !sslCloseFuture.awaitUninterruptibly(10000)) { ActiveMQClientLogger.LOGGER.timeoutClosingSSL(); } - } - catch (Throwable t) { + } catch (Throwable t) { // ignore } - } - else { + } else { ChannelFuture closeFuture = channel.close(); if (!inEventLoop && !closeFuture.awaitUninterruptibly(10000)) { ActiveMQClientLogger.LOGGER.timeoutClosingNettyChannel(); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java index 49c936bfd3..326fe2728b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java @@ -86,8 +86,8 @@ import io.netty.util.AttributeKey; import io.netty.util.ResourceLeakDetector; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GlobalEventExecutor; -import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; @@ -107,6 +107,7 @@ import org.jboss.logging.Logger; import static org.apache.activemq.artemis.utils.Base64.encodeBytes; public class NettyConnector extends AbstractConnector { + private static final Logger logger = Logger.getLogger(NettyConnector.class); // Constants ----------------------------------------------------- @@ -274,8 +275,7 @@ public class NettyConnector extends AbstractConnector { httpMaxClientIdleTime = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, TransportConstants.DEFAULT_HTTP_CLIENT_IDLE_TIME, configuration); httpClientIdleScanPeriod = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, TransportConstants.DEFAULT_HTTP_CLIENT_SCAN_PERIOD, configuration); httpRequiresSessionId = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_REQUIRES_SESSION_ID, TransportConstants.DEFAULT_HTTP_REQUIRES_SESSION_ID, configuration); - } - else { + } else { httpMaxClientIdleTime = 0; httpClientIdleScanPeriod = -1; httpRequiresSessionId = false; @@ -311,8 +311,7 @@ public class NettyConnector extends AbstractConnector { enabledProtocols = ConfigurationHelper.getStringProperty(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME, TransportConstants.DEFAULT_ENABLED_PROTOCOLS, configuration); verifyHost = ConfigurationHelper.getBooleanProperty(TransportConstants.VERIFY_HOST_PROP_NAME, TransportConstants.DEFAULT_VERIFY_HOST, configuration); - } - else { + } else { keyStoreProvider = TransportConstants.DEFAULT_KEYSTORE_PROVIDER; keyStorePath = TransportConstants.DEFAULT_KEYSTORE_PATH; keyStorePassword = TransportConstants.DEFAULT_KEYSTORE_PASSWORD; @@ -367,16 +366,14 @@ public class NettyConnector extends AbstractConnector { // Default to number of cores * 3 threadsToUse = Runtime.getRuntime().availableProcessors() * 3; - } - else { + } else { threadsToUse = this.nioRemotingThreads; } if (useNioGlobalWorkerPool) { channelClazz = NioSocketChannel.class; group = SharedNioEventLoopGroup.getInstance(threadsToUse); - } - else { + } else { channelClazz = NioSocketChannel.class; group = new NioEventLoopGroup(threadsToUse); } @@ -446,15 +443,13 @@ public class NettyConnector extends AbstractConnector { realTrustStorePassword = System.getProperty(ACTIVEMQ_TRUSTSTORE_PASSWORD_PROP_NAME); } context = SSLSupport.createContext(realKeyStoreProvider, realKeyStorePath, realKeyStorePassword, realTrustStoreProvider, realTrustStorePath, realTrustStorePassword); - } - catch (Exception e) { + } catch (Exception e) { close(); IllegalStateException ise = new IllegalStateException("Unable to create NettyConnector for " + host + ":" + port); ise.initCause(e); throw ise; } - } - else { + } else { context = null; // Unused } @@ -471,8 +466,7 @@ public class NettyConnector extends AbstractConnector { SSLEngine engine; if (verifyHost) { engine = context.createSSLEngine(host, port); - } - else { + } else { engine = context.createSSLEngine(); } @@ -488,8 +482,7 @@ public class NettyConnector extends AbstractConnector { if (enabledCipherSuites != null) { try { engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; } @@ -498,13 +491,11 @@ public class NettyConnector extends AbstractConnector { if (enabledProtocols != null) { try { engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e; } - } - else { + } else { engine.setEnabledProtocols(originalProtocols); } @@ -602,8 +593,7 @@ public class NettyConnector extends AbstractConnector { if (inet6Address.getScopeId() != 0) { try { remoteDestination = new InetSocketAddress(InetAddress.getByAddress(inet6Address.getAddress()), ((InetSocketAddress) remoteDestination).getPort()); - } - catch (UnknownHostException e) { + } catch (UnknownHostException e) { throw new IllegalArgumentException(e.getMessage()); } } @@ -617,13 +607,11 @@ public class NettyConnector extends AbstractConnector { SocketAddress localDestination; if (localAddress != null) { localDestination = new InetSocketAddress(localAddress, localPort); - } - else { + } else { localDestination = new InetSocketAddress(localPort); } future = bootstrap.connect(remoteDestination, localDestination); - } - else { + } else { future = bootstrap.connect(remoteDestination); } @@ -639,14 +627,12 @@ public class NettyConnector extends AbstractConnector { ChannelPipeline channelPipeline = ch.pipeline(); ActiveMQChannelHandler channelHandler = channelPipeline.get(ActiveMQChannelHandler.class); channelHandler.active = true; - } - else { + } else { ch.close().awaitUninterruptibly(); ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(handshakeFuture.cause()); return null; } - } - else { + } else { //handshakeFuture.setFailure(new SSLException("Handshake was not completed in 30 seconds")); ch.close().awaitUninterruptibly(); return null; @@ -688,13 +674,11 @@ public class NettyConnector extends AbstractConnector { ch.close().awaitUninterruptibly(); return null; } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(e); return null; } - } - else { + } else { ChannelPipeline channelPipeline = ch.pipeline(); ActiveMQChannelHandler channelHandler = channelPipeline.get(ActiveMQChannelHandler.class); channelHandler.active = true; @@ -705,8 +689,7 @@ public class NettyConnector extends AbstractConnector { NettyConnection conn = new NettyConnection(configuration, ch, connectionListener, !httpEnabled && batchDelay > 0, false); connectionListener.connectionCreated(null, conn, protocolManager); return conn; - } - else { + } else { Throwable t = future.cause(); if (t != null && !(t instanceof ConnectException)) { @@ -763,13 +746,11 @@ public class NettyConnector extends AbstractConnector { handshakeComplete = true; ActiveMQChannelHandler channelHandler = pipeline.get(ActiveMQChannelHandler.class); channelHandler.active = true; - } - else { + } else { ActiveMQClientLogger.LOGGER.httpHandshakeFailed(accept, expectedResponse); ctx.close(); } - } - else if (response.getStatus().code() == HttpResponseStatus.FORBIDDEN.code()) { + } else if (response.getStatus().code() == HttpResponseStatus.FORBIDDEN.code()) { ActiveMQClientLogger.LOGGER.httpUpgradeNotSupportedByRemoteAcceptor(); ctx.close(); } @@ -788,8 +769,7 @@ public class NettyConnector extends AbstractConnector { if (!latch.await(30000, TimeUnit.MILLISECONDS)) { return false; } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } return handshakeComplete; @@ -863,8 +843,7 @@ public class NettyConnector extends AbstractConnector { if (httpRequiresSessionId && !active) { if (handshaking) { handshaking = true; - } - else { + } else { if (!handShakeFuture.await(5000)) { throw new RuntimeException("Handshake failed after timeout"); } @@ -880,8 +859,7 @@ public class NettyConnector extends AbstractConnector { httpRequest.headers().add(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); lastSendTime = System.currentTimeMillis(); - } - else { + } else { ctx.write(msg, promise); lastSendTime = System.currentTimeMillis(); } @@ -958,7 +936,7 @@ public class NettyConnector extends AbstractConnector { @Override public void connectionReadyForWrites(Object connectionID, boolean ready) { - NettyConnection connection = (NettyConnection)connections.get(connectionID); + NettyConnection connection = (NettyConnection) connections.get(connectionID); if (connection != null) { connection.fireReady(ready); } @@ -1008,8 +986,7 @@ public class NettyConnector extends AbstractConnector { logger.debug(this + " host 1: " + host + " ip address: " + ip1 + " host 2: " + this.host + " ip address: " + ip2); result = ip1.equals(ip2); - } - catch (UnknownHostException e) { + } catch (UnknownHostException e) { ActiveMQClientLogger.LOGGER.error("Cannot resolve host", e); } @@ -1077,8 +1054,7 @@ public class NettyConnector extends AbstractConnector { digest.update(concat.getBytes(StandardCharsets.UTF_8)); final byte[] bytes = digest.digest(); return encodeBytes(bytes); - } - catch (NoSuchAlgorithmException e) { + } catch (NoSuchAlgorithmException e) { throw new IOException(e); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java index b9b1a31bce..0750105898 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.core.remoting.impl.netty; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.FutureListener; -import io.netty.util.concurrent.ImmediateEventExecutor; -import io.netty.util.concurrent.Promise; -import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; -import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; - import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.ScheduledFuture; @@ -32,6 +24,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.FutureListener; +import io.netty.util.concurrent.ImmediateEventExecutor; +import io.netty.util.concurrent.Promise; +import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; + public class SharedNioEventLoopGroup extends NioEventLoopGroup { private static SharedNioEventLoopGroup instance; @@ -58,8 +58,7 @@ public class SharedNioEventLoopGroup extends NioEventLoopGroup { if (f != null) { f.cancel(false); } - } - else { + } else { instance = new SharedNioEventLoopGroup(numThreads, AccessController.doPrivileged(new PrivilegedAction() { @Override public ThreadFactory run() { @@ -95,8 +94,7 @@ public class SharedNioEventLoopGroup extends NioEventLoopGroup { public void operationComplete(Future future) throws Exception { if (future.isSuccess()) { terminationPromise.setSuccess(null); - } - else { + } else { terminationPromise.setFailure(future.cause()); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java index 40aed3d8e5..864bce7dc7 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java @@ -291,8 +291,7 @@ public class TransportConstants { Version v = Version.identify().get("netty-transport"); if (v == null) { version = "unknown"; - } - else { + } else { version = v.artifactVersion(); } NETTY_VERSION = version; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java index d5e0fdc78b..8de398257f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.core.remoting.impl.ssl; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -26,12 +31,6 @@ import java.security.KeyStore; import java.security.PrivilegedAction; import java.security.SecureRandom; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; - import org.apache.activemq.artemis.utils.ClassloadingUtil; /** @@ -83,8 +82,7 @@ public class SSLSupport { final String trustStorePassword) throws Exception { if (trustStorePath == null && (trustStoreProvider == null || !"PKCS11".equals(trustStoreProvider.toUpperCase()))) { return null; - } - else { + } else { TrustManagerFactory trustMgrFactory; KeyStore trustStore = SSLSupport.loadKeystore(trustStoreProvider, trustStorePath, trustStorePassword); trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); @@ -104,13 +102,11 @@ public class SSLSupport { in = keystoreURL.openStream(); } ks.load(in, keystorePassword == null ? null : keystorePassword.toCharArray()); - } - finally { + } finally { if (in != null) { try { in.close(); - } - catch (IOException ignored) { + } catch (IOException ignored) { } } } @@ -122,8 +118,7 @@ public class SSLSupport { final String keystorePassword) throws Exception { if (keystorePath == null && (keyStoreProvider == null || !"PKCS11".equals(keyStoreProvider.toUpperCase()))) { return null; - } - else { + } else { KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = SSLSupport.loadKeystore(keyStoreProvider, keystorePath, keystorePassword); kmf.init(ks, keystorePassword == null ? null : keystorePassword.toCharArray()); @@ -138,13 +133,11 @@ public class SSLSupport { // First see if this is a URL try { return new URL(storePath); - } - catch (MalformedURLException e) { + } catch (MalformedURLException e) { File file = new File(storePath); if (file.exists() == true && file.isFile()) { return file.toURI().toURL(); - } - else { + } else { URL url = findResource(storePath); if (url != null) { return url; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java index 3185571462..2efddfaac0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java @@ -47,21 +47,10 @@ public class Role implements Serializable { private final boolean browse; public JsonObject toJson() { - return JsonLoader.createObjectBuilder() - .add("name", name) - .add("send", send) - .add("consume", consume) - .add("createDurableQueue", createDurableQueue) - .add("deleteDurableQueue", deleteDurableQueue) - .add("createNonDurableQueue", createNonDurableQueue) - .add("deleteNonDurableQueue", deleteNonDurableQueue) - .add("manage", manage) - .add("browse", browse) - .build(); + return JsonLoader.createObjectBuilder().add("name", name).add("send", send).add("consume", consume).add("createDurableQueue", createDurableQueue).add("deleteDurableQueue", deleteDurableQueue).add("createNonDurableQueue", createNonDurableQueue).add("deleteNonDurableQueue", deleteNonDurableQueue).add("manage", manage).add("browse", browse).build(); } /** - * @deprecated Use {@link #Role(String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)} * @param name * @param send * @param consume @@ -70,6 +59,7 @@ public class Role implements Serializable { * @param createNonDurableQueue * @param deleteNonDurableQueue * @param manage + * @deprecated Use {@link #Role(String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)} */ @Deprecated public Role(final String name, diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/transaction/impl/XidImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/transaction/impl/XidImpl.java index 324797a4de..a191cbd6c2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/transaction/impl/XidImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/transaction/impl/XidImpl.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.core.transaction.impl; +import javax.transaction.xa.Xid; import java.io.Serializable; import java.util.Arrays; -import javax.transaction.xa.Xid; - import org.apache.activemq.artemis.utils.Base64; /** diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/version/impl/VersionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/version/impl/VersionImpl.java index c8437e1b2d..4ec3ed157f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/version/impl/VersionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/version/impl/VersionImpl.java @@ -144,8 +144,7 @@ public class VersionImpl implements Version, Serializable { if (other.versionName != null) { return false; } - } - else if (!versionName.equals(other.versionName)) { + } else if (!versionName.equals(other.versionName)) { return false; } return true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/BytesMessageUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/BytesMessageUtil.java index a8dce4a3c3..3fbd705242 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/BytesMessageUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/BytesMessageUtil.java @@ -140,35 +140,25 @@ public class BytesMessageUtil extends MessageUtil { } if (value instanceof String) { bytesWriteUTF(message, (String) value); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { bytesWriteBoolean(message, (Boolean) value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { bytesWriteChar(message, (Character) value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { bytesWriteByte(message, (Byte) value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { bytesWriteShort(message, (Short) value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { bytesWriteInt(message, (Integer) value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { bytesWriteLong(message, (Long) value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { bytesWriteFloat(message, (Float) value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { bytesWriteDouble(message, (Double) value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { bytesWriteBytes(message, (byte[]) value); - } - else { + } else { return false; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java index be6568cf5f..09b190254b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MessageUtil.java @@ -53,17 +53,16 @@ public class MessageUtil { public static final SimpleString CONNECTION_ID_PROPERTY_NAME = new SimpleString("__AMQ_CID"); -// public static ActiveMQBuffer getBodyBuffer(Message message) { -// return message.getBodyBuffer(); -// } + // public static ActiveMQBuffer getBodyBuffer(Message message) { + // return message.getBodyBuffer(); + // } public static byte[] getJMSCorrelationIDAsBytes(Message message) { Object obj = message.getObjectProperty(CORRELATIONID_HEADER_NAME); if (obj instanceof byte[]) { return (byte[]) obj; - } - else { + } else { return null; } } @@ -77,8 +76,7 @@ public class MessageUtil { if (ss != null) { return ss.toString(); - } - else { + } else { return null; } } @@ -94,8 +92,7 @@ public class MessageUtil { public static void setJMSCorrelationID(Message message, final String correlationID) { if (correlationID == null) { message.removeProperty(CORRELATIONID_HEADER_NAME); - } - else { + } else { message.putStringProperty(CORRELATIONID_HEADER_NAME, new SimpleString(correlationID)); } } @@ -103,8 +100,7 @@ public class MessageUtil { public static String getJMSCorrelationID(Message message) { try { return message.getStringProperty(CORRELATIONID_HEADER_NAME); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { return null; } } @@ -117,8 +113,7 @@ public class MessageUtil { if (dest == null) { message.removeProperty(REPLYTO_HEADER_NAME); - } - else { + } else { message.putStringProperty(REPLYTO_HEADER_NAME, dest); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/StreamMessageUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/StreamMessageUtil.java index dbba989f5d..27e0da7bb9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/StreamMessageUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/StreamMessageUtil.java @@ -57,8 +57,7 @@ public class StreamMessageUtil extends MessageUtil { default: throw new IllegalStateException("Invalid conversion"); } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { buff.readerIndex(index); throw e; } @@ -89,8 +88,7 @@ public class StreamMessageUtil extends MessageUtil { String str = buff.readNullableString(); if (str == null) { throw new NullPointerException("Invalid conversion"); - } - else { + } else { throw new IllegalStateException("Invalid conversion"); } default: @@ -200,8 +198,7 @@ public class StreamMessageUtil extends MessageUtil { public static Pair streamReadBytes(ActiveMQBuffer buff, int remainingBytes, byte[] value) { if (remainingBytes == -1) { return new Pair<>(0, -1); - } - else if (remainingBytes == 0) { + } else if (remainingBytes == 0) { byte type = buff.readByte(); if (type != DataConstants.BYTES) { throw new IllegalStateException("Invalid conversion"); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java index e512adf2ba..a9e12aa6c2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java @@ -65,12 +65,10 @@ public abstract class AbstractRemotingConnection implements RemotingConnection { for (final FailureListener listener : listenersClone) { try { listener.connectionFailed(me, false, scaleDownTargetNodeID); - } - catch (ActiveMQInterruptedException interrupted) { + } catch (ActiveMQInterruptedException interrupted) { // this is an expected behaviour.. no warn or error here logger.debug("thread interrupted", interrupted); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -85,8 +83,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection { for (final CloseListener listener : listenersClone) { try { listener.connectionClosed(); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -107,7 +104,6 @@ public abstract class AbstractRemotingConnection implements RemotingConnection { return transportConnection.getID(); } - public String getLocalAddress() { return transportConnection.getLocalAddress(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java index 253986f1cd..39ecdf6260 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java @@ -186,13 +186,14 @@ public interface RemotingConnection extends BufferHandler { boolean isWritable(ReadyListener callback); /** - *if slow consumer is killed,send the msessage to client. + * if slow consumer is killed,send the msessage to client. */ void killMessage(SimpleString nodeID); /** * This will check if reconnects are supported on the protocol and configuration. * In case it's not supported a connection failure could remove messages right away from pending deliveries. + * * @return */ boolean isSupportReconnect(); @@ -201,6 +202,7 @@ public interface RemotingConnection extends BufferHandler { * Return true if the protocol supports flow control. * This is because in some cases we may need to hold message producers in cases like disk full. * If the protocol doesn't support it we trash the connection and throw exceptions. + * * @return */ boolean isSupportsFlowControl(); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java index 4352d493df..7ab0c40986 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java @@ -46,7 +46,7 @@ public interface Connection { /** * This will disable reading from the channel. * This is basically the same as blocking the reading. - * */ + */ void setAutoRead(boolean autoRead); /** @@ -131,4 +131,4 @@ public interface Connection { * @return */ boolean isUsingProtocolHandling(); -} \ No newline at end of file +} diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ConnectionLifeCycleListener.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ConnectionLifeCycleListener.java index f70222701a..0c1fe5fe88 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ConnectionLifeCycleListener.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ConnectionLifeCycleListener.java @@ -18,6 +18,7 @@ package org.apache.activemq.artemis.spi.core.remoting; /** * A ConnectionLifeCycleListener is called by the remoting implementation to notify of connection events. + * * @deprecated use {@link ClientConnectionLifeCycleListener} instead. */ @Deprecated diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/connector/InVMTransportConfigurationSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/connector/InVMTransportConfigurationSchema.java index 8e8b966248..8b9a3feb61 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/connector/InVMTransportConfigurationSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/connector/InVMTransportConfigurationSchema.java @@ -16,15 +16,15 @@ */ package org.apache.activemq.artemis.uri.schema.connector; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.utils.uri.SchemaConstants; - import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.utils.uri.SchemaConstants; + public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema { /* This is the same as org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED, diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/AbstractServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/AbstractServerLocatorSchema.java index d0693d45f1..45f6e7d918 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/AbstractServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/AbstractServerLocatorSchema.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.uri.schema.serverLocator; +import java.net.URI; +import java.util.Map; + import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.URISchema; -import java.net.URI; -import java.util.Map; - public abstract class AbstractServerLocatorSchema extends URISchema { protected ConnectionOptions newConnectionOptions(URI uri, Map query) throws Exception { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/InVMServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/InVMServerLocatorSchema.java index 2060ea946f..1831c74328 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/InVMServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/InVMServerLocatorSchema.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.uri.schema.serverLocator; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -23,10 +27,6 @@ import org.apache.activemq.artemis.uri.schema.connector.InVMTransportConfigurati import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.SchemaConstants; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; - public class InVMServerLocatorSchema extends AbstractServerLocatorSchema { @Override diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/JGroupsServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/JGroupsServerLocatorSchema.java index c8ee3054db..fb5b40894f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/JGroupsServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/JGroupsServerLocatorSchema.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.uri.schema.serverLocator; +import java.io.NotSerializableException; +import java.net.URI; +import java.util.Map; + import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory; @@ -25,10 +29,6 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.SchemaConstants; -import java.io.NotSerializableException; -import java.net.URI; -import java.util.Map; - public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema { @Override @@ -44,8 +44,7 @@ public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema { if (options.isHa()) { return ActiveMQClient.createServerLocatorWithHA(dcConfig); - } - else { + } else { return ActiveMQClient.createServerLocatorWithoutHA(dcConfig); } } @@ -57,11 +56,9 @@ public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema { String auth; if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) { auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName(); - } - else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) { + } else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) { auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName(); - } - else { + } else { throw new NotSerializableException(endpoint + "not serializable"); } String query = BeanSupport.getData(null, bean, dgc, endpoint); @@ -75,8 +72,7 @@ public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema { BroadcastEndpointFactory endpointFactory; if (query.containsKey("file")) { endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(uri.getAuthority()); - } - else { + } else { endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName(uri.getAuthority()); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java index 4a2e2aacd5..9468a5088a 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/TCPServerLocatorSchema.java @@ -31,6 +31,7 @@ import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.SchemaConstants; public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { + @Override public String getSchemaName() { return SchemaConstants.TCP; @@ -45,8 +46,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { configurations.toArray(tcs); if (options.isHa()) { return ActiveMQClient.createServerLocatorWithHA(tcs); - } - else { + } else { return ActiveMQClient.createServerLocatorWithoutHA(tcs); } } @@ -109,8 +109,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { if (query == null) { cb = new StringBuilder(); empty = true; - } - else { + } else { cb = new StringBuilder(query); empty = false; } @@ -119,8 +118,7 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema { if (entry.getValue() != null) { if (!empty) { cb.append("&"); - } - else { + } else { empty = false; } cb.append(BeanSupport.encodeURI(entry.getKey())); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/UDPServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/UDPServerLocatorSchema.java index 3498804367..c3bc6ba479 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/UDPServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/schema/serverLocator/UDPServerLocatorSchema.java @@ -50,8 +50,7 @@ public class UDPServerLocatorSchema extends AbstractServerLocatorSchema { if (options.isHa()) { return ActiveMQClient.createServerLocatorWithHA(dgc); - } - else { + } else { return ActiveMQClient.createServerLocatorWithoutHA(dgc); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java index 3cbaac9b2e..25c7585569 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ActiveMQBufferInputStream.java @@ -52,8 +52,7 @@ public class ActiveMQBufferInputStream extends InputStream { if (remainingBytes() == 0) { return -1; - } - else { + } else { return bb.readByte() & 0xFF; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java index 6659424654..1baa660e94 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/BufferHelper.java @@ -30,8 +30,7 @@ public class BufferHelper { public static int sizeOfNullableSimpleString(String str) { if (str == null) { return DataConstants.SIZE_BOOLEAN; - } - else { + } else { return DataConstants.SIZE_BOOLEAN + sizeOfSimpleString(str); } } @@ -76,8 +75,7 @@ public class BufferHelper { if (isNotNull) { return buffer.readBoolean(); - } - else { + } else { return null; } } @@ -117,8 +115,7 @@ public class BufferHelper { if (isNotNull) { return buffer.readLong(); - } - else { + } else { return null; } } @@ -143,8 +140,7 @@ public class BufferHelper { if (isNotNull) { return buffer.readInt(); - } - else { + } else { return null; } } @@ -154,8 +150,7 @@ public class BufferHelper { if (isNotNull) { return buffer.readDouble(); - } - else { + } else { return null; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java index 166c0a7a01..a205c191cf 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java @@ -35,12 +35,10 @@ public class ConfigurationHelper { if (prop == null) { return def; - } - else { + } else { if (prop instanceof String == false) { return prop.toString(); - } - else { + } else { return (String) prop; } } @@ -54,18 +52,15 @@ public class ConfigurationHelper { if (prop == null) { return def; - } - else { + } else { // The resource adapter will aways send Strings, hence the conversion here if (prop instanceof String) { return Integer.valueOf((String) prop); - } - else if (prop instanceof Number == false) { + } else if (prop instanceof Number == false) { ActiveMQClientLogger.LOGGER.propertyNotInteger(propName, prop.getClass().getName()); return def; - } - else { + } else { return ((Number) prop).intValue(); } } @@ -80,18 +75,15 @@ public class ConfigurationHelper { if (prop == null) { return def; - } - else { + } else { // The resource adapter will aways send Strings, hence the conversion here if (prop instanceof String) { return Long.valueOf((String) prop); - } - else if (prop instanceof Number == false) { + } else if (prop instanceof Number == false) { ActiveMQClientLogger.LOGGER.propertyNotLong(propName, prop.getClass().getName()); return def; - } - else { + } else { return ((Number) prop).longValue(); } } @@ -106,18 +98,15 @@ public class ConfigurationHelper { if (prop == null) { return def; - } - else { + } else { // The resource adapter will aways send Strings, hence the conversion here if (prop instanceof String) { return Boolean.valueOf((String) prop); - } - else if (prop instanceof Boolean == false) { + } else if (prop instanceof Boolean == false) { ActiveMQClientLogger.LOGGER.propertyNotBoolean(propName, prop.getClass().getName()); return def; - } - else { + } else { return (Boolean) prop; } } @@ -188,15 +177,13 @@ public class ConfigurationHelper { SensitiveDataCodec codec = null; try { codec = PasswordMaskingUtil.getCodec(classImpl); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { throw ActiveMQClientMessageBundle.BUNDLE.failedToGetDecoder(e1); } try { return codec.decode(value); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQClientMessageBundle.BUNDLE.errordecodingPassword(e); } } @@ -208,8 +195,7 @@ public class ConfigurationHelper { Object prop = props.get(name); if (prop == null) { return def; - } - else { + } else { String value = prop.toString(); return Double.parseDouble(value); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java index 028720f3e3..4142d27d86 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/DeflaterReader.java @@ -81,28 +81,24 @@ public class DeflaterReader extends InputStream { deflater.end(); compressDone = true; break; - } - else if (deflater.needsInput()) { + } else if (deflater.needsInput()) { // read some data from inputstream int m = input.read(readBuffer); if (m == -1) { deflater.finish(); isFinished = true; - } - else { + } else { if (bytesRead != null) { bytesRead.addAndGet(m); } deflater.setInput(readBuffer, 0, m); } - } - else { + } else { deflater.finish(); isFinished = true; } - } - else { + } else { read += n; offset += n; len -= n; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java index c7284df8b0..a5ee1ce9bc 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/FutureLatch.java @@ -36,8 +36,7 @@ public class FutureLatch implements Runnable { public boolean await(final long timeout) { try { return latch.await(timeout, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java index db98281310..ff43a569de 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterReader.java @@ -55,8 +55,7 @@ public class InflaterReader extends InputStream { return -1; } pointer = 0; - } - catch (DataFormatException e) { + } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; @@ -87,16 +86,14 @@ public class InflaterReader extends InputStream { if (n == 0) { if (inflater.finished()) { break; - } - else if (inflater.needsInput()) { + } else if (inflater.needsInput()) { //feeding int m = input.read(inputBuffer); if (m == -1) { //it shouldn't be here, throw exception throw new DataFormatException("Input is over while inflater still expecting data"); - } - else { + } else { //feed the data in inflater.setInput(inputBuffer, 0, m); n = inflater.inflate(buf, offset, len); @@ -106,13 +103,11 @@ public class InflaterReader extends InputStream { len -= n; } } - } - else { + } else { //it shouldn't be here, throw throw new DataFormatException("Inflater is neither finished nor needing input."); } - } - else { + } else { read += n; offset += n; len -= n; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java index 767ef6ce39..2921276ba8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/InflaterWriter.java @@ -58,8 +58,7 @@ public class InflaterWriter extends OutputStream { writePointer = 0; try { doWrite(); - } - catch (DataFormatException e) { + } catch (DataFormatException e) { IOException ie = new IOException("Error decompressing data"); ie.initCause(e); throw ie; @@ -78,8 +77,7 @@ public class InflaterWriter extends OutputStream { n = inflater.inflate(outputBuffer); } output.close(); - } - catch (DataFormatException e) { + } catch (DataFormatException e) { IOException io = new IOException(e.getMessage()); io.initCause(e); throw io; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java index bbdaaff25f..83a15101ea 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JNDIUtil.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.utils; -import java.util.StringTokenizer; - import javax.naming.Binding; import javax.naming.Context; import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; +import java.util.StringTokenizer; public class JNDIUtil { // Constants ----------------------------------------------------- @@ -44,8 +43,7 @@ public class JNDIUtil { } crtContext = (Context) o; continue; - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { // OK } crtContext = crtContext.createSubcontext(tok); @@ -83,8 +81,7 @@ public class JNDIUtil { boolean failed = false; try { context.rebind(name, o); - } - catch (Exception ignored) { + } catch (Exception ignored) { failed = true; } if (failed) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java index c2f9216902..dea1d4f12f 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java @@ -37,16 +37,18 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Map; -/** This is to make sure we use the proper classLoader to load JSon libraries. - * This is equivalent to using {@link javax.json.Json} */ +/** + * This is to make sure we use the proper classLoader to load JSon libraries. + * This is equivalent to using {@link javax.json.Json} + */ public class JsonLoader { private static final JsonProvider provider; + static { provider = loadProvider(); } - private static JsonProvider loadProvider() { return AccessController.doPrivileged(new PrivilegedAction() { @Override @@ -55,8 +57,7 @@ public class JsonLoader { try { Thread.currentThread().setContextClassLoader(JsonLoader.class.getClassLoader()); return JsonProvider.provider(); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(originalLoader); } } @@ -64,8 +65,6 @@ public class JsonLoader { } - - public static JsonParser createParser(Reader reader) { return provider.createParser(reader); } @@ -126,5 +125,4 @@ public class JsonLoader { return provider.createBuilderFactory(config); } - } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java index 4262274532..f0d2945684 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/LinkedListImpl.java @@ -58,8 +58,7 @@ public class LinkedListImpl implements LinkedList { if (size == 0) { tail = node; - } - else { + } else { // Need to set the previous element on the former head node.next.prev = node; } @@ -71,8 +70,7 @@ public class LinkedListImpl implements LinkedList { public void addTail(E e) { if (size == 0) { addHead(e); - } - else { + } else { Node node = new Node<>(e); node.prev = tail; @@ -93,8 +91,7 @@ public class LinkedListImpl implements LinkedList { removeAfter(head); return ret.val; - } - else { + } else { return null; } } @@ -281,16 +278,14 @@ public class LinkedListImpl implements LinkedList { if (e != null) { return e.val; - } - else { + } else { if (canAdvance()) { advance(); e = getNode(); return e.val; - } - else { + } else { throw new NoSuchElementException(); } } @@ -301,8 +296,7 @@ public class LinkedListImpl implements LinkedList { advance(); e = getNode(); - } - else { + } else { throw new NoSuchElementException(); } } @@ -338,16 +332,14 @@ public class LinkedListImpl implements LinkedList { if (current == node) { if (canAdvance()) { advance(); - } - else { + } else { if (current.prev != head) { current.iterCount--; current = current.prev; current.iterCount++; - } - else { + } else { current = null; } } @@ -365,8 +357,7 @@ public class LinkedListImpl implements LinkedList { if (current != null) { return current; - } - else { + } else { return null; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java index b3e47cc2b7..ed2ceb23be 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/MemorySize.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.utils; -import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; - import java.lang.ref.WeakReference; +import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; + public class MemorySize { private static final int numberOfObjects = 10000; @@ -37,8 +37,7 @@ public class MemorySize { if (arch != null) { is64bit = arch.contains("64"); } - } - catch (Exception e) { + } catch (Exception e) { // Ignore } @@ -111,8 +110,7 @@ public class MemorySize { System.gc(); try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } 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 6aa0f50842..31d7a4710f 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() { @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() { @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; } } 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 d80d7bd06d..609af8ead2 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, 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 06b24326ef..427a927d90 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 implements PriorityLinkedList { lastPriority = priority; if (lastReset == Integer.MAX_VALUE) { lastReset = 0; - } - else { + } else { lastReset++; } } 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 90994fb5f6..b4fe5815b2 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 createSecurity(String sendRoles, 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 71698b46c0..02143746f2 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"; } 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 17228c276a..070f91e07a 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 implemen if (value != null) { value.used(); return value.get(); - } - else { + } else { return null; } } @@ -148,8 +147,7 @@ public class SoftValueHashMap implemen newRef.used(); if (oldRef != null) { return oldRef.get(); - } - else { + } else { return null; } } @@ -190,8 +188,7 @@ public class SoftValueHashMap implemen if (k > 0) { return 1; - } - else if (k < 0) { + } else if (k < 0) { return -1; } @@ -199,11 +196,9 @@ public class SoftValueHashMap 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 implemen AggregatedSoftReference ref = mapDelegate.remove(key); if (ref != null) { return ref.get(); - } - else { + } else { return null; } } 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 1b402098f7..ac4d6411c2 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 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 96678f764c..f6e4caccb3 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) 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 699ccacb8a..ed11e4f309 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; } } 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 a0efdb5e5c..22d274d84f 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)); } 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 7a492c4a97..39b06578bc 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("'); - } - 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); 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 75b871dc4d..ad6363e376 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()); + ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); - 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()); - 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(); } - } 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 180ca6c552..2873bab568 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, 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 9f0d29c9b8..1b7a4793b7 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 configMap1 = new HashMap<>(); configMap1.put("host", "localhost"); HashMap configMap2 = new HashMap<>(); 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 f47787926c..392231b8f3 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 +} 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 b47e216e69..a8a62053c8 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 { 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 5508fc4f62..aa0669ed55 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. 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 e864822821..ff2474a6f5 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 { 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 76f3ec198a..324e24de20 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 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 671261e5cc..c2ec02d7c9 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(); 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 f2feeac9eb..c7dcdaf137 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(); } diff --git a/artemis-dto/pom.xml b/artemis-dto/pom.xml index ef39754910..2b67fb6d2f 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. --> - + 4.0.0 @@ -28,7 +29,7 @@ ActiveMQ Artemis DTO - ${project.basedir}/.. + ${project.basedir}/.. @@ -40,151 +41,153 @@ - - - target/schema - - **/* - - - - src/main/resources - - **/* - - true - - + + + target/schema + + **/* + + + + src/main/resources + + **/* + + true + + - - - maven-antrun-plugin - 1.7 - - - generate-resources - - - - - - - - - - - - - - - - - - - - run - - - + + + maven-antrun-plugin + 1.7 + + + generate-resources + + + + + + + + + + + + + + + + + + + + run + + + + + + javax.xml.bind + jaxb-api + 2.2.7 + + + com.sun.xml.bind + jaxb-impl + 2.2.7 + + + com.sun.xml.bind + jaxb-jxc + 2.2.7 + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-antrun-plugin + [1.7,) + + run + + + + + + + + + + + + + + + + + jdk-1.5 + + 1.5 + javax.xml.bind jaxb-api - 2.2.7 + ${jaxb-api-version} com.sun.xml.bind jaxb-impl - 2.2.7 - - - com.sun.xml.bind - jaxb-jxc - 2.2.7 + ${jaxb-version} - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-antrun-plugin - [1.7,) - - run - - - - - - - - - - - - - + - - - jdk-1.5 - - 1.5 - - - - javax.xml.bind - jaxb-api - ${jaxb-api-version} - - - com.sun.xml.bind - jaxb-impl - ${jaxb-version} - - - - - - ibmjdk - - - ${java.home}/../lib/tools.jar - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - com.sun - tools - - 1.5.0 - system - true - ${java.home}/../lib/tools.jar - - - - - - - + + ibmjdk + + + ${java.home}/../lib/tools.jar + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + com.sun + tools + + 1.5.0 + system + true + ${java.home}/../lib/tools.jar + + + + + + + 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 fa0ff9aef4..1af8542ea7 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 decode(Class 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 decode(Class clazz, + File configuration, + String artemisHome, + String artemisInstance) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance("org.apache.activemq.artemis.dto"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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 8f98eec4b9..0a8b297ee4 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; diff --git a/artemis-jdbc-store/pom.xml b/artemis-jdbc-store/pom.xml index 2e0c8c0416..3de4f8556c 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. --> - + 4.0.0 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 43b94e08bb..0098328741 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; 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 9ab28de301..b277523e73 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; } 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 7a32fcf631..7b2ab1f163 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 +} 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 d69cff9a65..254fa86c7d 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); 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 4d42d7f223..db74c056ae 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; } 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 19e9b69f06..84089918ef 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; } 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 48d03bffbf..8078417124 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; 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 0ae0335bcf..2110173c8e 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; } } 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 924fdc8054..ef45fe0645 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; 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 4678425456..cd8a411dce 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 getTransactions() { return loadTransactions; } -} \ No newline at end of file +} 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 2d31a8f177..3b570a0ad8 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 +} 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 0f354bc056..1fae83ac28 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); } } diff --git a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java index 0aa26ce77d..e94f51aed0 100644 --- a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java +++ b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java @@ -78,8 +78,7 @@ public class JDBCSequentialFileFactoryTest { public void shutdownDerby() { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } diff --git a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallbackTest.java b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallbackTest.java index c7e514b233..e4f83fa684 100644 --- a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallbackTest.java +++ b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalLoaderCallbackTest.java @@ -34,6 +34,7 @@ public class JDBCJournalLoaderCallbackTest { @Rule public ThreadLeakCheckRule threadLeakCheckRule = new ThreadLeakCheckRule(); + @Test public void testAddDeleteRecord() throws Exception { @@ -57,8 +58,7 @@ public class JDBCJournalLoaderCallbackTest { public void shutdownDerby() { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/ActiveMQJMSClient.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/ActiveMQJMSClient.java index 1cf038c1bc..6c146f0e9e 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/ActiveMQJMSClient.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/ActiveMQJMSClient.java @@ -67,20 +67,15 @@ public class ActiveMQJMSClient { ActiveMQConnectionFactory factory = null; if (jmsFactoryType.equals(JMSFactoryType.CF)) { factory = new ActiveMQJMSConnectionFactory(true, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { factory = new ActiveMQQueueConnectionFactory(true, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { factory = new ActiveMQTopicConnectionFactory(true, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { factory = new ActiveMQXAConnectionFactory(true, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { factory = new ActiveMQXAQueueConnectionFactory(true, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { factory = new ActiveMQXATopicConnectionFactory(true, groupConfiguration); } @@ -101,20 +96,15 @@ public class ActiveMQJMSClient { ActiveMQConnectionFactory factory = null; if (jmsFactoryType.equals(JMSFactoryType.CF)) { factory = new ActiveMQJMSConnectionFactory(false, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { factory = new ActiveMQQueueConnectionFactory(false, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { factory = new ActiveMQTopicConnectionFactory(false, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { factory = new ActiveMQXAConnectionFactory(false, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { factory = new ActiveMQXAQueueConnectionFactory(false, groupConfiguration); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { factory = new ActiveMQXATopicConnectionFactory(false, groupConfiguration); } @@ -142,20 +132,15 @@ public class ActiveMQJMSClient { ActiveMQConnectionFactory factory = null; if (jmsFactoryType.equals(JMSFactoryType.CF)) { factory = new ActiveMQJMSConnectionFactory(true, initialServers); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { factory = new ActiveMQQueueConnectionFactory(true, initialServers); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { factory = new ActiveMQTopicConnectionFactory(true, initialServers); - } - else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { factory = new ActiveMQXAConnectionFactory(true, initialServers); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { factory = new ActiveMQXAQueueConnectionFactory(true, initialServers); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { factory = new ActiveMQXATopicConnectionFactory(true, initialServers); } @@ -178,20 +163,15 @@ public class ActiveMQJMSClient { ActiveMQConnectionFactory factory = null; if (jmsFactoryType.equals(JMSFactoryType.CF)) { factory = new ActiveMQJMSConnectionFactory(false, transportConfigurations); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) { factory = new ActiveMQQueueConnectionFactory(false, transportConfigurations); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) { factory = new ActiveMQTopicConnectionFactory(false, transportConfigurations); - } - else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) { factory = new ActiveMQXAConnectionFactory(false, transportConfigurations); - } - else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) { factory = new ActiveMQXAQueueConnectionFactory(false, transportConfigurations); - } - else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { + } else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) { factory = new ActiveMQXATopicConnectionFactory(false, transportConfigurations); } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java index bca646cbc3..64da481e3e 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.api.jms.management; -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonArray; import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + public class JMSConnectionInfo { private final String connectionID; @@ -43,9 +43,7 @@ public class JMSConnectionInfo { String cid = obj.containsKey("clientID") ? obj.getString("clientID") : null; String uname = obj.containsKey("principal") ? obj.getString("principal") : null; - JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"), - obj.getJsonNumber("creationTime").longValue(), - cid, uname); + JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"), obj.getJsonNumber("creationTime").longValue(), cid, uname); infos[i] = info; } return infos; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java index 63fcdcd573..5b7f5e3a83 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.api.jms.management; -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonArray; import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + /** * Helper class to create Java Objects from the * JSON serialization returned by {@link JMSServerControl#listConsumersAsJSON(String)} and related methods. @@ -54,10 +54,7 @@ public class JMSConsumerInfo { JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()]; for (int i = 0; i < array.size(); i++) { JsonObject sub = array.getJsonObject(i); - JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(), sub.getString("connectionID"), - sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"), - sub.getJsonNumber("creationTime").longValue(), - sub.getBoolean("durable"), sub.getString("filter", null)); + JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(), sub.getString("connectionID"), sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"), sub.getJsonNumber("creationTime").longValue(), sub.getBoolean("durable"), sub.getString("filter", null)); infos[i] = info; } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSManagementHelper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSManagementHelper.java index 2e785df352..0e99106b6c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSManagementHelper.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSManagementHelper.java @@ -64,8 +64,7 @@ public class JMSManagementHelper { final String operationName) throws JMSException { try { ManagementHelper.putOperationInvocation(JMSManagementHelper.getCoreMessage(message), resourceName, operationName); - } - catch (Exception e) { + } catch (Exception e) { throw JMSManagementHelper.convertFromException(e); } } @@ -94,8 +93,7 @@ public class JMSManagementHelper { final Object... parameters) throws JMSException { try { ManagementHelper.putOperationInvocation(JMSManagementHelper.getCoreMessage(message), resourceName, operationName, parameters); - } - catch (Exception e) { + } catch (Exception e) { throw JMSManagementHelper.convertFromException(e); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSQueueControl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSQueueControl.java index 6b9aedc8d3..56a127cdcb 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSQueueControl.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSQueueControl.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.api.jms.management; -import java.util.Map; - import javax.management.MBeanOperationInfo; import javax.management.openmbean.CompositeData; +import java.util.Map; import org.apache.activemq.artemis.api.core.management.Attribute; import org.apache.activemq.artemis.api.core.management.Operation; @@ -200,7 +199,7 @@ public interface JMSQueueControl extends DestinationControl { * Sends a TextMessage to the destination. * * @param properties the message properties to set as a comma sep name=value list. Can only - * contain Strings maped to primitive types or JMS properties. eg: body=hi,JMSReplyTo=Queue2 + * contain Strings maped to primitive types or JMS properties. eg: body=hi,JMSReplyTo=Queue2 * @return the message id of the message sent. * @throws Exception */ @@ -212,17 +211,18 @@ public interface JMSQueueControl extends DestinationControl { * * @param headers the message headers and properties to set. Can only * container Strings maped to primitive types. - * @param body the text to send + * @param body the text to send * @return the message id of the message sent. * @throws Exception */ @Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION) - String sendTextMessage(@Parameter(name = "headers") Map headers, + String sendTextMessage(@Parameter(name = "headers") Map headers, @Parameter(name = "body") String body) throws Exception; /** * Sends a TextMesage to the destination. - * @param body the text to send + * + * @param body the text to send * @param user * @param password * @return @@ -234,20 +234,19 @@ public interface JMSQueueControl extends DestinationControl { @Parameter(name = "password") String password) throws Exception; /** - * - * @param headers the message headers and properties to set. Can only - * container Strings maped to primitive types. - * @param body the text to send - * @param user - * @param password - * @return - * @throws Exception - */ + * @param headers the message headers and properties to set. Can only + * container Strings maped to primitive types. + * @param body the text to send + * @param user + * @param password + * @return + * @throws Exception + */ @Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION) - String sendTextMessage(@Parameter(name = "headers") Map headers, - @Parameter(name = "body") String body, - @Parameter(name = "user") String user, - @Parameter(name = "password") String password) throws Exception; + String sendTextMessage(@Parameter(name = "headers") Map headers, + @Parameter(name = "body") String body, + @Parameter(name = "user") String user, + @Parameter(name = "password") String password) throws Exception; /** * Changes the message's priority corresponding to the specified message ID to the specified priority. @@ -382,7 +381,6 @@ public interface JMSQueueControl extends DestinationControl { @Operation(desc = "Resume the queue.", impact = MBeanOperationInfo.ACTION) void resume() throws Exception; - /** * Resumes the queue. Messages are again delivered to its consumers. */ diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java index b5f0d08ae6..f09c5cddbe 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSSessionInfo.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.api.jms.management; -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonArray; import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + public class JMSSessionInfo { private final String sessionID; @@ -38,8 +38,7 @@ public class JMSSessionInfo { for (int i = 0; i < array.size(); i++) { JsonObject obj = array.getJsonObject(i); - JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), - obj.getJsonNumber("creationTime").longValue()); + JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), obj.getJsonNumber("creationTime").longValue()); infos[i] = info; } return infos; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java index 1728d4f384..eee2667297 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/SubscriptionInfo.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.api.jms.management; - -import org.apache.activemq.artemis.api.core.JsonUtil; - import javax.json.JsonArray; import javax.json.JsonObject; +import org.apache.activemq.artemis.api.core.JsonUtil; + /** * Helper class to create Java Objects from the * JSON serialization returned by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods. @@ -53,9 +52,7 @@ public class SubscriptionInfo { SubscriptionInfo[] infos = new SubscriptionInfo[array.size()]; for (int i = 0; i < array.size(); i++) { JsonObject sub = array.getJsonObject(i); - SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"), sub.getString("clientID", null), - sub.getString("name", null), sub.getBoolean("durable"), sub.getString("selector", null), - sub.getInt("messageCount"), sub.getInt("deliveringCount")); + SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"), sub.getString("clientID", null), sub.getString("name", null), sub.getBoolean("durable"), sub.getString("selector", null), sub.getInt("messageCount"), sub.getInt("deliveringCount")); infos[i] = info; } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java index d94e3107b4..7e643f1ae5 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/TopicControl.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.api.jms.management; -import java.util.Map; - import javax.management.MBeanOperationInfo; +import java.util.Map; import org.apache.activemq.artemis.api.core.management.Attribute; import org.apache.activemq.artemis.api.core.management.Operation; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java index b585caf046..59f04e8775 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java @@ -104,8 +104,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadBoolean(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -115,8 +114,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadByte(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -126,8 +124,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadUnsignedByte(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -137,8 +134,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadShort(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -148,8 +144,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadUnsignedShort(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -159,8 +154,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadChar(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -170,8 +164,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadInt(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -181,8 +174,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadLong(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -192,8 +184,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadFloat(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -203,8 +194,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadDouble(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -214,11 +204,9 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkRead(); try { return bytesReadUTF(message.getBodyBuffer()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); - } - catch (Exception e) { + } catch (Exception e) { JMSException je = new JMSException("Failed to get UTF"); je.setLinkedException(e); je.initCause(e); @@ -292,8 +280,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag checkWrite(); try { bytesWriteUTF(message.getBodyBuffer(), value); - } - catch (Exception e) { + } catch (Exception e) { JMSException je = new JMSException("Failed to write UTF"); je.setLinkedException(e); je.initCause(e); @@ -346,8 +333,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag try { getBuffer().clear(); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { JMSException e2 = new JMSException(e.getMessage()); e2.initCause(e); throw e2; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java index fc9c59d2fc..f896494443 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java @@ -237,8 +237,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme try { initialSession.addUniqueMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) { throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection"); } @@ -247,8 +246,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme this.clientID = clientID; try { this.addSessionMetaData(initialSession); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { JMSException ex = new JMSException("Internal error setting metadata jms-client-id"); ex.setLinkedException(e); ex.initCause(e); @@ -349,15 +347,13 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme if (!initialSession.isClosed()) { try { initialSession.deleteQueue(queueName); - } - catch (ActiveMQException ignore) { + } catch (ActiveMQException ignore) { // Exception on deleting queue shouldn't prevent close from completing } } } } - } - finally { + } finally { if (initialSession != null) { initialSession.close(); } @@ -366,8 +362,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme failoverListenerExecutor.shutdown(); closed = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -592,23 +587,17 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme if (acknowledgeMode == Session.SESSION_TRANSACTED) { session = sessionFactory.createSession(username, password, isXA, false, false, sessionFactory.getServerLocator().isPreAcknowledge(), transactionBatchSize); - } - else if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) { + } else if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) { session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), 0); - } - else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) { + } else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) { session = sessionFactory.createSession(username, password, isXA, true, true, sessionFactory.getServerLocator().isPreAcknowledge(), dupsOKBatchSize); - } - else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) { + } else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) { session = sessionFactory.createSession(username, password, isXA, true, false, sessionFactory.getServerLocator().isPreAcknowledge(), transactionBatchSize); - } - else if (acknowledgeMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) { + } else if (acknowledgeMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) { session = sessionFactory.createSession(username, password, isXA, true, false, false, transactionBatchSize); - } - else if (acknowledgeMode == ActiveMQJMSConstants.PRE_ACKNOWLEDGE) { + } else if (acknowledgeMode == ActiveMQJMSConstants.PRE_ACKNOWLEDGE) { session = sessionFactory.createSession(username, password, isXA, true, false, true, transactionBatchSize); - } - else { + } else { throw new JMSRuntimeException("Invalid ackmode: " + acknowledgeMode); } @@ -631,8 +620,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme this.addSessionMetaData(session); return jbs; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -657,8 +645,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme int type) { if (isXA) { return new ActiveMQXASession(options, this, transacted, true, acknowledgeMode, session, type); - } - else { + } else { return new ActiveMQSession(options, this, transacted, false, acknowledgeMode, session, type); } } @@ -677,8 +664,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme initialSession.addFailureListener(listener); initialSession.addFailoverListener(failoverListener); - } - catch (ActiveMQException me) { + } catch (ActiveMQException me) { throw JMSExceptionHelper.convertFromActiveMQException(me); } } @@ -740,8 +726,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme } }).start(); } - } - catch (JMSException e) { + } catch (JMSException e) { if (!conn.closed) { ActiveMQJMSClientLogger.LOGGER.errorCallingExcListener(e); } @@ -786,8 +771,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme } }); } - } - catch (JMSException e) { + } catch (JMSException e) { if (!conn.closed) { ActiveMQJMSClientLogger.LOGGER.errorCallingFailoverListener(e); } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java index ce531f5063..3a16cbde51 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java @@ -89,8 +89,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { out.writeUTF(uri.toASCIIString()); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof IOException) { throw (IOException) e; } @@ -104,16 +103,13 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte if (serverLocator.getDiscoveryGroupConfiguration() != null) { if (serverLocator.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory() instanceof UDPBroadcastEndpointFactory) { scheme = "udp"; - } - else { + } else { scheme = "jgroups"; } - } - else { + } else { if (serverLocator.allInVM()) { scheme = "vm"; - } - else { + } else { scheme = "tcp"; } } @@ -122,8 +118,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { uri = parser.createSchema(scheme, this); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof IOException) { throw (IOException) e; } @@ -139,12 +134,11 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte public void setProtocolManagerFactoryStr(final String protocolManagerFactoryStr) { if (protocolManagerFactoryStr != null && !protocolManagerFactoryStr.trim().isEmpty() && - !protocolManagerFactoryStr.equals("undefined")) { + !protocolManagerFactoryStr.equals("undefined")) { AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { - ClientProtocolManagerFactory protocolManagerFactory = - (ClientProtocolManagerFactory) ClassloadingUtil.newInstanceFromClassLoader(protocolManagerFactoryStr); + ClientProtocolManagerFactory protocolManagerFactory = (ClientProtocolManagerFactory) ClassloadingUtil.newInstanceFromClassLoader(protocolManagerFactoryStr); serverLocator.setProtocolManagerFactory(protocolManagerFactory); return null; } @@ -183,8 +177,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte URI uri = new URI(url); serverLocator = locatorParser.newObject(uri, null); parser.populateObject(uri, this); - } - catch (Exception e) { + } catch (Exception e) { throw new InvalidObjectException(e.getMessage()); } } @@ -202,8 +195,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte URI uri = new URI(url); serverLocator = ServerLocatorImpl.newLocator(uri); cfParser.populateObject(uri, this); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } @@ -233,8 +225,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte public ActiveMQConnectionFactory(final boolean ha, final DiscoveryGroupConfiguration groupConfiguration) { if (ha) { serverLocator = ActiveMQClient.createServerLocatorWithHA(groupConfiguration); - } - else { + } else { serverLocator = ActiveMQClient.createServerLocatorWithoutHA(groupConfiguration); } @@ -244,8 +235,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte public ActiveMQConnectionFactory(final boolean ha, final TransportConfiguration... initialConnectors) { if (ha) { serverLocator = ActiveMQClient.createServerLocatorWithHA(initialConnectors); - } - else { + } else { serverLocator = ActiveMQClient.createServerLocatorWithoutHA(initialConnectors); } @@ -283,11 +273,9 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { ActiveMQConnection connection = createConnectionInternal(userName, password, false, ActiveMQConnection.TYPE_GENERIC_CONNECTION); return connection.createContext(sessionMode); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { throw new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -345,11 +333,9 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { ActiveMQConnection connection = createConnectionInternal(userName, password, true, ActiveMQConnection.TYPE_GENERIC_CONNECTION); return connection.createXAContext(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { throw new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -754,8 +740,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { factory = serverLocator.createSessionFactory(); - } - catch (Exception e) { + } catch (Exception e) { JMSException jmse = new JMSException("Failed to create session factory"); jmse.initCause(e); @@ -769,22 +754,17 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte if (isXA) { if (type == ActiveMQConnection.TYPE_GENERIC_CONNECTION) { connection = new ActiveMQXAConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); - } - else if (type == ActiveMQConnection.TYPE_QUEUE_CONNECTION) { + } else if (type == ActiveMQConnection.TYPE_QUEUE_CONNECTION) { + connection = new ActiveMQXAConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); + } else if (type == ActiveMQConnection.TYPE_TOPIC_CONNECTION) { connection = new ActiveMQXAConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); } - else if (type == ActiveMQConnection.TYPE_TOPIC_CONNECTION) { - connection = new ActiveMQXAConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); - } - } - else { + } else { if (type == ActiveMQConnection.TYPE_GENERIC_CONNECTION) { connection = new ActiveMQConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); - } - else if (type == ActiveMQConnection.TYPE_QUEUE_CONNECTION) { + } else if (type == ActiveMQConnection.TYPE_QUEUE_CONNECTION) { connection = new ActiveMQConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); - } - else if (type == ActiveMQConnection.TYPE_TOPIC_CONNECTION) { + } else if (type == ActiveMQConnection.TYPE_TOPIC_CONNECTION) { connection = new ActiveMQConnection(this, username, password, type, clientID, dupsOKBatchSize, transactionBatchSize, factory); } } @@ -796,12 +776,10 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte try { connection.authorize(); - } - catch (JMSException e) { + } catch (JMSException e) { try { connection.close(); - } - catch (JMSException me) { + } catch (JMSException me) { } throw e; } @@ -837,8 +815,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte protected void finalize() throws Throwable { try { serverLocator.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); //not much we can do here } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionForContextImpl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionForContextImpl.java index b1c44a3479..3ca26be01c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionForContextImpl.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionForContextImpl.java @@ -33,8 +33,7 @@ public abstract class ActiveMQConnectionForContextImpl implements ActiveMQConnec public void run() { try { close(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionMetaData.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionMetaData.java index 8a1491516e..c72c4d4bc7 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionMetaData.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionMetaData.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.jms.client; -import java.util.Enumeration; -import java.util.Vector; - import javax.jms.ConnectionMetaData; import javax.jms.JMSException; +import java.util.Enumeration; +import java.util.Vector; import org.apache.activemq.artemis.core.version.Version; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java index 6d4a40b48d..4aed49f881 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java @@ -76,14 +76,11 @@ public class ActiveMQDestination implements Destination, Serializable, Reference public static ActiveMQDestination createDestination(String name, byte defaultType) { if (name.startsWith(QUEUE_QUALIFIED_PREFIX)) { return new ActiveMQQueue(name.substring(QUEUE_QUALIFIED_PREFIX.length())); - } - else if (name.startsWith(TOPIC_QUALIFIED_PREFIX)) { + } else if (name.startsWith(TOPIC_QUALIFIED_PREFIX)) { return new ActiveMQTopic(name.substring(TOPIC_QUALIFIED_PREFIX.length())); - } - else if (name.startsWith(TEMP_QUEUE_QUALIFED_PREFIX)) { + } else if (name.startsWith(TEMP_QUEUE_QUALIFED_PREFIX)) { return new ActiveMQQueue(name.substring(TEMP_QUEUE_QUALIFED_PREFIX.length()), true); - } - else if (name.startsWith(TEMP_TOPIC_QUALIFED_PREFIX)) { + } else if (name.startsWith(TEMP_TOPIC_QUALIFED_PREFIX)) { return new ActiveMQTopic(name.substring(TEMP_TOPIC_QUALIFED_PREFIX.length()), true); } @@ -106,23 +103,19 @@ public class ActiveMQDestination implements Destination, Serializable, Reference String name = address.substring(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX.length()); return createQueue(name); - } - else if (address.startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX)) { + } else if (address.startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX)) { String name = address.substring(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX.length()); return createTopic(name); - } - else if (address.startsWith(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX)) { + } else if (address.startsWith(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX)) { String name = address.substring(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX.length()); return new ActiveMQTemporaryQueue(address, name, null); - } - else if (address.startsWith(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX)) { + } else if (address.startsWith(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX)) { String name = address.substring(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX.length()); return new ActiveMQTemporaryTopic(address, name, null); - } - else { + } else { throw new JMSRuntimeException("Invalid address " + address); } } @@ -134,18 +127,15 @@ public class ActiveMQDestination implements Destination, Serializable, Reference if (isDurable) { return ActiveMQDestination.escape(clientID) + SEPARATOR + ActiveMQDestination.escape(subscriptionName); - } - else { + } else { return "nonDurable" + SEPARATOR + ActiveMQDestination.escape(clientID) + SEPARATOR + ActiveMQDestination.escape(subscriptionName); } - } - else { + } else { if (isDurable) { return ActiveMQDestination.escape(subscriptionName); - } - else { + } else { return "nonDurable" + SEPARATOR + ActiveMQDestination.escape(subscriptionName); } @@ -159,8 +149,7 @@ public class ActiveMQDestination implements Destination, Serializable, Reference return (isDurable ? "Durable" : "nonDurable") + SEPARATOR + ActiveMQDestination.escape(clientID) + SEPARATOR + ActiveMQDestination.escape(subscriptionName); - } - else { + } else { return (isDurable ? "Durable" : "nonDurable") + SEPARATOR + ActiveMQDestination.escape(subscriptionName); } @@ -314,8 +303,7 @@ public class ActiveMQDestination implements Destination, Serializable, Reference } if (queue) { session.deleteTemporaryQueue(this); - } - else { + } else { session.deleteTemporaryTopic(this); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSClientBundle.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSClientBundle.java index f9711173ec..844446cb9e 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSClientBundle.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSClientBundle.java @@ -28,10 +28,10 @@ import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; import org.apache.activemq.artemis.api.core.ActiveMQInvalidFilterExpressionException; import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException; import org.apache.activemq.artemis.api.core.SimpleString; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 12 diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSConsumer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSConsumer.java index c59812ba88..e359f5b575 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSConsumer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSConsumer.java @@ -37,8 +37,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public String getMessageSelector() { try { return consumer.getMessageSelector(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -47,8 +46,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public MessageListener getMessageListener() throws JMSRuntimeException { try { return consumer.getMessageListener(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -57,8 +55,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public void setMessageListener(MessageListener listener) throws JMSRuntimeException { try { consumer.setMessageListener(new MessageListenerWrapper(listener)); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -67,8 +64,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public Message receive() { try { return context.setLastMessage(this, consumer.receive()); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -77,8 +73,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public Message receive(long timeout) { try { return context.setLastMessage(this, consumer.receive(timeout)); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -87,8 +82,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public Message receiveNoWait() { try { return context.setLastMessage(this, consumer.receiveNoWait()); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -97,8 +91,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { public void close() { try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -109,8 +102,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { Message message = consumer.receive(); context.setLastMessage(ActiveMQJMSConsumer.this, message); return message == null ? null : message.getBody(c); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -121,8 +113,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { Message message = consumer.receive(timeout); context.setLastMessage(ActiveMQJMSConsumer.this, message); return message == null ? null : message.getBody(c); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -133,8 +124,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { Message message = consumer.receiveNoWait(); context.setLastMessage(ActiveMQJMSConsumer.this, message); return message == null ? null : message.getBody(c); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -154,8 +144,7 @@ public class ActiveMQJMSConsumer implements JMSConsumer { context.getThreadAwareContext().setCurrentThread(false); try { wrapped.onMessage(message); - } - finally { + } finally { context.getThreadAwareContext().clearCurrentThread(false); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java index 3065f27aea..7a6c9ef0e0 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java @@ -111,8 +111,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return new ActiveMQJMSProducer(this, getInnerProducer()); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -137,12 +136,10 @@ public class ActiveMQJMSContext implements JMSContext { try { if (xa) { session = ((XAConnection) connection).createXASession(); - } - else { + } else { session = connection.createSession(sessionMode); } - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -154,8 +151,7 @@ public class ActiveMQJMSContext implements JMSContext { public String getClientID() { try { return connection.getClientID(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -164,8 +160,7 @@ public class ActiveMQJMSContext implements JMSContext { public void setClientID(String clientID) { try { connection.setClientID(clientID); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -174,8 +169,7 @@ public class ActiveMQJMSContext implements JMSContext { public ConnectionMetaData getMetaData() { try { return connection.getMetaData(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -184,8 +178,7 @@ public class ActiveMQJMSContext implements JMSContext { public ExceptionListener getExceptionListener() { try { return connection.getExceptionListener(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -194,8 +187,7 @@ public class ActiveMQJMSContext implements JMSContext { public void setExceptionListener(ExceptionListener listener) { try { connection.setExceptionListener(listener); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -204,8 +196,7 @@ public class ActiveMQJMSContext implements JMSContext { public void start() { try { connection.start(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -215,8 +206,7 @@ public class ActiveMQJMSContext implements JMSContext { threadAwareContext.assertNotMessageListenerThreadRuntime(); try { connection.stop(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -242,8 +232,7 @@ public class ActiveMQJMSContext implements JMSContext { connection.closeFromContext(); closed = true; } - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -253,8 +242,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createBytesMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -264,8 +252,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createMapMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -275,8 +262,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -286,8 +272,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createObjectMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -297,8 +282,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createObjectMessage(object); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -308,8 +292,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createStreamMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -319,8 +302,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createTextMessage(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -330,8 +312,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createTextMessage(text); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -341,8 +322,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.getTransacted(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -358,8 +338,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { session.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -370,8 +349,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { session.rollback(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -381,8 +359,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { session.recover(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -394,8 +371,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -407,8 +383,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination, messageSelector)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -420,8 +395,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination, messageSelector, noLocal)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -431,8 +405,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createQueue(queueName); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -442,8 +415,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createTopic(topicName); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -455,8 +427,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createDurableConsumer(topic, name)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -468,8 +439,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createDurableConsumer(topic, name, messageSelector, noLocal)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -481,8 +451,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedDurableConsumer(topic, name)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -494,8 +463,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedDurableConsumer(topic, name, messageSelector)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -507,8 +475,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -520,8 +487,7 @@ public class ActiveMQJMSContext implements JMSContext { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -533,8 +499,7 @@ public class ActiveMQJMSContext implements JMSContext { QueueBrowser browser = session.createBrowser(queue); checkAutoStart(); return browser; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -546,8 +511,7 @@ public class ActiveMQJMSContext implements JMSContext { QueueBrowser browser = session.createBrowser(queue, messageSelector); checkAutoStart(); return browser; - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -557,8 +521,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createTemporaryQueue(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -568,8 +531,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { return session.createTemporaryTopic(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -579,8 +541,7 @@ public class ActiveMQJMSContext implements JMSContext { checkSession(); try { session.unsubscribe(name); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -594,8 +555,7 @@ public class ActiveMQJMSContext implements JMSContext { if (lastMessagesWaitingAck != null) { lastMessagesWaitingAck.acknowledge(); } - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java index 17d6c3c126..9911302b59 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java @@ -94,12 +94,10 @@ public final class ActiveMQJMSProducer implements JMSProducer { if (completionListener != null) { CompletionListener wrapped = new CompletionListenerWrapper(completionListener); producer.send(destination, message, wrapped); - } - else { + } else { producer.send(destination, message); } - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } return this; @@ -134,41 +132,30 @@ public final class ActiveMQJMSProducer implements JMSProducer { final Object v = entry.getValue(); if (v instanceof String) { message.setString(name, (String) v); - } - else if (v instanceof Long) { + } else if (v instanceof Long) { message.setLong(name, (Long) v); - } - else if (v instanceof Double) { + } else if (v instanceof Double) { message.setDouble(name, (Double) v); - } - else if (v instanceof Integer) { + } else if (v instanceof Integer) { message.setInt(name, (Integer) v); - } - else if (v instanceof Character) { + } else if (v instanceof Character) { message.setChar(name, (Character) v); - } - else if (v instanceof Short) { + } else if (v instanceof Short) { message.setShort(name, (Short) v); - } - else if (v instanceof Boolean) { + } else if (v instanceof Boolean) { message.setBoolean(name, (Boolean) v); - } - else if (v instanceof Float) { + } else if (v instanceof Float) { message.setFloat(name, (Float) v); - } - else if (v instanceof Byte) { + } else if (v instanceof Byte) { message.setByte(name, (Byte) v); - } - else if (v instanceof byte[]) { + } else if (v instanceof byte[]) { byte[] array = (byte[]) v; message.setBytes(name, array, 0, array.length); - } - else { + } else { message.setObject(name, v); } } - } - catch (JMSException e) { + } catch (JMSException e) { throw new MessageFormatRuntimeException(e.getMessage()); } } @@ -182,8 +169,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { if (body != null) { try { message.writeBytes(body); - } - catch (JMSException e) { + } catch (JMSException e) { throw new MessageFormatRuntimeException(e.getMessage()); } } @@ -202,8 +188,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public JMSProducer setDisableMessageID(boolean value) { try { producer.setDisableMessageID(value); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } return this; @@ -213,8 +198,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public boolean getDisableMessageID() { try { return producer.getDisableMessageID(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -223,8 +207,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public JMSProducer setDisableMessageTimestamp(boolean value) { try { producer.setDisableMessageTimestamp(value); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } return this; @@ -234,8 +217,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public boolean getDisableMessageTimestamp() { try { return producer.getDisableMessageTimestamp(); - } - catch (JMSException e) { + } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } } @@ -244,8 +226,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public JMSProducer setDeliveryMode(int deliveryMode) { try { producer.setDeliveryMode(deliveryMode); - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -257,8 +238,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public int getDeliveryMode() { try { return producer.getDeliveryMode(); - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -269,8 +249,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public JMSProducer setPriority(int priority) { try { producer.setPriority(priority); - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -282,8 +261,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public int getPriority() { try { return producer.getPriority(); - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -295,8 +273,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { try { producer.setTimeToLive(timeToLive); return this; - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -309,8 +286,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { try { timeToLive = producer.getTimeToLive(); return timeToLive; - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -322,8 +298,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { try { producer.setDeliveryDelay(deliveryDelay); return this; - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -335,8 +310,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { long deliveryDelay = 0; try { deliveryDelay = producer.getDeliveryDelay(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } return deliveryDelay; } @@ -415,11 +389,9 @@ public final class ActiveMQJMSProducer implements JMSProducer { checkName(name); try { TypedProperties.setObjectProperty(new SimpleString(name), value, properties); - } - catch (ActiveMQPropertyConversionException amqe) { + } catch (ActiveMQPropertyConversionException amqe) { throw new MessageFormatRuntimeException(amqe.getMessage()); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } return this; @@ -430,8 +402,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { try { stringPropertyNames.clear(); properties.clear(); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } return this; @@ -446,11 +417,9 @@ public final class ActiveMQJMSProducer implements JMSProducer { public boolean getBooleanProperty(String name) { try { return properties.getBooleanProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } } @@ -459,8 +428,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public byte getByteProperty(String name) { try { return properties.getByteProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -469,8 +437,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public short getShortProperty(String name) { try { return properties.getShortProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -479,8 +446,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public int getIntProperty(String name) { try { return properties.getIntProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -489,8 +455,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public long getLongProperty(String name) { try { return properties.getLongProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -499,8 +464,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public float getFloatProperty(String name) { try { return properties.getFloatProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -509,8 +473,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { public double getDoubleProperty(String name) { try { return properties.getDoubleProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); } } @@ -522,11 +485,9 @@ public final class ActiveMQJMSProducer implements JMSProducer { if (prop == null) return null; return prop.toString(); - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } } @@ -540,11 +501,9 @@ public final class ActiveMQJMSProducer implements JMSProducer { property = property.toString(); } return property; - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } } @@ -559,11 +518,9 @@ public final class ActiveMQJMSProducer implements JMSProducer { propNames.add(str.toString()); } return propNames; - } - catch (ActiveMQPropertyConversionException ce) { + } catch (ActiveMQPropertyConversionException ce) { throw new MessageFormatRuntimeException(ce.getMessage()); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw new JMSRuntimeException(e.getMessage()); } } @@ -637,8 +594,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { context.getThreadAwareContext().setCurrentThread(true); try { wrapped.onCompletion(message); - } - finally { + } finally { context.getThreadAwareContext().clearCurrentThread(true); } } @@ -648,8 +604,7 @@ public final class ActiveMQJMSProducer implements JMSProducer { context.getThreadAwareContext().setCurrentThread(true); try { wrapped.onException(message, exception); - } - finally { + } finally { context.getThreadAwareContext().clearCurrentThread(true); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java index a80d550f7b..a69061e92e 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java @@ -32,8 +32,8 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.utils.TypedProperties; -import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap; import static org.apache.activemq.artemis.reader.MapMessageUtil.readBodyMap; +import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap; /** * ActiveMQ Artemis implementation of a JMS MapMessage. @@ -187,8 +187,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess checkName(name); try { TypedProperties.setObjectProperty(new SimpleString(name), value, map); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } invalid = true; @@ -198,8 +197,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public boolean getBoolean(final String name) throws JMSException { try { return map.getBooleanProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -208,8 +206,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public byte getByte(final String name) throws JMSException { try { return map.getByteProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -218,8 +215,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public short getShort(final String name) throws JMSException { try { return map.getShortProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -228,8 +224,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public char getChar(final String name) throws JMSException { try { return map.getCharProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -238,8 +233,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public int getInt(final String name) throws JMSException { try { return map.getIntProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -248,8 +242,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public long getLong(final String name) throws JMSException { try { return map.getLongProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -258,8 +251,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public float getFloat(final String name) throws JMSException { try { return map.getFloatProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -268,8 +260,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public double getDouble(final String name) throws JMSException { try { return map.getDoubleProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -280,12 +271,10 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess SimpleString str = map.getSimpleStringProperty(new SimpleString(name)); if (str == null) { return null; - } - else { + } else { return str.toString(); } - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -294,8 +283,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess public byte[] getBytes(final String name) throws JMSException { try { return map.getBytesProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java index 78acdb78e5..12b129659d 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java @@ -77,16 +77,13 @@ public class ActiveMQMessage implements javax.jms.Message { entry.getKey().equals("timestamp") || entry.getKey().equals("priority")) { // Ignore - } - else if (entry.getKey().equals("userID")) { + } else if (entry.getKey().equals("userID")) { jmsMessage.put("JMSMessageID", entry.getValue().toString()); - } - else { + } else { Object value = entry.getValue(); if (value instanceof SimpleString) { jmsMessage.put(entry.getKey(), value.toString()); - } - else { + } else { jmsMessage.put(entry.getKey(), value); } } @@ -95,8 +92,6 @@ public class ActiveMQMessage implements javax.jms.Message { return jmsMessage; } - - public static CompositeData coreCompositeTypeToJMSCompositeType(CompositeDataSupport data) throws Exception { CompositeData jmsdata = new CompositeDataSupport(data.getCompositeType(), new HashMap()); return jmsdata; @@ -124,7 +119,9 @@ public class ActiveMQMessage implements javax.jms.Message { return createMessage(message, session, null); } - public static ActiveMQMessage createMessage(final ClientMessage message, final ClientSession session, final ConnectionFactoryOptions options) { + public static ActiveMQMessage createMessage(final ClientMessage message, + final ClientSession session, + final ConnectionFactoryOptions options) { int type = message.getType(); ActiveMQMessage msg; @@ -248,16 +245,14 @@ public class ActiveMQMessage implements javax.jms.Message { try { byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes(); setJMSCorrelationIDAsBytes(corrIDBytes); - } - catch (JMSException e) { + } catch (JMSException e) { // specified as String String corrIDString = foreign.getJMSCorrelationID(); if (corrIDString != null) { setJMSCorrelationID(corrIDString); } } - } - else { + } else { // Some providers, like WSMQ do automatic conversions between native byte[] correlation id // and String correlation id. This makes it impossible for ActiveMQ Artemis to guarantee to return the correct // type as set by the user @@ -329,8 +324,7 @@ public class ActiveMQMessage implements javax.jms.Message { public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException { try { MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { JMSException ex = new JMSException(e.getMessage()); ex.initCause(e); throw ex; @@ -371,8 +365,7 @@ public class ActiveMQMessage implements javax.jms.Message { if (dest == null) { MessageUtil.setJMSReplyTo(message, null); replyTo = null; - } - else { + } else { if (dest instanceof ActiveMQDestination == false) { throw new InvalidDestinationException("Foreign destination " + dest); } @@ -410,11 +403,9 @@ public class ActiveMQMessage implements javax.jms.Message { public void setJMSDeliveryMode(final int deliveryMode) throws JMSException { if (deliveryMode == DeliveryMode.PERSISTENT) { message.setDurable(true); - } - else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { + } else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { message.setDurable(false); - } - else { + } else { throw ActiveMQJMSClientBundle.BUNDLE.illegalDeliveryMode(deliveryMode); } } @@ -428,12 +419,10 @@ public class ActiveMQMessage implements javax.jms.Message { public void setJMSRedelivered(final boolean redelivered) throws JMSException { if (!redelivered) { message.setDeliveryCount(1); - } - else { + } else { if (message.getDeliveryCount() > 1) { // do nothing - } - else { + } else { message.setDeliveryCount(2); } } @@ -500,8 +489,7 @@ public class ActiveMQMessage implements javax.jms.Message { public boolean getBooleanProperty(final String name) throws JMSException { try { return message.getBooleanProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -510,8 +498,7 @@ public class ActiveMQMessage implements javax.jms.Message { public byte getByteProperty(final String name) throws JMSException { try { return message.getByteProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -520,8 +507,7 @@ public class ActiveMQMessage implements javax.jms.Message { public short getShortProperty(final String name) throws JMSException { try { return message.getShortProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -534,8 +520,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { return message.getIntProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -548,8 +533,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { return message.getLongProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -558,8 +542,7 @@ public class ActiveMQMessage implements javax.jms.Message { public float getFloatProperty(final String name) throws JMSException { try { return message.getFloatProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -568,8 +551,7 @@ public class ActiveMQMessage implements javax.jms.Message { public double getDoubleProperty(final String name) throws JMSException { try { return message.getDoubleProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -583,15 +565,12 @@ public class ActiveMQMessage implements javax.jms.Message { try { if (MessageUtil.JMSXGROUPID.equals(name)) { return message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID); - } - else if (MessageUtil.JMSXUSERID.equals(name)) { + } else if (MessageUtil.JMSXUSERID.equals(name)) { return message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_VALIDATED_USER); - } - else { + } else { return message.getStringProperty(new SimpleString(name)); } - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -663,11 +642,9 @@ public class ActiveMQMessage implements javax.jms.Message { if (handleCoreProperty(name, value, MessageUtil.JMSXGROUPID, org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID)) { return; - } - else if (handleCoreProperty(name, value, MessageUtil.JMSXUSERID, org.apache.activemq.artemis.api.core.Message.HDR_VALIDATED_USER)) { + } else if (handleCoreProperty(name, value, MessageUtil.JMSXUSERID, org.apache.activemq.artemis.api.core.Message.HDR_VALIDATED_USER)) { return; - } - else { + } else { message.putStringProperty(new SimpleString(name), SimpleString.toSimpleString(value)); } } @@ -686,8 +663,7 @@ public class ActiveMQMessage implements javax.jms.Message { setOutputStream((OutputStream) value); return; - } - else if (ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM.equals(name)) { + } else if (ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM.equals(name)) { saveToOutputStream((OutputStream) value); return; @@ -703,8 +679,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { message.putObjectProperty(new SimpleString(name), value); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -718,8 +693,7 @@ public class ActiveMQMessage implements javax.jms.Message { } session.commit(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -730,15 +704,13 @@ public class ActiveMQMessage implements javax.jms.Message { Long value; try { value = message.getLongProperty(org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME); - } - catch (Exception e) { + } catch (Exception e) { return 0; } if (value == null) { return 0; - } - else { + } else { return value.longValue(); } } @@ -763,8 +735,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { ObjectInputStream ois = new ObjectInputStream(is); return (T) ois.readObject(); - } - catch (Exception e) { + } catch (Exception e) { throw new MessageFormatException(e.getMessage()); } } @@ -842,8 +813,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { message.setOutputStream(output); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -856,8 +826,7 @@ public class ActiveMQMessage implements javax.jms.Message { try { message.saveToOutputStream(output); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -866,8 +835,7 @@ public class ActiveMQMessage implements javax.jms.Message { checkStream(); try { return message.waitOutputStreamCompletion(timeWait); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -913,8 +881,7 @@ public class ActiveMQMessage implements javax.jms.Message { " or " + ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM + "?"); - } - else { + } else { throw ActiveMQJMSClientBundle.BUNDLE.messageNotWritable(); } } @@ -966,7 +933,10 @@ public class ActiveMQMessage implements javax.jms.Message { } } - private boolean handleCoreProperty(final String name, final Object value, String jmsPropertyName, SimpleString corePropertyName) { + private boolean handleCoreProperty(final String name, + final Object value, + String jmsPropertyName, + SimpleString corePropertyName) { boolean result = false; if (jmsPropertyName.equals(name)) { diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java index 5fbf4489b1..8bc1fd8181 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java @@ -117,8 +117,7 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr try { consumer.setMessageHandler(coreListener); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -149,8 +148,7 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr } session.removeConsumer(this); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -209,8 +207,7 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr if (noWait) { coreMessage = consumer.receiveImmediate(); - } - else { + } else { coreMessage = consumer.receive(timeout); } @@ -219,15 +216,14 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr if (coreMessage != null) { ClientSession coreSession = session.getCoreSession(); boolean needSession = ackMode == Session.CLIENT_ACKNOWLEDGE || - ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || - coreMessage.getType() == ActiveMQObjectMessage.TYPE; + ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || + coreMessage.getType() == ActiveMQObjectMessage.TYPE; jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); try { jmsMsg.doBeforeReceive(); - } - catch (IndexOutOfBoundsException ioob) { - ((ClientSessionInternal)session.getCoreSession()).markRollbackOnly(); + } catch (IndexOutOfBoundsException ioob) { + ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); // In case this exception happen you will need to know where it happened. // it has been a bug here in the past, and this was used to debug it. // nothing better than keep it for future investigations in case it happened again @@ -241,20 +237,17 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr // https://issues.jboss.org/browse/JBPAPP-6110 if (session.getAcknowledgeMode() == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) { jmsMsg.setIndividualAcknowledge(); - } - else { + } else { coreMessage.acknowledge(); } } return jmsMsg; - } - catch (ActiveMQException e) { - ((ClientSessionInternal)session.getCoreSession()).markRollbackOnly(); + } catch (ActiveMQException e) { + ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); throw JMSExceptionHelper.convertFromActiveMQException(e); - } - catch (ActiveMQInterruptedException e) { - ((ClientSessionInternal)session.getCoreSession()).markRollbackOnly(); + } catch (ActiveMQInterruptedException e) { + ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); throw JMSExceptionHelper.convertFromActiveMQException(e); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java index 8a47e8c3cf..270cc9f59b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java @@ -178,8 +178,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To connection.getThreadAwareContext().assertNotCompletionListenerThread(); try { clientProducer.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -373,15 +372,13 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To if (timeToLive == 0) { jmsMessage.setJMSExpiration(0); - } - else { + } else { jmsMessage.setJMSExpiration(System.currentTimeMillis() + timeToLive); } if (!disableMessageTimestamp) { jmsMessage.setJMSTimestamp(System.currentTimeMillis()); - } - else { + } else { jmsMessage.setJMSTimestamp(0); } @@ -393,8 +390,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To } destination = defaultDestination; - } - else { + } else { if (defaultDestination != null) { if (!destination.equals(defaultDestination)) { throw new UnsupportedOperationException("Where a default destination is specified " + "for the sender and a destination is " + "specified in the arguments to the send, " + "these destinations must be equal"); @@ -411,12 +407,10 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To // as that's a more efficient path for such operation if (!query.isExists() && ((address.toString().startsWith(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX) && !query.isAutoCreateJmsQueues()) || (address.toString().startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX) && !query.isAutoCreateJmsTopics()))) { throw new InvalidDestinationException("Destination " + address + " does not exist"); - } - else { + } else { connection.addKnownDestination(address); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -433,20 +427,15 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To if (jmsMessage instanceof BytesMessage) { activeMQJmsMessage = new ActiveMQBytesMessage((BytesMessage) jmsMessage, clientSession); - } - else if (jmsMessage instanceof MapMessage) { + } else if (jmsMessage instanceof MapMessage) { activeMQJmsMessage = new ActiveMQMapMessage((MapMessage) jmsMessage, clientSession); - } - else if (jmsMessage instanceof ObjectMessage) { + } else if (jmsMessage instanceof ObjectMessage) { activeMQJmsMessage = new ActiveMQObjectMessage((ObjectMessage) jmsMessage, clientSession, options); - } - else if (jmsMessage instanceof StreamMessage) { + } else if (jmsMessage instanceof StreamMessage) { activeMQJmsMessage = new ActiveMQStreamMessage((StreamMessage) jmsMessage, clientSession); - } - else if (jmsMessage instanceof TextMessage) { + } else if (jmsMessage instanceof TextMessage) { activeMQJmsMessage = new ActiveMQTextMessage((TextMessage) jmsMessage, clientSession); - } - else { + } else { activeMQJmsMessage = new ActiveMQMessage(jmsMessage, clientSession); } @@ -454,8 +443,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To jmsMessage.setJMSDestination(destination); foreign = true; - } - else { + } else { activeMQJmsMessage = (ActiveMQMessage) jmsMessage; } @@ -477,8 +465,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To try { activeMQJmsMessage.doBeforeSend(); - } - catch (Exception e) { + } catch (Exception e) { JMSException je = new JMSException(e.getMessage()); je.initCause(e); @@ -500,20 +487,16 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To */ if (completionListener != null) { clientProducer.send(address, coreMessage, new CompletionListenerWrapper(completionListener, jmsMessage, this)); - } - else { + } else { clientProducer.send(address, coreMessage); } - } - catch (ActiveMQInterruptedException e) { + } catch (ActiveMQInterruptedException e) { JMSException jmsException = new JMSException(e.getMessage()); jmsException.initCause(e); throw jmsException; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { JMSException je = new IllegalStateException(e.getMessage()); je.setStackTrace(e.getStackTrace()); je.initCause(e); @@ -550,16 +533,14 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To if (jmsMessage instanceof StreamMessage) { try { ((StreamMessage) jmsMessage).reset(); - } - catch (JMSException e) { + } catch (JMSException e) { // HORNETQ-1209 XXX ignore? } } if (jmsMessage instanceof BytesMessage) { try { ((BytesMessage) jmsMessage).reset(); - } - catch (JMSException e) { + } catch (JMSException e) { // HORNETQ-1209 XXX ignore? } } @@ -567,8 +548,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To try { producer.connection.getThreadAwareContext().setCurrentThread(true); completionListener.onCompletion(jmsMessage); - } - finally { + } finally { producer.connection.getThreadAwareContext().clearCurrentThread(true); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java index a149dbd024..173f29d457 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java @@ -58,7 +58,9 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess this.options = options; } - protected ActiveMQObjectMessage(final ClientMessage message, final ClientSession session, ConnectionFactoryOptions options) { + protected ActiveMQObjectMessage(final ClientMessage message, + final ClientSession session, + ConnectionFactoryOptions options) { super(message, session); this.options = options; } @@ -66,7 +68,9 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess /** * A copy constructor for foreign JMS ObjectMessages. */ - public ActiveMQObjectMessage(final ObjectMessage foreign, final ClientSession session, ConnectionFactoryOptions options) throws JMSException { + public ActiveMQObjectMessage(final ObjectMessage foreign, + final ClientSession session, + ConnectionFactoryOptions options) throws JMSException { super(foreign, ActiveMQObjectMessage.TYPE, session); setObject(foreign.getObject()); @@ -98,8 +102,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess int len = message.getBodyBuffer().readInt(); data = new byte[len]; message.getBodyBuffer().readBytes(data); - } - catch (Exception e) { + } catch (Exception e) { data = null; } @@ -122,8 +125,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess oos.flush(); data = baos.toByteArray(); - } - catch (Exception e) { + } catch (Exception e) { JMSException je = new JMSException("Failed to serialize object"); je.setLinkedException(e); je.initCause(e); @@ -150,8 +152,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess } Serializable object = (Serializable) ois.readObject(); return object; - } - catch (Exception e) { + } catch (Exception e) { JMSException je = new JMSException(e.getMessage()); je.setStackTrace(e.getStackTrace()); throw je; @@ -169,8 +170,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess protected T getBodyInternal(Class c) throws MessageFormatException { try { return (T) getObject(); - } - catch (JMSException e) { + } catch (JMSException e) { throw new MessageFormatException("Deserialization error on ActiveMQObjectMessage"); } } @@ -181,8 +181,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess return true; try { return Serializable.class == c || Object.class == c || c.isInstance(getObject()); - } - catch (JMSException e) { + } catch (JMSException e) { return false; } } @@ -190,8 +189,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess private String getDeserializationBlackList() { if (options == null) { return null; - } - else { + } else { return options.getDeserializationBlackList(); } } @@ -199,8 +197,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess private String getDeserializationWhiteList() { if (options == null) { return null; - } - else { + } else { return options.getDeserializationWhiteList(); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java index adb22192ef..bb58f3dde6 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.jms.client; -import java.util.Enumeration; -import java.util.NoSuchElementException; - import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueBrowser; +import java.util.Enumeration; +import java.util.NoSuchElementException; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -71,8 +70,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { if (consumer != null) { try { consumer.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -86,8 +84,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { consumer = session.createConsumer(queue.getSimpleAddress(), filterString, true); return new BrowserEnumeration(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } @@ -127,8 +124,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { if (current == null) { try { current = consumer.receiveImmediate(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { return false; } } @@ -144,15 +140,13 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { msg = ActiveMQMessage.createMessage(next, session, options); try { msg.doBeforeReceive(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(msg.getCoreMessage().toString(), e); return null; } return msg; - } - else { + } else { throw new NoSuchElementException(); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java index 3ba2945d11..47d151225f 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.jms.client; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - import javax.jms.BytesMessage; import javax.jms.Destination; import javax.jms.IllegalStateException; @@ -48,17 +43,21 @@ import javax.jms.TopicSession; import javax.jms.TopicSubscriber; import javax.jms.TransactionInProgressException; import javax.transaction.xa.XAResource; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; -import org.apache.activemq.artemis.selector.filter.FilterException; -import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery; import org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery; +import org.apache.activemq.artemis.selector.filter.FilterException; +import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.activemq.artemis.utils.SelectorTranslator; /** @@ -217,8 +216,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { } try { session.commit(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -234,8 +232,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { try { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -253,8 +250,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { session.close(); connection.removeSession(this); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -268,8 +264,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { try { session.rollback(true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } @@ -314,8 +309,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { ClientProducer producer = session.createProducer(jbd == null ? null : jbd.getSimpleAddress()); return new ActiveMQMessageProducer(connection, producer, jbd, session, options); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -369,12 +363,10 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (queue == null) { throw new JMSException("There is no queue with name " + queueName); - } - else { + } else { return queue; } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -395,12 +387,10 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (topic == null) { throw new JMSException("There is no topic with name " + topicName); - } - else { + } else { return topic; } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -470,8 +460,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { ActiveMQTopic localTopic; if (topic instanceof ActiveMQTopic) { localTopic = (ActiveMQTopic) topic; - } - else { + } else { localTopic = new ActiveMQTopic(topic.getTopicName()); } return internalCreateSharedConsumer(localTopic, name, messageSelector, ConsumerDurability.NON_DURABLE); @@ -494,8 +483,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { ActiveMQTopic localTopic; if (topic instanceof ActiveMQTopic) { localTopic = (ActiveMQTopic) topic; - } - else { + } else { localTopic = new ActiveMQTopic(topic.getTopicName()); } return createConsumer(localTopic, name, messageSelector, noLocal, ConsumerDurability.DURABLE); @@ -520,8 +508,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (topic instanceof ActiveMQTopic) { localTopic = (ActiveMQTopic) topic; - } - else { + } else { localTopic = new ActiveMQTopic(topic.getTopicName()); } return internalCreateSharedConsumer(localTopic, name, messageSelector, ConsumerDurability.DURABLE); @@ -587,14 +574,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (durability == ConsumerDurability.DURABLE) { try { session.createSharedQueue(dest.getSimpleAddress(), queueName, coreFilterString, true); - } - catch (ActiveMQQueueExistsException ignored) { + } catch (ActiveMQQueueExistsException ignored) { // We ignore this because querying and then creating the queue wouldn't be idempotent // we could also add a parameter to ignore existence what would require a bigger work around to avoid // compatibility. } - } - else { + } else { session.createSharedQueue(dest.getSimpleAddress(), queueName, coreFilterString, false); } @@ -605,8 +590,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { consumers.add(jbc); return jbc; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -626,15 +610,13 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (connection.getClientID() != null) { filter = ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString() + "<>'" + connection.getClientID() + "'"; - } - else { + } else { filter = ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString() + "<>'" + connection.getUID() + "'"; } if (selectorString != null) { selectorString += " AND " + filter; - } - else { + } else { selectorString = filter; } } @@ -659,8 +641,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!response.isExists() || !response.getQueueNames().contains(dest.getSimpleAddress())) { if (response.isAutoCreateJmsQueues()) { session.createQueue(dest.getSimpleAddress(), dest.getSimpleAddress(), true); - } - else { + } else { throw new InvalidDestinationException("Destination " + dest.getName() + " does not exist"); } } @@ -668,8 +649,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { connection.addKnownDestination(dest.getSimpleAddress()); consumer = session.createConsumer(dest.getSimpleAddress(), coreFilterString, false); - } - else { + } else { AddressQuery response = session.addressQuery(dest.getSimpleAddress()); if (!response.isExists() && !response.isAutoCreateJmsTopics()) { @@ -692,8 +672,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { consumer = session.createConsumer(queueName, null, false); autoDeleteQueueName = queueName; - } - else { + } else { // Durable sub if (durability != ConsumerDurability.DURABLE) throw new RuntimeException("Subscription name must be null for non-durable topic consumer"); @@ -711,8 +690,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!subResponse.isExists()) { session.createQueue(dest.getSimpleAddress(), queueName, coreFilterString, true); - } - else { + } else { // Already exists if (subResponse.getConsumerCount() > 0) { throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)"); @@ -757,8 +735,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { consumers.add(jbc); return jbc; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -793,8 +770,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (filterString != null) { SelectorParser.parse(filterString.trim()); } - } - catch (FilterException e) { + } catch (FilterException e) { throw JMSExceptionHelper.convertFromActiveMQException(ActiveMQJMSClientBundle.BUNDLE.invalidFilter(e, new SimpleString(filterString))); } @@ -809,13 +785,11 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!response.isExists()) { if (response.isAutoCreateJmsQueues()) { session.createQueue(jbq.getSimpleAddress(), jbq.getSimpleAddress(), true); - } - else { + } else { throw new InvalidDestinationException("Destination " + jbq.getName() + " does not exist"); } } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } @@ -840,8 +814,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { connection.addTemporaryQueue(simpleAddress); return queue; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -868,8 +841,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { connection.addTemporaryQueue(simpleAddress); return topic; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -897,8 +869,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { } session.deleteQueue(queueName); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -1007,8 +978,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { session.deleteQueue(address); connection.removeTemporaryQueue(address); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -1035,8 +1005,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { session.deleteQueue(address); connection.removeTemporaryQueue(address); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -1044,8 +1013,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { public void start() throws JMSException { try { session.start(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -1053,8 +1021,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { public void stop() throws JMSException { try { session.stop(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } } @@ -1069,8 +1036,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!session.isClosed()) { try { session.deleteQueue(queueName); - } - catch (ActiveMQException ignore) { + } catch (ActiveMQException ignore) { // Exception on deleting queue shouldn't prevent close from completing } } @@ -1091,8 +1057,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (isTemporary) { queue = ActiveMQDestination.createTemporaryQueue(queueName); - } - else { + } else { queue = ActiveMQDestination.createQueue(queueName); } @@ -1100,8 +1065,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!response.isExists() && !response.isAutoCreateJmsQueues()) { return null; - } - else { + } else { return queue; } } @@ -1112,8 +1076,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (isTemporary) { topic = ActiveMQDestination.createTemporaryTopic(topicName); - } - else { + } else { topic = ActiveMQDestination.createTopic(topicName); } @@ -1121,8 +1084,7 @@ public class ActiveMQSession implements QueueSession, TopicSession { if (!query.isExists() && !query.isAutoCreateJmsTopics()) { return null; - } - else { + } else { return topic; } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java index 1c7772cc6b..2762a9c8e7 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java @@ -66,8 +66,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre Object obj = foreign.readObject(); writeObject(obj); } - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // Ignore } } @@ -91,11 +90,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadBoolean(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -106,11 +103,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre try { return streamReadByte(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -120,11 +115,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadShort(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -134,11 +127,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadChar(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -148,11 +139,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadInteger(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -162,11 +151,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadLong(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -176,11 +163,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadFloat(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -190,11 +175,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadDouble(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -204,11 +187,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadString(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -226,11 +207,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre len = pairRead.getA(); return pairRead.getB(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -240,11 +219,9 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre checkRead(); try { return streamReadObject(message.getBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -332,38 +309,27 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre public void writeObject(final Object value) throws JMSException { if (value instanceof String) { writeString((String) value); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { writeBoolean((Boolean) value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { writeByte((Byte) value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { writeShort((Short) value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { writeInt((Integer) value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { writeLong((Long) value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { writeFloat((Float) value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { writeDouble((Double) value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { writeBytes((byte[]) value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { writeChar((Character) value); - } - else if (value == null) { + } else if (value == null) { writeString(null); - } - else { + } else { throw new MessageFormatException("Invalid object type: " + value.getClass()); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTextMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTextMessage.java index bb28604351..1406b4c93b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTextMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQTextMessage.java @@ -80,8 +80,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage if (text != null) { this.text = new SimpleString(text); - } - else { + } else { this.text = null; } @@ -92,8 +91,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage public String getText() { if (text != null) { return text.toString(); - } - else { + } else { return null; } } @@ -126,4 +124,4 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage return true; return c.isAssignableFrom(java.lang.String.class); } -} \ No newline at end of file +} diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ConnectionFactoryOptions.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ConnectionFactoryOptions.java index 2f27b15057..bf95c0f08c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ConnectionFactoryOptions.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ConnectionFactoryOptions.java @@ -17,9 +17,10 @@ package org.apache.activemq.artemis.jms.client; - -/** Common interface to be used to share common parameters between the RA and client JMS. - * Initially developed to carry on Serialization packages white list but it could eventually be expanded. */ +/** + * Common interface to be used to share common parameters between the RA and client JMS. + * Initially developed to carry on Serialization packages white list but it could eventually be expanded. + */ public interface ConnectionFactoryOptions { String getDeserializationBlackList(); diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java index 91ea34f568..92ae226e6a 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java @@ -76,8 +76,7 @@ public class JMSMessageListenerWrapper implements MessageHandler { try { msg.doBeforeReceive(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorPreparingMessageForReceipt(msg.getCoreMessage().toString(), e); return; @@ -86,9 +85,8 @@ public class JMSMessageListenerWrapper implements MessageHandler { if (transactedOrClientAck) { try { message.acknowledge(); - } - catch (ActiveMQException e) { - ((ClientSessionInternal)session.getCoreSession()).markRollbackOnly(); + } catch (ActiveMQException e) { + ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); ActiveMQJMSClientLogger.LOGGER.errorProcessingMessage(e); } } @@ -96,8 +94,7 @@ public class JMSMessageListenerWrapper implements MessageHandler { try { connection.getThreadAwareContext().setCurrentThread(false); listener.onMessage(msg); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { // See JMS 1.1 spec, section 4.5.2 ActiveMQJMSClientLogger.LOGGER.onMessageError(e); @@ -111,13 +108,11 @@ public class JMSMessageListenerWrapper implements MessageHandler { session.getCoreSession().rollback(true); session.setRecoverCalled(true); - } - catch (Exception e2) { + } catch (Exception e2) { ActiveMQJMSClientLogger.LOGGER.errorRecoveringSession(e2); } } - } - finally { + } finally { connection.getThreadAwareContext().clearCurrentThread(false); } if (!session.isRecoverCalled() && !individualACK) { @@ -126,9 +121,8 @@ public class JMSMessageListenerWrapper implements MessageHandler { if (!consumer.isClosed() && !transactedOrClientAck) { message.acknowledge(); } - } - catch (ActiveMQException e) { - ((ClientSessionInternal)session.getCoreSession()).markRollbackOnly(); + } catch (ActiveMQException e) { + ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); ActiveMQJMSClientLogger.LOGGER.errorProcessingMessage(e); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java index 7bdf35cb8b..c74264f2fc 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.jms.client; -import org.apache.activemq.artemis.utils.ConcurrentHashSet; - import javax.jms.IllegalStateException; import java.util.Set; +import org.apache.activemq.artemis.utils.ConcurrentHashSet; + /** * Restricts what can be called on context passed in wrapped CompletionListener. */ @@ -53,8 +53,7 @@ public class ThreadAwareContext { public void setCurrentThread(boolean isCompletionListener) { if (isCompletionListener) { completionListenerThread = Thread.currentThread(); - } - else { + } else { messageListenerThreads.add(Thread.currentThread().getId()); } } @@ -68,8 +67,7 @@ public class ThreadAwareContext { public void clearCurrentThread(boolean isCompletionListener) { if (isCompletionListener) { completionListenerThread = null; - } - else { + } else { messageListenerThreads.remove(Thread.currentThread().getId()); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java index 3443bf1dae..ad125f06cb 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.jms.referenceable; -import java.util.Hashtable; - import javax.naming.Context; import javax.naming.Name; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; +import java.util.Hashtable; /** * A ConnectionFactoryObjectFactory. diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java index a2c83335b6..896e81561f 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.jms.referenceable; -import java.util.Hashtable; - import javax.naming.Context; import javax.naming.Name; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; +import java.util.Hashtable; /** * A DestinationObjectFactory. diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java index a6e227fdc4..09c971d5c1 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.jms.referenceable; +import javax.naming.NamingException; +import javax.naming.RefAddr; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import javax.naming.NamingException; -import javax.naming.RefAddr; - /** * A SerializableObjectRefAddr. * @@ -52,8 +51,7 @@ public class SerializableObjectRefAddr extends RefAddr { oos.flush(); bytes = bos.toByteArray(); - } - catch (IOException e) { + } catch (IOException e) { throw new NamingException("Failed to serialize object:" + content + ", " + e.getMessage()); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java index 8b5a431dfd..26641e9509 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java @@ -57,8 +57,7 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory { try { ConnectionFactory factory = createConnectionFactory((String) environment.get(key), jndiName); data.put(jndiName, factory); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new NamingException("Invalid broker URL"); } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java index ff2c62c0fa..52269d3dca 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java @@ -25,8 +25,7 @@ public abstract class LazyCreateContext extends ReadOnlyContext { public Object lookup(String name) throws NamingException { try { return super.lookup(name); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { Object answer = createEntry(name); if (answer == null) { throw e; diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java index f3873ef3a0..6ffeabd284 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.jndi; -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; import javax.naming.Binding; import javax.naming.CompositeName; import javax.naming.Context; @@ -36,6 +30,12 @@ import javax.naming.NotContextException; import javax.naming.OperationNotSupportedException; import javax.naming.Reference; import javax.naming.spi.NamingManager; +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; @@ -82,8 +82,7 @@ public class ReadOnlyContext implements Context, Serializable { public ReadOnlyContext(Hashtable env) { if (env == null) { this.environment = new Hashtable<>(); - } - else { + } else { this.environment = new Hashtable<>(env); } this.bindings = Collections.EMPTY_MAP; @@ -93,8 +92,7 @@ public class ReadOnlyContext implements Context, Serializable { public ReadOnlyContext(Hashtable environment, Map bindings) { if (environment == null) { this.environment = new Hashtable<>(); - } - else { + } else { this.environment = new Hashtable<>(environment); } this.bindings = new HashMap<>(); @@ -103,8 +101,7 @@ public class ReadOnlyContext implements Context, Serializable { for (Map.Entry binding : bindings.entrySet()) { try { internalBind(binding.getKey(), binding.getValue()); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e); } } @@ -163,8 +160,7 @@ public class ReadOnlyContext implements Context, Serializable { } bindings.put(name, value); newBindings.put(name, value); - } - else { + } else { String segment = name.substring(0, pos); assert segment != null; assert !segment.equals(""); @@ -174,8 +170,7 @@ public class ReadOnlyContext implements Context, Serializable { treeBindings.put(segment, o); bindings.put(segment, o); newBindings.put(segment, o); - } - else if (!(o instanceof ReadOnlyContext)) { + } else if (!(o instanceof ReadOnlyContext)) { throw new NamingException("Something already bound where a subcontext should go"); } ReadOnlyContext readOnlyContext = (ReadOnlyContext) o; @@ -228,22 +223,19 @@ public class ReadOnlyContext implements Context, Serializable { throw new NamingException("scheme " + scheme + " not recognized"); } return ctx.lookup(name); - } - else { + } else { // Split out the first name of the path // and look for it in the bindings map. CompositeName path = new CompositeName(name); if (path.size() == 0) { return this; - } - else { + } else { String first = path.get(0); Object obj = bindings.get(first); if (obj == null) { throw new NameNotFoundException(name); - } - else if (obj instanceof Context && path.size() > 1) { + } else if (obj instanceof Context && path.size() > 1) { Context subContext = (Context) obj; obj = subContext.lookup(path.getSuffix(1)); } @@ -258,11 +250,9 @@ public class ReadOnlyContext implements Context, Serializable { if (result instanceof Reference) { try { result = NamingManager.getObjectInstance(result, null, null, this.environment); - } - catch (NamingException e) { + } catch (NamingException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw (NamingException) new NamingException("could not look up : " + name).initCause(e); } } @@ -305,11 +295,9 @@ public class ReadOnlyContext implements Context, Serializable { Object o = lookup(name); if (o == this) { return new ListEnumeration(); - } - else if (o instanceof Context) { + } else if (o instanceof Context) { return ((Context) o).list(""); - } - else { + } else { throw new NotContextException(); } } @@ -319,11 +307,9 @@ public class ReadOnlyContext implements Context, Serializable { Object o = lookup(name); if (o == this) { return new ListBindingEnumeration(); - } - else if (o instanceof Context) { + } else if (o instanceof Context) { return ((Context) o).listBindings(""); - } - else { + } else { throw new NotContextException(); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java index 18b0111442..73e826a7cc 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java @@ -16,16 +16,16 @@ */ package org.apache.activemq.artemis.uri; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.uri.schema.serverLocator.InVMServerLocatorSchema; -import org.apache.activemq.artemis.uri.schema.connector.InVMTransportConfigurationSchema; -import org.apache.activemq.artemis.utils.uri.BeanSupport; -import org.apache.activemq.artemis.utils.uri.SchemaConstants; - import java.net.URI; import java.util.Map; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.uri.schema.connector.InVMTransportConfigurationSchema; +import org.apache.activemq.artemis.uri.schema.serverLocator.InVMServerLocatorSchema; +import org.apache.activemq.artemis.utils.uri.BeanSupport; +import org.apache.activemq.artemis.utils.uri.SchemaConstants; + public class InVMSchema extends AbstractCFSchema { @Override diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java index 1bc78c39aa..2d82018844 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java @@ -49,8 +49,7 @@ public class JGroupsSchema extends AbstractCFSchema { ActiveMQConnectionFactory factory; if (options.isHa()) { factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dcConfig, options.getFactoryTypeEnum()); - } - else { + } else { factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum()); } return BeanSupport.setData(uri, factory, query); @@ -63,11 +62,9 @@ public class JGroupsSchema extends AbstractCFSchema { String auth; if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) { auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName(); - } - else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) { + } else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) { auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName(); - } - else { + } else { throw new NotSerializableException(endpoint + "not serializable"); } String query = BeanSupport.getData(null, bean, dgc, endpoint); diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java index 92fb3b7686..86ca984098 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java @@ -48,12 +48,10 @@ public class JMSConnectionOptions extends ConnectionOptions { try { if (type == null) { return JMSFactoryType.CF; - } - else { + } else { return Enum.valueOf(JMSFactoryType.class, type); } - } - catch (Exception e) { + } catch (Exception e) { return null; } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java index a35026355b..8ea3cfc166 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.uri; +import java.net.URI; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema; import org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfigurationSchema; +import org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.apache.activemq.artemis.utils.uri.SchemaConstants; -import java.net.URI; -import java.util.List; -import java.util.Map; - public class TCPSchema extends AbstractCFSchema { @Override @@ -53,8 +53,7 @@ public class TCPSchema extends AbstractCFSchema { if (options.isHa()) { factory = ActiveMQJMSClient.createConnectionFactoryWithHA(options.getFactoryTypeEnum(), tcs); - } - else { + } else { factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs); } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java index 4a1e87b115..45f7ebfa76 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java @@ -46,8 +46,7 @@ public class UDPSchema extends AbstractCFSchema { ActiveMQConnectionFactory factory; if (options.isHa()) { factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dgc, options.getFactoryTypeEnum()); - } - else { + } else { factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, options.getFactoryTypeEnum()); } return BeanSupport.setData(uri, factory, query); diff --git a/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java index 201d90b134..dc2d459790 100644 --- a/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java +++ b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java @@ -90,19 +90,16 @@ public class ConnectionFactoryURITest { TransportConfiguration configuration = new TransportConfiguration(NettyConnector.class.getName(), params); - ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, configuration); URI uri = factory.toURI(); ActiveMQConnectionFactory newFactory = ActiveMQJMSClient.createConnectionFactory(uri.toString(), "somefactory"); - - TransportConfiguration[] initialConnectors = ((ServerLocatorImpl)newFactory.getServerLocator()).getInitialConnectors(); + TransportConfiguration[] initialConnectors = ((ServerLocatorImpl) newFactory.getServerLocator()).getInitialConnectors(); Assert.assertEquals(1, initialConnectors.length); - Assert.assertEquals(BROKEN_PROPERTY, initialConnectors[0].getParams().get(TransportConstants.LOCAL_ADDRESS_PROP_NAME).toString()); } @@ -117,8 +114,7 @@ public class ConnectionFactoryURITest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (ObjectOutputStream outStream = new ObjectOutputStream(baos)) { outStream.writeObject(factory); - } - finally { + } finally { baos.close(); } try (ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); @@ -418,18 +414,15 @@ public class ConnectionFactoryURITest { String value = RandomUtil.randomString(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == int.class) { + } else if (descriptor.getPropertyType() == int.class) { int value = RandomUtil.randomPositiveInt(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == long.class) { + } else if (descriptor.getPropertyType() == long.class) { long value = RandomUtil.randomPositiveLong(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == double.class) { + } else if (descriptor.getPropertyType() == double.class) { double value = RandomUtil.randomDouble(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/ActiveMQJMSBridgeLogger.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/ActiveMQJMSBridgeLogger.java index 1af1492612..8ddd8faecc 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/ActiveMQJMSBridgeLogger.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/ActiveMQJMSBridgeLogger.java @@ -49,7 +49,7 @@ public interface ActiveMQJMSBridgeLogger extends BasicLogger { @LogMessage(level = Logger.Level.INFO) @Message(id = 341000, value = "Failed to set up JMS bridge {1} connections. Most probably the source or target servers are unavailable." + " Will retry after a pause of {0} ms", format = Message.Format.MESSAGE_FORMAT) - void failedToSetUpBridge(long failureRetryInterval,String bridgeName); + void failedToSetUpBridge(long failureRetryInterval, String bridgeName); @LogMessage(level = Logger.Level.INFO) @Message(id = 341001, value = "JMS Bridge {0} succeeded in reconnecting to servers", format = Message.Format.MESSAGE_FORMAT) @@ -69,7 +69,7 @@ public interface ActiveMQJMSBridgeLogger extends BasicLogger { @LogMessage(level = Logger.Level.WARN) @Message(id = 342002, value = "Failed to unregisted JMS Bridge {0} - {1}", format = Message.Format.MESSAGE_FORMAT) - void errorUnregisteringBridge(ObjectName objectName,String bridgeName); + void errorUnregisteringBridge(ObjectName objectName, String bridgeName); @LogMessage(level = Logger.Level.WARN) @Message(id = 342003, value = "JMS Bridge {0} unable to set up connections, bridge will be stopped", format = Message.Format.MESSAGE_FORMAT) @@ -77,7 +77,7 @@ public interface ActiveMQJMSBridgeLogger extends BasicLogger { @LogMessage(level = Logger.Level.WARN) @Message(id = 342004, value = "JMS Bridge {1}, will retry after a pause of {0} ms", format = Message.Format.MESSAGE_FORMAT) - void bridgeRetry(long failureRetryInterval,String bridgeName); + void bridgeRetry(long failureRetryInterval, String bridgeName); @LogMessage(level = Logger.Level.WARN) @Message(id = 342005, value = "JMS Bridge {0} unable to set up connections, bridge will not be started", format = Message.Format.MESSAGE_FORMAT) @@ -85,21 +85,21 @@ public interface ActiveMQJMSBridgeLogger extends BasicLogger { @LogMessage(level = Logger.Level.WARN) @Message(id = 342006, value = "JMS Bridge {0}, detected failure on bridge connection", format = Message.Format.MESSAGE_FORMAT) - void bridgeFailure(@Cause Exception e,String bridgeName); + void bridgeFailure(@Cause Exception e, String bridgeName); @LogMessage(level = Logger.Level.WARN) @Message(id = 342009, value = "JMS Bridge {0} failed to send + acknowledge batch, closing JMS objects", format = Message.Format.MESSAGE_FORMAT) - void bridgeAckError(@Cause Exception e,String bridgeName); + void bridgeAckError(@Cause Exception e, String bridgeName); @LogMessage(level = Logger.Level.WARN) @Message(id = 342010, value = "Failed to connect JMS Bridge {0}", format = Message.Format.MESSAGE_FORMAT) - void bridgeConnectError(@Cause Exception e,String bridgeName); + void bridgeConnectError(@Cause Exception e, String bridgeName); @LogMessage(level = Logger.Level.ERROR) @Message(id = 344001, value = "JMS Bridge {0}, failed to start source connection", format = Message.Format.MESSAGE_FORMAT) - void jmsBridgeSrcConnectError(@Cause Exception e,String bridgeName); + void jmsBridgeSrcConnectError(@Cause Exception e, String bridgeName); @LogMessage(level = Logger.Level.ERROR) @Message(id = 344002, value = "Failed to start JMS Bridge {1}. QoS Mode: {0} requires a Transaction Manager, none found", format = Message.Format.MESSAGE_FORMAT) - void jmsBridgeTransactionManagerMissing(QualityOfServiceMode qosMode,String bridgeName); + void jmsBridgeTransactionManagerMissing(QualityOfServiceMode qosMode, String bridgeName); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java index b457831bbb..33e079922b 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.jms.bridge.impl; +import javax.management.StandardMBean; + import org.apache.activemq.artemis.jms.bridge.JMSBridge; import org.apache.activemq.artemis.jms.bridge.JMSBridgeControl; import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; -import javax.management.StandardMBean; - public class JMSBridgeControlImpl extends StandardMBean implements JMSBridgeControl { private final JMSBridge bridge; @@ -90,8 +90,7 @@ public class JMSBridgeControlImpl extends StandardMBean implements JMSBridgeCont QualityOfServiceMode mode = bridge.getQualityOfServiceMode(); if (mode != null) { return mode.name(); - } - else { + } else { return null; } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java index 339ebcff0c..e06231abba 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java @@ -16,28 +16,6 @@ */ package org.apache.activemq.artemis.jms.bridge.impl; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException; -import org.apache.activemq.artemis.api.core.client.FailoverEventListener; -import org.apache.activemq.artemis.api.core.client.FailoverEventType; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; -import org.apache.activemq.artemis.jms.bridge.ActiveMQJMSBridgeLogger; -import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; -import org.apache.activemq.artemis.jms.bridge.DestinationFactory; -import org.apache.activemq.artemis.jms.bridge.JMSBridge; -import org.apache.activemq.artemis.jms.bridge.JMSBridgeControl; -import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; -import org.apache.activemq.artemis.jms.client.ActiveMQConnection; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQMessage; -import org.apache.activemq.artemis.jms.server.ActiveMQJMSServerBundle; -import org.apache.activemq.artemis.service.extensions.ServiceUtils; -import org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQRegistry; -import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; -import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; -import org.apache.activemq.artemis.utils.PasswordMaskingUtil; -import org.apache.activemq.artemis.utils.SensitiveDataCodec; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -72,6 +50,28 @@ import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException; +import org.apache.activemq.artemis.api.core.client.FailoverEventListener; +import org.apache.activemq.artemis.api.core.client.FailoverEventType; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; +import org.apache.activemq.artemis.jms.bridge.ActiveMQJMSBridgeLogger; +import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; +import org.apache.activemq.artemis.jms.bridge.DestinationFactory; +import org.apache.activemq.artemis.jms.bridge.JMSBridge; +import org.apache.activemq.artemis.jms.bridge.JMSBridgeControl; +import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; +import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQMessage; +import org.apache.activemq.artemis.jms.server.ActiveMQJMSServerBundle; +import org.apache.activemq.artemis.service.extensions.ServiceUtils; +import org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQRegistry; +import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; +import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; +import org.apache.activemq.artemis.utils.PasswordMaskingUtil; +import org.apache.activemq.artemis.utils.SensitiveDataCodec; + public final class JMSBridgeImpl implements JMSBridge { private static final String[] RESOURCE_RECOVERY_CLASS_NAMES = new String[]{"org.jboss.as.messaging.jms.AS7RecoveryRegistry"}; @@ -308,12 +308,10 @@ public final class JMSBridgeImpl implements JMSBridge { StandardMBean mbean = new StandardMBean(controlBean, JMSBridgeControl.class); mbeanServer.registerMBean(mbean, this.objectName); ActiveMQJMSBridgeLogger.LOGGER.debug("Registered JMSBridge instance as: " + this.objectName.getCanonicalName()); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException("Failed to register JMSBridge MBean", e); } - } - else { + } else { throw new IllegalArgumentException("objectName is required when specifying an MBeanServer"); } } @@ -380,7 +378,7 @@ public final class JMSBridgeImpl implements JMSBridge { } if (tm == null) { - ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeTransactionManagerMissing(qualityOfServiceMode,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeTransactionManagerMissing(qualityOfServiceMode, bridgeName); throw new RuntimeException(); } @@ -391,14 +389,12 @@ public final class JMSBridgeImpl implements JMSBridge { toResume = tm.suspend(); ok = setupJMSObjects(); - } - finally { + } finally { if (toResume != null) { tm.resume(toResume); } } - } - else { + } else { ok = setupJMSObjects(); } @@ -406,8 +402,7 @@ public final class JMSBridgeImpl implements JMSBridge { connectedSource = true; connectedTarget = true; startSource(); - } - else { + } else { ActiveMQJMSBridgeLogger.LOGGER.errorStartingBridge(bridgeName); handleFailureOnStartup(); } @@ -459,8 +454,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (this.targetPassword != null) { targetPassword = codecInstance.decode(targetPassword); } - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQJMSServerBundle.BUNDLE.errorDecodingPassword(e); } @@ -506,8 +500,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { tx.rollback(); abortedMessageCount += messages.size(); - } - catch (Exception ignore) { + } catch (Exception ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to rollback", ignore); } @@ -520,8 +513,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { sourceConn.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to close source conn", ignore); } @@ -530,8 +522,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (targetConn != null) { try { targetConn.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to close target conn", ignore); } @@ -553,9 +544,8 @@ public final class JMSBridgeImpl implements JMSBridge { if (mbeanServer != null && objectName != null) { try { mbeanServer.unregisterMBean(objectName); - } - catch (Exception e) { - ActiveMQJMSBridgeLogger.LOGGER.errorUnregisteringBridge(objectName,bridgeName); + } catch (Exception e) { + ActiveMQJMSBridgeLogger.LOGGER.errorUnregisteringBridge(objectName, bridgeName); } } } @@ -908,8 +898,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { tx.delistResource(resSource, XAResource.TMSUCCESS); - } - catch (Exception e) { + } catch (Exception e) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to delist source resource", e); } @@ -919,8 +908,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { tx.delistResource(resDest, XAResource.TMSUCCESS); - } - catch (Exception e) { + } catch (Exception e) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to delist target resource", e); } @@ -984,22 +972,19 @@ public final class JMSBridgeImpl implements JMSBridge { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection"); } conn = ((XAConnectionFactory) cf).createXAConnection(); - } - else { + } else { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection"); } conn = ((ConnectionFactory) cf).createConnection(); } - } - else { + } else { if (isXA) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection"); } conn = ((XAConnectionFactory) cf).createXAConnection(username, password); - } - else { + } else { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection"); } @@ -1071,14 +1056,12 @@ public final class JMSBridgeImpl implements JMSBridge { // everything becomes once and only once forwardMode = JMSBridgeImpl.FORWARD_MODE_LOCALTX; - } - else { + } else { // Different servers if (qualityOfServiceMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE) { // Use XA forwardMode = JMSBridgeImpl.FORWARD_MODE_XA; - } - else { + } else { forwardMode = JMSBridgeImpl.FORWARD_MODE_NONTX; } } @@ -1094,8 +1077,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff, clientID, false, true); sourceSession = sourceConn.createSession(true, Session.SESSION_TRANSACTED); - } - else { // bridging across different servers + } else { // bridging across different servers // QoS = ONCE_AND_ONLY_ONCE if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { // Create an XASession for consuming from the source @@ -1105,8 +1087,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff, clientID, true, true); sourceSession = ((XAConnection) sourceConn).createXASession(); - } - else { // QoS = DUPLICATES_OK || AT_MOST_ONCE + } else { // QoS = DUPLICATES_OK || AT_MOST_ONCE if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating non XA source session"); } @@ -1114,8 +1095,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff, clientID, false, true); if (qualityOfServiceMode == QualityOfServiceMode.AT_MOST_ONCE && maxBatchSize == 1) { sourceSession = sourceConn.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - else { + } else { sourceSession = sourceConn.createSession(false, Session.CLIENT_ACKNOWLEDGE); } } @@ -1124,17 +1104,14 @@ public final class JMSBridgeImpl implements JMSBridge { if (subName == null) { if (selector == null) { sourceConsumer = sourceSession.createConsumer(sourceDestination); - } - else { + } else { sourceConsumer = sourceSession.createConsumer(sourceDestination, selector, false); } - } - else { + } else { // Durable subscription if (selector == null) { sourceConsumer = sourceSession.createDurableSubscriber((Topic) sourceDestination, subName); - } - else { + } else { sourceConsumer = sourceSession.createDurableSubscriber((Topic) sourceDestination, subName, selector, false); } } @@ -1145,8 +1122,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (forwardMode == JMSBridgeImpl.FORWARD_MODE_LOCALTX) { targetConn = sourceConn; targetSession = sourceSession; - } - else { // bridging across different servers + } else { // bridging across different servers // QoS = ONCE_AND_ONLY_ONCE if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { if (JMSBridgeImpl.trace) { @@ -1158,8 +1134,7 @@ public final class JMSBridgeImpl implements JMSBridge { targetConn = createConnection(targetUsername, targetPassword, targetCff, null, true, false); targetSession = ((XAConnection) targetConn).createXASession(); - } - else { // QoS = DUPLICATES_OK || AT_MOST_ONCE + } else { // QoS = DUPLICATES_OK || AT_MOST_ONCE if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Creating non XA dest session"); } @@ -1189,14 +1164,13 @@ public final class JMSBridgeImpl implements JMSBridge { targetProducer = targetSession.createProducer(null); return true; - } - catch (Exception e) { + } catch (Exception e) { // We shouldn't log this, as it's expected when trying to connect when target/source is not available // If this fails we should attempt to cleanup or we might end up in some weird state // Adding a log.warn, so the use may see the cause of the failure and take actions - ActiveMQJMSBridgeLogger.LOGGER.bridgeConnectError(e,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.bridgeConnectError(e, bridgeName); cleanup(); @@ -1208,8 +1182,7 @@ public final class JMSBridgeImpl implements JMSBridge { // Stop the source connection try { sourceConn.stop(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to stop source connection", ignore); } @@ -1218,8 +1191,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (tx != null) { try { delistResources(tx); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to delist resources", ignore); } @@ -1228,8 +1200,7 @@ public final class JMSBridgeImpl implements JMSBridge { // Terminate the tx tx.rollback(); abortedMessageCount += messages.size(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to rollback", ignore); } @@ -1239,8 +1210,7 @@ public final class JMSBridgeImpl implements JMSBridge { // Close the old objects try { sourceConn.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to close source connection", ignore); } @@ -1249,8 +1219,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (targetConn != null) { targetConn.close(); } - } - catch (Throwable ignore) { + } catch (Throwable ignore) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failed to close target connection", ignore); } @@ -1262,8 +1231,7 @@ public final class JMSBridgeImpl implements JMSBridge { while (System.currentTimeMillis() - start < failureRetryInterval) { try { Thread.sleep(failureRetryInterval); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { } } } @@ -1288,7 +1256,7 @@ public final class JMSBridgeImpl implements JMSBridge { break; } - ActiveMQJMSBridgeLogger.LOGGER.failedToSetUpBridge(failureRetryInterval,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.failedToSetUpBridge(failureRetryInterval, bridgeName); pause(failureRetryInterval); } @@ -1313,11 +1281,9 @@ public final class JMSBridgeImpl implements JMSBridge { if (forwardMode == JMSBridgeImpl.FORWARD_MODE_LOCALTX) { sendBatchLocalTx(); - } - else if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { + } else if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { sendBatchXA(); - } - else { + } else { sendBatchNonTransacted(); } } @@ -1344,8 +1310,7 @@ public final class JMSBridgeImpl implements JMSBridge { exHappened = false; try { sendMessages(); - } - catch (TransactionRolledbackException e) { + } catch (TransactionRolledbackException e) { ActiveMQJMSBridgeLogger.LOGGER.warn(e.getMessage() + ", retrying TX", e); exHappened = true; } @@ -1381,10 +1346,9 @@ public final class JMSBridgeImpl implements JMSBridge { ActiveMQJMSBridgeLogger.LOGGER.trace("Client acked source session"); } } - } - catch (Exception e) { + } catch (Exception e) { if (!stopping) { - ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e, bridgeName); } // We don't call failure otherwise failover would be broken with ActiveMQ @@ -1393,13 +1357,11 @@ public final class JMSBridgeImpl implements JMSBridge { if (connectedSource) { try { sourceSession.recover(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } - } - finally { + } finally { // Clear the messages messages.clear(); @@ -1422,24 +1384,21 @@ public final class JMSBridgeImpl implements JMSBridge { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Committed JTA transaction"); } - } - catch (Exception e) { + } catch (Exception e) { try { // we call this just in case there is a failure other than failover tx.rollback(); abortedMessageCount += messages.size(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } - ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e, bridgeName); //we don't do handle failure here because the tx //may be rolledback due to failover. All failure handling //will be done through exception listener. //handleFailureOnSend(); - } - finally { + } finally { try { tx = startTx(); @@ -1448,9 +1407,8 @@ public final class JMSBridgeImpl implements JMSBridge { // Clear the messages messages.clear(); - } - catch (Exception e) { - ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e,bridgeName); + } catch (Exception e) { + ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e, bridgeName); handleFailureOnSend(); } @@ -1471,24 +1429,20 @@ public final class JMSBridgeImpl implements JMSBridge { ActiveMQJMSBridgeLogger.LOGGER.trace("Committed source session"); } - } - catch (Exception e) { - ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e,bridgeName); + } catch (Exception e) { + ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(e, bridgeName); try { sourceSession.rollback(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { targetSession.rollback(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } // We don't call failure here, we let the exception listener to deal with it - } - finally { + } finally { messages.clear(); } } @@ -1567,8 +1521,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (val == null) { val = msg.getJMSMessageID(); - } - else { + } else { StringBuffer sb = new StringBuffer(val); sb.append(",").append(msg.getJMSMessageID()); @@ -1611,8 +1564,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (val instanceof byte[] == false) { //Can't set byte[] array props through the JMS API - if we're bridging an ActiveMQ Artemis message it might have such props msg.setObjectProperty(propName, entry.getValue()); - } - else if (msg instanceof ActiveMQMessage) { + } else if (msg instanceof ActiveMQMessage) { ((ActiveMQMessage) msg).getCoreMessage().putBytesProperty(propName, (byte[]) val); } } @@ -1671,8 +1623,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (paused || failed) { try { lock.wait(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { if (stopping) { return; } @@ -1690,8 +1641,7 @@ public final class JMSBridgeImpl implements JMSBridge { // As we need to reconstruct the buffer before resending the message ((ActiveMQMessage) msg).checkBuffer(); } - } - catch (JMSException jmse) { + } catch (JMSException jmse) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace(this + " exception while receiving a message", jmse); } @@ -1700,8 +1650,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (msg == null) { try { lock.wait(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace(this + " thread was interrupted"); } @@ -1750,9 +1699,8 @@ public final class JMSBridgeImpl implements JMSBridge { protected void startSourceConnection() { try { sourceConn.start(); - } - catch (JMSException e) { - ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeSrcConnectError(e,bridgeName); + } catch (JMSException e) { + ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeSrcConnectError(e, bridgeName); } } @@ -1773,8 +1721,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { stop(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } @@ -1792,7 +1739,7 @@ public final class JMSBridgeImpl implements JMSBridge { boolean ok = false; if (maxRetries > 0 || maxRetries == -1) { - ActiveMQJMSBridgeLogger.LOGGER.bridgeRetry(failureRetryInterval,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.bridgeRetry(failureRetryInterval, bridgeName); pause(failureRetryInterval); @@ -1802,8 +1749,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (!ok) { failed(); - } - else { + } else { succeeded(); } } @@ -1834,9 +1780,8 @@ public final class JMSBridgeImpl implements JMSBridge { try { startSource(); - } - catch (JMSException e) { - ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeSrcConnectError(e,bridgeName); + } catch (JMSException e) { + ActiveMQJMSBridgeLogger.LOGGER.jmsBridgeSrcConnectError(e, bridgeName); } } } @@ -1874,8 +1819,7 @@ public final class JMSBridgeImpl implements JMSBridge { } batchExpiryTime = System.currentTimeMillis() + maxBatchTime; - } - else { + } else { try { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace(this + " waiting for " + toWait); @@ -1886,8 +1830,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace(this + " woke up"); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace(this + " thread was interrupted"); } @@ -1920,11 +1863,10 @@ public final class JMSBridgeImpl implements JMSBridge { if (stopping) { return; } - ActiveMQJMSBridgeLogger.LOGGER.bridgeFailure(e,bridgeName); + ActiveMQJMSBridgeLogger.LOGGER.bridgeFailure(e, bridgeName); if (isSource) { connectedSource = false; - } - else { + } else { connectedTarget = false; } @@ -1937,8 +1879,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Failure recovery already in progress"); } - } - else { + } else { boolean shouldHandleFailure = true; if (ha) { //make sure failover happened @@ -1961,8 +1902,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (sl.iterator().hasNext()) { registry = sl.iterator().next(); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJMSBridgeLogger.LOGGER.debug("unable to load recovery registry " + locatorClasse, e); } if (registry != null) { @@ -2012,8 +1952,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (eventType == FailoverEventType.FAILURE_DETECTED) { if (isSource) { connectedSource = false; - } - else { + } else { connectedTarget = false; } } @@ -2037,10 +1976,8 @@ public final class JMSBridgeImpl implements JMSBridge { } start = System.currentTimeMillis(); this.wait(toWait); - } - catch (InterruptedException e) { - } - finally { + } catch (InterruptedException e) { + } finally { waited = System.currentTimeMillis() - start; toWait = failoverTimeout - waited; } @@ -2061,8 +1998,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (result == FailoverEventType.FAILOVER_COMPLETED) { if (isSource) { connectedSource = true; - } - else { + } else { connectedTarget = true; } return true; diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIConnectionFactoryFactory.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIConnectionFactoryFactory.java index 95c3ce9060..67e09275f5 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIConnectionFactoryFactory.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIConnectionFactoryFactory.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.jms.bridge.impl; -import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; - import java.util.Hashtable; +import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; + public class JNDIConnectionFactoryFactory extends JNDIFactorySupport implements ConnectionFactoryFactory { public JNDIConnectionFactoryFactory(final Hashtable jndiProperties, final String lookup) { diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIDestinationFactory.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIDestinationFactory.java index 2fc864fe70..2869e1cc06 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIDestinationFactory.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIDestinationFactory.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.jms.bridge.impl; -import org.apache.activemq.artemis.jms.bridge.DestinationFactory; - +import javax.jms.Destination; import java.util.Hashtable; -import javax.jms.Destination; +import org.apache.activemq.artemis.jms.bridge.DestinationFactory; public class JNDIDestinationFactory extends JNDIFactorySupport implements DestinationFactory { diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIFactorySupport.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIFactorySupport.java index b94e3f5fe6..31571ac327 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIFactorySupport.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JNDIFactorySupport.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.jms.bridge.impl; -import java.util.Hashtable; - import javax.naming.InitialContext; +import java.util.Hashtable; public abstract class JNDIFactorySupport { @@ -40,14 +39,12 @@ public abstract class JNDIFactorySupport { try { if (jndiProperties == null) { ic = new InitialContext(); - } - else { + } else { ic = new InitialContext(jndiProperties); } obj = ic.lookup(lookup); - } - finally { + } finally { if (ic != null) { ic.close(); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSConnectionFactoryControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSConnectionFactoryControlImpl.java index 71239c770b..3175b9c365 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSConnectionFactoryControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSConnectionFactoryControlImpl.java @@ -441,6 +441,7 @@ public class JMSConnectionFactoryControlImpl extends StandardMBean implements Co public String getProtocolManagerFactoryStr() { return cfConfig.getProtocolManagerFactoryStr(); } + @Override public boolean isAutoGroup() { return cfConfig.isAutoGroup(); @@ -459,8 +460,7 @@ public class JMSConnectionFactoryControlImpl extends StandardMBean implements Co private void recreateCF() { try { this.cf = jmsManager.recreateCF(this.name, this.cfConfig); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSQueueControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSQueueControlImpl.java index 38ccd15e1b..a83614661d 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSQueueControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSQueueControlImpl.java @@ -32,9 +32,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQInvalidFilterExpressionException; import org.apache.activemq.artemis.api.core.FilterConstants; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.management.MessageCounterInfo; import org.apache.activemq.artemis.api.core.management.Operation; import org.apache.activemq.artemis.api.core.management.QueueControl; @@ -211,8 +211,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro Map[] coreMessages = coreQueueControl.listMessages(filter); return toJMSMap(coreMessages); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); } } @@ -258,8 +257,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro } return returnMap; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); } } @@ -319,7 +317,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro for (String kv : kvs) { String[] it = kv.split("="); if (it.length == 2) { - props.put(it[0],it[1]); + props.put(it[0], it[1]); } } return sendTextMessage(props, props.remove("body"), props.remove("username"), props.remove("password")); @@ -341,7 +339,10 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro } @Override - public String sendTextMessage(Map headers, String body, String user, String password) throws Exception { + public String sendTextMessage(Map headers, + String body, + String user, + String password) throws Exception { boolean durable = false; if (headers.containsKey("JMSDeliveryMode")) { String jmsDeliveryMode = headers.remove("JMSDeliveryMode"); @@ -379,13 +380,13 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro // Figure out messageID from JMSMessageID. final String filter = createFilterForJMSMessageID(jmsMessageID); - Map[] messages = coreQueueControl.listMessages(filter); - if ( messages.length != 1) { // if no messages. There should not be more than one, JMSMessageID should be unique. + Map[] messages = coreQueueControl.listMessages(filter); + if (messages.length != 1) { // if no messages. There should not be more than one, JMSMessageID should be unique. return false; } - final Map messageToRedeliver = messages[0]; - Long messageID = (Long)messageToRedeliver.get("messageID"); + final Map messageToRedeliver = messages[0]; + Long messageID = (Long) messageToRedeliver.get("messageID"); return messageID != null && coreQueueControl.retryMessage(messageID); } @@ -394,7 +395,6 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro return coreQueueControl.retryMessages(); } - @Override public boolean moveMessage(final String messageID, final String otherQueueName) throws Exception { return moveMessage(messageID, otherQueueName, false); @@ -438,8 +438,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro public String listMessageCounter() { try { return MessageCounterInfo.toJSon(counter); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -487,7 +486,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro @Override public CompositeData[] browse(String filter) throws Exception { try { - CompositeData[] messages = coreQueueControl.browse(filter); + CompositeData[] messages = coreQueueControl.browse(filter); ArrayList c = new ArrayList<>(); @@ -497,8 +496,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro CompositeData[] rc = new CompositeData[c.size()]; c.toArray(rc); return rc; - } - catch (ActiveMQInvalidFilterExpressionException e) { + } catch (ActiveMQInvalidFilterExpressionException e) { throw new InvalidSelectorException(e.getMessage()); } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java index 6f9f8c3e7c..974d8fbbc5 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java @@ -30,7 +30,6 @@ import javax.management.NotificationBroadcasterSupport; import javax.management.NotificationEmitter; import javax.management.NotificationFilter; import javax.management.NotificationListener; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -107,20 +106,16 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo if (coreAddress.startsWith(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX)) { result[0] = coreAddress.substring(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX.length()); result[1] = "queue"; - } - else if (coreAddress.startsWith(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX)) { + } else if (coreAddress.startsWith(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX)) { result[0] = coreAddress.substring(ActiveMQDestination.JMS_TEMP_QUEUE_ADDRESS_PREFIX.length()); result[1] = "tempqueue"; - } - else if (coreAddress.startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX)) { + } else if (coreAddress.startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX)) { result[0] = coreAddress.substring(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX.length()); result[1] = "topic"; - } - else if (coreAddress.startsWith(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX)) { + } else if (coreAddress.startsWith(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX)) { result[0] = coreAddress.substring(ActiveMQDestination.JMS_TEMP_TOPIC_ADDRESS_PREFIX.length()); result[1] = "temptopic"; - } - else { + } else { ActiveMQJMSServerLogger.LOGGER.debug("JMSServerControlImpl.determineJMSDestination()" + coreAddress); // not related to JMS return null; @@ -170,8 +165,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo throw new IllegalArgumentException("no discovery group name supplied"); } server.createConnectionFactory(name, ha, JMSFactoryType.valueOf(cfType), connectorNames[0], JMSServerControlImpl.convert(bindings)); - } - else { + } else { List connectorList = new ArrayList<>(connectorNames.length); for (String str : connectorNames) { @@ -180,8 +174,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo server.createConnectionFactory(name, ha, JMSFactoryType.valueOf(cfType), connectorList, JMSServerControlImpl.convert(bindings)); } - } - finally { + } finally { blockOnIO(); } } @@ -270,8 +263,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo if (useDiscovery) { configuration.setDiscoveryGroupName(connectorNames[0]); - } - else { + } else { ArrayList connectorNamesList = new ArrayList<>(); for (String nameC : connectorNames) { connectorNamesList.add(nameC); @@ -284,8 +276,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo } server.createConnectionFactory(true, configuration, bindings); - } - finally { + } finally { blockOnIO(); } } @@ -331,8 +322,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.createQueue(true, name, selector, durable, JMSServerControlImpl.toArray(bindings)); - } - finally { + } finally { blockOnIO(); } } @@ -350,8 +340,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.destroyQueue(name, removeConsumers); - } - finally { + } finally { blockOnIO(); } } @@ -369,8 +358,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.createTopic(true, topicName, JMSServerControlImpl.toArray(bindings)); - } - finally { + } finally { blockOnIO(); } } @@ -388,8 +376,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.destroyTopic(name, removeConsumers); - } - finally { + } finally { blockOnIO(); } } @@ -402,8 +389,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { server.destroyConnectionFactory(name); - } - finally { + } finally { blockOnIO(); } } @@ -434,8 +420,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo names[i] = queueControl.getName(); } return names; - } - finally { + } finally { blockOnIO(); } } @@ -454,8 +439,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo names[i] = topicControl.getName(); } return names; - } - finally { + } finally { blockOnIO(); } } @@ -474,8 +458,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo names[i] = cfControl.getName(); } return names; - } - finally { + } finally { blockOnIO(); } } @@ -519,8 +502,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listRemoteAddresses(); - } - finally { + } finally { blockOnIO(); } } @@ -533,8 +515,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listRemoteAddresses(ipAddress); - } - finally { + } finally { blockOnIO(); } } @@ -547,8 +528,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.closeConnectionsForAddress(ipAddress); - } - finally { + } finally { blockOnIO(); } } @@ -561,8 +541,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.closeConsumerConnectionsForAddress(address); - } - finally { + } finally { blockOnIO(); } } @@ -575,8 +554,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.closeConnectionsForUser(userName); - } - finally { + } finally { blockOnIO(); } } @@ -589,8 +567,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listConnectionIDs(); - } - finally { + } finally { blockOnIO(); } } @@ -620,10 +597,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo for (RemotingConnection connection : connections) { ServerSession session = jmsSessions.get(connection.getID()); if (session != null) { - JsonObjectBuilder objectBuilder = JsonLoader.createObjectBuilder() - .add("connectionID", connection.getID().toString()) - .add("clientAddress", connection.getRemoteAddress()) - .add("creationTime", connection.getCreationTime()); + JsonObjectBuilder objectBuilder = JsonLoader.createObjectBuilder().add("connectionID", connection.getID().toString()).add("clientAddress", connection.getRemoteAddress()).add("creationTime", connection.getCreationTime()); if (session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null) { objectBuilder.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY)); @@ -637,8 +611,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo } } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -668,8 +641,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo } } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -683,8 +655,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { JsonArray jsonArray = toJsonArray(server.getActiveMQServer().getSessions()); return jsonArray.toString(); - } - finally { + } finally { blockOnIO(); } } @@ -697,8 +668,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listSessions(connectionID); - } - finally { + } finally { blockOnIO(); } } @@ -711,8 +681,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listPreparedTransactionDetailsAsJSON(); - } - finally { + } finally { blockOnIO(); } } @@ -725,8 +694,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listPreparedTransactionDetailsAsHTML(); - } - finally { + } finally { blockOnIO(); } } @@ -810,8 +778,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo try { return server.listSessionsAsJSON(connectionID); - } - finally { + } finally { blockOnIO(); } } @@ -834,8 +801,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo JsonObjectBuilder obj = JsonLoader.createObjectBuilder(); TransportConfiguration live = member.getLive(); if (live != null) { - obj.add("nodeID", member.getNodeId()) - .add("live", live.getParams().get("host") + ":" + live.getParams().get("port")); + obj.add("nodeID", member.getNodeId()).add("live", live.getParams().get("host") + ":" + live.getParams().get("port")); TransportConfiguration backup = member.getBackup(); if (backup != null) { obj.add("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port")); @@ -846,8 +812,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo } } return brokers.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -862,32 +827,21 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo if (destinationInfo == null) { return null; } - JsonObjectBuilder obj = JsonLoader.createObjectBuilder() - .add("consumerID", consumer.getID()) - .add("connectionID", consumer.getConnectionID().toString()) - .add("sessionID", consumer.getSessionID()) - .add("queueName", consumer.getQueue().getName().toString()) - .add("browseOnly", consumer.isBrowseOnly()) - .add("creationTime", consumer.getCreationTime()) - .add("destinationName", destinationInfo[0]) - .add("destinationType", destinationInfo[1]); + JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", consumer.getID()).add("connectionID", consumer.getConnectionID().toString()).add("sessionID", consumer.getSessionID()).add("queueName", consumer.getQueue().getName().toString()).add("browseOnly", consumer.isBrowseOnly()).add("creationTime", consumer.getCreationTime()).add("destinationName", destinationInfo[0]).add("destinationType", destinationInfo[1]); // JMS consumer with message filter use the queue's filter Filter queueFilter = consumer.getQueue().getFilter(); if (queueFilter != null) { obj.add("filter", queueFilter.getFilterString().toString()); } - if (destinationInfo[1].equals("topic")) { try { ActiveMQDestination.decomposeQueueNameForDurableSubscription(consumer.getQueue().getName().toString()); obj.add("durable", true); - } - catch (IllegalArgumentException | JMSRuntimeException e) { + } catch (IllegalArgumentException | JMSRuntimeException e) { obj.add("durable", false); } - } - else { + } else { obj.add("durable", false); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java index 6706c17822..d8c4179baf 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java @@ -16,20 +16,19 @@ */ package org.apache.activemq.artemis.jms.management.impl; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.management.MBeanInfo; +import javax.management.StandardMBean; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import javax.management.MBeanInfo; -import javax.management.StandardMBean; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; +import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.core.management.ResourceNames; import org.apache.activemq.artemis.api.jms.management.TopicControl; @@ -302,8 +301,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl { Pair pair = ActiveMQDestination.decomposeQueueNameForDurableSubscription(queue.getName()); clientID = pair.getA(); subName = pair.getB(); - } - else if (queue.getName().startsWith(ResourceNames.JMS_TOPIC)) { + } else if (queue.getName().startsWith(ResourceNames.JMS_TOPIC)) { // in the case of heirarchical topics the queue name will not follow the . pattern of normal // durable subscribers so skip decomposing the name for the client ID and subscription name and just // hard-code it @@ -313,23 +311,13 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl { String filter = queue.getFilter() != null ? queue.getFilter() : null; - JsonObject info = JsonLoader.createObjectBuilder() - .add("queueName", queue.getName()) - .add("clientID", nullSafe(clientID)) - .add("selector", nullSafe(filter)) - .add("name", nullSafe(subName)) - .add("durable", queue.isDurable()) - .add("messageCount", queue.getMessageCount()) - .add("deliveringCount", queue.getDeliveringCount()) - .add("consumers", queue.listConsumersAsJSON()) - .build(); + JsonObject info = JsonLoader.createObjectBuilder().add("queueName", queue.getName()).add("clientID", nullSafe(clientID)).add("selector", nullSafe(filter)).add("name", nullSafe(subName)).add("durable", queue.isDurable()).add("messageCount", queue.getMessageCount()).add("deliveringCount", queue.getDeliveringCount()).add("consumers", queue.listConsumersAsJSON()).build(); array.add(info); } return array.build().toString(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return e.toString(); } @@ -360,8 +348,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl { } } return matchingQueues; - } - catch (Exception e) { + } catch (Exception e) { return Collections.emptyList(); } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSCompositeDataConstants.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSCompositeDataConstants.java index e75b2f5940..dc5b33b5f8 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSCompositeDataConstants.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSCompositeDataConstants.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -18,6 +17,7 @@ package org.apache.activemq.artemis.jms.management.impl.openmbean; public interface JMSCompositeDataConstants { + String JMS_DESTINATION = "JMSDestination"; String JMS_MESSAGE_ID = "JMSMessageID"; String JMS_TYPE = "JMSType"; @@ -54,5 +54,4 @@ public interface JMSCompositeDataConstants { String MESSAGE_TEXT = "Text"; String MESSAGE_URL = "Url"; - } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSOpenTypeSupport.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSOpenTypeSupport.java index 06ba26ccae..285657ddf6 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSOpenTypeSupport.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/openmbean/JMSOpenTypeSupport.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.jms.management.impl.openmbean; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.management.impl.openmbean.CompositeDataConstants; -import org.apache.activemq.artemis.reader.MapMessageUtil; -import org.apache.activemq.artemis.utils.TypedProperties; - import javax.management.openmbean.ArrayType; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataSupport; @@ -39,9 +31,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.ActiveMQBuffers; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.management.impl.openmbean.CompositeDataConstants; +import org.apache.activemq.artemis.reader.MapMessageUtil; +import org.apache.activemq.artemis.utils.TypedProperties; + public final class JMSOpenTypeSupport { public interface OpenTypeFactory { + CompositeType getCompositeType() throws OpenDataException; Map getFields(CompositeDataSupport data) throws OpenDataException; @@ -95,6 +96,7 @@ public final class JMSOpenTypeSupport { } static class MessageOpenTypeFactory extends AbstractOpenTypeFactory { + protected TabularType stringPropertyTabularType; protected TabularType booleanPropertyTabularType; protected TabularType bytePropertyTabularType; @@ -158,7 +160,7 @@ public final class JMSOpenTypeSupport { putString(rc, data, JMSCompositeDataConstants.JMS_DESTINATION, CompositeDataConstants.ADDRESS); putStringProperty(rc, data, JMSCompositeDataConstants.JMS_REPLY_TO, "JMSReplyTo"); rc.put(JMSCompositeDataConstants.JMS_TYPE, getType()); - rc.put(JMSCompositeDataConstants.JMS_DELIVERY_MODE, ((Boolean)data.get(CompositeDataConstants.DURABLE)) ? "PERSISTENT" : "NON-PERSISTENT"); + rc.put(JMSCompositeDataConstants.JMS_DELIVERY_MODE, ((Boolean) data.get(CompositeDataConstants.DURABLE)) ? "PERSISTENT" : "NON-PERSISTENT"); rc.put(JMSCompositeDataConstants.JMS_EXPIRATION, data.get(CompositeDataConstants.EXPIRATION)); rc.put(JMSCompositeDataConstants.JMS_TIMESTAMP, new Date((Long) data.get(CompositeDataConstants.TIMESTAMP))); rc.put(JMSCompositeDataConstants.JMS_PRIORITY, ((Byte) data.get(CompositeDataConstants.PRIORITY)).intValue()); @@ -187,8 +189,7 @@ public final class JMSOpenTypeSupport { String prop = (String) data.get(source); if (prop != null) { rc.put(target, prop); - } - else { + } else { rc.put(target, ""); } } @@ -226,7 +227,6 @@ public final class JMSOpenTypeSupport { return value.toString(); } - protected TabularType createTabularType(Class type, OpenType openType) throws OpenDataException { String typeName = "java.util.Map"; String[] keyValue = new String[]{"key", "value"}; @@ -238,7 +238,6 @@ public final class JMSOpenTypeSupport { static class ByteMessageOpenTypeFactory extends MessageOpenTypeFactory { - @Override protected String getTypeName() { return "BytesMessage"; @@ -290,12 +289,15 @@ public final class JMSOpenTypeSupport { } static class ObjectMessageOpenTypeFactory extends MessageOpenTypeFactory { + @Override protected String getTypeName() { return "ObjectMessage"; } } + static class StreamMessageOpenTypeFactory extends MessageOpenTypeFactory { + @Override protected String getTypeName() { return "StreamMessage"; diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/JMSStorageManager.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/JMSStorageManager.java index 5a084e41d6..3e5e9976ba 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/JMSStorageManager.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/JMSStorageManager.java @@ -19,9 +19,9 @@ package org.apache.activemq.artemis.jms.persistence; import java.util.List; import org.apache.activemq.artemis.core.server.ActiveMQComponent; +import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; -import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedType; public interface JMSStorageManager extends ActiveMQComponent { diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java index f47f1bb1ed..32c438df19 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java @@ -26,19 +26,19 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.replication.ReplicatedJournal; import org.apache.activemq.artemis.core.replication.ReplicationManager; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.jms.persistence.JMSStorageManager; +import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; -import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedType; import org.apache.activemq.artemis.utils.IDGenerator; @@ -90,8 +90,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { if (replicator != null) { jmsJournal = new ReplicatedJournal((byte) 2, localJMS, replicator); - } - else { + } else { jmsJournal = localJMS; } @@ -152,8 +151,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { PersistedBindings currentBindings = mapBindings.get(key); if (currentBindings != null) { jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId()); - } - else { + } else { currentBindings = new PersistedBindings(type, name); } @@ -181,8 +179,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { PersistedBindings currentBindings = mapBindings.get(key); if (currentBindings == null) { return; - } - else { + } else { jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId()); } @@ -190,8 +187,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { if (currentBindings.getBindings().size() == 0) { mapBindings.remove(key); - } - else { + } else { long newId = idGenerator.generateID(); currentBindings.setId(newId); jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings); @@ -261,21 +257,18 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { cf.decode(buffer); cf.setId(id); mapFactories.put(cf.getName(), cf); - } - else if (rec == DESTINATION_RECORD) { + } else if (rec == DESTINATION_RECORD) { PersistedDestination destination = new PersistedDestination(); destination.decode(buffer); destination.setId(id); destinations.put(new Pair<>(destination.getType(), destination.getName()), destination); - } - else if (rec == BINDING_RECORD) { + } else if (rec == BINDING_RECORD) { PersistedBindings bindings = new PersistedBindings(); bindings.decode(buffer); bindings.setId(id); Pair key = new Pair<>(bindings.getType(), bindings.getName()); mapBindings.put(key, bindings); - } - else { + } else { throw new IllegalStateException("Invalid record type " + rec); } @@ -296,8 +289,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager { if (!dir.mkdirs()) { throw new IllegalStateException("Failed to create directory " + dir); } - } - else { + } else { throw new IllegalArgumentException("Directory " + dir + " does not exist and will not create it"); } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java index d1b69c171f..7e1618d7b5 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java @@ -20,9 +20,9 @@ import java.util.Collections; import java.util.List; import org.apache.activemq.artemis.jms.persistence.JMSStorageManager; +import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory; import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; -import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; import org.apache.activemq.artemis.jms.persistence.config.PersistedType; public class NullJMSStorageManagerImpl implements JMSStorageManager { diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/ActiveMQJMSServerBundle.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/ActiveMQJMSServerBundle.java index e591fa47f5..c44283283c 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/ActiveMQJMSServerBundle.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/ActiveMQJMSServerBundle.java @@ -19,10 +19,10 @@ package org.apache.activemq.artemis.jms.server; import org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 12 diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java index d5f1878b02..32841105ff 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java @@ -77,7 +77,6 @@ public interface JMSServerManager extends ActiveMQComponent { boolean createTopic(boolean storeConfig, String topicName, String... bindings) throws Exception; /** - * * @param storeConfig * @param topicName * @param autoCreated diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/ConnectionFactoryConfiguration.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/ConnectionFactoryConfiguration.java index edba5d1a94..538dbe55fd 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/ConnectionFactoryConfiguration.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/ConnectionFactoryConfiguration.java @@ -44,7 +44,7 @@ public interface ConnectionFactoryConfiguration extends EncodingSupport { ConnectionFactoryConfiguration setConnectorNames(List connectorNames); - ConnectionFactoryConfiguration setConnectorNames(String...connectorNames); + ConnectionFactoryConfiguration setConnectorNames(String... connectorNames); boolean isHA(); diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java index b72a566c55..f4562332a8 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java @@ -186,9 +186,8 @@ public class ConnectionFactoryConfigurationImpl implements ConnectionFactoryConf return this; } - @Override - public ConnectionFactoryConfiguration setConnectorNames(final String...names) { + public ConnectionFactoryConfiguration setConnectorNames(final String... names) { return this.setConnectorNames(Arrays.asList(names)); } @@ -634,8 +633,7 @@ public class ConnectionFactoryConfigurationImpl implements ConnectionFactoryConf if (this.connectorNames == null) { buffer.writeInt(0); - } - else { + } else { buffer.writeInt(connectorNames.size()); for (String tc : connectorNames) { @@ -819,7 +817,7 @@ public class ConnectionFactoryConfigurationImpl implements ConnectionFactoryConf BufferHelper.sizeOfNullableSimpleString(groupID) + DataConstants.SIZE_INT + - // factoryType + // factoryType BufferHelper.sizeOfNullableSimpleString(protocolManagerFactoryStr) + diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java index a0c81f9dfb..0fa203e3ec 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.jms.server.config.impl; +import javax.management.MBeanServer; +import java.net.URL; +import java.util.ArrayList; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.config.impl.Validators; import org.apache.activemq.artemis.core.deployers.Deployable; @@ -32,11 +37,6 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import javax.management.MBeanServer; -import java.net.URL; -import java.util.ArrayList; -import java.util.Map; - public class FileJMSConfiguration extends JMSConfigurationImpl implements Deployable { private static final String CONFIGURATION_SCHEMA_URL = "schema/artemis-jms.xsd"; @@ -111,8 +111,7 @@ public class FileJMSConfiguration extends JMSConfigurationImpl implements Deploy if (node.getNodeName().equals(TOPIC_NODE_NAME)) { topics.add(parseTopicConfiguration(node)); - } - else if (node.getNodeName().equals(QUEUE_NODE_NAME)) { + } else if (node.getNodeName().equals(QUEUE_NODE_NAME)) { queues.add(parseQueueConfiguration(node)); } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/embedded/EmbeddedJMS.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/embedded/EmbeddedJMS.java index 57430b87a9..5efffe6add 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/embedded/EmbeddedJMS.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/embedded/EmbeddedJMS.java @@ -81,20 +81,19 @@ public class EmbeddedJMS extends EmbeddedActiveMQ { return this; } - @Override public EmbeddedJMS setConfiguration(Configuration configuration) { super.setConfiguration(configuration); return this; } - /** - * Lookup in the registry for registered object, i.e. a ConnectionFactory. - *

- * This is a convenience method. - * - * @param name - */ + /** + * Lookup in the registry for registered object, i.e. a ConnectionFactory. + *

+ * This is a convenience method. + * + * @param name + */ public Object lookup(String name) { return serverManager.getRegistry().lookup(name); } @@ -104,14 +103,12 @@ public class EmbeddedJMS extends EmbeddedActiveMQ { super.initStart(); if (jmsConfiguration != null) { serverManager = new JMSServerManagerImpl(activeMQServer, jmsConfiguration); - } - else { + } else { FileJMSConfiguration fileConfiguration = new FileJMSConfiguration(); FileDeploymentManager deploymentManager; if (configResourcePath != null) { deploymentManager = new FileDeploymentManager(configResourcePath); - } - else { + } else { deploymentManager = new FileDeploymentManager(); } deploymentManager.addDeployable(fileConfiguration); diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java index 392a7d9986..dfa92188ad 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java @@ -215,9 +215,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback recoverBindings(); - - } - catch (Exception e) { + } catch (Exception e) { active = false; ActiveMQJMSServerLogger.LOGGER.jmsDeployerStartError(e); } @@ -266,8 +264,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback active = false; } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -548,7 +545,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback return true; } - @Override public synchronized boolean createTopic(final boolean storeConfig, final String topicName, @@ -734,8 +730,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (removeFromBindings(topicBindings, name, bindings)) { storage.deleteBindings(PersistedType.Topic, name, bindings); return true; - } - else { + } else { return false; } } @@ -815,8 +810,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback sendNotification(JMSNotificationType.QUEUE_DESTROYED, name); return true; - } - else { + } else { return false; } } @@ -856,12 +850,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback sendNotification(JMSNotificationType.TOPIC_DESTROYED, name); return true; - } - else { + } else { return false; } - } - else { + } else { return false; } } @@ -1054,8 +1046,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback Notification notif = new Notification(null, type, prop); try { server.getManagementService().sendNotification(notif); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJMSServerLogger.LOGGER.failedToSendNotification(notif.toString()); } } @@ -1073,8 +1064,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback List result = map.get(name); if (result == null) { return new String[0]; - } - else { + } else { String[] strings = new String[result.size()]; result.toArray(strings); return strings; @@ -1082,19 +1072,18 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback } private synchronized boolean internalCreateQueue(final String queueName, - final String selectorString, - final boolean durable) throws Exception { + final String selectorString, + final boolean durable) throws Exception { return internalCreateQueue(queueName, selectorString, durable, false); } private synchronized boolean internalCreateQueue(final String queueName, - final String selectorString, - final boolean durable, - final boolean autoCreated) throws Exception { + final String selectorString, + final boolean durable, + final boolean autoCreated) throws Exception { if (queues.get(queueName) != null) { return false; - } - else { + } else { ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queueName); // Convert from JMS selector to core filter @@ -1116,8 +1105,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback } } - - /** * Performs the internal creation without activating any storage. * The storage load will call this method @@ -1130,12 +1117,12 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback return internalCreateTopic(topicName, false); } - private synchronized boolean internalCreateTopic(final String topicName, final boolean autoCreated) throws Exception { + private synchronized boolean internalCreateTopic(final String topicName, + final boolean autoCreated) throws Exception { if (topics.get(topicName) != null) { return false; - } - else { + } else { ActiveMQTopic activeMQTopic = ActiveMQDestination.createTopic(topicName); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that @@ -1189,12 +1176,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (cfConfig.isHA()) { cf = ActiveMQJMSClient.createConnectionFactoryWithHA(groupConfig, cfConfig.getFactoryType()); - } - else { + } else { cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfig, cfConfig.getFactoryType()); } - } - else { + } else { if (cfConfig.getConnectorNames() == null || cfConfig.getConnectorNames().size() == 0) { throw ActiveMQJMSServerBundle.BUNDLE.noConnectorNameOnCF(); } @@ -1213,8 +1198,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (cfConfig.isHA()) { cf = ActiveMQJMSClient.createConnectionFactoryWithHA(cfConfig.getFactoryType(), configs); - } - else { + } else { cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(cfConfig.getFactoryType(), configs); } } @@ -1521,8 +1505,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback for (String key : elementList) { try { registry.unbind(key); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJMSServerLogger.LOGGER.bindingsUnbindError(e, key); } } @@ -1551,8 +1534,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback for (PersistedDestination destination : destinations) { if (destination.getType() == PersistedType.Queue) { internalCreateQueue(destination.getName(), destination.getSelector(), destination.isDurable()); - } - else if (destination.getType() == PersistedType.Topic) { + } else if (destination.getType() == PersistedType.Topic) { internalCreateTopic(destination.getName()); } } @@ -1565,12 +1547,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (storage == null) { if (coreConfig.isPersistenceEnabled()) { storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(), server.getConfiguration(), server.getReplicationManager()); - } - else { + } else { storage = new NullJMSStorageManagerImpl(); } - } - else { + } else { if (storage.isStarted()) { storage.stop(); } @@ -1586,8 +1566,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback List registryBindings = bindingsMap.remove(name); if (registryBindings == null || registryBindings.size() == 0) { return false; - } - else { + } else { keys.remove(name); } if (registry != null) { @@ -1613,8 +1592,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (registryBindings.remove(bindings)) { registry.unbind(bindings); return true; - } - else { + } else { return false; } } @@ -1623,8 +1601,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (active) { runnable.runException(); return true; - } - else { + } else { ActiveMQJMSServerLogger.LOGGER.serverCachingCommand(runnable); if (!cachedCommands.contains(runnable)) cachedCommands.add(runnable); @@ -1638,8 +1615,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback public void run() { try { runException(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJMSServerLogger.LOGGER.jmsServerError(e); } } @@ -1657,8 +1633,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback String newHost = InetAddress.getLocalHost().getHostName(); ActiveMQJMSServerLogger.LOGGER.invalidHostForConnector(transportConfiguration.getName(), newHost); params.put(TransportConstants.HOST_PROP_NAME, newHost); - } - catch (UnknownHostException e) { + } catch (UnknownHostException e) { ActiveMQJMSServerLogger.LOGGER.failedToCorrectHost(e, transportConfiguration.getName()); } } @@ -1669,22 +1644,22 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback * to a non-existent JMS queue or topic */ class JMSDestinationCreator implements QueueCreator { + @Override public boolean create(SimpleString address) throws Exception { AddressSettings settings = server.getAddressSettingsRepository().getMatch(address.toString()); if (address.toString().startsWith(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX) && settings.isAutoCreateJmsQueues()) { return internalCreateJMSQueue(false, address.toString().substring(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX.length()), null, true, true); - } - else if (address.toString().startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX) && settings.isAutoCreateJmsTopics()) { + } else if (address.toString().startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX) && settings.isAutoCreateJmsTopics()) { return createTopic(false, address.toString().substring(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX.length()), true); - } - else { + } else { return false; } } } class JMSQueueDeleter implements QueueDeleter { + @Override public boolean delete(SimpleString queueName) throws Exception { Queue queue = server.locateQueue(queueName); @@ -1699,8 +1674,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback } return destroyQueue(queueName.toString().substring(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX.length()), false); - } - else { + } else { return false; } } @@ -1712,6 +1686,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback * autoCreateJmsTopics = true. */ class JMSPostQueueCreationCallback implements PostQueueCreationCallback { + @Override public void callback(SimpleString queueName) throws Exception { Queue queue = server.locateQueue(queueName); @@ -1734,6 +1709,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback * for that topic. */ class JMSPostQueueDeletionCallback implements PostQueueDeletionCallback { + @Override public void callback(SimpleString address, SimpleString queueName) throws Exception { Queue queue = server.locateQueue(address); @@ -1744,8 +1720,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback if (address.toString().startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX) && settings.isAutoDeleteJmsTopics() && bindings.size() == 1 && queue != null && queue.isAutoCreated()) { try { destroyTopic(address.toString().substring(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX.length())); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { /* * During shutdown the callback can be invoked after the JMSServerManager is already shut down so we just * ignore the exception in that case @@ -1759,6 +1734,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback } private final class JMSReloader implements ReloadCallback { + @Override public void reload(URL url) throws Exception { ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms"); @@ -1772,13 +1748,11 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback Element e = XMLUtil.stringToElement(xml); if (config instanceof FileJMSConfiguration) { - ((FileJMSConfiguration)config).parse(e, url); + ((FileJMSConfiguration) config).parse(e, url); JMSServerManagerImpl.this.deploy(); } - - } } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java index cd09f4a2b9..6cf20ffe50 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.jms.transaction; -import java.util.Map; - import javax.transaction.xa.Xid; +import java.util.Map; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.transaction.Transaction; @@ -61,8 +60,7 @@ public class JMSTransactionDetail extends TransactionDetail { public Map decodeMessageProperties(ServerMessage msg) { try { return ActiveMQMessage.coreMaptoJMSMap(msg.toMap()); - } - catch (Throwable t) { + } catch (Throwable t) { return null; } } diff --git a/artemis-journal/pom.xml b/artemis-journal/pom.xml index ccd1dfd60a..ab79918c59 100644 --- a/artemis-journal/pom.xml +++ b/artemis-journal/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java index 487d8a52bf..5665e571c4 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java @@ -29,11 +29,11 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; +import org.apache.activemq.artemis.core.io.buffer.TimedBuffer; +import org.apache.activemq.artemis.core.io.buffer.TimedBufferObserver; import org.apache.activemq.artemis.core.io.util.FileIOUtil; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback; -import org.apache.activemq.artemis.core.io.buffer.TimedBuffer; -import org.apache.activemq.artemis.core.io.buffer.TimedBufferObserver; import org.apache.activemq.artemis.journal.ActiveMQJournalBundle; import org.apache.activemq.artemis.journal.ActiveMQJournalLogger; @@ -117,8 +117,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { FileIOUtil.copyData(this, newFileName, buffer); newFileName.close(); this.close(); - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -141,8 +140,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { public final void renameTo(final String newFileName) throws IOException, InterruptedException, ActiveMQException { try { close(); - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -183,8 +181,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { public final boolean fits(final int size) { if (timedBuffer == null) { return position.get() + size <= fileSize; - } - else { + } else { return timedBuffer.checkSize(size); } } @@ -208,8 +205,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { if (timedBuffer != null) { bytes.setIndex(0, bytes.capacity()); timedBuffer.addBytes(bytes, sync, callback); - } - else { + } else { ByteBuffer buffer = factory.newBuffer(bytes.capacity()); buffer.put(bytes.toByteBuffer().array()); buffer.rewind(); @@ -226,8 +222,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { write(bytes, true, completion); completion.waitCompletion(); - } - else { + } else { write(bytes, false, DummyCallback.getInstance()); } } @@ -236,8 +231,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { public void write(final EncodingSupport bytes, final boolean sync, final IOCallback callback) { if (timedBuffer != null) { timedBuffer.addBytes(bytes, sync, callback); - } - else { + } else { ByteBuffer buffer = factory.newBuffer(bytes.getEncodeSize()); // If not using the TimedBuffer, a final copy is necessary @@ -259,8 +253,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { write(bytes, true, completion); completion.waitCompletion(); - } - else { + } else { write(bytes, false, DummyCallback.getInstance()); } } @@ -282,8 +275,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { for (IOCallback callback : delegates) { try { callback.done(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e); } } @@ -294,8 +286,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { for (IOCallback callback : delegates) { try { callback.onError(errorCode, errorMessage); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorCallingErrorCallback(e); } } @@ -319,8 +310,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { if (buffer.limit() == 0) { factory.releaseBuffer(buffer); - } - else { + } else { writeDirect(buffer, requestedSync, new DelegateCallback(callbacks)); } } @@ -334,8 +324,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { public int getRemainingBytes() { if (fileSize - position.get() > Integer.MAX_VALUE) { return Integer.MAX_VALUE; - } - else { + } else { return (int) (fileSize - position.get()); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java index 9f9a883190..6e61c867d6 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java @@ -72,8 +72,7 @@ public abstract class AbstractSequentialFileFactory implements SequentialFileFac if (buffered && bufferTimeout > 0) { timedBuffer = new TimedBuffer(bufferSize, bufferTimeout, logRates); - } - else { + } else { timedBuffer = null; } this.bufferSize = bufferSize; @@ -95,8 +94,7 @@ public abstract class AbstractSequentialFileFactory implements SequentialFileFac if (!writeExecutor.awaitTermination(AbstractSequentialFileFactory.EXECUTOR_TIMEOUT, TimeUnit.SECONDS)) { ActiveMQJournalLogger.LOGGER.timeoutOnWriterShutdown(new Exception("trace")); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java index ab61b8d4bd..8f7cfb5ad4 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java @@ -22,8 +22,8 @@ import java.nio.ByteBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.io.buffer.TimedBuffer; +import org.apache.activemq.artemis.core.journal.EncodingSupport; public interface SequentialFile { diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java index 1a109cb4df..a0d20d2eec 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java @@ -26,9 +26,9 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQNativeIOError; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.AbstractSequentialFile; import org.apache.activemq.artemis.core.io.DummyCallback; +import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback; import org.apache.activemq.artemis.jlibaio.LibaioFile; @@ -139,8 +139,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { try { aioFile = aioFactory.libaioContext.openFile(getFile(), true); - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(e, e.getMessage(), this); throw new ActiveMQNativeIOError(e.getMessage(), e); } @@ -164,8 +163,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { // because we want the buffer available. // Sending it through the callback would make it released aioFile.read(positionToRead, bytesToRead, bytes, getCallback(callback, null)); - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(e, e.getMessage(), this); throw new ActiveMQNativeIOError(e.getMessage(), e); } @@ -192,8 +190,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { writeDirect(bytes, true, completion); completion.waitCompletion(); - } - else { + } else { writeDirect(bytes, false, DummyCallback.getInstance()); } } @@ -205,8 +202,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { public void writeDirect(final ByteBuffer bytes, final boolean sync, final IOCallback callback) { try { checkOpened(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.warn(e.getMessage(), e); callback.onError(-1, e.getMessage()); return; @@ -220,8 +216,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { runnableCallback.initWrite(positionToWrite, bytesToWrite); if (writerExecutor != null) { writerExecutor.execute(runnableCallback); - } - else { + } else { runnableCallback.run(); } } @@ -244,8 +239,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { callback.sequentialDone(); pendingCallbacks.countDown(); flushCallbacks(); - } - else { + } else { pendingCallbackList.add(callback); } @@ -269,8 +263,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { public long size() throws Exception { if (aioFile == null) { return getFile().length(); - } - else { + } else { return aioFile.getSize(); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java index f3f12a5804..da0d0792de 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java @@ -120,18 +120,18 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor int fd = LibaioContext.open(aioTestFile.getAbsolutePath(), true); LibaioContext.close(fd); aioTestFile.delete(); - } - catch (Exception e) { + } catch (Exception e) { // try to handle the file using plain Java // return false if and only if we can create/remove the file using // plain Java but not using AIO try { if (!aioTestFile.exists()) { - if (!aioTestFile.createNewFile()) return true; + if (!aioTestFile.createNewFile()) + return true; } - if (!aioTestFile.delete()) return true; - } - catch (Exception ie) { + if (!aioTestFile.delete()) + return true; + } catch (Exception ie) { // we can not even create the test file using plain java return true; } @@ -236,8 +236,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor if (pollerThread.isAlive()) { ActiveMQJournalLogger.LOGGER.timeoutOnPollerShutdown(new Exception("trace")); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -285,8 +284,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor public void run() { try { libaioFile.write(position, bytes, buffer, this); - } - catch (IOException e) { + } catch (IOException e) { callback.onError(-1, e.getMessage()); } } @@ -295,11 +293,9 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor public int compareTo(AIOSequentialCallback other) { if (this == other || this.writeSequence == other.writeSequence) { return 0; - } - else if (other.writeSequence < this.writeSequence) { + } else if (other.writeSequence < this.writeSequence) { return 1; - } - else { + } else { return -1; } } @@ -342,8 +338,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor if (error) { callback.onError(errorCode, errorMessage); errorMessage = null; - } - else { + } else { if (callback != null) { callback.done(); } @@ -368,8 +363,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor while (running.get()) { try { libaioContext.poll(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.warn(e.getMessage(), e); } } @@ -394,7 +388,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor if (bufferSize > 0 && System.currentTimeMillis() - bufferReuseLastTime > 10000) { if (logger.isTraceEnabled()) { logger.trace("Clearing reuse buffers queue with " + reuseBuffersQueue.size() + - " elements"); + " elements"); } bufferReuseLastTime = System.currentTimeMillis(); @@ -406,8 +400,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor // buffer. if (size > bufferSize) { return LibaioContext.newAlignedBuffer(size, 512); - } - else { + } else { // We need to allocate buffers following the rules of the storage // being used (AIO/NIO) int alignedSize = calculateBlockSize(size); @@ -420,8 +413,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor buffer = LibaioContext.newAlignedBuffer(size, 512); buffer.limit(alignedSize); - } - else { + } else { clearBuffer(buffer); // set the limit of the buffer to the bufferSize being required @@ -452,16 +444,14 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor if (stopped) { releaseBuffer(buffer); - } - else { + } else { bufferReuseLastTime = System.currentTimeMillis(); // If a buffer has any other than the configured bufferSize, the buffer // will be just sent to GC if (buffer.capacity() == bufferSize) { reuseBuffersQueue.offer(buffer); - } - else { + } else { releaseBuffer(buffer); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java index 23e0981478..91e5e12d04 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java @@ -133,8 +133,7 @@ public class TimedBuffer { // Need to start with the spin limiter acquired try { spinLimiter.acquire(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } @@ -173,8 +172,7 @@ public class TimedBuffer { while (timerThread.isAlive()) { try { timerThread.join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -217,8 +215,7 @@ public class TimedBuffer { if (sizeChecked > remainingInFile) { return false; - } - else { + } else { // There is enough space in the file for this size // Need to re-calculate buffer limit @@ -227,8 +224,7 @@ public class TimedBuffer { return true; } - } - else { + } else { delayFlush = true; return true; @@ -380,8 +376,7 @@ public class TimedBuffer { // if using sleep, we will always flush flush(); lastFlushTime = System.nanoTime(); - } - else if (bufferObserver != null && System.nanoTime() > lastFlushTime + timeout) { + } else if (bufferObserver != null && System.nanoTime() > lastFlushTime + timeout) { // if not using flush we will spin and do the time checks manually flush(); lastFlushTime = System.nanoTime(); @@ -397,8 +392,7 @@ public class TimedBuffer { Thread.yield(); spinLimiter.release(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -417,11 +411,9 @@ public class TimedBuffer { try { sleep(sleepMillis, sleepNanos); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); - } - catch (Exception e) { + } catch (Exception e) { setUseSleep(false); ActiveMQJournalLogger.LOGGER.warn(e.getMessage() + ", disabling sleep on TimedBuffer, using spin now", e); } @@ -469,8 +461,7 @@ public class TimedBuffer { // We acquire the spinLimiter semaphore - this prevents the timer flush thread unnecessarily spinning // when the buffer is inactive spinLimiter.acquire(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java index 5bba39179c..73384c8181 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java @@ -119,8 +119,7 @@ final class MappedByteBufferCache implements AutoCloseable { } } } - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new IOException("Failed to resize to " + minSize, ioe); } } @@ -146,8 +145,7 @@ final class MappedByteBufferCache implements AutoCloseable { if (mbb != null) { try { PlatformDependent.freeDirectBuffer(mbb); - } - catch (Throwable t) { + } catch (Throwable t) { //TO_FIX: force releasing of the other buffers } } @@ -165,27 +163,21 @@ final class MappedByteBufferCache implements AutoCloseable { } } } - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new IllegalStateException("Failed to resize to " + length, ioe); } } - } - catch (IOException ex) { + } catch (IOException ex) { throw new IllegalStateException("Failed to get size", ex); - } - finally { + } finally { try { fileChannel.close(); - } - catch (IOException e) { + } catch (IOException e) { throw new IllegalStateException("Failed to close channel", e); - } - finally { + } finally { try { raf.close(); - } - catch (IOException e) { + } catch (IOException e) { throw new IllegalStateException("Failed to close RandomAccessFile", e); } } @@ -208,8 +200,7 @@ final class MappedByteBufferCache implements AutoCloseable { if (mbb != null) { try { PlatformDependent.freeDirectBuffer(mbb); - } - catch (Throwable t) { + } catch (Throwable t) { //TO_FIX: force releasing of the other buffers } } @@ -218,15 +209,12 @@ final class MappedByteBufferCache implements AutoCloseable { this.byteBuffers.clear(); try { fileChannel.close(); - } - catch (IOException e) { + } catch (IOException e) { throw new IllegalStateException("Failed to close channel", e); - } - finally { + } finally { try { raf.close(); - } - catch (IOException e) { + } catch (IOException e) { throw new IllegalStateException("Failed to close RandomAccessFile", e); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java index 6dca716cef..0aa98669a2 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java @@ -70,15 +70,12 @@ final class MappedFile implements AutoCloseable { lastMappedLimit = mappedLimit; final int bufferPosition = (int) (offset - mappedPosition); return bufferPosition; - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new IOException(e); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new BufferUnderflowException(); } - } - else { + } else { final int bufferPosition = (int) (offset - lastMappedStart); return bufferPosition; } @@ -101,12 +98,10 @@ final class MappedFile implements AutoCloseable { if (dst.hasMemoryAddress()) { final long dstAddress = dst.memoryAddress() + dstStart; PlatformDependent.copyMemory(srcAddress, dstAddress, dstLength); - } - else if (dst.hasArray()) { + } else if (dst.hasArray()) { final byte[] dstArray = dst.array(); PlatformDependent.copyMemory(srcAddress, dstArray, dstStart, dstLength); - } - else { + } else { throw new IllegalArgumentException("unsupported byte buffer"); } position += dstLength; @@ -127,8 +122,7 @@ final class MappedFile implements AutoCloseable { if (dst.isDirect()) { final long dstAddress = PlatformDependent.directBufferAddress(dst) + dstStart; PlatformDependent.copyMemory(srcAddress, dstAddress, dstLength); - } - else { + } else { final byte[] dstArray = dst.array(); PlatformDependent.copyMemory(srcAddress, dstArray, dstStart, dstLength); } @@ -153,12 +147,10 @@ final class MappedFile implements AutoCloseable { if (dst.hasMemoryAddress()) { final long dstAddress = dst.memoryAddress() + dstStart; PlatformDependent.copyMemory(srcAddress, dstAddress, read); - } - else if (dst.hasArray()) { + } else if (dst.hasArray()) { final byte[] dstArray = dst.array(); PlatformDependent.copyMemory(srcAddress, dstArray, dstStart, read); - } - else { + } else { throw new IllegalArgumentException("unsupported byte buffer"); } position += read; @@ -179,8 +171,7 @@ final class MappedFile implements AutoCloseable { if (dst.isDirect()) { final long dstAddress = PlatformDependent.directBufferAddress(dst) + dstStart; PlatformDependent.copyMemory(srcAddress, dstAddress, read); - } - else { + } else { final byte[] dstArray = dst.array(); PlatformDependent.copyMemory(srcAddress, dstArray, dstStart, read); } @@ -199,12 +190,10 @@ final class MappedFile implements AutoCloseable { if (src.hasMemoryAddress()) { final long srcAddress = src.memoryAddress() + srcStart; PlatformDependent.copyMemory(srcAddress, destAddress, srcLength); - } - else if (src.hasArray()) { + } else if (src.hasArray()) { final byte[] srcArray = src.array(); PlatformDependent.copyMemory(srcArray, srcStart, destAddress, srcLength); - } - else { + } else { throw new IllegalArgumentException("unsupported byte buffer"); } position += srcLength; @@ -224,8 +213,7 @@ final class MappedFile implements AutoCloseable { if (src.isDirect()) { final long srcAddress = PlatformDependent.directBufferAddress(src) + srcStart; PlatformDependent.copyMemory(srcAddress, destAddress, srcLength); - } - else { + } else { final byte[] srcArray = src.array(); PlatformDependent.copyMemory(srcArray, srcStart, destAddress, srcLength); } @@ -246,12 +234,10 @@ final class MappedFile implements AutoCloseable { if (src.hasMemoryAddress()) { final long srcAddress = src.memoryAddress() + srcStart; PlatformDependent.copyMemory(srcAddress, destAddress, srcLength); - } - else if (src.hasArray()) { + } else if (src.hasArray()) { final byte[] srcArray = src.array(); PlatformDependent.copyMemory(srcArray, srcStart, destAddress, srcLength); - } - else { + } else { throw new IllegalArgumentException("unsupported byte buffer"); } position += srcLength; @@ -271,8 +257,7 @@ final class MappedFile implements AutoCloseable { if (src.isDirect()) { final long srcAddress = PlatformDependent.directBufferAddress(src) + srcStart; PlatformDependent.copyMemory(srcAddress, destAddress, srcLength); - } - else { + } else { final byte[] srcArray = src.array(); PlatformDependent.copyMemory(srcArray, srcStart, destAddress, srcLength); } @@ -328,4 +313,4 @@ final class MappedFile implements AutoCloseable { public void closeAndResize(long length) { cache.closeAndResize(length); } -} \ No newline at end of file +} diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java index c890ff419a..522dbd1cc3 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java @@ -160,8 +160,7 @@ final class MappedSequentialFile implements SequentialFile { } } callback.done(); - } - catch (IOException e) { + } catch (IOException e) { if (this.criticalErrorListener != null) { this.criticalErrorListener.onIOException(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); } @@ -188,8 +187,7 @@ final class MappedSequentialFile implements SequentialFile { private ActiveMQBuffer acquiresActiveMQBufferWithAtLeast(int size) { if (this.pooledActiveMQBuffer == null || this.pooledActiveMQBuffer.capacity() < size) { this.pooledActiveMQBuffer = new ChannelBufferWrapper(Unpooled.directBuffer(size, size).order(ByteOrder.nativeOrder())); - } - else { + } else { this.pooledActiveMQBuffer.clear(); } return pooledActiveMQBuffer; @@ -216,8 +214,7 @@ final class MappedSequentialFile implements SequentialFile { } } callback.done(); - } - catch (IOException e) { + } catch (IOException e) { if (this.criticalErrorListener != null) { this.criticalErrorListener.onIOException(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); } @@ -261,8 +258,7 @@ final class MappedSequentialFile implements SequentialFile { } } callback.done(); - } - catch (IOException e) { + } catch (IOException e) { if (this.criticalErrorListener != null) { this.criticalErrorListener.onIOException(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); } @@ -304,8 +300,7 @@ final class MappedSequentialFile implements SequentialFile { return bytesRead; } return 0; - } - catch (IOException e) { + } catch (IOException e) { if (this.criticalErrorListener != null) { this.criticalErrorListener.onIOException(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); } @@ -360,8 +355,7 @@ final class MappedSequentialFile implements SequentialFile { public long size() { if (this.mappedFile != null) { return this.mappedFile.length(); - } - else { + } else { return this.file.length(); } } @@ -376,8 +370,7 @@ final class MappedSequentialFile implements SequentialFile { final File newFile = new File(this.directory, newFileName); if (!file.renameTo(newFile)) { throw ActiveMQJournalBundle.BUNDLE.ioRenameFileError(file.getName(), newFileName); - } - else { + } else { this.file = newFile; this.fileName = newFileName; this.absoluteFile = null; @@ -431,4 +424,4 @@ final class MappedSequentialFile implements SequentialFile { } return this.absoluteFile; } -} \ No newline at end of file +} diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFileFactory.java index 4dc320689a..23af0b6a5c 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFileFactory.java @@ -164,13 +164,11 @@ public final class MappedSequentialFileFactory implements SequentialFileFactory buffer.clear(); if (buffer.isDirect()) { BytesUtils.zerosDirect(buffer); - } - else if (buffer.hasArray()) { + } else if (buffer.hasArray()) { final byte[] array = buffer.array(); //SIMD OPTIMIZATION Arrays.fill(array, (byte) 0); - } - else { + } else { //TODO VERIFY IF IT COULD HAPPENS final int capacity = buffer.capacity(); for (int i = 0; i < capacity; i++) { @@ -201,4 +199,4 @@ public final class MappedSequentialFileFactory implements SequentialFileFactory public void flush() { } -} \ No newline at end of file +} diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java index e60c21c0f3..40e0544216 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java @@ -30,8 +30,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.AbstractSequentialFile; +import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.journal.ActiveMQJournalBundle; @@ -93,11 +93,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { channel = rfile.getChannel(); fileSize = channel.size(); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -120,11 +118,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { channel.write(bb); channel.force(false); channel.position(0); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -157,11 +153,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { if (rfile != null) { rfile.close(); } - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -193,11 +187,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { bytes.flip(); return bytesRead; - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { if (callback != null) { callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getLocalizedMessage()); } @@ -213,11 +205,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { if (channel != null) { try { channel.force(false); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -232,11 +222,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { try { return channel.size(); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -247,11 +235,9 @@ public final class NIOSequentialFile extends AbstractSequentialFile { try { super.position(pos); channel.position(pos); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); throw e; } @@ -275,8 +261,7 @@ public final class NIOSequentialFile extends AbstractSequentialFile { try { internalWrite(bytes, sync, callback); - } - catch (Exception e) { + } catch (Exception e) { callback.onError(ActiveMQExceptionType.GENERIC_EXCEPTION.getCode(), e.getMessage()); } } @@ -305,8 +290,7 @@ public final class NIOSequentialFile extends AbstractSequentialFile { if (!isOpen()) { if (callback != null) { callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), "File not opened"); - } - else { + } else { throw ActiveMQJournalBundle.BUNDLE.fileNotOpened(); } return; @@ -318,15 +302,12 @@ public final class NIOSequentialFile extends AbstractSequentialFile { // if maxIOSemaphore == null, that means we are not using executors and the writes are synchronous try { doInternalWrite(bytes, sync, callback); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { throw e; - } - catch (IOException e) { + } catch (IOException e) { factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this); } - } - else { + } else { // This is a flow control on writing, just like maxAIO on libaio maxIOSemaphore.acquire(); @@ -336,21 +317,17 @@ public final class NIOSequentialFile extends AbstractSequentialFile { try { try { doInternalWrite(bytes, sync, callback); - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { ActiveMQJournalLogger.LOGGER.errorSubmittingWrite(e); - } - catch (IOException e) { + } catch (IOException e) { ActiveMQJournalLogger.LOGGER.errorSubmittingWrite(e); factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), NIOSequentialFile.this); callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getMessage()); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorSubmittingWrite(e); callback.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getMessage()); } - } - finally { + } finally { maxIOSemaphore.release(); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java index a5884b9afb..f90bebffb7 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFileFactory.java @@ -70,8 +70,7 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory { ByteBuffer buffer2 = null; try { buffer2 = ByteBuffer.allocateDirect(size); - } - catch (OutOfMemoryError error) { + } catch (OutOfMemoryError error) { // This is a workaround for the way the JDK will deal with native buffers. // the main portion is outside of the VM heap // and the JDK will not have any reference about it to take GC into account @@ -83,8 +82,7 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory { System.gc(); Thread.sleep(100); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } buffer2 = ByteBuffer.allocateDirect(size); diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java index 70ddb243ac..705aaaad98 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java @@ -62,18 +62,15 @@ public class FileIOUtil { break; } } - } - finally { + } finally { if (!fromIsOpen) { from.close(); - } - else { + } else { from.position(from.size()); } if (!toIsOpen) { to.close(); - } - else { + } else { to.position(to.size()); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java index a8ffebcaa8..8bbecd2966 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java @@ -96,8 +96,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback if (files == null) { filesToRename.writeInt(0); - } - else { + } else { filesToRename.writeInt(files.size()); for (JournalFile file : files) { @@ -109,8 +108,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback if (newFiles == null) { filesToRename.writeInt(0); - } - else { + } else { filesToRename.writeInt(newFiles.size()); for (JournalFile file : newFiles) { @@ -121,8 +119,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback // Renames from clean up third if (renames == null) { filesToRename.writeInt(0); - } - else { + } else { filesToRename.writeInt(renames.size()); for (Pair rename : renames) { filesToRename.writeUTF(rename.getA()); @@ -147,8 +144,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback controlFile.writeDirect(writeBuffer, true); return controlFile; - } - finally { + } finally { controlFile.close(); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java index 2be920040c..51fb1543d7 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java @@ -25,6 +25,7 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQUnsupportedPacketException; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.IOCompletion; import org.apache.activemq.artemis.core.journal.Journal; @@ -32,7 +33,6 @@ import org.apache.activemq.artemis.core.journal.JournalLoadInformation; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord; import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX; @@ -115,12 +115,10 @@ public final class FileWrapperJournal extends JournalBase { if (callback != null) { currentFile.getFile().write(encoder, sync, callback); - } - else { + } else { currentFile.getFile().write(encoder, sync); } - } - finally { + } finally { lockAppend.unlock(); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java index 40926e00dc..b95d64130a 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java @@ -27,9 +27,9 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding; import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord; import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX; @@ -81,8 +81,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ if (records.size() == 0) { return null; - } - else { + } else { ActiveMQBuffer input = ActiveMQBuffers.wrappedBuffer(records.get(0).data); int numberDataFiles = input.readInt(); @@ -107,8 +106,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ } return controlFile; - } - else { + } else { return null; } } @@ -197,8 +195,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ // will need to open a file either way openFile(); } - } - else { + } else { if (compactCount >= 0) { if (checkCompact(compactCount)) { // The file was already moved on this case, no need to check for the size. @@ -230,8 +227,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ splitted = false; openFile(); return true; - } - else { + } else { return false; } } @@ -243,8 +239,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ for (CompactCommand command : pendingCommands) { try { command.execute(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorReplayingCommands(e); } } @@ -291,8 +286,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ if (pendingTransactions.get(transactionID) != null) { // Sanity check, this should never happen ActiveMQJournalLogger.LOGGER.inconsistencyDuringCompacting(transactionID); - } - else { + } else { JournalTransaction newTransaction = newTransactions.remove(transactionID); if (newTransaction != null) { JournalInternalRecord commitRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.COMMIT, transactionID, null); @@ -361,8 +355,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ // Sanity check, this should never happen throw new IllegalStateException("Inconsistency during compacting: RollbackRecord ID = " + transactionID + " for an already rolled back transaction during compacting"); - } - else { + } else { JournalTransaction newTransaction = newTransactions.remove(transactionID); if (newTransaction != null) { @@ -391,8 +384,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ if (newRecord == null) { ActiveMQJournalLogger.LOGGER.compactingWithNoAddRecord(info.id); - } - else { + } else { newRecord.addUpdateFile(currentFile, updateRecord.getEncodeSize()); } @@ -414,8 +406,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ writeEncoder(updateRecordTX); newTransaction.addPositive(currentFile, info.id, updateRecordTX.getEncodeSize()); - } - else { + } else { onReadUpdateRecord(info); } } @@ -454,8 +445,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ JournalRecord deleteRecord = journal.getRecords().remove(id); if (deleteRecord == null) { ActiveMQJournalLogger.LOGGER.noRecordDuringCompactReplay(id); - } - else { + } else { deleteRecord.delete(usedFile); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalConstants.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalConstants.java index 037e319b2b..052b84be79 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalConstants.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalConstants.java @@ -21,6 +21,6 @@ import org.apache.activemq.artemis.ArtemisConstants; @Deprecated /** * @deprecated Use ArtemisConstants instead. - */ -public final class JournalConstants extends ArtemisConstants { + */ public final class JournalConstants extends ArtemisConstants { + } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFileImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFileImpl.java index 210fcd6606..45d33cc2e0 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFileImpl.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFileImpl.java @@ -104,8 +104,7 @@ public class JournalFileImpl implements JournalFile { if (count == null) { return 0; - } - else { + } else { return count.intValue(); } } @@ -152,8 +151,7 @@ public class JournalFileImpl implements JournalFile { public String toString() { try { return "JournalFileImpl: (" + file.getFileName() + " id = " + fileID + ", recordID = " + recordID + ")"; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return "Error:" + e.toString(); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java index af01b860d4..8440d932b6 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java @@ -88,8 +88,7 @@ public class JournalFilesRepository { public void run() { try { pushOpenedFile(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorPushingFile(e); } } @@ -140,8 +139,7 @@ public class JournalFilesRepository { for (JournalFile file : openedFiles) { try { file.getFile().close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorClosingFile(e); } } @@ -208,8 +206,7 @@ public class JournalFilesRepository { public void openFile(final JournalFile file, final boolean multiAIO) throws Exception { if (multiAIO) { file.getFile().open(); - } - else { + } else { file.getFile().open(1, false); } @@ -348,15 +345,13 @@ public class JournalFilesRepository { long calculatedSize = 0; try { calculatedSize = file.getFile().size(); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e.getMessage() + " file: " + file); } if (calculatedSize != fileSize) { ActiveMQJournalLogger.LOGGER.deletingFile(file); file.getFile().delete(); - } - else if (!checkDelete || (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size() < poolSize) || (poolSize < 0)) { + } else if (!checkDelete || (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size() < poolSize) || (poolSize < 0)) { // Re-initialise it if (logger.isTraceEnabled()) { @@ -371,16 +366,15 @@ public class JournalFilesRepository { freeFiles.add(jf); freeFilesCount.getAndIncrement(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("DataFiles.size() = " + dataFiles.size()); logger.trace("openedFiles.size() = " + openedFiles.size()); logger.trace("minfiles = " + minFiles + ", poolSize = " + poolSize); logger.trace("Free Files = " + freeFilesCount.get()); logger.trace("File " + file + " being deleted as freeFiles.size() + dataFiles.size() + 1 + openedFiles.size() (" + - (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size()) + - ") < minFiles (" + minFiles + ")"); + (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size()) + + ") < minFiles (" + minFiles + ")"); } file.getFile().delete(); } @@ -420,8 +414,7 @@ public class JournalFilesRepository { if (openFilesExecutor == null) { pushOpenRunnable.run(); - } - else { + } else { openFilesExecutor.execute(pushOpenRunnable); } @@ -495,8 +488,7 @@ public class JournalFilesRepository { if (nextFile == null) { nextFile = createFile(keepOpened, multiAIO, initFile, tmpCompactExtension, -1); - } - else { + } else { if (tmpCompactExtension) { SequentialFile sequentialFile = nextFile.getFile(); sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp"); @@ -535,8 +527,7 @@ public class JournalFilesRepository { final long fileIdPreSet) throws Exception { if (System.getSecurityManager() == null) { return createFile0(keepOpened, multiAIO, init, tmpCompact, fileIdPreSet); - } - else { + } else { try { return AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override @@ -544,8 +535,7 @@ public class JournalFilesRepository { return createFile0(keepOpened, multiAIO, init, tmpCompact, fileIdPreSet); } }); - } - catch (PrivilegedActionException e) { + } catch (PrivilegedActionException e) { throw unwrapException(e); } } @@ -555,11 +545,9 @@ public class JournalFilesRepository { Throwable c = e.getCause(); 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); } } @@ -602,8 +590,7 @@ public class JournalFilesRepository { if (keepOpened) { if (multiAIO) { sequentialFile.open(); - } - else { + } else { sequentialFile.open(1, false); } sequentialFile.position(position); @@ -621,8 +608,7 @@ public class JournalFilesRepository { String fileName; if (tmpCompact) { fileName = filePrefix + "-" + fileID + "." + fileExtension + ".cmp"; - } - else { + } else { fileName = filePrefix + "-" + fileID + "." + fileExtension; } return fileName; @@ -638,8 +624,7 @@ public class JournalFilesRepository { private long getFileNameID(final String fileName) { try { return Long.parseLong(fileName.substring(filePrefix.length() + 1, fileName.indexOf('.'))); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorRetrievingID(e, fileName); return 0; } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java index 61d6800ee4..6dd2a7fb74 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java @@ -237,8 +237,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (compactPercentage == 0) { this.compactPercentage = 0; - } - else { + } else { this.compactPercentage = compactPercentage / 100f; } @@ -350,12 +349,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFileImpl jrnFile = readFileHeader(file); orderedFiles.add(jrnFile); - } - finally { + } finally { file.close(); } - } - else { + } else { ActiveMQJournalLogger.LOGGER.ignoringShortFile(fileName); file.delete(); } @@ -537,17 +534,17 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // Avoid a buffer overflow caused by damaged data... continue // scanning for more pendingTransactions... logger.trace("Record at position " + pos + - " recordType = " + - recordType + - " file:" + - file.getFile().getFileName() + - " recordSize: " + - recordSize + - " variableSize: " + - variableSize + - " preparedTransactionExtraDataSize: " + - preparedTransactionExtraDataSize + - " is corrupted and it is being ignored (II)"); + " recordType = " + + recordType + + " file:" + + file.getFile().getFileName() + + " recordSize: " + + recordSize + + " variableSize: " + + variableSize + + " preparedTransactionExtraDataSize: " + + preparedTransactionExtraDataSize + + " is corrupted and it is being ignored (II)"); // If a file has damaged pendingTransactions, we make it a dataFile, and the // next reclaiming will fix it reader.markAsDataFile(file); @@ -570,15 +567,15 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // checkSize by some sort of calculated hash) if (checkSize != variableSize + recordSize + preparedTransactionExtraDataSize) { logger.trace("Record at position " + pos + - " recordType = " + - recordType + - " possible transactionID = " + - transactionID + - " possible recordID = " + - recordID + - " file:" + - file.getFile().getFileName() + - " is corrupted and it is being ignored (III)"); + " recordType = " + + recordType + + " possible transactionID = " + + transactionID + + " possible recordID = " + + recordID + + " file:" + + file.getFile().getFileName() + + " is corrupted and it is being ignored (III)"); // If a file has damaged pendingTransactions, we make it a dataFile, and the // next reclaiming will fix it @@ -667,20 +664,17 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } return lastDataPos; - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorReadingFile(e); throw new Exception(e.getMessage(), e); - } - finally { + } finally { if (wholeFileBuffer != null) { fileFactory.releaseBuffer(wholeFileBuffer); } try { file.getFile().close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -710,17 +704,16 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (logger.isTraceEnabled()) { logger.trace("appendAddRecord::id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + ", userRecordType=" + + recordType + + ", record = " + record + + ", usedFile = " + + usedFile); } records.put(id, new JournalRecord(usedFile, addRecord.getEncodeSize())); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -755,24 +748,22 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (logger.isTraceEnabled()) { logger.trace("appendUpdateRecord::id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + ", userRecordType=" + + recordType + + ", record = " + record + + ", usedFile = " + + usedFile); } // record== null here could only mean there is a compactor, and computing the delete should be done after // compacting is done if (jrnRecord == null) { compactor.addCommandUpdate(id, usedFile, updateRecord.getEncodeSize()); - } - else { + } else { jrnRecord.addUpdateFile(usedFile, updateRecord.getEncodeSize()); } } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -792,8 +783,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (record == null) { throw new IllegalStateException("Cannot find add info " + id); } - } - else { + } else { if (!records.containsKey(id) && !compactor.lookupRecord(id)) { throw new IllegalStateException("Cannot find add info " + id + " on compactor or current records"); } @@ -816,14 +806,12 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // compacting is done if (record == null) { compactor.addCommandDelete(id, usedFile); - } - else { + } else { record.delete(usedFile); } } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -847,19 +835,18 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (logger.isTraceEnabled()) { logger.trace("appendAddRecordTransactional:txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + ",id=" + + id + + ", userRecordType=" + + recordType + + ", record = " + record + + ", usedFile = " + + usedFile); } tx.addPositive(usedFile, id, addRecord.getEncodeSize()); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -893,19 +880,18 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (logger.isTraceEnabled()) { logger.trace("appendUpdateRecordTransactional::txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + ",id=" + + id + + ", userRecordType=" + + recordType + + ", record = " + record + + ", usedFile = " + + usedFile); } tx.addPositive(usedFile, id, updateRecordTX.getEncodeSize()); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -928,16 +914,15 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (logger.isTraceEnabled()) { logger.trace("appendDeleteRecordTransactional::txID=" + txID + - ", id=" + - id + - ", usedFile = " + - usedFile); + ", id=" + + id + + ", usedFile = " + + usedFile); } tx.addNegative(usedFile, id); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -983,8 +968,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal tx.prepare(usedFile); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -1029,8 +1013,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal tx.commit(usedFile); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -1062,8 +1045,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal tx.rollback(usedFile); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -1215,13 +1197,11 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal try { JournalImpl.this.compact(); - } - catch (Throwable e) { + } catch (Throwable e) { errors.incrementAndGet(); ActiveMQJournalLogger.LOGGER.errorCompacting(e); e.printStackTrace(); - } - finally { + } finally { latch.countDown(); } } @@ -1234,8 +1214,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (errors.get() > 0) { throw new RuntimeException("Error during compact, look at the logs"); } - } - finally { + } finally { compactorRunning.set(false); } } @@ -1305,8 +1284,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // We will calculate the new records during compacting, what will take the position the records will take // after compacting records.clear(); - } - finally { + } finally { journalLock.writeLock().unlock(); } @@ -1320,8 +1298,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (final JournalFile file : dataFilesToProcess) { try { JournalImpl.readJournalFile(fileFactory, file, compactor); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.compactReadError(file); throw new Exception("Error on reading compacting for " + file, e); } @@ -1386,13 +1363,11 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalTransaction liveTransaction = transactions.get(newTransaction.getId()); if (liveTransaction != null) { liveTransaction.merge(newTransaction); - } - else { + } else { ActiveMQJournalLogger.LOGGER.compactMergeError(newTransaction.getId()); } } - } - finally { + } finally { journalLock.writeLock().unlock(); } @@ -1402,22 +1377,19 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal ActiveMQJournalLogger.LOGGER.debug("Finished compacting on journal"); - } - finally { + } finally { // An Exception was probably thrown, and the compactor was not cleared if (compactor != null) { try { compactor.flush(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } compactor = null; } setAutoReclaim(previousReclaimValue); } - } - finally { + } finally { compactorLock.writeLock().unlock(); } @@ -1650,8 +1622,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (healthy) { journalTransaction.prepare(file); - } - else { + } else { ActiveMQJournalLogger.LOGGER.preparedTXIncomplete(transactionID); tx.invalid = true; } @@ -1681,8 +1652,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (RecordInfo txRecord : tx.recordInfos) { if (txRecord.isUpdate) { loadManager.updateRecord(txRecord); - } - else { + } else { loadManager.addRecord(txRecord); } } @@ -1692,8 +1662,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } journalTransaction.commit(file); - } - else { + } else { ActiveMQJournalLogger.LOGGER.txMissingElements(transactionID); journalTransaction.forget(); @@ -1737,8 +1706,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (hasData.get()) { lastDataPos = resultLastPost; filesRepository.addDataFileOnBottom(file); - } - else { + } else { if (changeData) { // Empty dataFiles with no data filesRepository.addFreeFile(file, false, false); @@ -1766,8 +1734,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } loadManager.failedTransaction(transaction.transactionID, transaction.recordInfos, transaction.recordsToDelete); - } - else { + } else { for (RecordInfo info : transaction.recordInfos) { if (info.id > maxID.get()) { maxID.set(info.id); @@ -1823,8 +1790,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal filesRepository.addFreeFile(file, false); } } - } - finally { + } finally { journalLock.readLock().unlock(); } @@ -1878,11 +1844,9 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal try { JournalImpl.this.compact(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorCompacting(e); - } - finally { + } finally { compactorRunning.set(false); } } @@ -1934,8 +1898,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (currentFile instanceof JournalFileImpl) { builder.append(((JournalFileImpl) currentFile).debug()); } - } - else { + } else { builder.append("CurrentFile: No current file at this point!"); } @@ -2035,8 +1998,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal moveNextFile(false); debugWait(); } - } - finally { + } finally { journalLock.readLock().unlock(); } } @@ -2113,8 +2075,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (CountDownLatch latch : latches) { latch.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.warn(e.getMessage(), e); } @@ -2130,8 +2091,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal currentFile = null; } - } - finally { + } finally { journalLock.writeLock().unlock(); } } @@ -2147,8 +2107,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal ArrayList> cleanupList; if (cleanupRename == null) { cleanupList = null; - } - else { + } else { cleanupList = new ArrayList<>(); cleanupList.add(cleanupRename); } @@ -2178,13 +2137,11 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (JournalFile file : oldFiles) { try { filesRepository.addFreeFile(file, false); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQJournalLogger.LOGGER.errorReinitializingFile(e, file); } } - } - finally { + } finally { done.countDown(); } } @@ -2308,8 +2265,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } if (journalVersion >= 2) { return recordSize + 1; - } - else { + } else { return recordSize; } } @@ -2380,8 +2336,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal sequentialFile.writeDirect(bb, true); return bufferSize; - } - finally { + } finally { // release it by first unwrap the unreleasable buffer and then release it. buffer.byteBuf().unwrap().release(); } @@ -2429,8 +2384,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal txcallback.setDelegateCompletion(parameterCallback); } callback = txcallback; - } - else { + } else { callback = null; } @@ -2439,8 +2393,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // Filling the number of pendingTransactions at the current file tx.fillNumberOfRecords(currentFile, encoder); } - } - else { + } else { callback = parameterCallback; } @@ -2449,8 +2402,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (callback != null) { currentFile.getFile().write(encoder, sync, callback); - } - else { + } else { currentFile.getFile().write(encoder, sync); } @@ -2471,8 +2423,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (!checkReclaimStatus()) { checkCompact(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorSchedulingCompacting(e); } } @@ -2563,8 +2514,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal private static boolean isInvalidSize(final int fileSize, final int bufferPos, final int size) { if (size < 0) { return true; - } - else { + } else { final int position = bufferPos + size; return position > fileSize || position < 0; @@ -2642,8 +2592,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (int i = 0; i < pages; i++) { appendRecord(blastRecord, false, false, null, null); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQJournalLogger.LOGGER.failedToPerfBlast(e); } } @@ -2660,8 +2609,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal public final void synchronizationUnlock() { try { compactorLock.writeLock().unlock(); - } - finally { + } finally { journalLock.writeLock().unlock(); } } @@ -2687,8 +2635,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } filesRepository.setNextFileID(maxID); return map; - } - finally { + } finally { synchronizationUnlock(); } } @@ -2715,8 +2662,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (!currentFile.getFile().isOpen()) currentFile.getFile().open(); currentFile.getFile().position(currentFile.getFile().calculateBlockStart(lastDataPos)); - } - else { + } else { currentFile = filesRepository.getFreeFile(); filesRepository.openFile(currentFile, true); } @@ -2763,8 +2709,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal try { if (timeout < 0) { latch.await(); - } - else { + } else { latch.await(timeout, TimeUnit.SECONDS); } @@ -2772,8 +2717,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (state == JournalState.STOPPED) { throw new RuntimeException("Server is not started"); } - } - finally { + } finally { latches.remove(latch); } } @@ -2811,8 +2755,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal public void testCompact() { try { scheduleCompactAndBlock(60); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java index a01efede45..6e41c1799c 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java @@ -78,8 +78,7 @@ public class JournalTransaction { public long[] getPositiveArray() { if (pos == null) { return new long[0]; - } - else { + } else { int i = 0; long[] ids = new long[pos.size()]; for (JournalUpdate el : pos) { @@ -220,8 +219,7 @@ public class JournalTransaction { if (compacting) { compactor.addCommandCommit(this, file); - } - else { + } else { if (pos != null) { for (JournalUpdate trUpdate : pos) { @@ -232,13 +230,11 @@ public class JournalTransaction { // but the commit arrived while compacting was working // We need to cache the counter update, so compacting will take the correct files when it is done compactor.addCommandUpdate(trUpdate.id, trUpdate.file, trUpdate.size); - } - else if (posFiles == null) { + } else if (posFiles == null) { posFiles = new JournalRecord(trUpdate.file, trUpdate.size); journal.getRecords().put(trUpdate.id, posFiles); - } - else { + } else { posFiles.addUpdateFile(trUpdate.file, trUpdate.size); } } @@ -248,8 +244,7 @@ public class JournalTransaction { for (JournalUpdate trDelete : neg) { if (compactor != null) { compactor.addCommandDelete(trDelete.id, trDelete.file); - } - else { + } else { JournalRecord posFiles = journal.getRecords().remove(trDelete.id); if (posFiles != null) { @@ -294,8 +289,7 @@ public class JournalTransaction { if (compacting && compactor != null) { compactor.addCommandRollback(this, file); - } - else { + } else { // Now add negs for the pos we added in each file in which there were // transactional operations // Note that we do this on rollback as we do on commit, since we need diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/Reclaimer.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/Reclaimer.java index accbe80ef4..3760723043 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/Reclaimer.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/Reclaimer.java @@ -58,8 +58,7 @@ public class Reclaimer { if (outstandingNeg) { continue; // Move to next file as we already know that this file can't be reclaimed because criterion 2) - } - else { + } else { currentFile.setNegReclaimCriteria(); } } @@ -78,10 +77,9 @@ public class Reclaimer { } } - if (negCount < posCount ) { + if (negCount < posCount) { logger.tracef("%s can't be reclaimed because there are not enough negatives %d", currentFile, negCount); - } - else { + } else { logger.tracef("%s can be reclaimed", currentFile); currentFile.setPosReclaimCriteria(); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java index aa0e961fd0..c6a5d4a128 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java @@ -49,8 +49,7 @@ public class JournalAddRecord extends JournalInternalRecord { public void encode(final ActiveMQBuffer buffer) { if (add) { buffer.writeByte(JournalImpl.ADD_RECORD); - } - else { + } else { buffer.writeByte(JournalImpl.UPDATE_RECORD); } @@ -73,4 +72,4 @@ public class JournalAddRecord extends JournalInternalRecord { public int getEncodeSize() { return JournalImpl.SIZE_ADD_RECORD + record.getEncodeSize() + 1; } -} \ No newline at end of file +} diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java index 2af8797a09..6cec1220e9 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java @@ -58,8 +58,7 @@ public class JournalAddRecordTX extends JournalInternalRecord { public void encode(final ActiveMQBuffer buffer) { if (add) { buffer.writeByte(JournalImpl.ADD_RECORD_TX); - } - else { + } else { buffer.writeByte(JournalImpl.UPDATE_RECORD_TX); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalCompleteRecordTX.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalCompleteRecordTX.java index b0c2c49a2e..ff106d4c09 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalCompleteRecordTX.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalCompleteRecordTX.java @@ -62,8 +62,7 @@ public class JournalCompleteRecordTX extends JournalInternalRecord { public void encode(final ActiveMQBuffer buffer) { if (txRecordType == TX_RECORD_TYPE.COMMIT) { buffer.writeByte(JournalImpl.COMMIT_RECORD); - } - else { + } else { buffer.writeByte(JournalImpl.PREPARE_RECORD); } @@ -100,8 +99,7 @@ public class JournalCompleteRecordTX extends JournalInternalRecord { public int getEncodeSize() { if (txRecordType == TX_RECORD_TYPE.COMMIT) { return JournalImpl.SIZE_COMPLETE_TRANSACTION_RECORD + 1; - } - else { + } else { return JournalImpl.SIZE_PREPARE_RECORD + (transactionData != null ? transactionData.getEncodeSize() : 0) + 1; } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalInternalRecord.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalInternalRecord.java index 0087816731..988194b32d 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalInternalRecord.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalInternalRecord.java @@ -51,8 +51,7 @@ public abstract class JournalInternalRecord implements EncodingSupport { public void setCompactCount(final short compactCount) { if (compactCount > Byte.MAX_VALUE) { this.compactCount = Byte.MAX_VALUE; - } - else { + } else { this.compactCount = (byte) compactCount; } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalBundle.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalBundle.java index 247064cde9..472f16f294 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalBundle.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalBundle.java @@ -17,9 +17,9 @@ package org.apache.activemq.artemis.journal; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 14 diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java index 67574d1dff..198185c1ae 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java @@ -72,8 +72,8 @@ public interface ActiveMQJournalLogger extends BasicLogger { @LogMessage(level = Logger.Level.INFO) @Message(id = 141007, value = "Current File on the journal is <= the sequence file.getFileID={0} on the dataFiles" + - "\nCurrentfile.getFileId={1} while the file.getFileID()={2}" + - "\nIs same = ({3})", + "\nCurrentfile.getFileId={1} while the file.getFileID()={2}" + + "\nIs same = ({3})", format = Message.Format.MESSAGE_FORMAT) void currentFile(Long fileID, Long id, Long fileFileID, Boolean b); diff --git a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java index 926981cf91..1749ca173a 100644 --- a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java +++ b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.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, diff --git a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/FileIOUtilTest.java b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/FileIOUtilTest.java index 0e3d7d7a2e..4c8aba4c18 100644 --- a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/FileIOUtilTest.java +++ b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/FileIOUtilTest.java @@ -61,7 +61,6 @@ public class FileIOUtilTest { file2.open(); file2.writeDirect(buffer, true); - // This is allocating a reusable buffer to perform the copy, just like it's used within LargeMessageInSync buffer = ByteBuffer.allocate(4 * 1024); @@ -83,5 +82,4 @@ public class FileIOUtilTest { } - } diff --git a/artemis-junit/pom.xml b/artemis-junit/pom.xml index 89aa47ffe7..ca5972dbe2 100644 --- a/artemis-junit/pom.xml +++ b/artemis-junit/pom.xml @@ -17,54 +17,54 @@ - 4.0.0 + 4.0.0 - - org.apache.activemq - artemis-pom - 1.5.0-SNAPSHOT - + + org.apache.activemq + artemis-pom + 1.5.0-SNAPSHOT + - artemis-junit - jar - ActiveMQ Artemis JUnit Rules + artemis-junit + jar + ActiveMQ Artemis JUnit Rules - - ${project.basedir}/.. - + + ${project.basedir}/.. + - - - junit - junit - provided - - - - org.jboss.logmanager - jboss-logmanager - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - + + + junit + junit + provided + + + + org.jboss.logmanager + jboss-logmanager + + + org.apache.activemq + artemis-jms-server + ${project.version} + + + org.apache.activemq + artemis-jms-client + ${project.version} + - - org.slf4j - slf4j-api - + + org.slf4j + slf4j-api + - - org.slf4j - slf4j-simple - - + + org.slf4j + slf4j-simple + + diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/AbstractActiveMQClientResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/AbstractActiveMQClientResource.java index 74b9db87c2..b9179b1849 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/AbstractActiveMQClientResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/AbstractActiveMQClientResource.java @@ -45,8 +45,7 @@ public abstract class AbstractActiveMQClientResource extends ExternalResource { try { this.serverLocator = ActiveMQClient.createServerLocator(url); - } - catch (Exception ex) { + } catch (Exception ex) { throw new RuntimeException(String.format("Error creating {} - createServerLocator( {} ) failed", this.getClass().getSimpleName(), url.toString()), ex); } } @@ -90,11 +89,9 @@ public abstract class AbstractActiveMQClientResource extends ExternalResource { try { sessionFactory = serverLocator.createSessionFactory(); session = sessionFactory.createSession(); - } - catch (RuntimeException runtimeEx) { + } catch (RuntimeException runtimeEx) { throw runtimeEx; - } - catch (Exception ex) { + } catch (Exception ex) { throw new ActiveMQClientResourceException(String.format("%s initialisation failure", this.getClass().getSimpleName()), ex); } @@ -102,8 +99,7 @@ public abstract class AbstractActiveMQClientResource extends ExternalResource { try { session.start(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("%s startup failure", this.getClass().getSimpleName()), amqEx); } } @@ -113,11 +109,9 @@ public abstract class AbstractActiveMQClientResource extends ExternalResource { if (session != null) { try { session.close(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { log.warn("ActiveMQException encountered closing InternalClient ClientSession - ignoring", amqEx); - } - finally { + } finally { session = null; } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResource.java index 175b771d10..65f5392b7a 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResource.java @@ -88,8 +88,7 @@ public class ActiveMQConsumerResource extends AbstractActiveMQClientResource { session.createQueue(queueName, queueName); } consumer = session.createConsumer(queueName, browseOnly); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Error creating consumer for queueName %s", queueName.toString()), amqEx); } } @@ -99,11 +98,9 @@ public class ActiveMQConsumerResource extends AbstractActiveMQClientResource { if (consumer != null) { try { consumer.close(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { log.warn("Exception encountered closing consumer - ignoring", amqEx); - } - finally { + } finally { consumer = null; } } @@ -133,24 +130,19 @@ public class ActiveMQConsumerResource extends AbstractActiveMQClientResource { if (timeout > 0) { try { message = consumer.receive(timeout); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResource.EmbeddedActiveMQResourceException(String.format("ClientConsumer.receive( timeout = %d ) for %s failed", timeout, queueName.toString()), amqEx); } - } - else if (timeout == 0) { + } else if (timeout == 0) { try { message = consumer.receiveImmediate(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResource.EmbeddedActiveMQResourceException(String.format("ClientConsumer.receiveImmediate() for %s failed", queueName.toString()), amqEx); } - } - else { + } else { try { message = consumer.receive(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResource.EmbeddedActiveMQResourceException(String.format("ClientConsumer.receive() for %s failed", queueName.toString()), amqEx); } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResource.java index acb8601101..7a34cf5c76 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResource.java @@ -68,12 +68,10 @@ public class ActiveMQDynamicProducerResource extends ActiveMQProducerResource { session.createQueue(address, address); } producer = session.createProducer((SimpleString) null); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { if (address == null) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); - } - else { + } else { throw new ActiveMQClientResourceException("Error creating producer", amqEx); } } @@ -104,15 +102,13 @@ public class ActiveMQDynamicProducerResource extends ActiveMQProducerResource { log.warn("queue does not exist - creating queue: address = {}, name = {}", address.toString(), address.toString()); session.createQueue(targetAddress, targetAddress); } - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Queue creation failed for queue: address = %s, name = %s", address.toString(), address.toString())); } try { producer.send(targetAddress, message); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Failed to send message to %s", targetAddress.toString()), amqEx); } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQProducerResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQProducerResource.java index 8d57bac613..a443a18095 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQProducerResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ActiveMQProducerResource.java @@ -102,8 +102,7 @@ public class ActiveMQProducerResource extends AbstractActiveMQClientResource { session.createQueue(address, address); } producer = session.createProducer(address); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Error creating producer for address %s", address.toString()), amqEx); } } @@ -113,11 +112,9 @@ public class ActiveMQProducerResource extends AbstractActiveMQClientResource { if (producer != null) { try { producer.close(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { log.warn("ActiveMQException encountered closing InternalClient ClientProducer - ignoring", amqEx); - } - finally { + } finally { producer = null; } } @@ -231,8 +228,7 @@ public class ActiveMQProducerResource extends AbstractActiveMQClientResource { public void sendMessage(ClientMessage message) { try { producer.send(message); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new ActiveMQClientResourceException(String.format("Failed to send message to %s", producer.getAddress().toString()), amqEx); } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResource.java index 43bae8c9ac..b9e12e723e 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResource.java @@ -123,8 +123,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { deploymentManager.addDeployable(config); try { deploymentManager.readConfiguration(); - } - catch (Exception ex) { + } catch (Exception ex) { throw new EmbeddedActiveMQResourceException(String.format("Failed to read configuration file %s", filename), ex); } this.configuration = config; @@ -160,8 +159,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { public void start() { try { server.start(); - } - catch (Exception ex) { + } catch (Exception ex) { throw new RuntimeException(String.format("Exception encountered starting %s: %s", server.getClass().getName(), this.getServerName()), ex); } @@ -183,8 +181,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { if (server != null) { try { server.stop(); - } - catch (Exception ex) { + } catch (Exception ex) { log.warn(String.format("Exception encountered stopping %s: %s", server.getClass().getSimpleName(), this.getServerName()), ex); } } @@ -274,8 +271,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { ActiveMQServer activeMQServer = server.getActiveMQServer(); if (activeMQServer != null) { name = activeMQServer.getConfiguration().getName(); - } - else if (configuration != null) { + } else if (configuration != null) { name = configuration.getName(); } @@ -340,8 +336,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { BindingQueryResult bindingQueryResult = null; try { bindingQueryResult = server.getActiveMQServer().bindingQuery(address); - } - catch (Exception e) { + } catch (Exception e) { throw new EmbeddedActiveMQResourceException(String.format("getBoundQueues( %s ) - bindingQuery( %s ) failed", address.toString(), address.toString())); } if (bindingQueryResult.isExists()) { @@ -366,8 +361,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { Queue queue = null; try { queue = server.getActiveMQServer().createQueue(address, name, filter, isUseDurableQueue(), temporary); - } - catch (Exception ex) { + } catch (Exception ex) { throw new EmbeddedActiveMQResourceException(String.format("Failed to create queue: queueName = %s, name = %s", address.toString(), name.toString()), ex); } @@ -386,8 +380,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { SimpleString filter = null; try { server.getActiveMQServer().createSharedQueue(address, name, filter, user, isUseDurableQueue()); - } - catch (Exception ex) { + } catch (Exception ex) { throw new EmbeddedActiveMQResourceException(String.format("Failed to create shared queue: queueName = %s, name = %s, user = %s", address.toString(), name.toString(), user.toString()), ex); } } @@ -569,8 +562,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { public void sendMessage(SimpleString address, ClientMessage message) { if (address == null) { throw new IllegalArgumentException("sendMessage failure - queueName is required"); - } - else if (message == null) { + } else if (message == null) { throw new IllegalArgumentException("sendMessage failure - a ClientMessage is required"); } @@ -770,11 +762,9 @@ public class EmbeddedActiveMQResource extends ExternalResource { try { serverLocator = ActiveMQClient.createServerLocator(getVmURL()); sessionFactory = serverLocator.createSessionFactory(); - } - catch (RuntimeException runtimeEx) { + } catch (RuntimeException runtimeEx) { throw runtimeEx; - } - catch (Exception ex) { + } catch (Exception ex) { throw new EmbeddedActiveMQResourceException("Internal Client creation failure", ex); } @@ -782,8 +772,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { session = sessionFactory.createSession(); producer = session.createProducer((String) null); session.start(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException("Internal Client creation failure", amqEx); } } @@ -792,22 +781,18 @@ public class EmbeddedActiveMQResource extends ExternalResource { if (producer != null) { try { producer.close(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { log.warn("ActiveMQException encountered closing InternalClient ClientProducer - ignoring", amqEx); - } - finally { + } finally { producer = null; } } if (session != null) { try { session.close(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { log.warn("ActiveMQException encountered closing InternalClient ClientSession - ignoring", amqEx); - } - finally { + } finally { session = null; } } @@ -836,8 +821,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { try { producer.send(address, message); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException(String.format("Failed to send message to %s", address.toString()), amqEx); } } @@ -848,8 +832,7 @@ public class EmbeddedActiveMQResource extends ExternalResource { ClientConsumer consumer = null; try { consumer = session.createConsumer(address, browseOnly); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException(String.format("Failed to create consumer for %s", address.toString()), amqEx); } @@ -857,24 +840,19 @@ public class EmbeddedActiveMQResource extends ExternalResource { if (timeout > 0) { try { message = consumer.receive(timeout); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException(String.format("ClientConsumer.receive( timeout = %d ) for %s failed", timeout, address.toString()), amqEx); } - } - else if (timeout == 0) { + } else if (timeout == 0) { try { message = consumer.receiveImmediate(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException(String.format("ClientConsumer.receiveImmediate() for %s failed", address.toString()), amqEx); } - } - else { + } else { try { message = consumer.receive(); - } - catch (ActiveMQException amqEx) { + } catch (ActiveMQException amqEx) { throw new EmbeddedActiveMQResourceException(String.format("ClientConsumer.receive() for %s failed", address.toString()), amqEx); } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java index 1471a5194c..539ddeee9b 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java @@ -151,8 +151,7 @@ public class EmbeddedJMSResource extends ExternalResource { coreDeploymentManager.addDeployable(coreConfiguration); try { coreDeploymentManager.readConfiguration(); - } - catch (Exception readCoreConfigEx) { + } catch (Exception readCoreConfigEx) { throw new EmbeddedJMSResourceException(String.format("Failed to read ActiveMQServer configuration from file %s", serverConfigurationFileName), readCoreConfigEx); } this.configuration = coreConfiguration; @@ -162,8 +161,7 @@ public class EmbeddedJMSResource extends ExternalResource { jmsDeploymentManager.addDeployable(jmsConfiguration); try { jmsDeploymentManager.readConfiguration(); - } - catch (Exception readJmsConfigEx) { + } catch (Exception readJmsConfigEx) { throw new EmbeddedJMSResourceException(String.format("Failed to read JMSServerManager configuration from file %s", jmsConfigurationFileName), readJmsConfigEx); } this.jmsConfiguration = jmsConfiguration; @@ -176,8 +174,7 @@ public class EmbeddedJMSResource extends ExternalResource { for (Map.Entry property : properties.entrySet()) { try { message.setObjectProperty(property.getKey(), property.getValue()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to set property {%s = %s}", property.getKey(), property.getValue().toString()), jmsEx); } } @@ -200,8 +197,7 @@ public class EmbeddedJMSResource extends ExternalResource { log.info("Starting {}: {}", this.getClass().getSimpleName(), this.getServerName()); try { jmsServer.start(); - } - catch (Exception ex) { + } catch (Exception ex) { throw new RuntimeException(String.format("Exception encountered starting %s: %s", jmsServer.getClass().getSimpleName(), this.getServerName()), ex); } } @@ -222,8 +218,7 @@ public class EmbeddedJMSResource extends ExternalResource { if (jmsServer != null) { try { jmsServer.stop(); - } - catch (Exception ex) { + } catch (Exception ex) { log.warn(String.format("Exception encountered stopping %s: %s - ignoring", jmsServer.getClass().getSimpleName(), this.getServerName()), ex); } } @@ -278,8 +273,7 @@ public class EmbeddedJMSResource extends ExternalResource { ActiveMQServer activeMQServer = jmsServer.getActiveMQServer(); if (activeMQServer != null) { name = activeMQServer.getConfiguration().getName(); - } - else if (configuration != null) { + } else if (configuration != null) { name = configuration.getName(); } @@ -320,13 +314,11 @@ public class EmbeddedJMSResource extends ExternalResource { String name = destination.getName(); if (destination.isQueue()) { queue = jmsServer.getActiveMQServer().locateQueue(destination.getSimpleAddress()); - } - else { + } else { BindingQueryResult bindingQueryResult = null; try { bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress()); - } - catch (Exception ex) { + } catch (Exception ex) { log.error(String.format("getDestinationQueue( %s ) - bindingQuery for %s failed", destinationName, destination.getAddress()), ex); return null; } @@ -357,8 +349,7 @@ public class EmbeddedJMSResource extends ExternalResource { BindingQueryResult bindingQueryResult = null; try { bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress()); - } - catch (Exception ex) { + } catch (Exception ex) { log.error(String.format("getTopicQueues( %s ) - bindingQuery for %s failed", topicName, destination.getAddress()), ex); return queues; } @@ -396,12 +387,10 @@ public class EmbeddedJMSResource extends ExternalResource { if (queue == null) { log.warn("getMessageCount(destinationName) - destination {} not found; returning -1", destinationName); count = -1; - } - else { + } else { count = queue.getMessageCount(); } - } - else { + } else { for (Queue topicQueue : getTopicQueues(destinationName)) { count += topicQueue.getMessageCount(); } @@ -451,8 +440,7 @@ public class EmbeddedJMSResource extends ExternalResource { if (body != null) { try { message.writeBytes(body); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on BytesMessage", new String(body)), jmsEx); } } @@ -467,8 +455,7 @@ public class EmbeddedJMSResource extends ExternalResource { if (body != null) { try { message.setText(body); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on TextMessage", body), jmsEx); } } @@ -485,8 +472,7 @@ public class EmbeddedJMSResource extends ExternalResource { for (Map.Entry entry : body.entrySet()) { try { message.setObject(entry.getKey(), entry.getValue()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to set body entry {%s = %s} on MapMessage", entry.getKey(), entry.getValue().toString()), jmsEx); } } @@ -503,8 +489,7 @@ public class EmbeddedJMSResource extends ExternalResource { if (body != null) { try { message.setObject(body); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on ObjectMessage", body.toString()), jmsEx); } } @@ -517,8 +502,7 @@ public class EmbeddedJMSResource extends ExternalResource { public void pushMessage(String destinationName, Message message) { if (destinationName == null) { throw new IllegalArgumentException("sendMessage failure - destination name is required"); - } - else if (message == null) { + } else if (message == null) { throw new IllegalArgumentException("sendMessage failure - a Message is required"); } ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE); @@ -648,8 +632,7 @@ public class EmbeddedJMSResource extends ExternalResource { session = connection.createSession(); producer = session.createProducer(null); connection.start(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("InternalClient creation failure", jmsEx); } } @@ -657,32 +640,26 @@ public class EmbeddedJMSResource extends ExternalResource { void stop() { try { producer.close(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { log.warn("JMSException encounter closing InternalClient Session - MessageProducer", jmsEx); - } - finally { + } finally { producer = null; } try { session.close(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { log.warn("JMSException encounter closing InternalClient Session - ignoring", jmsEx); - } - finally { + } finally { session = null; } if (null != connection) { try { connection.close(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { log.warn("JMSException encounter closing InternalClient Connection - ignoring", jmsEx); - } - finally { + } finally { connection = null; } } @@ -693,8 +670,7 @@ public class EmbeddedJMSResource extends ExternalResource { try { return session.createBytesMessage(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("Failed to create BytesMessage", jmsEx); } } @@ -704,8 +680,7 @@ public class EmbeddedJMSResource extends ExternalResource { try { return session.createTextMessage(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("Failed to create TextMessage", jmsEx); } } @@ -715,8 +690,7 @@ public class EmbeddedJMSResource extends ExternalResource { try { return session.createMapMessage(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("Failed to create MapMessage", jmsEx); } } @@ -726,8 +700,7 @@ public class EmbeddedJMSResource extends ExternalResource { try { return session.createObjectMessage(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("Failed to create ObjectMessage", jmsEx); } } @@ -736,8 +709,7 @@ public class EmbeddedJMSResource extends ExternalResource { checkSession(); try { return session.createStreamMessage(); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException("Failed to create StreamMessage", jmsEx); } } @@ -749,8 +721,7 @@ public class EmbeddedJMSResource extends ExternalResource { try { producer.send(destination, message); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { throw new EmbeddedJMSResourceException(String.format("Failed to push %s to %s", message.getClass().getSimpleName(), destination.toString()), jmsEx); } } diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ThreadLeakCheckRule.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ThreadLeakCheckRule.java index 43da4f5884..d3c6bee387 100644 --- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ThreadLeakCheckRule.java +++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/ThreadLeakCheckRule.java @@ -36,6 +36,7 @@ import org.junit.rules.ExternalResource; * This will also clear Client Thread Pools from ActiveMQClient. */ public class ThreadLeakCheckRule extends ExternalResource { + private static Logger log = Logger.getLogger(ThreadLeakCheckRule.class); private static Set knownThreads = new HashSet<>(); @@ -84,26 +85,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; } @@ -130,21 +127,20 @@ 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; } log.info("#test forceGC Done "); } + public static void removeKownThread(String name) { knownThreads.remove(name); } @@ -160,7 +156,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) { @@ -182,11 +177,9 @@ public class ThreadLeakCheckRule extends ExternalResource { } } - return failedThread; } - /** * if it's an expected thread... we will just move along ignoring it * @@ -195,7 +188,7 @@ public class ThreadLeakCheckRule extends ExternalResource { */ private boolean isExpectedThread(Thread thread) { - for (String known: knownThreads) { + for (String known : knownThreads) { if (thread.getName().contains(known)) { return true; } @@ -204,7 +197,6 @@ public class ThreadLeakCheckRule extends ExternalResource { return false; } - protected static class DumbReference { private CountDownLatch finalized; diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java index 90269edb8a..2f4b11c0d1 100644 --- a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java +++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java @@ -50,11 +50,9 @@ public class ActiveMQConsumerResourceTest { ActiveMQConsumerResource consumer = new ActiveMQConsumerResource(server.getVmURL(), TEST_QUEUE); - @Rule public RuleChain ruleChain = RuleChain.outerRule(new ThreadLeakCheckRule()).outerRule(server).around(consumer); - ClientMessage sent = null; @After @@ -92,4 +90,4 @@ public class ActiveMQConsumerResourceTest { sent = server.sendMessageWithProperties(TEST_ADDRESS, TEST_BODY, TEST_PROPERTIES); } -} \ No newline at end of file +} diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java index fae54ccb06..180ef914bb 100644 --- a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java +++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java @@ -32,6 +32,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; public class EmbeddedActiveMQResourceCustomConfigurationTest { + static final String TEST_QUEUE = "test.queue"; static final String TEST_ADDRESS = "test.address"; @@ -48,7 +49,7 @@ public class EmbeddedActiveMQResourceCustomConfigurationTest { Configuration configuration = server.getServer().getActiveMQServer().getConfiguration(); assertFalse("Persistence should have been disabled", configuration.isPersistenceEnabled()); - assertTrue( "Security should have been enabled", configuration.isSecurityEnabled()); + assertTrue("Security should have been enabled", configuration.isSecurityEnabled()); assertNotNull(TEST_QUEUE + " should exist", server.locateQueue(TEST_QUEUE)); @@ -57,4 +58,4 @@ public class EmbeddedActiveMQResourceCustomConfigurationTest { assertEquals("Should have one queue bound to address " + TEST_ADDRESS, 1, boundQueues.size()); } -} \ No newline at end of file +} diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java index ef1017339f..6731f9f566 100644 --- a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java +++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java @@ -37,7 +37,6 @@ public class EmbeddedActiveMQResourceFileConfigurationTest { @Rule public RuleChain rulechain = RuleChain.outerRule(new ThreadLeakCheckRule()).around(server); - @Test public void testConfiguredQueue() throws Exception { assertNotNull(TEST_QUEUE + " should exist", server.locateQueue(TEST_QUEUE)); @@ -47,4 +46,4 @@ public class EmbeddedActiveMQResourceFileConfigurationTest { assertEquals("Should have one queue bound to address " + TEST_ADDRESS, 1, boundQueues.size()); } -} \ No newline at end of file +} diff --git a/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml b/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml index 11d13bae16..6f68659326 100644 --- a/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml +++ b/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml @@ -15,15 +15,15 @@ limitations under the License. --> - + true - + - \ No newline at end of file + diff --git a/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml b/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml index fda43ddb2d..b2dfdfeff9 100644 --- a/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml +++ b/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml @@ -15,8 +15,8 @@ limitations under the License. --> @@ -31,10 +31,10 @@ - + true - + - \ No newline at end of file + diff --git a/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml b/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml index 451ce539ef..b931e4678c 100644 --- a/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml +++ b/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml @@ -15,8 +15,8 @@ limitations under the License. --> @@ -28,4 +28,4 @@ vm://0 - \ No newline at end of file + diff --git a/artemis-junit/src/test/resources/embedded-artemis-server.xml b/artemis-junit/src/test/resources/embedded-artemis-server.xml index 088ed54f2e..8253243143 100644 --- a/artemis-junit/src/test/resources/embedded-artemis-server.xml +++ b/artemis-junit/src/test/resources/embedded-artemis-server.xml @@ -15,8 +15,8 @@ limitations under the License. --> @@ -38,4 +38,4 @@ - \ No newline at end of file + diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java index 32a9f6ac88..ea6758bb53 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.activemq.artemis.maven; import java.io.File; @@ -62,16 +61,13 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo { @Parameter(defaultValue = "${localRepository}") protected ArtifactRepository localRepository; - - @Override public void execute() throws MojoExecutionException, MojoFailureException { if (isIgnore()) { getLog().debug("******************************************************************************************************"); getLog().debug("Execution of " + getClass().getSimpleName() + " is being ignored as ignore has been set to true"); getLog().debug("******************************************************************************************************"); - } - else { + } else { doExecute(); // We could execute the maven plugins over and over on examples // For that reason we just unlock the server here @@ -88,8 +84,7 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo { Artifact artifact; try { artifact = new DefaultArtifact(artifactID); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new MojoFailureException(e.getMessage(), e); } return artifact; @@ -103,8 +98,7 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo { ArtifactResult result; try { result = repositorySystem.resolveArtifact(repoSession, request); - } - catch (ArtifactResolutionException e) { + } catch (ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } @@ -148,7 +142,8 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo { return dependencies; } - protected Set resolveDependencies(String[] dependencyListParameter, String[] individualListParameter) throws DependencyCollectionException, MojoFailureException, MojoExecutionException { + protected Set resolveDependencies(String[] dependencyListParameter, + String[] individualListParameter) throws DependencyCollectionException, MojoFailureException, MojoExecutionException { Set filesSet = new HashSet<>(); if (dependencyListParameter != null) { for (String lib : dependencyListParameter) { diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java index 6a204eaedc..140251355c 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -21,6 +21,7 @@ import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; +import org.apache.activemq.artemis.boot.Artemis; import org.apache.activemq.artemis.cli.commands.Run; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.maven.plugin.MojoExecutionException; @@ -30,7 +31,6 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.activemq.artemis.boot.Artemis; @Mojo(name = "cli", defaultPhase = LifecyclePhase.VERIFY) public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { @@ -99,7 +99,6 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { return ignore; } - @Override protected void doExecute() throws MojoExecutionException, MojoFailureException { // This is to avoid the Run issuing a kill at any point @@ -110,8 +109,7 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { if (!lookupHome(home.toPath())) { if (lookupHome(alternateHome.toPath())) { home = alternateHome; - } - else { + } else { getLog().error("********************************************************************************************"); getLog().error("Could not locate suitable Artemis.home on either " + home + " or " + alternateHome); getLog().error("Use the binary distribution or build the distribution before running the examples"); @@ -137,13 +135,11 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(testURI)) { if (testUser != null && testPassword != null) { cf.createConnection(testUser, testPassword).close(); - } - else { + } else { cf.createConnection().close(); } getLog().info("Server started"); - } - catch (Exception e) { + } catch (Exception e) { getLog().info("awaiting server to start"); Thread.sleep(500); continue; @@ -151,16 +147,14 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { break; } } - } - else { + } else { Artemis.execute(home, location, args); } Thread.sleep(600); org.apache.activemq.artemis.cli.process.ProcessBuilder.cleanupProcess(); - } - catch (Throwable e) { + } catch (Throwable e) { throw new MojoExecutionException(e.getMessage(), e); } } diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java index 6023cc133a..533fc6ba59 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java @@ -59,8 +59,7 @@ public class ArtemisClientPlugin extends ArtemisAbstractPlugin { Class aClass = Class.forName(clientClass); Method method = aClass.getDeclaredMethod("main", new Class[]{String[].class}); method.invoke(null, new Object[]{args}); - } - catch (Exception e) { + } catch (Exception e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java index b8359f0d93..fdc308a250 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -128,7 +128,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { @Parameter private String[] libListWithDeps; - @Parameter(defaultValue = "${localRepository}") private org.apache.maven.artifact.repository.ArtifactRepository localRepository; @@ -178,8 +177,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { if (!lookupHome(home.toPath())) { if (lookupHome(alternateHome.toPath())) { home = alternateHome; - } - else { + } else { getLog().error("********************************************************************************************"); getLog().error("Could not locate suitable Artemis.home on either " + home + " or " + alternateHome); getLog().error("Use the binary distribution or build the distribution before running the examples"); @@ -204,8 +202,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { if (allowAnonymous) { add(listCommands, "--allow-anonymous"); - } - else { + } else { add(listCommands, "--require-login"); } @@ -256,8 +253,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { FileOutputStream outputStream; try { outputStream = new FileOutputStream(commandLine); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new MojoExecutionException(e.getMessage(), e); } @@ -282,7 +278,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { Set files = resolveDependencies(libListWithDeps, libList); - if (!files.isEmpty() ) { + if (!files.isEmpty()) { commandLineStream.println(); commandLineStream.println("# This is a list of files that need to be installed under ./lib."); commandLineStream.println("# We are copying them from your maven lib home"); @@ -300,14 +296,16 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { getLog().info("under " + commandLine.getParent()); getLog().info("###################################################################################################"); - } - catch (Throwable e) { + } catch (Throwable e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } } - private void copyConfigurationFiles(String[] list, Path sourcePath, Path targetPath, PrintStream commandLineStream) throws IOException { + private void copyConfigurationFiles(String[] list, + Path sourcePath, + Path targetPath, + PrintStream commandLineStream) throws IOException { for (String file : list) { Path target = targetPath.resolve(file); @@ -322,8 +320,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { commandLineStream.println("mkdir " + target); copyConfigurationFiles(originalFile.toFile().list(), originalFile, target, commandLineStream); - } - else { + } else { getLog().debug("Copying " + file + " to " + target); commandLineStream.println("# copying config file " + originalFile.getFileName()); commandLineStream.println("cp " + originalFile + " " + target); @@ -349,7 +346,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { commandLineStream.println("mkdir " + file.getParent()); } - commandLineStream.println("cp " + projectLib.getAbsolutePath() + " " + target); getLog().debug("Copying " + projectLib.getName() + " as " + target.toFile().getAbsolutePath()); Files.copy(projectLib.toPath(), target, StandardCopyOption.REPLACE_EXISTING); diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java index 3b00c99ec6..e59bc366c8 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -76,7 +76,6 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin { getLog().info("... key=" + entry.getKey() + " = " + entry.getValue()); } - try { StringBuffer buffer = new StringBuffer(); Set filesSet = resolveDependencies(libListWithDeps, libList); @@ -100,8 +99,7 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin { Files.copy(file.toPath(), targetFolder.toPath(), StandardCopyOption.REPLACE_EXISTING); } } - } - catch (Throwable e) { + } catch (Throwable e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java index df4c61ba95..8049a97529 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java @@ -67,12 +67,10 @@ public class LibaioContext implements Closeable { if (getNativeVersion() != EXPECTED_NATIVE_VERSION) { NativeLogger.LOGGER.incompatibleNativeLibrary(); return false; - } - else { + } else { return true; } - } - catch (Throwable e) { + } catch (Throwable e) { NativeLogger.LOGGER.debug(name + " -> error loading the native library", e); return false; } @@ -93,8 +91,7 @@ public class LibaioContext implements Closeable { } }); break; - } - else { + } else { NativeLogger.LOGGER.debug("Library " + library + " not found!"); } } @@ -161,16 +158,14 @@ public class LibaioContext implements Closeable { try { contexts.incrementAndGet(); this.ioContext = newContext(queueSize); - } - catch (Exception e) { + } catch (Exception e) { throw e; } this.queueSize = queueSize; totalMaxIO.addAndGet(queueSize); if (useSemaphore) { this.ioSpace = new Semaphore(queueSize); - } - else { + } else { this.ioSpace = null; } } @@ -197,8 +192,7 @@ public class LibaioContext implements Closeable { if (ioSpace != null) { ioSpace.acquire(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException(e.getMessage(), e); } @@ -217,8 +211,7 @@ public class LibaioContext implements Closeable { if (ioSpace != null) { ioSpace.acquire(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException(e.getMessage(), e); } @@ -238,8 +231,7 @@ public class LibaioContext implements Closeable { if (ioSpace != null) { try { ioSpace.tryAcquire(queueSize, 10, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { NativeLogger.LOGGER.error(e); } } diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java index 92a6733c6c..43d80eab46 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java @@ -121,8 +121,7 @@ public final class LibaioFile implements AutoClosea public void fill(long size) { try { LibaioContext.fill(fd, size); - } - catch (OutOfMemoryError e) { + } catch (OutOfMemoryError e) { NativeLogger.LOGGER.debug("Didn't have enough memory to allocate " + size + " bytes in memory, using simple fallocate"); LibaioContext.fallocate(fd, size); } diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java index 22051033f7..afde2fc727 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -42,8 +42,7 @@ public class CallbackCache { synchronized (lock) { if (available <= 0) { return null; - } - else { + } else { Callback retValue = (Callback) pool[get]; pool[get] = null; if (retValue == null) { diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java index 6785d78d70..bed9da3349 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -14,13 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.activemq.artemis.jlibaio.test; import java.util.HashSet; -import org.apache.activemq.artemis.jlibaio.util.CallbackCache; import org.apache.activemq.artemis.jlibaio.SubmitInfo; +import org.apache.activemq.artemis.jlibaio.util.CallbackCache; import org.junit.Assert; import org.junit.Test; diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java index fec742c680..7f98f0d965 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java @@ -53,19 +53,16 @@ public class LibaioTest { try { parent.mkdirs(); - boolean failed = false; try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) { fileDescriptor.fallocate(4 * 1024); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed = true; } Assume.assumeFalse("There is not enough support to libaio", failed); - } - finally { + } finally { file.delete(); } } @@ -218,8 +215,7 @@ public class LibaioTest { file.close(); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); } } @@ -270,8 +266,7 @@ public class LibaioTest { for (int i = 0; i < 512; i++) { Assert.assertEquals('B', buffer.get()); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); fileDescriptor.close(); } @@ -330,8 +325,7 @@ public class LibaioTest { for (int i = 0; i < BUFFER_SIZE; i++) { Assert.assertEquals('B', buffer.get()); } - } - finally { + } finally { fileDescriptor.close(); } } @@ -372,8 +366,7 @@ public class LibaioTest { for (int i = 0; i < BUFFER_SIZE; i++) { Assert.assertEquals('@', buffer.get()); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); fileDescriptor.close(); } @@ -432,8 +425,7 @@ public class LibaioTest { callback = null; TestInfo.checkLeaks(); - } - finally { + } finally { fileDescriptor.close(); } } @@ -470,8 +462,7 @@ public class LibaioTest { } TestInfo.checkLeaks(); - } - finally { + } finally { LibaioContext.freeBuffer(bufferWrite); } } @@ -501,8 +492,7 @@ public class LibaioTest { boolean failed = false; try { LibaioContext.freeBuffer(null); - } - catch (Exception expected) { + } catch (Exception expected) { failed = true; } @@ -546,8 +536,7 @@ public class LibaioTest { try { // There is no space for a queue this huge, the native layer should throw the exception LibaioContext newController = new LibaioContext(Integer.MAX_VALUE, false); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } @@ -557,8 +546,7 @@ public class LibaioTest { try { // this should throw an exception, we shouldn't be able to open a directory! control.openFile(temporaryFolder.getRoot(), true); - } - catch (IOException expected) { + } catch (IOException expected) { exceptionThrown = true; } @@ -570,8 +558,7 @@ public class LibaioTest { fileDescriptor.close(); try { fileDescriptor.close(); - } - catch (IOException expected) { + } catch (IOException expected) { exceptionThrown = true; } @@ -593,8 +580,7 @@ public class LibaioTest { boolean ex = false; try { fileDescriptor.write(0, 512, buffer, new TestInfo()); - } - catch (Exception e) { + } catch (Exception e) { ex = true; } @@ -623,8 +609,7 @@ public class LibaioTest { exceptionThrown = false; try { LibaioContext.newAlignedBuffer(300, 512); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } @@ -633,14 +618,12 @@ public class LibaioTest { exceptionThrown = false; try { LibaioContext.newAlignedBuffer(-512, 512); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } Assert.assertTrue(exceptionThrown); - } - finally { + } finally { LibaioContext.freeBuffer(buffer); } } diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java index 6c7d69b058..c04bff447b 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -48,7 +48,8 @@ public class OpenCloseContextTest { @Test public void testRepeatOpenCloseContext() throws Exception { ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512); - for (int i = 0; i < 512; i++) buffer.put((byte)'x'); + for (int i = 0; i < 512; i++) + buffer.put((byte) 'x'); for (int i = 0; i < 10; i++) { System.out.println("#test " + i); @@ -75,8 +76,7 @@ public class OpenCloseContextTest { insideMethod.countDown(); try { awaitInside.await(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } System.out.println("done"); @@ -98,17 +98,16 @@ public class OpenCloseContextTest { awaitInside.countDown(); control.close(); - t.join(); } - } @Test public void testRepeatOpenCloseContext2() throws Exception { ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512); - for (int i = 0; i < 512; i++) buffer.put((byte)'x'); + for (int i = 0; i < 512; i++) + buffer.put((byte) 'x'); for (int i = 0; i < 10; i++) { System.out.println("#test " + i); @@ -135,8 +134,7 @@ public class OpenCloseContextTest { insideMethod.countDown(); try { awaitInside.await(100, TimeUnit.MILLISECONDS); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } System.out.println("done"); @@ -162,7 +160,6 @@ public class OpenCloseContextTest { t.join(); } - } @Test @@ -173,7 +170,6 @@ public class OpenCloseContextTest { control.close(); control.poll(); - control2.close(); control2.poll(); diff --git a/artemis-protocols/artemis-amqp-protocol/pom.xml b/artemis-protocols/artemis-amqp-protocol/pom.xml index aac507ed1d..b5be461d96 100644 --- a/artemis-protocols/artemis-amqp-protocol/pom.xml +++ b/artemis-protocols/artemis-amqp-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java index fd7954793e..31abf87cb4 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java @@ -30,15 +30,21 @@ import io.netty.channel.ChannelFutureListener; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper; -import org.apache.activemq.artemis.protocol.amqp.sasl.AnonymousServerSASL; -import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASL; import org.apache.activemq.artemis.core.remoting.CloseListener; import org.apache.activemq.artemis.core.remoting.FailureListener; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; import org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport; +import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; +import org.apache.activemq.artemis.protocol.amqp.sasl.AnonymousServerSASL; +import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASL; +import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; +import org.apache.activemq.artemis.protocol.amqp.sasl.ServerSASL; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -46,14 +52,9 @@ import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.transport.AmqpError; import org.jboss.logging.Logger; -import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; -import org.apache.activemq.artemis.protocol.amqp.sasl.ServerSASL; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; -import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; -import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; public class AMQPConnectionCallback implements FailureListener, CloseListener { + private static final Logger logger = Logger.getLogger(AMQPConnectionCallback.class); private ConcurrentMap transactions = new ConcurrentHashMap<>(); @@ -92,8 +93,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { if (isSupportsAnonymous()) { result = new ServerSASL[]{new PlainSASL(manager.getServer().getSecurityStore()), new AnonymousServerSASL()}; - } - else { + } else { result = new ServerSASL[]{new PlainSASL(manager.getServer().getSecurityStore())}; } @@ -105,8 +105,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { try { manager.getServer().getSecurityStore().authenticate(null, null, null); supportsAnonymous = true; - } - catch (Exception e) { + } catch (Exception e) { // authentication failed so no anonymous support } return supportsAnonymous; @@ -119,13 +118,11 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { } connection.close(); amqpConnection.close(); - } - finally { + } finally { for (Transaction tx : transactions.values()) { try { tx.rollback(); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -135,8 +132,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { public Executor getExeuctor() { if (protonConnectionDelegate != null) { return protonConnectionDelegate.getExecutor(); - } - else { + } else { return null; } } @@ -172,8 +168,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { if (amqpConnection.isSyncOnFlush()) { try { latch.await(5, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -245,7 +240,6 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { transactions.remove(xid); } - protected XidImpl newXID() { return newXID(UUIDGenerator.getInstance().generateStringUUID().getBytes()); } @@ -254,7 +248,4 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { return new XidImpl("amqp".getBytes(), 1, bytes); } - - - } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java index 9bdf4e1027..46ed1c9429 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java @@ -28,8 +28,6 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.paging.PagingStore; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; -import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; import org.apache.activemq.artemis.core.server.BindingQueryResult; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.QueueQueryResult; @@ -39,7 +37,15 @@ import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext; import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASLResult; +import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ReadyListener; @@ -56,12 +62,6 @@ import org.apache.qpid.proton.engine.Delivery; import org.apache.qpid.proton.engine.Link; import org.apache.qpid.proton.engine.Receiver; import org.apache.qpid.proton.message.ProtonJMessage; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext; -import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; -import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException; public class AMQPSessionCallback implements SessionCallback { @@ -111,15 +111,13 @@ public class AMQPSessionCallback implements SessionCallback { public void run() { try { plugSender.getSender().drained(); - } - finally { + } finally { draining.set(false); } } }); } - } - else { + } else { serverConsumer.receiveCredits(-1); } } @@ -203,8 +201,7 @@ public class AMQPSessionCallback implements SessionCallback { if (!queueQueryResult.isExists() && queueQueryResult.isAutoCreateJmsQueues() && autoCreate) { try { serverSession.createQueue(new SimpleString(queueName), new SimpleString(queueName), null, false, true); - } - catch (ActiveMQQueueExistsException e) { + } catch (ActiveMQQueueExistsException e) { // The queue may have been created by another thread in the mean time. Catch and do nothing. } queueQueryResult = new QueueQueryResult(queueQueryResult.getName(), queueQueryResult.getAddress(), queueQueryResult.isDurable(), queueQueryResult.isTemporary(), queueQueryResult.getFilterString(), queueQueryResult.getConsumerCount(), queueQueryResult.getMessageCount(), queueQueryResult.isAutoCreateJmsQueues(), true); @@ -217,8 +214,7 @@ public class AMQPSessionCallback implements SessionCallback { if (!bindingQueryResult.isExists() && bindingQueryResult.isAutoCreateJmsQueues()) { try { serverSession.createQueue(new SimpleString(address), new SimpleString(address), null, false, true); - } - catch (ActiveMQQueueExistsException e) { + } catch (ActiveMQQueueExistsException e) { // The queue may have been created by another thread in the mean time. Catch and do nothing. } bindingQueryResult = serverSession.executeBindingQuery(SimpleString.toSimpleString(address)); @@ -237,8 +233,7 @@ public class AMQPSessionCallback implements SessionCallback { try { consumer.close(false); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { } } }; @@ -250,15 +245,13 @@ public class AMQPSessionCallback implements SessionCallback { if (executor != null) { executor.execute(runnable); - } - else { + } else { runnable.run(); } try { latch.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQAMQPInternalErrorException("Unable to close consumers for queue: " + consumer.getQueue()); } } @@ -277,8 +270,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { serverSession.close(false); - } - finally { + } finally { resetContext(); } } @@ -291,8 +283,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { ((ServerConsumer) brokerConsumer).individualAcknowledge(transaction, ((ServerMessage) message).getMessageID()); - } - finally { + } finally { resetContext(); } } @@ -301,8 +292,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { ((ServerConsumer) brokerConsumer).individualCancel(((ServerMessage) message).getMessageID(), updateCounts); - } - finally { + } finally { resetContext(); } } @@ -336,12 +326,10 @@ public class AMQPSessionCallback implements SessionCallback { ActiveMQException e = new ActiveMQAMQPResourceLimitExceededException("Address is full: " + amqpAddress); transaction.markAsRollbackOnly(e); } - } - else { + } else { rejectMessage(delivery); } - } - else { + } else { serverSend(transaction, message, delivery, receiver); } } @@ -355,7 +343,10 @@ public class AMQPSessionCallback implements SessionCallback { connection.flush(); } - private void serverSend(final Transaction transaction, final ServerMessage message, final Delivery delivery, final Receiver receiver) throws Exception { + private void serverSend(final Transaction transaction, + final ServerMessage message, + final Delivery delivery, + final Receiver receiver) throws Exception { try { message.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString(), receiver.getSession().getConnection().getRemoteContainer()); @@ -380,8 +371,7 @@ public class AMQPSessionCallback implements SessionCallback { } } }); - } - finally { + } finally { resetContext(); } } @@ -390,7 +380,10 @@ public class AMQPSessionCallback implements SessionCallback { return manager.getPubSubPrefix(); } - public void offerProducerCredit(final String address, final int credits, final int threshold, final Receiver receiver) { + public void offerProducerCredit(final String address, + final int credits, + final int threshold, + final Receiver receiver) { try { final PagingStore store = manager.getServer().getPagingManager().getPageStore(new SimpleString(address)); store.checkMemory(new Runnable() { @@ -402,8 +395,7 @@ public class AMQPSessionCallback implements SessionCallback { } } }); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -442,8 +434,7 @@ public class AMQPSessionCallback implements SessionCallback { try { return plugSender.deliverMessage(message, deliveryCount); - } - catch (Exception e) { + } catch (Exception e) { synchronized (connection.getLock()) { plugSender.getSender().setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, e.getMessage())); connection.flush(); @@ -454,7 +445,11 @@ public class AMQPSessionCallback implements SessionCallback { } @Override - public int sendLargeMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, long bodySize, int deliveryCount) { + public int sendLargeMessage(MessageReference ref, + ServerMessage message, + ServerConsumer consumer, + long bodySize, + int deliveryCount) { return 0; } @@ -484,8 +479,7 @@ public class AMQPSessionCallback implements SessionCallback { if (plugSender != null && plugSender.getSender().getCredit() > 0) { return true; - } - else { + } else { return false; } } @@ -498,7 +492,6 @@ public class AMQPSessionCallback implements SessionCallback { return protonSPI.newTransaction(); } - public void commitTX(Binary txid) throws Exception { Transaction tx = protonSPI.getTransaction(txid); tx.commit(true); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java index 8fd3169fbc..7f129a1981 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java @@ -22,9 +22,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; import org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection; import org.apache.activemq.artemis.spi.core.remoting.Connection; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; /** * This is a Server's Connection representation used by ActiveMQ Artemis. diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java index fe7b9764ec..f5b6c780f0 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java @@ -25,13 +25,14 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConstants; -import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnection; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.management.Notification; import org.apache.activemq.artemis.core.server.management.NotificationListener; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConstants; import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry; import org.apache.activemq.artemis.spi.core.protocol.MessageConverter; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager; @@ -39,7 +40,6 @@ import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; import org.apache.activemq.artemis.spi.core.remoting.Connection; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; /** * A proton protocol manager, basically reads the Proton Input and maps proton resources to ActiveMQ Artemis resources @@ -108,8 +108,7 @@ public class ProtonProtocolManager implements ProtocolManager, Noti } String id = server.getConfiguration().getName(); - AMQPConnectionContext amqpConnection = - new AMQPConnectionContext(connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, server.getExecutorFactory().getExecutor(), server.getScheduledPool()); + AMQPConnectionContext amqpConnection = new AMQPConnectionContext(connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, server.getExecutorFactory().getExecutor(), server.getScheduledPool()); Executor executor = server.getExecutorFactory().getExecutor(); @@ -161,7 +160,6 @@ public class ProtonProtocolManager implements ProtocolManager, Noti this.pubSubPrefix = pubSubPrefix; } - public int getMaxFrameSize() { return maxFrameSize; } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java index 7255ca0c3a..bef8ef07ee 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.protocol.amqp.broker; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -25,10 +29,6 @@ import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.osgi.service.component.annotations.Component; -import java.util.Collections; -import java.util.List; -import java.util.Map; - @Component(service = ProtocolManagerFactory.class) public class ProtonProtocolManagerFactory extends AbstractProtocolManagerFactory { diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java index 7e3ba67f2a..0b28660864 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java @@ -26,17 +26,17 @@ import javax.jms.StreamMessage; import javax.jms.TextMessage; import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer; +import org.apache.activemq.artemis.core.server.ServerMessage; +import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerDestination; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; -import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSVendor; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage; -import org.apache.activemq.artemis.core.server.ServerMessage; -import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSVendor; import org.apache.activemq.artemis.utils.IDGenerator; public class ActiveMQJMSVendor implements JMSVendor { @@ -90,8 +90,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXGroupID(Message message, String s) { try { message.setStringProperty("_AMQ_GROUP_ID", s); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -100,8 +99,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXGroupSequence(Message message, int i) { try { message.setIntProperty("JMSXGroupSeq", i); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -110,8 +108,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXDeliveryCount(Message message, long l) { try { message.setLongProperty("JMSXDeliveryCount", l); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java index f5203870e0..6eb78d02d8 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter; +import javax.jms.BytesMessage; +import java.io.IOException; + import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; +import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; import org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPNativeOutboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; import org.apache.activemq.artemis.protocol.amqp.converter.message.InboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingInboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingOutboundTransformer; -import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.spi.core.protocol.MessageConverter; import org.apache.activemq.artemis.utils.IDGenerator; -import javax.jms.BytesMessage; -import java.io.IOException; - public class ProtonMessageConverter implements MessageConverter { ActiveMQJMSVendor activeMQJMSVendor; @@ -58,7 +58,7 @@ public class ProtonMessageConverter implements MessageConverter { * * @param messageSource * @return - * @throws Exception https://issues.jboss.org/browse/ENTMQ-1560 + * @throws Exception https://issues.jboss.org/browse/ENTMQ-1560 */ public ServerJMSMessage inboundJMSType(EncodedMessage messageSource) throws Exception { EncodedMessage encodedMessageSource = messageSource; @@ -70,8 +70,7 @@ public class ProtonMessageConverter implements MessageConverter { try { transformedMessage = (ServerJMSMessage) transformer.transform(encodedMessageSource); break; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.debug("Transform of message using [{}] transformer, failed" + inboundTransformer.getTransformerName()); ActiveMQClientLogger.LOGGER.trace("Transformation error:", e); @@ -97,12 +96,10 @@ public class ProtonMessageConverter implements MessageConverter { if (jmsMessage.getBooleanProperty(prefixVendor + "NATIVE")) { if (jmsMessage instanceof BytesMessage) { return AMQPNativeOutboundTransformer.transform(outboundTransformer, (BytesMessage) jmsMessage); - } - else { + } else { return null; } - } - else { + } else { return outboundTransformer.convert(jmsMessage); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java index 967ba08b5d..8e82b89fe2 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java @@ -16,16 +16,17 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.jms; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; - import javax.jms.JMSException; import javax.jms.Queue; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; + /** * This is just here to avoid all the client checks we need with valid JMS destinations, protocol convertors don't need to * adhere to the jms. semantics. */ public class ServerDestination extends ActiveMQDestination implements Queue { + public ServerDestination(String name) { super(name, name, false, false, null); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java index 548deb3ac9..0268065ea8 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java @@ -123,8 +123,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public void setObject(final String name, final Object value) throws JMSException { try { TypedProperties.setObjectProperty(new SimpleString(name), value, map); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -133,8 +132,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public boolean getBoolean(final String name) throws JMSException { try { return map.getBooleanProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -143,8 +141,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public byte getByte(final String name) throws JMSException { try { return map.getByteProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -153,8 +150,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public short getShort(final String name) throws JMSException { try { return map.getShortProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -163,8 +159,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public char getChar(final String name) throws JMSException { try { return map.getCharProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -173,8 +168,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public int getInt(final String name) throws JMSException { try { return map.getIntProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -183,8 +177,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public long getLong(final String name) throws JMSException { try { return map.getLongProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -193,8 +186,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public float getFloat(final String name) throws JMSException { try { return map.getFloatProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -203,8 +195,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public double getDouble(final String name) throws JMSException { try { return map.getDoubleProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -215,12 +206,10 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe SimpleString str = map.getSimpleStringProperty(new SimpleString(name)); if (str == null) { return null; - } - else { + } else { return str.toString(); } - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -229,8 +218,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public byte[] getBytes(final String name) throws JMSException { try { return map.getBytesProperty(new SimpleString(name)); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java index d15d22b527..a6eac1dd34 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java @@ -49,7 +49,9 @@ public class ServerJMSMessage implements Message { private ActiveMQBuffer readBodyBuffer; - /** When reading we use a protected copy so multi-threads can work fine */ + /** + * When reading we use a protected copy so multi-threads can work fine + */ protected ActiveMQBuffer getReadBodyBuffer() { if (readBodyBuffer == null) { // to avoid clashes between multiple threads @@ -58,13 +60,14 @@ public class ServerJMSMessage implements Message { return readBodyBuffer; } - /** When writing on the conversion we use the buffer directly */ + /** + * When writing on the conversion we use the buffer directly + */ protected ActiveMQBuffer getWriteBodyBuffer() { readBodyBuffer = null; // it invalidates this buffer if anything is written return message.getBodyBuffer(); } - @Override public final String getJMSMessageID() throws JMSException { if (message.containsProperty(NATIVE_MESSAGE_ID)) { @@ -99,8 +102,7 @@ public class ServerJMSMessage implements Message { public final void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException { try { MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new JMSException(e.getMessage()); } } @@ -120,8 +122,7 @@ public class ServerJMSMessage implements Message { SimpleString reply = MessageUtil.getJMSReplyTo(message); if (reply != null) { return new ServerDestination(reply.toString()); - } - else { + } else { return null; } } @@ -138,8 +139,7 @@ public class ServerJMSMessage implements Message { if (sdest == null) { return null; - } - else { + } else { return new ServerDestination(sdest.toString()); } } @@ -148,8 +148,7 @@ public class ServerJMSMessage implements Message { public final void setJMSDestination(Destination destination) throws JMSException { if (destination == null) { message.setAddress(null); - } - else { + } else { message.setAddress(((ActiveMQDestination) destination).getSimpleAddress()); } @@ -164,11 +163,9 @@ public class ServerJMSMessage implements Message { public final void setJMSDeliveryMode(int deliveryMode) throws JMSException { if (deliveryMode == DeliveryMode.PERSISTENT) { message.setDurable(true); - } - else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { + } else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { message.setDurable(false); - } - else { + } else { throw new JMSException("Invalid mode " + deliveryMode); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java index c8fb00306b..349934b124 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.jms; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.core.message.impl.MessageInternal; -import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; - import javax.jms.JMSException; import javax.jms.ObjectMessage; import java.io.ByteArrayInputStream; @@ -27,17 +23,21 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.core.message.impl.MessageInternal; +import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; + +public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMessage { -public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMessage { private static final String DEFAULT_WHITELIST; private static final String DEFAULT_BLACKLIST; static { - DEFAULT_WHITELIST = System.getProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY, - "java.lang,java.math,javax.security,java.util,org.apache.activemq,org.apache.qpid.proton.amqp"); + DEFAULT_WHITELIST = System.getProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY, "java.lang,java.math,javax.security,java.util,org.apache.activemq,org.apache.qpid.proton.amqp"); DEFAULT_BLACKLIST = System.getProperty(ObjectInputStreamWithClassLoader.BLACKLIST_PROPERTY, null); } + public static final byte TYPE = Message.STREAM_TYPE; private Serializable object; diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java index c63b7017e5..a53fc0e9ca 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java @@ -55,11 +55,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadBoolean(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -68,11 +66,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St public byte readByte() throws JMSException { try { return streamReadByte(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -82,11 +78,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadShort(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -96,11 +90,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadChar(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -110,11 +102,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadInteger(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -124,11 +114,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadLong(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -138,11 +126,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadFloat(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -152,11 +138,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadDouble(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -166,11 +150,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadString(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -188,11 +170,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St len = pairRead.getA(); return pairRead.getB(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -205,11 +185,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St } try { return streamReadObject(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -297,38 +275,27 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St public void writeObject(final Object value) throws JMSException { if (value instanceof String) { writeString((String) value); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { writeBoolean((Boolean) value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { writeByte((Byte) value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { writeShort((Short) value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { writeInt((Integer) value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { writeLong((Long) value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { writeFloat((Float) value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { writeDouble((Double) value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { writeBytes((byte[]) value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { writeChar((Character) value); - } - else if (value == null) { + } else if (value == null) { writeString(null); - } - else { + } else { throw new MessageFormatException("Invalid object type: " + value.getClass()); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java index 5178dc2105..eb88de0814 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java @@ -59,8 +59,7 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag public void setText(final String text) throws JMSException { if (text != null) { this.text = new SimpleString(text); - } - else { + } else { this.text = null; } @@ -71,8 +70,7 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag public String getText() { if (text != null) { return text.toString(); - } - else { + } else { return null; } } @@ -96,4 +94,4 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag text = readBodyText(getReadBodyBuffer()); } -} \ No newline at end of file +} diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java index 9e172fad4d..dc7891cb27 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java @@ -20,13 +20,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; +import java.nio.ByteBuffer; +import java.util.UUID; + import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.UnsignedLong; -import java.nio.ByteBuffer; -import java.util.UUID; - /** * Helper class for identifying and converting message-id and correlation-id values between * the AMQP types and the Strings values used by JMS. @@ -73,8 +73,7 @@ public class AMQPMessageIdHelper { public String toBaseMessageIdString(Object messageId) { if (messageId == null) { return null; - } - else if (messageId instanceof String) { + } else if (messageId instanceof String) { String stringId = (String) messageId; // If the given string has a type encoding prefix, @@ -82,18 +81,14 @@ public class AMQPMessageIdHelper { // the existing encoding prefix was also for string) if (hasTypeEncodingPrefix(stringId)) { return AMQP_STRING_PREFIX + stringId; - } - else { + } else { return stringId; } - } - else if (messageId instanceof UUID) { + } else if (messageId instanceof UUID) { return AMQP_UUID_PREFIX + messageId.toString(); - } - else if (messageId instanceof UnsignedLong) { + } else if (messageId instanceof UnsignedLong) { return AMQP_ULONG_PREFIX + messageId.toString(); - } - else if (messageId instanceof Binary) { + } else if (messageId instanceof Binary) { ByteBuffer dup = ((Binary) messageId).asByteBuffer(); byte[] bytes = new byte[dup.remaining()]; @@ -102,8 +97,7 @@ public class AMQPMessageIdHelper { String hex = convertBinaryToHexString(bytes); return AMQP_BINARY_PREFIX + hex; - } - else { + } else { throw new IllegalArgumentException("Unsupported type provided: " + messageId.getClass()); } } @@ -125,25 +119,20 @@ public class AMQPMessageIdHelper { if (hasAmqpUuidPrefix(baseId)) { String uuidString = strip(baseId, AMQP_UUID_PREFIX_LENGTH); return UUID.fromString(uuidString); - } - else if (hasAmqpUlongPrefix(baseId)) { + } else if (hasAmqpUlongPrefix(baseId)) { String longString = strip(baseId, AMQP_ULONG_PREFIX_LENGTH); return UnsignedLong.valueOf(longString); - } - else if (hasAmqpStringPrefix(baseId)) { + } else if (hasAmqpStringPrefix(baseId)) { return strip(baseId, AMQP_STRING_PREFIX_LENGTH); - } - else if (hasAmqpBinaryPrefix(baseId)) { + } else if (hasAmqpBinaryPrefix(baseId)) { String hexString = strip(baseId, AMQP_BINARY_PREFIX_LENGTH); byte[] bytes = convertHexStringToBinary(hexString); return new Binary(bytes); - } - else { + } else { // We have a string without any type prefix, transmit it as-is. return baseId; } - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new ActiveMQAMQPIllegalStateException("Unable to convert ID value"); } } @@ -213,7 +202,7 @@ public class AMQPMessageIdHelper { private boolean hasTypeEncodingPrefix(String stringId) { return hasAmqpBinaryPrefix(stringId) || hasAmqpUuidPrefix(stringId) || - hasAmqpUlongPrefix(stringId) || hasAmqpStringPrefix(stringId); + hasAmqpUlongPrefix(stringId) || hasAmqpStringPrefix(stringId); } private boolean hasAmqpStringPrefix(String stringId) { @@ -240,13 +229,11 @@ public class AMQPMessageIdHelper { if (ch >= '0' && ch <= '9') { // subtract '0' to get difference in position as an int return ch - '0'; - } - else if (ch >= 'A' && ch <= 'F') { + } else if (ch >= 'A' && ch <= 'F') { // subtract 'A' to get difference in position as an int // and then add 10 for the offset of 'A' return ch - 'A' + 10; - } - else if (ch >= 'a' && ch <= 'f') { + } else if (ch >= 'a' && ch <= 'f') { // subtract 'a' to get difference in position as an int // and then add 10 for the offset of 'a' return ch - 'a' + 10; diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java index 613de6de18..9b0635aa72 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.protocol.amqp.converter.message; public class AMQPMessageTypes { + public static final String AMQP_TYPE_KEY = "amqp:type"; public static final String AMQP_SEQUENCE = "amqp:sequence"; diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java index 67175ab9b1..ac18a94f7f 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; +import javax.jms.BytesMessage; +import javax.jms.JMSException; + import org.apache.qpid.proton.amqp.UnsignedInteger; import org.apache.qpid.proton.amqp.messaging.Header; import org.apache.qpid.proton.message.ProtonJMessage; -import javax.jms.BytesMessage; -import javax.jms.JMSException; - public class AMQPNativeOutboundTransformer extends OutboundTransformer { public AMQPNativeOutboundTransformer(JMSVendor vendor) { diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java index 55195eb11c..ff0c03521b 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.Message; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Set; + import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.Decimal128; import org.apache.qpid.proton.amqp.Decimal32; @@ -31,14 +38,6 @@ import org.apache.qpid.proton.amqp.messaging.Header; import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; import org.apache.qpid.proton.amqp.messaging.Properties; -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.Message; - -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Set; - import static org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME; public abstract class InboundTransformer { @@ -116,15 +115,13 @@ public abstract class InboundTransformer { if (header.getDurable() != null) { jms.setJMSDeliveryMode(header.getDurable().booleanValue() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); - } - else { + } else { jms.setJMSDeliveryMode(defaultDeliveryMode); } if (header.getPriority() != null) { jms.setJMSPriority(header.getPriority().intValue()); - } - else { + } else { jms.setJMSPriority(defaultPriority); } @@ -143,12 +140,10 @@ public abstract class InboundTransformer { if ("x-opt-jms-type".equals(key) && entry.getValue() != null) { // Legacy annotation, JMSType value will be replaced by Subject further down if also present. jms.setJMSType(entry.getValue().toString()); - } - else if ("x-opt-delivery-time".equals(key) && entry.getValue() != null) { + } else if ("x-opt-delivery-time".equals(key) && entry.getValue() != null) { long deliveryTime = ((Number) entry.getValue()).longValue(); jms.setLongProperty(HDR_SCHEDULED_DELIVERY_TIME.toString(), deliveryTime); - } - else if ("x-opt-delivery-delay".equals(key) && entry.getValue() != null) { + } else if ("x-opt-delivery-delay".equals(key) && entry.getValue() != null) { long delay = ((Number) entry.getValue()).longValue(); if (delay > 0) { jms.setLongProperty(HDR_SCHEDULED_DELIVERY_TIME.toString(), System.currentTimeMillis() + delay); @@ -182,14 +177,11 @@ public abstract class InboundTransformer { String key = entry.getKey().toString(); if ("JMSXGroupID".equals(key)) { vendor.setJMSXGroupID(jms, entry.getValue().toString()); - } - else if ("JMSXGroupSequence".equals(key)) { + } else if ("JMSXGroupSequence".equals(key)) { vendor.setJMSXGroupSequence(jms, ((Number) entry.getValue()).intValue()); - } - else if ("JMSXUserID".equals(key)) { + } else if ("JMSXUserID".equals(key)) { vendor.setJMSXUserID(jms, entry.getValue().toString()); - } - else { + } else { setProperty(jms, key, entry.getValue()); } } @@ -249,8 +241,7 @@ public abstract class InboundTransformer { if (ttl == 0) { jms.setJMSExpiration(0); - } - else { + } else { jms.setJMSExpiration(System.currentTimeMillis() + ttl); } } @@ -268,50 +259,38 @@ public abstract class InboundTransformer { if (value instanceof UnsignedLong) { long v = ((UnsignedLong) value).longValue(); msg.setLongProperty(key, v); - } - else if (value instanceof UnsignedInteger) { + } else if (value instanceof UnsignedInteger) { long v = ((UnsignedInteger) value).longValue(); if (Integer.MIN_VALUE <= v && v <= Integer.MAX_VALUE) { msg.setIntProperty(key, (int) v); - } - else { + } else { msg.setLongProperty(key, v); } - } - else if (value instanceof UnsignedShort) { + } else if (value instanceof UnsignedShort) { int v = ((UnsignedShort) value).intValue(); if (Short.MIN_VALUE <= v && v <= Short.MAX_VALUE) { msg.setShortProperty(key, (short) v); - } - else { + } else { msg.setIntProperty(key, v); } - } - else if (value instanceof UnsignedByte) { + } else if (value instanceof UnsignedByte) { short v = ((UnsignedByte) value).shortValue(); if (Byte.MIN_VALUE <= v && v <= Byte.MAX_VALUE) { msg.setByteProperty(key, (byte) v); - } - else { + } else { msg.setShortProperty(key, v); } - } - else if (value instanceof Symbol) { + } else if (value instanceof Symbol) { msg.setStringProperty(key, value.toString()); - } - else if (value instanceof Decimal128) { + } else if (value instanceof Decimal128) { msg.setDoubleProperty(key, ((Decimal128) value).doubleValue()); - } - else if (value instanceof Decimal64) { + } else if (value instanceof Decimal64) { msg.setDoubleProperty(key, ((Decimal64) value).doubleValue()); - } - else if (value instanceof Decimal32) { + } else if (value instanceof Decimal32) { msg.setFloatProperty(key, ((Decimal32) value).floatValue()); - } - else if (value instanceof Binary) { + } else if (value instanceof Binary) { msg.setStringProperty(key, value.toString()); - } - else { + } else { msg.setObjectProperty(key, value); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java index 2bcbfe2b5f..9dd29ab20b 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; -import org.apache.qpid.proton.amqp.Binary; -import org.apache.qpid.proton.amqp.messaging.AmqpSequence; -import org.apache.qpid.proton.amqp.messaging.AmqpValue; -import org.apache.qpid.proton.amqp.messaging.Data; -import org.apache.qpid.proton.amqp.messaging.Section; - import javax.jms.BytesMessage; import javax.jms.MapMessage; import javax.jms.Message; @@ -33,6 +27,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.qpid.proton.amqp.Binary; +import org.apache.qpid.proton.amqp.messaging.AmqpSequence; +import org.apache.qpid.proton.amqp.messaging.AmqpValue; +import org.apache.qpid.proton.amqp.messaging.Data; +import org.apache.qpid.proton.amqp.messaging.Section; + public class JMSMappingInboundTransformer extends InboundTransformer { public JMSMappingInboundTransformer(JMSVendor vendor) { @@ -58,14 +58,12 @@ public class JMSMappingInboundTransformer extends InboundTransformer { final Section body = amqp.getBody(); if (body == null) { rc = vendor.createMessage(); - } - else if (body instanceof Data) { + } else if (body instanceof Data) { Binary d = ((Data) body).getValue(); BytesMessage m = vendor.createBytesMessage(); m.writeBytes(d.getArray(), d.getArrayOffset(), d.getLength()); rc = m; - } - else if (body instanceof AmqpSequence) { + } else if (body instanceof AmqpSequence) { AmqpSequence sequence = (AmqpSequence) body; StreamMessage m = vendor.createStreamMessage(); for (Object item : sequence.getValue()) { @@ -73,8 +71,7 @@ public class JMSMappingInboundTransformer extends InboundTransformer { } rc = m; m.setStringProperty(AMQPMessageTypes.AMQP_TYPE_KEY, AMQPMessageTypes.AMQP_SEQUENCE); - } - else if (body instanceof AmqpValue) { + } else if (body instanceof AmqpValue) { Object value = ((AmqpValue) body).getValue(); if (value == null) { rc = vendor.createObjectMessage(); @@ -83,36 +80,31 @@ public class JMSMappingInboundTransformer extends InboundTransformer { TextMessage m = vendor.createTextMessage(); m.setText((String) value); rc = m; - } - else if (value instanceof Binary) { + } else if (value instanceof Binary) { Binary d = (Binary) value; BytesMessage m = vendor.createBytesMessage(); m.writeBytes(d.getArray(), d.getArrayOffset(), d.getLength()); rc = m; - } - else if (value instanceof List) { + } else if (value instanceof List) { StreamMessage m = vendor.createStreamMessage(); for (Object item : (List) value) { m.writeObject(item); } rc = m; m.setStringProperty(AMQPMessageTypes.AMQP_TYPE_KEY, AMQPMessageTypes.AMQP_LIST); - } - else if (value instanceof Map) { + } else if (value instanceof Map) { MapMessage m = vendor.createMapMessage(); final Set> set = ((Map) value).entrySet(); for (Map.Entry entry : set) { m.setObject(entry.getKey(), entry.getValue()); } rc = m; - } - else { + } else { ObjectMessage m = vendor.createObjectMessage(); m.setObject((Serializable) value); rc = m; } - } - else { + } else { throw new RuntimeException("Unexpected body type: " + body.getClass()); } rc.setJMSDeliveryMode(defaultDeliveryMode); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java index 40cbf79218..9f28a6be49 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java @@ -16,26 +16,6 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; -import org.apache.activemq.artemis.core.message.impl.MessageInternal; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; -import org.apache.qpid.proton.amqp.Binary; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedByte; -import org.apache.qpid.proton.amqp.UnsignedInteger; -import org.apache.qpid.proton.amqp.messaging.AmqpSequence; -import org.apache.qpid.proton.amqp.messaging.AmqpValue; -import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; -import org.apache.qpid.proton.amqp.messaging.Data; -import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations; -import org.apache.qpid.proton.amqp.messaging.Footer; -import org.apache.qpid.proton.amqp.messaging.Header; -import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; -import org.apache.qpid.proton.amqp.messaging.Properties; -import org.apache.qpid.proton.amqp.messaging.Section; -import org.apache.qpid.proton.message.ProtonJMessage; -import org.jboss.logging.Logger; - import javax.jms.BytesMessage; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -57,7 +37,28 @@ import java.util.Date; import java.util.Enumeration; import java.util.HashMap; +import org.apache.activemq.artemis.core.message.impl.MessageInternal; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; +import org.apache.qpid.proton.amqp.Binary; +import org.apache.qpid.proton.amqp.Symbol; +import org.apache.qpid.proton.amqp.UnsignedByte; +import org.apache.qpid.proton.amqp.UnsignedInteger; +import org.apache.qpid.proton.amqp.messaging.AmqpSequence; +import org.apache.qpid.proton.amqp.messaging.AmqpValue; +import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; +import org.apache.qpid.proton.amqp.messaging.Data; +import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations; +import org.apache.qpid.proton.amqp.messaging.Footer; +import org.apache.qpid.proton.amqp.messaging.Header; +import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; +import org.apache.qpid.proton.amqp.messaging.Properties; +import org.apache.qpid.proton.amqp.messaging.Section; +import org.apache.qpid.proton.message.ProtonJMessage; +import org.jboss.logging.Logger; + public class JMSMappingOutboundTransformer extends OutboundTransformer { + private static final Logger logger = Logger.getLogger(JMSMappingOutboundTransformer.class); public static final Symbol JMS_DEST_TYPE_MSG_ANNOTATION = Symbol.valueOf("x-opt-jms-dest"); public static final Symbol JMS_REPLY_TO_TYPE_MSG_ANNOTATION = Symbol.valueOf("x-opt-jms-reply-to"); @@ -116,15 +117,13 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { while (true) { list.add(m.readObject()); } - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } String amqpType = msg.getStringProperty(AMQPMessageTypes.AMQP_TYPE_KEY); if (amqpType.equals(AMQPMessageTypes.AMQP_LIST)) { body = new AmqpValue(list); - } - else { + } else { body = new AmqpSequence(list); } } @@ -142,11 +141,9 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { if (s != null) { body = new AmqpValue(s.toString()); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { logger.debug("Exception ignored during conversion, should be ok!", ignored.getMessage(), ignored); - } - finally { + } finally { internalMessage.getBodyBuffer().readerIndex(readerIndex); } } @@ -163,8 +160,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { try { props.setMessageId(AMQPMessageIdHelper.INSTANCE.toIdObject(msgId)); - } - catch (ActiveMQAMQPIllegalStateException e) { + } catch (ActiveMQAMQPIllegalStateException e) { props.setMessageId(msgId); } } @@ -187,8 +183,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { try { props.setCorrelationId(AMQPMessageIdHelper.INSTANCE.toIdObject(correlationId)); - } - catch (ActiveMQAMQPIllegalStateException e) { + } catch (ActiveMQAMQPIllegalStateException e) { props.setCorrelationId(correlationId); } } @@ -210,72 +205,59 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { String key = keys.nextElement(); if (key.equals(messageFormatKey) || key.equals(nativeKey) || key.equals(ServerJMSMessage.NATIVE_MESSAGE_ID)) { // skip.. - } - else if (key.equals(firstAcquirerKey)) { + } else if (key.equals(firstAcquirerKey)) { header.setFirstAcquirer(msg.getBooleanProperty(key)); - } - else if (key.startsWith("JMSXDeliveryCount")) { + } else if (key.startsWith("JMSXDeliveryCount")) { // The AMQP delivery-count field only includes prior failed delivery attempts, // whereas JMSXDeliveryCount includes the first/current delivery attempt. int amqpDeliveryCount = msg.getIntProperty(key) - 1; if (amqpDeliveryCount > 0) { header.setDeliveryCount(new UnsignedInteger(amqpDeliveryCount)); } - } - else if (key.startsWith("JMSXUserID")) { + } else if (key.startsWith("JMSXUserID")) { String value = msg.getStringProperty(key); props.setUserId(new Binary(value.getBytes(StandardCharsets.UTF_8))); - } - else if (key.startsWith("JMSXGroupID") || key.startsWith("_AMQ_GROUP_ID")) { + } else if (key.startsWith("JMSXGroupID") || key.startsWith("_AMQ_GROUP_ID")) { String value = msg.getStringProperty(key); props.setGroupId(value); if (apMap == null) { apMap = new HashMap(); } apMap.put(key, value); - } - else if (key.startsWith("JMSXGroupSeq")) { + } else if (key.startsWith("JMSXGroupSeq")) { UnsignedInteger value = new UnsignedInteger(msg.getIntProperty(key)); props.setGroupSequence(value); if (apMap == null) { apMap = new HashMap(); } apMap.put(key, value); - } - else if (key.startsWith(prefixDeliveryAnnotationsKey)) { + } else if (key.startsWith(prefixDeliveryAnnotationsKey)) { if (daMap == null) { daMap = new HashMap<>(); } String name = key.substring(prefixDeliveryAnnotationsKey.length()); daMap.put(Symbol.valueOf(name), msg.getObjectProperty(key)); - } - else if (key.startsWith(prefixMessageAnnotationsKey)) { + } else if (key.startsWith(prefixMessageAnnotationsKey)) { if (maMap == null) { maMap = new HashMap<>(); } String name = key.substring(prefixMessageAnnotationsKey.length()); maMap.put(Symbol.valueOf(name), msg.getObjectProperty(key)); - } - else if (key.equals(contentTypeKey)) { + } else if (key.equals(contentTypeKey)) { props.setContentType(Symbol.getSymbol(msg.getStringProperty(key))); - } - else if (key.equals(contentEncodingKey)) { + } else if (key.equals(contentEncodingKey)) { props.setContentEncoding(Symbol.getSymbol(msg.getStringProperty(key))); - } - else if (key.equals(replyToGroupIDKey)) { + } else if (key.equals(replyToGroupIDKey)) { props.setReplyToGroupId(msg.getStringProperty(key)); - } - else if (key.startsWith(prefixFooterKey)) { + } else if (key.startsWith(prefixFooterKey)) { if (footerMap == null) { footerMap = new HashMap(); } String name = key.substring(prefixFooterKey.length()); footerMap.put(name, msg.getObjectProperty(key)); - } - else if (key.equals(AMQPMessageTypes.AMQP_TYPE_KEY)) { + } else if (key.equals(AMQPMessageTypes.AMQP_TYPE_KEY)) { // skip - } - else { + } else { if (apMap == null) { apMap = new HashMap(); } @@ -283,8 +265,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { if (objectProperty instanceof byte[]) { Binary binary = new Binary((byte[]) objectProperty); apMap.put(key, binary); - } - else { + } else { apMap.put(key, objectProperty); } } @@ -314,16 +295,13 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { if (destination instanceof Queue) { if (destination instanceof TemporaryQueue) { return TEMP_QUEUE_TYPE; - } - else { + } else { return QUEUE_TYPE; } - } - else if (destination instanceof Topic) { + } else if (destination instanceof Topic) { if (destination instanceof TemporaryTopic) { return TEMP_TOPIC_TYPE; - } - else { + } else { return TOPIC_TYPE; } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java index 2bfe5fc37a..898bab0062 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.logger; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInvalidFieldException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 11 diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java index 8b14e67161..3d79026c9d 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java @@ -16,13 +16,22 @@ */ package org.apache.activemq.artemis.protocol.amqp.proton; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + import io.netty.buffer.ByteBuf; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPConnectionCallback; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; import org.apache.activemq.artemis.protocol.amqp.proton.handler.EventHandler; -import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; +import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; import org.apache.activemq.artemis.protocol.amqp.proton.handler.ProtonHandler; +import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; import org.apache.activemq.artemis.utils.ByteUtil; import org.apache.activemq.artemis.utils.VersionLoader; import org.apache.qpid.proton.amqp.Symbol; @@ -35,17 +44,8 @@ import org.apache.qpid.proton.engine.Sender; import org.apache.qpid.proton.engine.Session; import org.apache.qpid.proton.engine.Transport; import org.jboss.logging.Logger; -import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -public class AMQPConnectionContext extends ProtonInitializable { +public class AMQPConnectionContext extends ProtonInitializable { private static final Logger log = Logger.getLogger(AMQPConnectionContext.class); @@ -63,8 +63,6 @@ public class AMQPConnectionContext extends ProtonInitializable { protected LocalListener listener = new LocalListener(); - - public AMQPConnectionContext(AMQPConnectionCallback connectionSP, String containerId, int idleTimeout, @@ -138,7 +136,6 @@ public class AMQPConnectionContext extends ProtonInitializable { handler.close(); } - protected AMQPSessionContext getSessionExtension(Session realSession) throws ActiveMQAMQPException { AMQPSessionContext sessionExtension = sessions.get(realSession); if (sessionExtension == null) { @@ -150,8 +147,6 @@ public class AMQPConnectionContext extends ProtonInitializable { return sessionExtension; } - - protected boolean validateConnection(Connection connection) { return connectionCallback.validateConnection(connection, handler.getSASLResult()); } @@ -194,12 +189,10 @@ public class AMQPConnectionContext extends ProtonInitializable { if (link.getRemoteTarget() instanceof Coordinator) { Coordinator coordinator = (Coordinator) link.getRemoteTarget(); protonSession.addTransactionHandler(coordinator, receiver); - } - else { + } else { protonSession.addReceiver(receiver); } - } - else { + } else { Sender sender = (Sender) link; protonSession.addSender(sender); sender.offer(1); @@ -210,8 +203,6 @@ public class AMQPConnectionContext extends ProtonInitializable { return ExtCapability.getCapabilities(); } - - // This listener will perform a bunch of things here class LocalListener implements EventHandler { @@ -269,8 +260,7 @@ public class AMQPConnectionContext extends ProtonInitializable { public void onAuthInit(ProtonHandler handler, Connection connection, boolean sasl) { if (sasl) { handler.createServerSASL(connectionCallback.getSASLMechnisms()); - } - else { + } else { if (!connectionCallback.isSupportsAnonymous()) { connectionCallback.sendSASLSupported(); connectionCallback.close(); @@ -289,14 +279,12 @@ public class AMQPConnectionContext extends ProtonInitializable { synchronized (getLock()) { try { initInternal(); - } - catch (Exception e) { + } catch (Exception e) { log.error("Error init connection", e); } if (!validateConnection(connection)) { connection.close(); - } - else { + } else { connection.setContext(AMQPConnectionContext.this); connection.setContainer(containerId); connection.setProperties(connectionProperties); @@ -365,7 +353,7 @@ public class AMQPConnectionContext extends ProtonInitializable { session.close(); } - AMQPSessionContext sessionContext = (AMQPSessionContext)session.getContext(); + AMQPSessionContext sessionContext = (AMQPSessionContext) session.getContext(); if (sessionContext != null) { sessionContext.close(); sessions.remove(session); @@ -411,8 +399,7 @@ public class AMQPConnectionContext extends ProtonInitializable { ProtonDeliveryHandler handler = (ProtonDeliveryHandler) delivery.getLink().getContext(); if (handler != null) { handler.onMessage(delivery); - } - else { + } else { // TODO: logs System.err.println("Handler is null, can't delivery " + delivery); @@ -420,5 +407,4 @@ public class AMQPConnectionContext extends ProtonInitializable { } } - } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPSessionContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPSessionContext.java index 9003d3bce7..6a6c1fa2a2 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPSessionContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPSessionContext.java @@ -22,8 +22,8 @@ import java.util.Map; import java.util.Set; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.transaction.Coordinator; import org.apache.qpid.proton.amqp.transport.ErrorCondition; @@ -49,9 +49,7 @@ public class AMQPSessionContext extends ProtonInitializable { protected boolean closed = false; - public AMQPSessionContext(AMQPSessionCallback sessionSPI, - AMQPConnectionContext connection, - Session session) { + public AMQPSessionContext(AMQPSessionCallback sessionSPI, AMQPConnectionContext connection, Session session) { this.connection = connection; this.sessionSPI = sessionSPI; this.session = session; @@ -67,8 +65,7 @@ public class AMQPSessionContext extends ProtonInitializable { if (sessionSPI != null) { try { sessionSPI.init(this, connection.getSASLResult()); - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } } @@ -84,15 +81,13 @@ public class AMQPSessionContext extends ProtonInitializable { if (protonConsumer != null) { try { protonConsumer.close(false); - } - catch (ActiveMQAMQPException e) { + } catch (ActiveMQAMQPException e) { protonConsumer.getSender().setTarget(null); protonConsumer.getSender().setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage())); } } } - /** * The consumer object from the broker or the key used to store the sender * @@ -129,8 +124,7 @@ public class AMQPSessionContext extends ProtonInitializable { for (ProtonServerReceiverContext protonProducer : receiversCopy) { try { protonProducer.close(false); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); } } @@ -142,8 +136,7 @@ public class AMQPSessionContext extends ProtonInitializable { for (ProtonServerSenderContext protonConsumer : protonSendersClone) { try { protonConsumer.close(false); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); } } @@ -152,8 +145,7 @@ public class AMQPSessionContext extends ProtonInitializable { if (sessionSPI != null) { sessionSPI.close(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); } closed = true; @@ -166,9 +158,7 @@ public class AMQPSessionContext extends ProtonInitializable { public void addTransactionHandler(Coordinator coordinator, Receiver receiver) { ProtonTransactionHandler transactionHandler = new ProtonTransactionHandler(sessionSPI); - coordinator.setCapabilities(Symbol.getSymbol("amqp:local-transactions"), - Symbol.getSymbol("amqp:multi-txns-per-ssn"), - Symbol.getSymbol("amqp:multi-ssns-per-txn")); + coordinator.setCapabilities(Symbol.getSymbol("amqp:local-transactions"), Symbol.getSymbol("amqp:multi-txns-per-ssn"), Symbol.getSymbol("amqp:multi-ssns-per-txn")); receiver.setContext(transactionHandler); receiver.open(); @@ -185,8 +175,7 @@ public class AMQPSessionContext extends ProtonInitializable { sender.setContext(protonSender); sender.open(); protonSender.start(); - } - catch (ActiveMQAMQPException e) { + } catch (ActiveMQAMQPException e) { senders.remove(sender); sender.setSource(null); sender.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage())); @@ -196,7 +185,7 @@ public class AMQPSessionContext extends ProtonInitializable { public void removeSender(Sender sender) throws ActiveMQAMQPException { senders.remove(sender); - ProtonServerSenderContext senderRemoved = senders.remove(sender); + ProtonServerSenderContext senderRemoved = senders.remove(sender); if (senderRemoved != null) { serverSenders.remove(senderRemoved.getBrokerConsumer()); } @@ -209,8 +198,7 @@ public class AMQPSessionContext extends ProtonInitializable { receivers.put(receiver, protonReceiver); receiver.setContext(protonReceiver); receiver.open(); - } - catch (ActiveMQAMQPException e) { + } catch (ActiveMQAMQPException e) { receivers.remove(receiver); receiver.setTarget(null); receiver.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage())); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AmqpSupport.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AmqpSupport.java index 848f0d2183..13d7170c38 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AmqpSupport.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AmqpSupport.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.proton; +import java.util.AbstractMap; +import java.util.Map; + import org.apache.qpid.proton.amqp.DescribedType; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.UnsignedLong; -import java.util.AbstractMap; -import java.util.Map; - /** * Set of useful methods and definitions used in the AMQP protocol handling */ @@ -61,14 +61,12 @@ public class AmqpSupport { public static final Symbol LIFETIME_POLICY = Symbol.valueOf("lifetime-policy"); public static final Symbol SOLE_CONNECTION_CAPABILITY = Symbol.valueOf("sole-connection-for-container"); + /** * Search for a given Symbol in a given array of Symbol object. * - * @param symbols - * the set of Symbols to search. - * @param key - * the value to try and find in the Symbol array. - * + * @param symbols the set of Symbols to search. + * @param key the value to try and find in the Symbol array. * @return true if the key is found in the given Symbol array. */ public static boolean contains(Symbol[] symbols, Symbol key) { @@ -89,11 +87,8 @@ public class AmqpSupport { * Search for a particular filter using a set of known indentification values * in the Map of filters. * - * @param filters - * The filters map that should be searched. - * @param filterIds - * The aliases for the target filter to be located. - * + * @param filters The filters map that should be searched. + * @param filterIds The aliases for the target filter to be located. * @return the filter if found in the mapping or null if not found. */ public static Map.Entry findFilter(Map filters, Object[] filterIds) { diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java index 4b978318fb..41caea9926 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java @@ -18,13 +18,13 @@ package org.apache.activemq.artemis.protocol.amqp.proton; import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; +import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; -import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException; +import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; import org.apache.activemq.artemis.protocol.amqp.util.DeliveryUtil; -import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.messaging.Rejected; import org.apache.qpid.proton.amqp.transaction.TransactionalState; @@ -47,7 +47,6 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements protected final AMQPSessionCallback sessionSPI; - /* The maximum number of credits we will allocate to clients. This number is also used by the broker when refresh client credits. @@ -85,13 +84,11 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements try { sessionSPI.createTemporaryQueue(address); - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } target.setAddress(address); - } - else { + } else { //if not dynamic then we use the targets address as the address to forward the messages to, however there has to //be a queue bound to it so we nee to check this. address = target.getAddress(); @@ -103,11 +100,9 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements if (!sessionSPI.bindingQuery(address)) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist(); } - } - catch (ActiveMQAMQPNotFoundException e) { + } catch (ActiveMQAMQPNotFoundException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } } @@ -152,12 +147,10 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements flow(maxCreditAllocation, minCreditRefresh); } - } - finally { + } finally { buffer.release(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); Rejected rejected = new Rejected(); ErrorCondition condition = new ErrorCondition(); @@ -183,8 +176,7 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements // Use the SessionSPI to allocate producer credits, or default, always allocate credit. if (sessionSPI != null) { sessionSPI.offerProducerCredit(address, credits, threshold, receiver); - } - else { + } else { synchronized (connection.getLock()) { receiver.flow(credits); connection.flush(); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java index 0a071fd487..7ef49449f2 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java @@ -22,15 +22,17 @@ import java.util.Objects; import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; -import org.apache.activemq.artemis.protocol.amqp.util.CreditsSemaphore; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException; import org.apache.activemq.artemis.core.server.QueueQueryResult; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException; import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; +import org.apache.activemq.artemis.protocol.amqp.util.CreditsSemaphore; +import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable; import org.apache.activemq.artemis.selector.filter.FilterException; import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.qpid.proton.amqp.DescribedType; @@ -52,8 +54,6 @@ import org.apache.qpid.proton.engine.Delivery; import org.apache.qpid.proton.engine.Sender; import org.apache.qpid.proton.message.ProtonJMessage; import org.jboss.logging.Logger; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; -import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable; public class ProtonServerSenderContext extends ProtonInitializable implements ProtonDeliveryHandler { @@ -72,7 +72,6 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr protected final AMQPSessionCallback sessionSPI; protected CreditsSemaphore creditsSemaphore = new CreditsSemaphore(0); - public ProtonServerSenderContext(AMQPConnectionContext connection, Sender sender, AMQPSessionContext protonSession, @@ -113,8 +112,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr sessionSPI.startSender(brokerConsumer); } //protonSession.getServerSession().receiveConsumerCredits(consumerID, -1); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorStartingConsumer(e.getMessage()); } } @@ -142,8 +140,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr // Validate the Selector. try { SelectorParser.parse(selector); - } - catch (FilterException e) { + } catch (FilterException e) { close(new ErrorCondition(AmqpError.INVALID_FIELD, e.getMessage())); return; } @@ -162,8 +159,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr String noLocalFilter = ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString() + "<>'" + remoteContainerId + "'"; if (selector != null) { selector += " AND " + noLocalFilter; - } - else { + } else { selector = noLocalFilter; } } @@ -188,12 +184,10 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr source.setDistributionMode(COPY); source.setCapabilities(TOPIC); sender.setSource(source); - } - else { + } else { throw new ActiveMQAMQPNotFoundException("Unknown subscription link: " + sender.getName()); } - } - else { + } else { if (source.getDynamic()) { //if dynamic we have to create the node (queue) and set the address on the target, the node is temporary and // will be deleted on closing of the session @@ -201,19 +195,16 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr try { sessionSPI.createTemporaryQueue(queue); //protonSession.getServerSession().createQueue(queue, queue, null, true, false); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCreatingTemporaryQueue(e.getMessage()); } source.setAddress(queue); - } - else { + } else { //if not dynamic then we use the targets address as the address to forward the messages to, however there has to //be a queue bound to it so we nee to check this. if (isPubSub) { // if we are a subscription and durable create a durable queue using the container id and link name - if (TerminusDurability.UNSETTLED_STATE.equals(source.getDurable()) || - TerminusDurability.CONFIGURATION.equals(source.getDurable())) { + if (TerminusDurability.UNSETTLED_STATE.equals(source.getDurable()) || TerminusDurability.CONFIGURATION.equals(source.getDurable())) { String clientId = connection.getRemoteContainer(); String pubId = sender.getName(); queue = clientId + ":" + pubId; @@ -223,35 +214,29 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr // If a client reattaches to a durable subscription with a different no-local filter value, selector // or address then we must recreate the queue (JMS semantics). - if (!Objects.equals(result.getFilterString(), SimpleString.toSimpleString(selector)) || - (sender.getSource() != null && !sender.getSource().getAddress().equals(result.getAddress().toString()))) { + if (!Objects.equals(result.getFilterString(), SimpleString.toSimpleString(selector)) || (sender.getSource() != null && !sender.getSource().getAddress().equals(result.getAddress().toString()))) { if (result.getConsumerCount() == 0) { sessionSPI.deleteQueue(queue); sessionSPI.createDurableQueue(source.getAddress(), queue, selector); - } - else { + } else { throw new ActiveMQAMQPIllegalStateException("Unable to recreate subscription, consumers already exist"); } } - } - else { + } else { sessionSPI.createDurableQueue(source.getAddress(), queue, selector); } source.setAddress(queue); - } - //otherwise we are a volatile subscription - else { + } else { + //otherwise we are a volatile subscription queue = java.util.UUID.randomUUID().toString(); try { sessionSPI.createTemporaryQueue(source.getAddress(), queue, selector); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCreatingTemporaryQueue(e.getMessage()); } source.setAddress(queue); } - } - else { + } else { queue = source.getAddress(); } if (queue == null) { @@ -262,11 +247,9 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr if (!sessionSPI.queueQuery(queue, !isPubSub).isExists()) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist(); } - } - catch (ActiveMQAMQPNotFoundException e) { + } catch (ActiveMQAMQPNotFoundException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } } @@ -274,8 +257,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr boolean browseOnly = !isPubSub && source.getDistributionMode() != null && source.getDistributionMode().equals(COPY); try { brokerConsumer = sessionSPI.createSender(this, queue, isPubSub ? null : selector, browseOnly); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCreatingConsumer(e.getMessage()); } } @@ -300,8 +282,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr try { sessionSPI.closeSender(brokerConsumer); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); throw new ActiveMQAMQPInternalErrorException(e.getMessage()); } @@ -323,8 +304,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr QueueQueryResult result = sessionSPI.queueQuery(queueName, false); if (result.isExists() && source.getDynamic()) { sessionSPI.deleteQueue(queueName); - } - else { + } else { String clientId = connection.getRemoteContainer(); String pubId = sender.getName(); String queue = clientId + ":" + pubId; @@ -338,8 +318,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr } } } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); throw new ActiveMQAMQPInternalErrorException(e.getMessage()); } @@ -373,36 +352,29 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr // from dealer, a perf hit but a must try { sessionSPI.ack(tx, brokerConsumer, message); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorAcknowledgingMessage(message.toString(), e.getMessage()); } } } - } - else if (remoteState instanceof Accepted) { + } else if (remoteState instanceof Accepted) { //we have to individual ack as we can't guarantee we will get the delivery updates (including acks) in order // from dealer, a perf hit but a must try { sessionSPI.ack(null, brokerConsumer, message); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorAcknowledgingMessage(message.toString(), e.getMessage()); } - } - else if (remoteState instanceof Released) { + } else if (remoteState instanceof Released) { try { sessionSPI.cancel(brokerConsumer, message, false); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCancellingMessage(message.toString(), e.getMessage()); } - } - else if (remoteState instanceof Rejected || remoteState instanceof Modified) { + } else if (remoteState instanceof Rejected || remoteState instanceof Modified) { try { sessionSPI.cancel(brokerConsumer, message, true); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCancellingMessage(message.toString(), e.getMessage()); } } @@ -416,8 +388,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr sender.offer(1); } - } - else { + } else { //todo not sure if we need to do anything here } } @@ -440,8 +411,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr try { // This can be done a lot better here serverMessage = sessionSPI.encodeMessage(message, deliveryCount); - } - catch (Throwable e) { + } catch (Throwable e) { log.warn(e.getMessage(), e); throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } @@ -461,12 +431,12 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr } return false; } + protected int performSend(ProtonJMessage serverMessage, Object context) { if (!creditsSemaphore.tryAcquire()) { try { creditsSemaphore.acquire(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); // nothing to be done here.. we just keep going throw new IllegalStateException(e.getMessage(), e); @@ -495,8 +465,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr if (preSettle) { delivery.settle(); - } - else { + } else { sender.advance(); } } @@ -504,8 +473,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr connection.flush(); return size; - } - finally { + } finally { nettyBuffer.release(); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java index 6d4e73ae99..51f42a3d71 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java @@ -19,6 +19,7 @@ package org.apache.activemq.artemis.protocol.amqp.proton; import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; import org.apache.activemq.artemis.protocol.amqp.util.DeliveryUtil; import org.apache.qpid.proton.amqp.Binary; @@ -34,7 +35,6 @@ import org.apache.qpid.proton.engine.Delivery; import org.apache.qpid.proton.engine.Receiver; import org.apache.qpid.proton.message.impl.MessageImpl; import org.jboss.logging.Logger; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; /** * handles an amqp Coordinator to deal with transaction boundaries etc @@ -75,8 +75,7 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler { declared.setTxnId(txID); delivery.disposition(declared); delivery.settle(); - } - else if (action instanceof Discharge) { + } else if (action instanceof Discharge) { Discharge discharge = (Discharge) action; Binary txID = discharge.getTxnId(); @@ -84,33 +83,26 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler { try { sessionSPI.rollbackTX(txID, true); delivery.disposition(new Accepted()); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorRollingbackCoordinator(e.getMessage()); } - } - else { + } else { try { sessionSPI.commitTX(txID); delivery.disposition(new Accepted()); - } - catch (ActiveMQAMQPException amqpE) { + } catch (ActiveMQAMQPException amqpE) { throw amqpE; - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorCommittingCoordinator(e.getMessage()); } } } - } - catch (ActiveMQAMQPException amqpE) { + } catch (ActiveMQAMQPException amqpE) { delivery.disposition(createRejected(amqpE.getAmqpError(), amqpE.getMessage())); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); delivery.disposition(createRejected(Symbol.getSymbol("failed"), e.getMessage())); - } - finally { + } finally { delivery.settle(); buffer.release(); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExtCapability.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExtCapability.java index b2a62304b9..6325ff6c36 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExtCapability.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExtCapability.java @@ -22,9 +22,7 @@ import org.apache.qpid.proton.engine.Connection; public class ExtCapability { - public static final Symbol[] capabilities = new Symbol[] { - AmqpSupport.SOLE_CONNECTION_CAPABILITY, AmqpSupport.DELAYED_DELIVERY - }; + public static final Symbol[] capabilities = new Symbol[]{AmqpSupport.SOLE_CONNECTION_CAPABILITY, AmqpSupport.DELAYED_DELIVERY}; public static Symbol[] getCapabilities() { return capabilities; diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java index 2efaa1b716..0d667b01cf 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java @@ -99,8 +99,7 @@ public class ProtonHandler extends ProtonInitializable { } return rescheduleAt; } - } - catch (Exception e) { + } catch (Exception e) { transport.close(); connection.setCondition(new ErrorCondition()); } @@ -166,8 +165,7 @@ public class ProtonHandler extends ProtonInitializable { * */ capacity = transport.capacity(); } - } - catch (Throwable e) { + } catch (Throwable e) { log.debug(e.getMessage(), e); } @@ -181,12 +179,10 @@ public class ProtonHandler extends ProtonInitializable { buffer.readBytes(tail); flush(); - } - else { + } else { if (capacity == 0) { log.debugf("abandoning: readableBytes=%d", buffer.readableBytes()); - } - else { + } else { log.debugf("transport closed, discarding: readableBytes=%d, capacity=%d", buffer.readableBytes(), transport.capacity()); } break; @@ -289,13 +285,11 @@ public class ProtonHandler extends ProtonInitializable { serverSasl = null; saslHandlers.clear(); saslHandlers = null; - } - else { + } else { serverSasl.done(Sasl.SaslOutcome.PN_SASL_AUTH); } serverSasl = null; - } - else { + } else { // no auth available, system error serverSasl.done(Sasl.SaslOutcome.PN_SASL_SYS); } @@ -329,14 +323,13 @@ public class ProtonHandler extends ProtonInitializable { // while processing events (for instance onTransport) // while a client is also trying to write here while ((ev = popEvent()) != null) { - for ( EventHandler h : handlers) { + for (EventHandler h : handlers) { if (log.isTraceEnabled()) { log.trace("Handling " + ev + " towards " + h); } try { Events.dispatch(ev, h); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); connection.setCondition(new ErrorCondition()); } @@ -346,8 +339,7 @@ public class ProtonHandler extends ProtonInitializable { for (EventHandler h : handlers) { try { h.onTransport(transport); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); connection.setCondition(new ErrorCondition()); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/PlainSASL.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/PlainSASL.java index cb82eba42a..20cd8add98 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/PlainSASL.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/PlainSASL.java @@ -32,12 +32,10 @@ public class PlainSASL extends ServerSASLPlain { try { securityStore.authenticate(user, password, null); return true; - } - catch (Exception e) { + } catch (Exception e) { return false; } - } - else { + } else { return true; } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphore.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphore.java index 3eda1990ec..77b61bcd31 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphore.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphore.java @@ -41,8 +41,7 @@ public class CreditsSemaphore { if (actualSize == getState()) { return -1; } - } - else if (compareAndSetState(actualSize, newValue)) { + } else if (compareAndSetState(actualSize, newValue)) { return newValue; } } @@ -107,4 +106,4 @@ public class CreditsSemaphore { return sync.hasQueuedThreads(); } -} \ No newline at end of file +} diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/ProtonServerMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/ProtonServerMessage.java index c15741e47a..5f46f2254c 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/ProtonServerMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/ProtonServerMessage.java @@ -109,8 +109,7 @@ public class ProtonServerMessage implements ProtonJMessage { rawBody = new byte[buffer.limit() - buffer.position()]; buffer.get(rawBody); } - } - finally { + } finally { decoder.setByteBuffer(null); } @@ -151,14 +150,12 @@ public class ProtonServerMessage implements ProtonJMessage { if (parsedFooter != null) { encoder.writeObject(parsedFooter); } - } - else if (rawBody != null) { + } else if (rawBody != null) { writableBuffer.put(rawBody, 0, rawBody.length); } return writableBuffer.position() - firstPosition; - } - finally { + } finally { encoder.setByteBuffer((WritableBuffer) null); } } @@ -173,12 +170,10 @@ public class ProtonServerMessage implements ProtonJMessage { try { if (buffer.get() != 0) { return EOF; - } - else { + } else { return ((Number) decoder.readObject()).intValue(); } - } - finally { + } finally { buffer.position(pos); } } @@ -186,8 +181,7 @@ public class ProtonServerMessage implements ProtonJMessage { private Section readSection(ByteBuffer buffer, DecoderImpl decoder) { if (buffer.hasRemaining()) { return (Section) decoder.readObject(); - } - else { + } else { return null; } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java index 27a533ad40..148482ecc7 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java @@ -28,13 +28,19 @@ import java.util.Map; import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage; -import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.journal.EncodingSupport; +import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; +import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable; +import org.apache.activemq.artemis.utils.SimpleIDGenerator; import org.apache.blacklist.ABadClass; import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.messaging.AmqpSequence; @@ -44,14 +50,8 @@ import org.apache.qpid.proton.amqp.messaging.Data; import org.apache.qpid.proton.message.Message; import org.apache.qpid.proton.message.ProtonJMessage; import org.apache.qpid.proton.message.impl.MessageImpl; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.journal.EncodingSupport; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; -import org.apache.activemq.artemis.core.server.ServerMessage; -import org.apache.activemq.artemis.utils.SimpleIDGenerator; import org.junit.Assert; import org.junit.Test; -import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable; public class TestConversions extends Assert { @@ -81,7 +81,7 @@ public class TestConversions extends Assert { Object obj = converter.outbound((ServerMessage) serverMessage.getInnerMessage(), 0); - AmqpValue value = (AmqpValue) ((Message)obj).getBody(); + AmqpValue value = (AmqpValue) ((Message) obj).getBody(); assertEquals(value.getValue(), true); } @@ -89,7 +89,6 @@ public class TestConversions extends Assert { @Test public void testObjectMessageNotOnWhiteList() throws Exception { - ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0)); ServerMessageImpl message = new ServerMessageImpl(1, 1024); message.setType((byte) 2); @@ -104,13 +103,11 @@ public class TestConversions extends Assert { try { converter.outbound((ServerMessage) serverMessage.getInnerMessage(), 0); fail("should throw ClassNotFoundException"); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { //ignore } } - @Test public void testSimpleConversionBytes() throws Exception { Map mapprop = createPropertiesMap(); diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/sasl/ClientSASLPlain.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/sasl/ClientSASLPlain.java index 0e9d0d43ef..ca17139528 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/sasl/ClientSASLPlain.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/sasl/ClientSASLPlain.java @@ -19,7 +19,7 @@ package org.apache.activemq.artemis.protocol.amqp.sasl; /** * This will generate what a client would generate for bytes on Plain sasl. Used on test */ -public class ClientSASLPlain { +public class ClientSASLPlain { private String username; private String password; diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java index c608b854b3..f795fa5ab2 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java @@ -44,8 +44,7 @@ public class CreditsSemaphoreTest { } acquired.incrementAndGet(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/blacklist/ABadClass.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/blacklist/ABadClass.java index 7ea54a56f6..fea3a5f53c 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/blacklist/ABadClass.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/blacklist/ABadClass.java @@ -19,4 +19,5 @@ package org.apache.blacklist; import java.io.Serializable; public class ABadClass implements Serializable { + } diff --git a/artemis-protocols/artemis-hornetq-protocol/pom.xml b/artemis-protocols/artemis-hornetq-protocol/pom.xml index a485129d8c..91e81d0758 100644 --- a/artemis-protocols/artemis-hornetq-protocol/pom.xml +++ b/artemis-protocols/artemis-hornetq-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq diff --git a/artemis-protocols/artemis-hornetq-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HornetQProtocolManager.java b/artemis-protocols/artemis-hornetq-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HornetQProtocolManager.java index bd4274a0af..2f6ed2fcc4 100644 --- a/artemis-protocols/artemis-hornetq-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HornetQProtocolManager.java +++ b/artemis-protocols/artemis-hornetq-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HornetQProtocolManager.java @@ -58,10 +58,9 @@ class HornetQProtocolManager extends CoreProtocolManager { return true; } - @Override public boolean isProtocol(byte[] array) { String frameStart = new String(array, StandardCharsets.US_ASCII); return frameStart.startsWith("HORNETQ"); } -} \ No newline at end of file +} diff --git a/artemis-protocols/artemis-hqclient-protocol/pom.xml b/artemis-protocols/artemis-hqclient-protocol/pom.xml index d4a177c234..8615b07501 100644 --- a/artemis-protocols/artemis-hqclient-protocol/pom.xml +++ b/artemis-protocols/artemis-hqclient-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq @@ -52,19 +53,19 @@ - - - - org.apache.felix - maven-bundle-plugin - 3.0.0 - true - - - - - - - - + + + + org.apache.felix + maven-bundle-plugin + 3.0.0 + true + + + + + + + + diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HQPropertiesConversionInterceptor.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HQPropertiesConversionInterceptor.java index 012727f9a8..1f14ba8484 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HQPropertiesConversionInterceptor.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/HQPropertiesConversionInterceptor.java @@ -26,7 +26,6 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; public class HQPropertiesConversionInterceptor implements Interceptor { - private final boolean replaceHQ; public HQPropertiesConversionInterceptor(final boolean replaceHQ) { @@ -45,8 +44,7 @@ public class HQPropertiesConversionInterceptor implements Interceptor { private void handleReceiveMessage(MessagePacketI messagePacket) { if (replaceHQ) { HQPropertiesConverter.replaceHQProperties(messagePacket.getMessage()); - } - else { + } else { HQPropertiesConverter.replaceAMQProperties(messagePacket.getMessage()); } } diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManager.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManager.java index c6fec87c1d..6a998ef0f0 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManager.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManager.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, @@ -30,11 +30,11 @@ import org.apache.activemq.artemis.spi.core.remoting.SessionContext; public class HornetQClientProtocolManager extends ActiveMQClientProtocolManager { private static final int VERSION_PLAYED = 123; + @Override protected void sendHandshake(Connection transportConnection) { } - @Override protected SessionContext newSessionContext(String name, int confirmationWindowSize, @@ -64,6 +64,4 @@ public class HornetQClientProtocolManager extends ActiveMQClientProtocolManager getChannel0().send(new SubscribeClusterTopologyUpdatesMessageV2(isServer, VERSION_PLAYED)); } - - } diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java index 351b096d1d..99cfcb99bb 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.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, @@ -26,7 +26,6 @@ import org.osgi.service.component.annotations.Component; @Component(service = ClientProtocolManagerFactory.class) public class HornetQClientProtocolManagerFactory implements ClientProtocolManagerFactory { - ServerLocator locator; @Override diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientSessionContext.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientSessionContext.java index d5e8df44ad..d9322744ff 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientSessionContext.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientSessionContext.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, @@ -48,7 +48,6 @@ public class HornetQClientSessionContext extends ActiveMQSessionContext { super(name, remotingConnection, sessionChannel, serverVersion, confirmationWindow); } - @Override public ClientSession.QueueQuery queueQuery(final SimpleString queueName) throws ActiveMQException { SessionQueueQueryMessage request = new SessionQueueQueryMessage(queueName); @@ -69,7 +68,6 @@ public class HornetQClientSessionContext extends ActiveMQSessionContext { return new CreateSessionMessage(getName(), getSessionChannel().getID(), 123, username, password, minLargeMessageSize, xa, autoCommitSends, autoCommitAcks, preAcknowledge, getConfirmationWindow(), defaultAddress == null ? null : defaultAddress.toString()); } - @Override public ClientSession.AddressQuery addressQuery(final SimpleString address) throws ActiveMQException { SessionBindingQueryResponseMessage response = (SessionBindingQueryResponseMessage) getSessionChannel().sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP); @@ -101,5 +99,4 @@ public class HornetQClientSessionContext extends ActiveMQSessionContext { return new ClientConsumerImpl(session, consumerContext, queueName, filterString, browseOnly, calcWindowSize(windowSize), ackBatchSize, maxRate > 0 ? new TokenBucketLimiterImpl(maxRate, false) : null, executor, flowControlExecutor, this, queueInfo.toQueueQuery(), lookupTCCL()); } - } diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/util/HQPropertiesConverter.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/util/HQPropertiesConverter.java index ee7116219d..cfb8d2f888 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/util/HQPropertiesConverter.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/util/HQPropertiesConverter.java @@ -51,7 +51,7 @@ public class HQPropertiesConverter { d = new HashMap<>(); // inverting the direction - for (Map.Entry entry: hqAmqDictionary.entrySet()) { + for (Map.Entry entry : hqAmqDictionary.entrySet()) { d.put(entry.getValue(), entry.getKey()); } diff --git a/artemis-protocols/artemis-mqtt-protocol/pom.xml b/artemis-protocols/artemis-mqtt-protocol/pom.xml index ae6bf62724..2260d51481 100644 --- a/artemis-protocols/artemis-mqtt-protocol/pom.xml +++ b/artemis-protocols/artemis-mqtt-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq @@ -48,27 +49,27 @@ io.netty netty-codec-mqtt - - junit - junit - + + junit + junit + - - - - org.apache.felix - maven-bundle-plugin - 3.0.0 - true - - - netty-codec-mqtt - !* - io.netty.*;version="[4,6)", * - - - - - + + + + org.apache.felix + maven-bundle-plugin + 3.0.0 + true + + + netty-codec-mqtt + !* + io.netty.*;version="[4,6)", * + + + + + diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java index 31486ff315..446e362016 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.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, diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java index a05ecb52c7..3a1f4479e4 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnectionManager.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, @@ -17,6 +17,9 @@ package org.apache.activemq.artemis.core.protocol.mqtt; +import java.util.Set; +import java.util.UUID; + import io.netty.handler.codec.mqtt.MqttConnectReturnCode; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -26,9 +29,6 @@ import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl; import org.apache.activemq.artemis.utils.ConcurrentHashSet; import org.apache.activemq.artemis.utils.UUIDGenerator; -import java.util.Set; -import java.util.UUID; - /** * MQTTConnectionMananager is responsible for handle Connect and Disconnect packets and any resulting behaviour of these * events. @@ -96,12 +96,7 @@ public class MQTTConnectionManager { String id = UUIDGenerator.getInstance().generateStringUUID(); ActiveMQServer server = session.getServer(); - ServerSession serverSession = server.createSession(id, username, password, - ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, - session.getConnection(), MQTTUtil.SESSION_AUTO_COMMIT_SENDS, - MQTTUtil.SESSION_AUTO_COMMIT_ACKS, MQTTUtil.SESSION_PREACKNOWLEDGE, - MQTTUtil.SESSION_XA, null, session.getSessionCallback(), - MQTTUtil.SESSION_AUTO_CREATE_QUEUE); + ServerSession serverSession = server.createSession(id, username, password, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, session.getConnection(), MQTTUtil.SESSION_AUTO_COMMIT_SENDS, MQTTUtil.SESSION_AUTO_COMMIT_ACKS, MQTTUtil.SESSION_PREACKNOWLEDGE, MQTTUtil.SESSION_XA, null, session.getSessionCallback(), MQTTUtil.SESSION_AUTO_CREATE_QUEUE); return (ServerSessionImpl) serverSession; } @@ -122,8 +117,7 @@ public class MQTTConnectionManager { session.stop(); session.getConnection().disconnect(false); session.getConnection().destroy(); - } - catch (Exception e) { + } catch (Exception e) { /* FIXME Failure during disconnect would leave the session state in an unrecoverable state. We should handle errors more gracefully. */ @@ -144,8 +138,7 @@ public class MQTTConnectionManager { if (cleanSession) { MQTTSession.SESSIONS.remove(clientId); return new MQTTSessionState(clientId); - } - else { + } else { /* [MQTT-3.1.2-4] Attach an existing session if one exists (if cleanSession flag is false) otherwise create a new one. */ MQTTSessionState state = MQTTSession.SESSIONS.get(clientId); @@ -155,8 +148,7 @@ public class MQTTConnectionManager { Thread.sleep(1000); } return state; - } - else { + } else { state = new MQTTSessionState(clientId); MQTTSession.SESSIONS.put(clientId, state); return state; @@ -170,14 +162,14 @@ public class MQTTConnectionManager { // [MQTT-3.1.3-7] [MQTT-3.1.3-6] If client does not specify a client ID and clean session is set to 1 create it. if (cleanSession) { clientId = UUID.randomUUID().toString(); - } - else { + } else { // [MQTT-3.1.3-8] Return ID rejected and disconnect if clean session = false and client id is null return null; } - } - // If the client ID is not unique (i.e. it has already registered) then do not accept it. - else if (!CONNECTED_CLIENTS.add(clientId)) { + } else if (!CONNECTED_CLIENTS.add(clientId)) { + // ^^^ If the client ID is not unique (i.e. it has already registered) then do not accept it. + + // [MQTT-3.1.3-9] Return ID Rejected if server rejects the client ID return null; } diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTFailureListener.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTFailureListener.java index ee03bba889..7bd9fadae5 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTFailureListener.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTFailureListener.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, diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTInterceptor.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTInterceptor.java index ba22f25dc7..90346556d2 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTInterceptor.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTInterceptor.java @@ -23,4 +23,5 @@ import io.netty.handler.codec.mqtt.MqttMessage; import org.apache.activemq.artemis.api.core.BaseInterceptor; public interface MQTTInterceptor extends BaseInterceptor { + } diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTLogger.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTLogger.java index 08f552a7cb..0a8f24b0e6 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTLogger.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTLogger.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, diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTMessageInfo.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTMessageInfo.java index ffa620202b..53785faaf8 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTMessageInfo.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTMessageInfo.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, diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java index 17fc978984..68648cdaa0 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.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, @@ -144,8 +144,7 @@ public class MQTTProtocolHandler extends ChannelInboundHandlerAdapter { default: disconnect(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn("Error processing Control Packet, Disconnecting Client" + e.getMessage()); disconnect(); } diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolManager.java index 17f7e33ec7..f8bdf2aacd 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolManager.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolManager.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,8 +41,7 @@ import org.apache.activemq.artemis.spi.core.remoting.Connection; /** * MQTTProtocolManager */ -class MQTTProtocolManager extends AbstractProtocolManager - implements NotificationListener { +class MQTTProtocolManager extends AbstractProtocolManager implements NotificationListener { private static final List websocketRegistryNames = Arrays.asList("mqtt", "mqttv3.1"); @@ -52,7 +51,9 @@ class MQTTProtocolManager extends AbstractProtocolManager incomingInterceptors = new ArrayList<>(); private final List outgoingInterceptors = new ArrayList<>(); - MQTTProtocolManager(ActiveMQServer server, List incomingInterceptors, List outgoingInterceptors) { + MQTTProtocolManager(ActiveMQServer server, + List incomingInterceptors, + List outgoingInterceptors) { this.server = server; this.updateInterceptors(incomingInterceptors, outgoingInterceptors); } @@ -86,8 +87,7 @@ class MQTTProtocolManager extends AbstractProtocolManager SESSIONS = new ConcurrentHashMap<>(); diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java index ea3fa0fc12..fa282d495b 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.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, @@ -42,11 +42,13 @@ public class MQTTSessionCallback implements SessionCallback { } @Override - public int sendMessage(MessageReference reference, ServerMessage message, ServerConsumer consumer, int deliveryCount) { + public int sendMessage(MessageReference reference, + ServerMessage message, + ServerConsumer consumer, + int deliveryCount) { try { session.getMqttPublishManager().sendMessage(message, consumer, deliveryCount); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage()); } @@ -58,7 +60,6 @@ public class MQTTSessionCallback implements SessionCallback { return false; } - @Override public int sendLargeMessageContinuation(ServerConsumer consumerID, byte[] body, @@ -69,7 +70,11 @@ public class MQTTSessionCallback implements SessionCallback { } @Override - public int sendLargeMessage(MessageReference reference, ServerMessage message, ServerConsumer consumer, long bodySize, int deliveryCount) { + public int sendLargeMessage(MessageReference reference, + ServerMessage message, + ServerConsumer consumer, + long bodySize, + int deliveryCount) { return sendMessage(reference, message, consumer, deliveryCount); } @@ -77,8 +82,7 @@ public class MQTTSessionCallback implements SessionCallback { public void disconnect(ServerConsumer consumer, String queueName) { try { consumer.removeItself(); - } - catch (Exception e) { + } catch (Exception e) { log.error(e.getMessage()); } } @@ -88,7 +92,6 @@ public class MQTTSessionCallback implements SessionCallback { } - @Override public void browserFinished(ServerConsumer consumer) { diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionState.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionState.java index 9bc307454f..dd7a360fae 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionState.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionState.java @@ -84,8 +84,7 @@ public class MQTTSessionState { if (qos == 2) { if (reverseOutboundReferenceStore.containsKey(address)) { reverseOutboundReferenceStore.get(address).put(serverMessageId, mqttId); - } - else { + } else { ConcurrentHashMap serverToMqttId = new ConcurrentHashMap<>(); serverToMqttId.put(serverMessageId, mqttId); reverseOutboundReferenceStore.put(address, serverToMqttId); @@ -159,8 +158,7 @@ public class MQTTSessionState { subscriptions.put(subscription.topicName(), subscription); return true; } - } - else { + } else { subscriptions.put(subscription.topicName(), subscription); return true; } diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSubscriptionManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSubscriptionManager.java index 9c18e45b81..ea3ab19e16 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSubscriptionManager.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSubscriptionManager.java @@ -121,8 +121,7 @@ public class MQTTSubscriptionManager { if (s == null) { createConsumerForSubscriptionQueue(q, topic, qos); - } - else { + } else { consumerQoSLevels.put(consumers.get(topic).getID(), qos); } session.getRetainMessageManager().addRetainedMessagesToQueue(q, topic); diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java index 2313248ac7..e6affc1c5d 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.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, @@ -156,8 +156,7 @@ public class MQTTUtil { if (message.variableHeader() instanceof MqttPublishVariableHeader) { log.append("(" + ((MqttPublishVariableHeader) message.variableHeader()).messageId() + ") " + message.fixedHeader().qosLevel()); - } - else if (message.variableHeader() instanceof MqttMessageIdVariableHeader) { + } else if (message.variableHeader() instanceof MqttMessageIdVariableHeader) { log.append("(" + ((MqttMessageIdVariableHeader) message.variableHeader()).messageId() + ")"); } diff --git a/artemis-protocols/artemis-openwire-protocol/pom.xml b/artemis-protocols/artemis-openwire-protocol/pom.xml index 9ad0db368a..423638cc9e 100644 --- a/artemis-protocols/artemis-openwire-protocol/pom.xml +++ b/artemis-protocols/artemis-openwire-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq @@ -49,8 +50,8 @@ activemq-client - org.slf4j - slf4j-api + org.slf4j + slf4j-api org.apache.activemq diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java index a29b3ee862..c6582bd4e0 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java @@ -251,15 +251,13 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { setLastCommand(command); response = command.visit(commandProcessorInstance); - } - catch (Exception e) { + } catch (Exception e) { // TODO: logging e.printStackTrace(); if (responseRequired) { response = convertException(e); } - } - finally { + } finally { setLastCommand(null); } @@ -294,8 +292,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se dispatchSync(response); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.debug(e); sendException(e); @@ -306,8 +303,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se Response resp = convertException(e); try { dispatch(resp); - } - catch (IOException e2) { + } catch (IOException e2) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e2); } } @@ -316,11 +312,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se Response resp; if (e instanceof ActiveMQSecurityException) { resp = new ExceptionResponse(new JMSSecurityException(e.getMessage())); - } - else if (e instanceof ActiveMQNonExistentQueueException) { + } else if (e instanceof ActiveMQNonExistentQueueException) { resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage())); - } - else { + } else { resp = new ExceptionResponse(e); } return resp; @@ -374,8 +368,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se for (final FailureListener listener : listenersClone) { try { listener.connectionFailed(me, false); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -402,11 +395,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se getTransportConnection().write(buffer, false, false); } bufferSent(); - } - catch (IOException e) { + } catch (IOException e) { throw e; - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.error("error sending", t); } @@ -439,8 +430,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } dispatch(command); } - } - catch (IOException e) { + } catch (IOException e) { if (messageDispatch != null) { TransmitCallback sub = messageDispatch.getTransmitCallback(); protocolManager.postProcessDispatch(messageDispatch); @@ -450,8 +440,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se messageDispatch = null; throw e; } - } - finally { + } finally { if (messageDispatch != null) { TransmitCallback sub = messageDispatch.getTransmitCallback(); protocolManager.postProcessDispatch(messageDispatch); @@ -467,8 +456,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (result == null) { if (consumerList.size() == 1) { result = new AMQSingleConsumerBrokerExchange(amqSession, consumerList.get(0)); - } - else { + } else { result = new AMQCompositeConsumerBrokerExchange(amqSession, consumerList); } synchronized (consumerExchanges) { @@ -523,8 +511,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (fail) { transportConnection.forceClose(); - } - else { + } else { transportConnection.close(); } } @@ -558,8 +545,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se lastResponse.setCorrelationId(command.getCommandId()); try { dispatchSync(lastResponse); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -578,8 +564,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } try { protocolManager.removeConnection(this.getConnectionInfo(), me); - } - catch (InvalidClientIDException e) { + } catch (InvalidClientIDException e) { ActiveMQServerLogger.LOGGER.warn("Couldn't close connection because invalid clientID", e); } shutdown(true); @@ -682,11 +667,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { physicalSend(command); - } - catch (Exception e) { + } catch (Exception e) { return false; - } - catch (Throwable t) { + } catch (Throwable t) { return false; } return true; @@ -700,8 +683,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (binding == null) { if (dest.isTemporary()) { internalSession.createQueue(qName, qName, null, dest.isTemporary(), false); - } - else { + } else { ConnectionInfo connInfo = getState().getInfo(); CheckType checkType = dest.isTemporary() ? CheckType.CREATE_NON_DURABLE_QUEUE : CheckType.CREATE_DURABLE_QUEUE; server.getSecurityStore().check(qName, checkType, this); @@ -761,7 +743,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se this.connectionEntry = connectionEntry; } - public void setUpTtl(final long inactivityDuration, final long inactivityDurationInitialDelay, final boolean useKeepAlive) { + public void setUpTtl(final long inactivityDuration, + final long inactivityDurationInitialDelay, + final boolean useKeepAlive) { this.useKeepAlive = useKeepAlive; this.maxInactivityDuration = inactivityDuration; @@ -787,8 +771,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, amqConsumer.getId().toString()); protocolManager.fireAdvisory(context, topic, advisoryMessage, amqConsumer.getId()); - } - catch (Exception e) { + } catch (Exception e) { // TODO-NOW: LOGGING e.printStackTrace(); } @@ -833,8 +816,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se public void removeDestination(ActiveMQDestination dest) throws Exception { if (dest.isQueue()) { server.destroyQueue(OpenWireUtil.toCoreAddress(dest)); - } - else { + } else { Bindings bindings = server.getPostOffice().getBindingsForAddress(OpenWireUtil.toCoreAddress(dest)); for (Binding binding : bindings.getBindings()) { @@ -886,8 +868,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se public Response processAddConnection(ConnectionInfo info) throws Exception { try { protocolManager.addConnection(OpenWireConnection.this, info); - } - catch (Exception e) { + } catch (Exception e) { Response resp = new ExceptionResponse(e); return resp; } @@ -977,8 +958,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se for (ProducerId producerId : session.getProducerIds()) { try { processRemoveProducer(producerId); - } - catch (Throwable e) { + } catch (Throwable e) { // LOG.warn("Failed to remove producer: {}", producerId, e); } } @@ -1000,8 +980,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se Transaction tx = lookupTX(info.getTransactionId(), null); if (info.getTransactionId().isXATransaction() && tx == null) { throw newXAException("Transaction '" + info.getTransactionId() + "' has not been started.", XAException.XAER_NOTA); - } - else if (tx != null) { + } else if (tx != null) { AMQSession amqSession = (AMQSession) tx.getProtocolData(); @@ -1010,8 +989,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { returnReferences(tx, amqSession); - } - finally { + } finally { amqSession.getCoreSession().resetTX(null); } } @@ -1074,12 +1052,10 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se Response resp = null; try { addDestination(dest); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof ActiveMQSecurityException) { resp = new ExceptionResponse(new JMSSecurityException(e.getMessage())); - } - else { + } else { resp = new ExceptionResponse(e); } } @@ -1106,8 +1082,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (txID.isXATransaction()) { Xid xid = OpenWireUtil.toXID(txID); internalSession.xaStart(xid); - } - else { + } else { Transaction transaction = internalSession.newTransaction(); txMap.put(txID, transaction); transaction.addOperation(new TransactionOperationAbstract() { @@ -1117,8 +1092,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } }); } - } - finally { + } finally { internalSession.resetTX(null); clearOpeartionContext(); } @@ -1140,8 +1114,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se setOperationContext(session); try { tx.commit(onePhase); - } - finally { + } finally { clearOpeartionContext(); } @@ -1163,17 +1136,14 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { Xid xid = OpenWireUtil.toXID(info.getTransactionId()); internalSession.xaForget(xid); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; } - } - else { + } else { txMap.remove(txID); } - } - finally { + } finally { clearOpeartionContext(); } @@ -1190,18 +1160,15 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { Xid xid = OpenWireUtil.toXID(info.getTransactionId()); internalSession.xaPrepare(xid); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; } - } - else { + } else { Transaction tx = lookupTX(txID, null); tx.prepare(); } - } - finally { + } finally { internalSession.resetTX(null); clearOpeartionContext(); } @@ -1221,17 +1188,14 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { Xid xid = OpenWireUtil.toXID(info.getTransactionId()); internalSession.xaEnd(xid); - } - finally { + } finally { internalSession.resetTX(null); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; } - } - else { + } else { txMap.remove(txID); clearOpeartionContext(); } @@ -1263,8 +1227,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se //after successful reconnect try { updateConsumer(consumerControl); - } - catch (Exception e) { + } catch (Exception e) { //log error } return null; @@ -1301,13 +1264,11 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se session.getCoreSession().resetTX(tx); try { session.send(producerInfo, messageSend, sendProducerAck); - } - finally { + } finally { session.getCoreSession().resetTX(null); clearOpeartionContext(); } - return null; } @@ -1321,8 +1282,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(ack.getConsumerId()); consumerBrokerExchange.acknowledge(ack); - } - finally { + } finally { session.getCoreSession().resetTX(null); clearOpeartionContext(); } @@ -1371,8 +1331,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se //we let protocol manager to handle connection add/remove try { protocolManager.removeConnection(state.getInfo(), null); - } - catch (Throwable e) { + } catch (Throwable e) { // log } return null; @@ -1405,14 +1364,12 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se OperationContext ctx; if (session == null) { ctx = this.internalSession.getSessionContext(); - } - else { + } else { ctx = session.getCoreSession().getSessionContext(); } server.getStorageManager().setContext(ctx); } - private void clearOpeartionContext() { server.getStorageManager().clearContext(); } @@ -1427,8 +1384,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (txID.isXATransaction()) { xid = OpenWireUtil.toXID(txID); transaction = server.getResourceManager().getTransaction(xid); - } - else { + } else { transaction = txMap.get(txID); } diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java index fd6aef2cc7..131cfd13cb 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java @@ -94,7 +94,6 @@ public class OpenWireMessageConverter implements MessageConverter { private static final String AMQ_MSG_DROPPABLE = AMQ_PREFIX + "DROPPABLE"; private static final String AMQ_MSG_COMPRESSED = AMQ_PREFIX + "COMPRESSED"; - private final WireFormat marshaller; public OpenWireMessageConverter(WireFormat marshaller) { @@ -107,11 +106,10 @@ public class OpenWireMessageConverter implements MessageConverter { return null; } - @Override public ServerMessage inbound(Object message) throws Exception { - Message messageSend = (Message)message; + Message messageSend = (Message) message; ServerMessageImpl coreMessage = new ServerMessageImpl(-1, messageSend.getSize()); String type = messageSend.getType(); @@ -131,8 +129,7 @@ public class OpenWireMessageConverter implements MessageConverter { ByteSequence contents = messageSend.getContent(); if (contents == null && coreType == org.apache.activemq.artemis.api.core.Message.TEXT_TYPE) { body.writeNullableString(null); - } - else if (contents != null) { + } else if (contents != null) { boolean messageCompressed = messageSend.isCompressed(); if (messageCompressed) { coreMessage.putBooleanProperty(AMQ_MSG_COMPRESSED, messageCompressed); @@ -265,11 +262,9 @@ public class OpenWireMessageConverter implements MessageConverter { int count = inflater.inflate(buffer); decompressed.write(buffer, 0, count); contents = decompressed.toByteSequence(); - } - catch (Exception e) { + } catch (Exception e) { throw new IOException(e); - } - finally { + } finally { inflater.end(); } } @@ -281,8 +276,7 @@ public class OpenWireMessageConverter implements MessageConverter { OutputStream os = new InflaterOutputStream(decompressed)) { os.write(contents.data, contents.offset, contents.getLength()); contents = decompressed.toByteSequence(); - } - catch (Exception e) { + } catch (Exception e) { throw new IOException(e); } } @@ -356,8 +350,7 @@ public class OpenWireMessageConverter implements MessageConverter { Object value = ent.getValue(); try { coreMessage.putObjectProperty(ent.getKey(), value); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { coreMessage.putStringProperty(ent.getKey(), value.toString()); } } @@ -372,7 +365,6 @@ public class OpenWireMessageConverter implements MessageConverter { ConsumerId consumerId = messageSend.getTargetConsumerId(); - String userId = messageSend.getUserID(); if (userId != null) { coreMessage.putStringProperty(AMQ_MSG_USER_ID, userId); @@ -421,7 +413,8 @@ public class OpenWireMessageConverter implements MessageConverter { } } - public static MessageDispatch createMessageDispatch(MessageReference reference, ServerMessage message, + public static MessageDispatch createMessageDispatch(MessageReference reference, + ServerMessage message, AMQConsumer consumer) throws IOException, JMSException { ActiveMQMessage amqMessage = toAMQMessage(reference, message, consumer.getMarshaller(), consumer.getOpenwireDestination()); @@ -438,7 +431,10 @@ public class OpenWireMessageConverter implements MessageConverter { return md; } - private static ActiveMQMessage toAMQMessage(MessageReference reference, ServerMessage coreMessage, WireFormat marshaller, ActiveMQDestination actualDestination) throws IOException { + private static ActiveMQMessage toAMQMessage(MessageReference reference, + ServerMessage coreMessage, + WireFormat marshaller, + ActiveMQDestination actualDestination) throws IOException { ActiveMQMessage amqMsg = null; byte coreType = coreMessage.getType(); switch (coreType) { @@ -480,7 +476,7 @@ public class OpenWireMessageConverter implements MessageConverter { amqMsg.setBrokerInTime(brokerInTime); ActiveMQBuffer buffer = coreMessage.getBodyBufferDuplicate(); - Boolean compressProp = (Boolean)coreMessage.getObjectProperty(AMQ_MSG_COMPRESSED); + Boolean compressProp = (Boolean) coreMessage.getObjectProperty(AMQ_MSG_COMPRESSED); boolean isCompressed = compressProp == null ? false : compressProp.booleanValue(); amqMsg.setCompressed(isCompressed); @@ -501,8 +497,7 @@ public class OpenWireMessageConverter implements MessageConverter { bytes = bytesOut.toByteArray(); } } - } - else if (coreType == org.apache.activemq.artemis.api.core.Message.MAP_TYPE) { + } else if (coreType == org.apache.activemq.artemis.api.core.Message.MAP_TYPE) { TypedProperties mapData = new TypedProperties(); mapData.decode(buffer); @@ -516,8 +511,7 @@ public class OpenWireMessageConverter implements MessageConverter { MarshallingSupport.marshalPrimitiveMap(map, dataOut); } bytes = out.toByteArray(); - } - else if (coreType == org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE) { + } else if (coreType == org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE) { int len = buffer.readInt(); bytes = new byte[len]; buffer.readBytes(bytes); @@ -528,8 +522,7 @@ public class OpenWireMessageConverter implements MessageConverter { } bytes = bytesOut.toByteArray(); } - } - else if (coreType == org.apache.activemq.artemis.api.core.Message.STREAM_TYPE) { + } else if (coreType == org.apache.activemq.artemis.api.core.Message.STREAM_TYPE) { org.apache.activemq.util.ByteArrayOutputStream bytesOut = new org.apache.activemq.util.ByteArrayOutputStream(); OutputStream out = bytesOut; if (isCompressed) { @@ -578,8 +571,7 @@ public class OpenWireMessageConverter implements MessageConverter { String string = buffer.readNullableString(); if (string == null) { MarshallingSupport.marshalNull(dataOut); - } - else { + } else { MarshallingSupport.marshalString(dataOut, string); } break; @@ -591,8 +583,7 @@ public class OpenWireMessageConverter implements MessageConverter { } } bytes = bytesOut.toByteArray(); - } - else if (coreType == org.apache.activemq.artemis.api.core.Message.BYTES_TYPE) { + } else if (coreType == org.apache.activemq.artemis.api.core.Message.BYTES_TYPE) { int n = buffer.readableBytes(); bytes = new byte[n]; buffer.readBytes(bytes); @@ -611,13 +602,11 @@ public class OpenWireMessageConverter implements MessageConverter { ByteSequence byteSeq = compressed.toByteSequence(); ByteSequenceData.writeIntBig(byteSeq, length); bytes = Arrays.copyOfRange(byteSeq.data, 0, byteSeq.length); - } - finally { + } finally { deflater.end(); } } - } - else { + } else { int n = buffer.readableBytes(); bytes = new byte[n]; buffer.readBytes(bytes); @@ -706,8 +695,7 @@ public class OpenWireMessageConverter implements MessageConverter { if (midBytes != null) { ByteSequence midSeq = new ByteSequence(midBytes); mid = (MessageId) marshaller.unmarshal(midSeq); - } - else { + } else { mid = new MessageId(UUIDGenerator.getInstance().generateStringUUID() + ":-1"); } @@ -744,7 +732,6 @@ public class OpenWireMessageConverter implements MessageConverter { amqMsg.setReplyTo(replyTo); } - String userId = (String) coreMessage.getObjectProperty(AMQ_MSG_USER_ID); if (userId != null) { amqMsg.setUserID(userId); @@ -759,8 +746,7 @@ public class OpenWireMessageConverter implements MessageConverter { if (dlqCause != null) { try { amqMsg.setStringProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY, dlqCause.toString()); - } - catch (JMSException e) { + } catch (JMSException e) { throw new IOException("failure to set dlq property " + dlqCause, e); } } @@ -776,12 +762,10 @@ public class OpenWireMessageConverter implements MessageConverter { try { if (prop instanceof SimpleString) { amqMsg.setObjectProperty(s.toString(), prop.toString()); - } - else { + } else { amqMsg.setObjectProperty(s.toString(), prop); } - } - catch (JMSException e) { + } catch (JMSException e) { throw new IOException("exception setting property " + s + " : " + prop, e); } } @@ -789,8 +773,7 @@ public class OpenWireMessageConverter implements MessageConverter { try { amqMsg.onSend(); amqMsg.setCompressed(isCompressed); - } - catch (JMSException e) { + } catch (JMSException e) { throw new IOException("Failed to covert to Openwire message", e); } return amqMsg; diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java index 8497970690..0ee1711a11 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java @@ -167,8 +167,7 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl this.connections.remove(context.getConnection()); this.clientIdSet.remove(clientId); } - } - else { + } else { throw new InvalidClientIDException("No clientID specified for connection disconnect request"); } } @@ -193,8 +192,7 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl ConnectionControl control = newConnectionControl(); try { c.updateClient(control); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); c.sendException(e); } @@ -308,12 +306,10 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl oldConnection.disconnect(true); connections.remove(oldConnection); connection.reconnect(context, info); - } - else { + } else { throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + context.getConnection().getRemoteAddress()); } - } - else { + } else { //new connection context = connection.initContext(info); clientIdSet.put(clientId, context); @@ -379,8 +375,7 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl if (sess != null) { sess.send(producerExchange.getProducerState().getInfo(), advisoryMessage, false); } - } - finally { + } finally { context.setProducerFlowControl(originalFlowControl); } } @@ -389,8 +384,7 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl if (brokerName == null) { try { brokerName = InetAddressUtil.getLocalHostName().toLowerCase(Locale.ENGLISH); - } - catch (Exception e) { + } catch (Exception e) { brokerName = server.getNodeID().toString(); } } @@ -462,8 +456,7 @@ public class OpenWireProtocolManager implements ProtocolManager, Cl if (sm != null && server.getConfiguration().isSecurityEnabled()) { if (sm instanceof ActiveMQSecurityManager3) { validated = ((ActiveMQSecurityManager3) sm).validateUser(login, passcode, null) != null; - } - else { + } else { validated = sm.validateUser(login, passcode); } } diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQCompositeConsumerBrokerExchange.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQCompositeConsumerBrokerExchange.java index 5b9d72e492..69d1ccf4d5 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQCompositeConsumerBrokerExchange.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQCompositeConsumerBrokerExchange.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.core.protocol.openwire.amq; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.MessageAck; -import org.apache.activemq.command.MessagePull; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.MessageAck; +import org.apache.activemq.command.MessagePull; + public class AMQCompositeConsumerBrokerExchange extends AMQConsumerBrokerExchange { private final Map consumerMap; diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java index 17f5b79c47..e53b96238d 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java @@ -47,6 +47,7 @@ import org.apache.activemq.command.RemoveInfo; import org.apache.activemq.wireformat.WireFormat; public class AMQConsumer { + private AMQSession session; private org.apache.activemq.command.ActiveMQDestination openwireDestination; private ConsumerInfo info; @@ -84,8 +85,7 @@ public class AMQConsumer { if (openwireDestination.isTopic()) { if (openwireDestination.isTemporary()) { address = new SimpleString("jms.temptopic." + physicalName); - } - else { + } else { address = new SimpleString("jms.topic." + physicalName); } @@ -93,8 +93,7 @@ public class AMQConsumer { serverConsumer = session.getCoreSession().createConsumer(nativeId, queueName, null, info.isBrowser(), false, -1); serverConsumer.setlowConsumerDetection(slowConsumerDetectionListener); - } - else { + } else { SimpleString queueName = OpenWireUtil.toCoreAddress(openwireDestination); session.getCoreServer().getJMSDestinationCreator().create(queueName); serverConsumer = session.getCoreSession().createConsumer(nativeId, queueName, selector, info.isBrowser(), false, -1); @@ -149,12 +148,10 @@ public class AMQConsumer { // Create the new one session.getCoreSession().createQueue(address, queueName, selector, false, true); } - } - else { + } else { session.getCoreSession().createQueue(address, queueName, selector, false, true); } - } - else { + } else { queueName = new SimpleString(UUID.randomUUID().toString()); session.getCoreSession().createQueue(address, queueName, selector, true, false); @@ -200,12 +197,10 @@ public class AMQConsumer { session.deliverMessage(dispatch); currentWindow.decrementAndGet(); return size; - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); return 0; - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); return 0; } @@ -218,10 +213,12 @@ public class AMQConsumer { session.deliverMessage(md); } - /** The acknowledgement in openwire is done based on intervals. - * We will iterate through the list of delivering messages at {@link ServerConsumer#getDeliveringReferencesBasedOnProtocol(boolean, Object, Object)} - * and add those to the Transaction. - * Notice that we will start a new transaction on the cases where there is no transaction. */ + /** + * The acknowledgement in openwire is done based on intervals. + * We will iterate through the list of delivering messages at {@link ServerConsumer#getDeliveringReferencesBasedOnProtocol(boolean, Object, Object)} + * and add those to the Transaction. + * Notice that we will start a new transaction on the cases where there is no transaction. + */ public void acknowledge(MessageAck ack) throws Exception { MessageId first = ack.getFirstMessageId(); @@ -248,8 +245,7 @@ public class AMQConsumer { if (originalTX == null) { transaction = session.getCoreSession().newTransaction(); - } - else { + } else { transaction = originalTX; } @@ -257,8 +253,7 @@ public class AMQConsumer { for (MessageReference ref : ackList) { ref.acknowledge(transaction); } - } - else if (ack.isPoisonAck()) { + } else if (ack.isPoisonAck()) { for (MessageReference ref : ackList) { Throwable poisonCause = ack.getPoisonCause(); if (poisonCause != null) { @@ -340,7 +335,7 @@ public class AMQConsumer { /** * The MessagePullHandler is used with slow consumer policies. - * */ + */ private class MessagePullHandler { private long next = -1; @@ -368,8 +363,7 @@ public class AMQConsumer { if (next >= 0) { if (timeout <= 0) { latch.countDown(); - } - else { + } else { messagePullFuture = scheduledPool.schedule(new Runnable() { @Override public void run() { @@ -381,8 +375,7 @@ public class AMQConsumer { } } return false; - } - else { + } else { next = -1; if (messagePullFuture != null) { messagePullFuture.cancel(true); diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java index 4e1e8c46f0..714a29aa36 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java @@ -113,8 +113,7 @@ public class AMQSession implements SessionCallback { if (sessionId == -1) { this.connection.setAdvisorySession(this); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.error("error init session", e); } @@ -124,8 +123,7 @@ public class AMQSession implements SessionCallback { public boolean updateDeliveryCountAfterCancel(ServerConsumer consumer, MessageReference ref, boolean failed) { if (consumer.getProtocolData() != null) { return ((AMQConsumer) consumer.getProtocolData()).updateDeliveryCountAfterCancel(ref); - } - else { + } else { return false; } @@ -138,8 +136,7 @@ public class AMQSession implements SessionCallback { ActiveMQDestination[] dests = null; if (dest.isComposite()) { dests = dest.getCompositeDestinations(); - } - else { + } else { dests = new ActiveMQDestination[]{dest}; } @@ -260,8 +257,7 @@ public class AMQSession implements SessionCallback { if (destination.isComposite()) { actualDestinations = destination.getCompositeDestinations(); messageSend.setOriginalDestination(destination); - } - else { + } else { actualDestinations = new ActiveMQDestination[]{destination}; } @@ -284,16 +280,14 @@ public class AMQSession implements SessionCallback { try { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize()); connection.dispatchSync(ack); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); connection.sendException(e); } } }; - } - else { + } else { final Connection transportConnection = connection.getTransportConnection(); // new Exception("Setting to false").printStackTrace(); @@ -301,8 +295,7 @@ public class AMQSession implements SessionCallback { if (transportConnection == null) { // I don't think this could happen, but just in case, avoiding races runnable = null; - } - else { + } else { runnable = new Runnable() { @Override public void run() { @@ -324,8 +317,7 @@ public class AMQSession implements SessionCallback { if (actualDestinations.length <= 1 || onComplete == null) { // if onComplete is null, this will be null ;) runToUse = onComplete; - } - else { + } else { final AtomicInteger count = new AtomicInteger(actualDestinations.length); runToUse = new Runnable() { @Override diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java index 3e7410cee0..05e1e34400 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java @@ -46,16 +46,13 @@ public class OpenWireUtil { if (dest.isQueue()) { if (dest.isTemporary()) { return new SimpleString(JMS_TEMP_QUEUE_ADDRESS_PREFIX + dest.getPhysicalName()); - } - else { + } else { return new SimpleString(JMS_QUEUE_ADDRESS_PREFIX + dest.getPhysicalName()); } - } - else { + } else { if (dest.isTemporary()) { return new SimpleString(JMS_TEMP_TOPIC_ADDRESS_PREFIX + dest.getPhysicalName()); - } - else { + } else { return new SimpleString(JMS_TOPIC_ADDRESS_PREFIX + dest.getPhysicalName()); } } @@ -72,8 +69,7 @@ public class OpenWireUtil { String strippedAddress = address.replace(JMS_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TEMP_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TOPIC_ADDRESS_PREFIX, "").replace(JMS_TEMP_TOPIC_ADDRESS_PREFIX, ""); if (actualDestination.isQueue()) { return new ActiveMQQueue(strippedAddress); - } - else { + } else { return new ActiveMQTopic(strippedAddress); } } @@ -89,7 +85,7 @@ public class OpenWireUtil { } public static XidImpl toXID(TransactionId xaXid) { - return toXID((XATransactionId)xaXid); + return toXID((XATransactionId) xaXid); } public static XidImpl toXID(XATransactionId xaXid) { diff --git a/artemis-protocols/artemis-stomp-protocol/pom.xml b/artemis-protocols/artemis-stomp-protocol/pom.xml index 38eec7e081..7fff55f988 100644 --- a/artemis-protocols/artemis-stomp-protocol/pom.xml +++ b/artemis-protocols/artemis-stomp-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-protocols org.apache.activemq diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java index 7966037ed6..118f7f8db5 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java @@ -70,8 +70,7 @@ public class ActiveMQStompException extends Exception { StompFrame frame = null; if (handler == null) { frame = new StompFrame(Stomp.Responses.ERROR); - } - else { + } else { frame = handler.createStompFrame(Stomp.Responses.ERROR); } frame.addHeader(Stomp.Headers.Error.MESSAGE, this.getMessage()); @@ -82,8 +81,7 @@ public class ActiveMQStompException extends Exception { if (body != null) { frame.addHeader(Stomp.Headers.CONTENT_TYPE, "text/plain"); frame.setByteBody(body.getBytes(StandardCharsets.UTF_8)); - } - else { + } else { frame.setByteBody(new byte[0]); } if (disconnect != null) { diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java index b119054bb4..e535725407 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java @@ -17,10 +17,10 @@ package org.apache.activemq.artemis.core.protocol.stomp; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 33 diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java index f1605cbad7..a6ddf68f0b 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java @@ -111,8 +111,7 @@ public final class StompConnection implements RemotingConnection { StompFrame frame = null; try { frame = frameHandler.decode(buffer); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { switch (e.getCode()) { case ActiveMQStompException.INVALID_EOL_V10: if (version != null) @@ -258,8 +257,7 @@ public final class StompConnection implements RemotingConnection { if (queueCreator != null) { queueCreator.create(SimpleString.toSimpleString(queue)); } - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQStompException(e.getMessage(), e).setHandler(frameHandler); } } @@ -400,8 +398,7 @@ public final class StompConnection implements RemotingConnection { for (final FailureListener listener : listenersClone) { try { listener.connectionFailed(me, false); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -416,8 +413,7 @@ public final class StompConnection implements RemotingConnection { for (final CloseListener listener : listenersClone) { try { listener.connectionClosed(); - } - catch (final Throwable t) { + } catch (final Throwable t) { // Failure of one listener to execute shouldn't prevent others // from // executing @@ -435,8 +431,7 @@ public final class StompConnection implements RemotingConnection { if (acceptVersion == null) { this.version = StompVersions.V1_0; - } - else { + } else { StringTokenizer tokenizer = new StringTokenizer(acceptVersion, ","); Set requestVersions = new HashSet<>(tokenizer.countTokens()); while (tokenizer.hasMoreTokens()) { @@ -445,14 +440,11 @@ public final class StompConnection implements RemotingConnection { if (requestVersions.contains(StompVersions.V1_2.toString())) { this.version = StompVersions.V1_2; - } - else if (requestVersions.contains(StompVersions.V1_1.toString())) { + } else if (requestVersions.contains(StompVersions.V1_1.toString())) { this.version = StompVersions.V1_1; - } - else if (requestVersions.contains(StompVersions.V1_0.toString())) { + } else if (requestVersions.contains(StompVersions.V1_0.toString())) { this.version = StompVersions.V1_0; - } - else { + } else { //not a supported version! ActiveMQStompException error = BUNDLE.versionNotSupported(acceptVersion).setHandler(frameHandler); error.addHeader(Stomp.Headers.Error.VERSION, manager.getSupportedVersionsAsErrorVersion()); @@ -508,8 +500,7 @@ public final class StompConnection implements RemotingConnection { } reply = frameHandler.handleFrame(request); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { reply = e.getFrame(); } @@ -544,12 +535,10 @@ public final class StompConnection implements RemotingConnection { try { if (txID == null) { session = manager.getSession(this); - } - else { + } else { session = manager.getTransactedSession(this, txID); } - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorGetSession(e).setHandler(frameHandler); } @@ -574,12 +563,10 @@ public final class StompConnection implements RemotingConnection { try { if (minLargeMessageSize == -1 || (message.getBodyBuffer().writerIndex() < minLargeMessageSize)) { stompSession.sendInternal(message, false); - } - else { + } else { stompSession.sendInternalLarge(message, false); } - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorSendMessage(message, e).setHandler(frameHandler); } } @@ -597,11 +584,9 @@ public final class StompConnection implements RemotingConnection { protected void beginTransaction(String txID) throws ActiveMQStompException { try { manager.beginTransaction(this, txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorBeginTx(txID, e).setHandler(frameHandler); } } @@ -609,8 +594,7 @@ public final class StompConnection implements RemotingConnection { public void commitTransaction(String txID) throws ActiveMQStompException { try { manager.commitTransaction(this, txID); - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorCommitTx(txID, e).setHandler(frameHandler); } } @@ -618,11 +602,9 @@ public final class StompConnection implements RemotingConnection { public void abortTransaction(String txID) throws ActiveMQStompException { try { manager.abortTransaction(this, txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorAbortTx(txID, e).setHandler(frameHandler); } } @@ -638,8 +620,7 @@ public final class StompConnection implements RemotingConnection { String noLocalFilter = CONNECTION_ID_PROP + " <> '" + getID().toString() + "'"; if (selector == null) { selector = noLocalFilter; - } - else { + } else { selector += " AND " + noLocalFilter; } } @@ -651,8 +632,7 @@ public final class StompConnection implements RemotingConnection { String subscriptionID = null; if (id != null) { subscriptionID = id; - } - else { + } else { if (destination == null) { throw BUNDLE.noDestination().setHandler(frameHandler); } @@ -661,11 +641,9 @@ public final class StompConnection implements RemotingConnection { try { manager.createSubscription(this, subscriptionID, durableSubscriptionName, destination, selector, ack, noLocal); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorCreatSubscription(subscriptionID, e).setHandler(frameHandler); } } @@ -673,11 +651,9 @@ public final class StompConnection implements RemotingConnection { public void unsubscribe(String subscriptionID, String durableSubscriptionName) throws ActiveMQStompException { try { manager.unsubscribe(this, subscriptionID, durableSubscriptionName); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorUnsubscrib(subscriptionID, e).setHandler(frameHandler); } } @@ -685,11 +661,9 @@ public final class StompConnection implements RemotingConnection { public void acknowledge(String messageID, String subscriptionID) throws ActiveMQStompException { try { manager.acknowledge(this, messageID, subscriptionID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw BUNDLE.errorAck(messageID, e).setHandler(frameHandler); } } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java index 427509f024..cd2a9292ba 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java @@ -221,16 +221,14 @@ public class StompDecoder { if (contentLength != -1) { if (pos + contentLength + 1 > data) { // Need more bytes - } - else { + } else { content = new byte[contentLength]; System.arraycopy(workingBuffer, pos, content, 0, contentLength); pos += contentLength + 1; } - } - else { + } else { // Need to scan for terminating NUL if (bodyStart == -1) { @@ -269,8 +267,7 @@ public class StompDecoder { init(); return ret; - } - else { + } else { return null; } } @@ -371,13 +368,11 @@ public class StompDecoder { while (offset < data) { if (workingBuffer[offset] == NEW_LINE) { nextChar = false; - } - else if (workingBuffer[offset] == CR) { + } else if (workingBuffer[offset] == CR) { if (nextChar) throw BUNDLE.invalidTwoCRs().setHandler(handler); nextChar = true; - } - else { + } else { break; } offset++; @@ -404,8 +399,7 @@ public class StompDecoder { // ABORT command = COMMAND_ABORT; - } - else { + } else { if (!tryIncrement(offset + COMMAND_ACK_LENGTH + 1)) { return false; } @@ -433,18 +427,14 @@ public class StompDecoder { // COMMIT command = COMMAND_COMMIT; - } - /**** added by meddy, 27 april 2011, handle header parser for reply to websocket protocol ****/ - else if (workingBuffer[offset + 7] == E) { + } else if (workingBuffer[offset + 7] == E) { if (!tryIncrement(offset + COMMAND_CONNECTED_LENGTH + 1)) { return false; } // CONNECTED command = COMMAND_CONNECTED; - } - /**** end ****/ - else { + } else { if (!tryIncrement(offset + COMMAND_CONNECT_LENGTH + 1)) { return false; } @@ -504,16 +494,14 @@ public class StompDecoder { // SEND command = COMMAND_SEND; - } - else if (workingBuffer[offset + 1] == T) { + } else if (workingBuffer[offset + 1] == T) { if (!tryIncrement(offset + COMMAND_STOMP_LENGTH + 1)) { return false; } // STOMP command = COMMAND_STOMP; - } - else { + } else { if (!tryIncrement(offset + COMMAND_SUBSCRIBE_LENGTH + 1)) { return false; } @@ -594,8 +582,7 @@ public class StompDecoder { public boolean tryIncrement(final int length) { if (pos + length >= data) { return false; - } - else { + } else { pos += length; return true; @@ -612,8 +599,7 @@ public class StompDecoder { //Unreadable characters str.append(bytes[i]); - } - else { + } else { str.append(b); } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java index 5dd74f5c84..50c3108029 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java @@ -93,7 +93,7 @@ public class StompFrame { if (buffer == null) { if (isPing()) { buffer = ActiveMQBuffers.fixedBuffer(1); - buffer.writeByte((byte)10); + buffer.writeByte((byte) 10); size = buffer.writerIndex(); return buffer; } @@ -124,8 +124,7 @@ public class StompFrame { buffer.writeBytes(END_OF_FRAME); size = buffer.writerIndex(); - } - else { + } else { buffer.readerIndex(0); } return buffer; @@ -183,27 +182,17 @@ public class StompFrame { if (c == (byte) 10) { buffer[iBuffer] = (byte) 92; buffer[++iBuffer] = (byte) 110; - } - - // \r - else if (c == (byte) 13) { + } else if (c == (byte) 13) { // \r buffer[iBuffer] = (byte) 92; buffer[++iBuffer] = (byte) 114; - } + } else if (c == (byte) 92) { // \ - // \ - else if (c == (byte) 92) { buffer[iBuffer] = (byte) 92; buffer[++iBuffer] = (byte) 92; - } - - // : - else if (c == (byte) 58) { + } else if (c == (byte) 58) { // : buffer[iBuffer] = (byte) 92; buffer[++iBuffer] = (byte) 99; - } - - else { + } else { buffer[iBuffer] = c; } iBuffer++; diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java index 235cddd468..46f8e4ce4c 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java @@ -56,7 +56,7 @@ import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProto /** * StompProtocolManager */ -public class StompProtocolManager extends AbstractProtocolManager { +public class StompProtocolManager extends AbstractProtocolManager { private static final List websocketRegistryNames = Arrays.asList("v10.stomp", "v11.stomp", "v12.stomp"); @@ -136,8 +136,7 @@ public class StompProtocolManager extends AbstractProtocolManager(consumer.getID(), length)); // Must send AFTER adding to messagesToAck - or could get acked from client BEFORE it's been added! manager.send(connection, frame); } return length; - } - catch (Exception e) { + } catch (Exception e) { if (ActiveMQStompProtocolLogger.LOGGER.isDebugEnabled()) { ActiveMQStompProtocolLogger.LOGGER.debug(e); } return 0; - } - finally { + } finally { if (largeMessage != null) { largeMessage.releaseResources(); largeMessage = null; @@ -216,7 +216,11 @@ public class StompSession implements SessionCallback { } @Override - public int sendLargeMessage(MessageReference ref, ServerMessage msg, ServerConsumer consumer, long bodySize, int deliveryCount) { + public int sendLargeMessage(MessageReference ref, + ServerMessage msg, + ServerConsumer consumer, + long bodySize, + int deliveryCount) { return 0; } @@ -260,8 +264,7 @@ public class StompSession implements SessionCallback { if (sub.getAck().equals(Stomp.Headers.Subscribe.AckModeValues.CLIENT_INDIVIDUAL)) { session.individualAcknowledge(consumerID, id); - } - else { + } else { session.acknowledge(consumerID, id); } @@ -293,14 +296,12 @@ public class StompSession implements SessionCallback { if (manager.getServer().locateQueue(queueName) == null) { session.createQueue(SimpleString.toSimpleString(destination), queueName, SimpleString.toSimpleString(selector), false, true); } - } - else { + } else { queueName = UUIDGenerator.getInstance().generateSimpleStringUUID(); session.createQueue(SimpleString.toSimpleString(destination), queueName, SimpleString.toSimpleString(selector), true, false); } session.createConsumer(consumerID, queueName, null, false, false, receiveCredits); - } - else { + } else { session.createConsumer(consumerID, queueName, SimpleString.toSimpleString(selector), false, false, receiveCredits); } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java index e45b2200ae..affab846ce 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java @@ -43,8 +43,7 @@ public class StompUtils { String priority = headers.remove(Stomp.Headers.Send.PRIORITY); if (priority != null) { msg.setPriority(Byte.parseByte(priority)); - } - else { + } else { msg.setPriority(Byte.parseByte(DEFAULT_MESSAGE_PRIORITY)); } String persistent = headers.remove(Stomp.Headers.Send.PERSISTENT); diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java index 25d32be5a8..003865c8aa 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java @@ -42,7 +42,10 @@ public abstract class VersionedStompFrameHandler { protected final ScheduledExecutorService scheduledExecutorService; protected final ExecutorFactory executorFactory; - public static VersionedStompFrameHandler getHandler(StompConnection connection, StompVersions version, ScheduledExecutorService scheduledExecutorService, ExecutorFactory executorFactory) { + public static VersionedStompFrameHandler getHandler(StompConnection connection, + StompVersions version, + ScheduledExecutorService scheduledExecutorService, + ExecutorFactory executorFactory) { if (version == StompVersions.V1_0) { return new StompFrameHandlerV10(connection, scheduledExecutorService, executorFactory); } @@ -55,7 +58,9 @@ public abstract class VersionedStompFrameHandler { return null; } - protected VersionedStompFrameHandler(StompConnection connection, ScheduledExecutorService scheduledExecutorService, ExecutorFactory executorFactory) { + protected VersionedStompFrameHandler(StompConnection connection, + ScheduledExecutorService scheduledExecutorService, + ExecutorFactory executorFactory) { this.connection = connection; this.scheduledExecutorService = scheduledExecutorService; this.executorFactory = executorFactory; @@ -78,45 +83,33 @@ public abstract class VersionedStompFrameHandler { if (Stomp.Commands.SEND.equals(request.getCommand())) { response = onSend(request); - } - else if (Stomp.Commands.ACK.equals(request.getCommand())) { + } else if (Stomp.Commands.ACK.equals(request.getCommand())) { response = onAck(request); - } - else if (Stomp.Commands.NACK.equals(request.getCommand())) { + } else if (Stomp.Commands.NACK.equals(request.getCommand())) { response = onNack(request); - } - else if (Stomp.Commands.BEGIN.equals(request.getCommand())) { + } else if (Stomp.Commands.BEGIN.equals(request.getCommand())) { response = onBegin(request); - } - else if (Stomp.Commands.COMMIT.equals(request.getCommand())) { + } else if (Stomp.Commands.COMMIT.equals(request.getCommand())) { response = onCommit(request); - } - else if (Stomp.Commands.ABORT.equals(request.getCommand())) { + } else if (Stomp.Commands.ABORT.equals(request.getCommand())) { response = onAbort(request); - } - else if (Stomp.Commands.SUBSCRIBE.equals(request.getCommand())) { + } else if (Stomp.Commands.SUBSCRIBE.equals(request.getCommand())) { response = onSubscribe(request); - } - else if (Stomp.Commands.UNSUBSCRIBE.equals(request.getCommand())) { + } else if (Stomp.Commands.UNSUBSCRIBE.equals(request.getCommand())) { response = onUnsubscribe(request); - } - else if (Stomp.Commands.CONNECT.equals(request.getCommand())) { + } else if (Stomp.Commands.CONNECT.equals(request.getCommand())) { response = onConnect(request); - } - else if (Stomp.Commands.STOMP.equals(request.getCommand())) { + } else if (Stomp.Commands.STOMP.equals(request.getCommand())) { response = onStomp(request); - } - else if (Stomp.Commands.DISCONNECT.equals(request.getCommand())) { + } else if (Stomp.Commands.DISCONNECT.equals(request.getCommand())) { response = onDisconnect(request); - } - else { + } else { response = onUnknown(request.getCommand()); } if (response == null) { response = postprocess(request); - } - else { + } else { if (request.hasHeader(Stomp.Headers.RECEIPT_REQUESTED)) { response.addHeader(Stomp.Headers.Response.RECEIPT_ID, request.getHeader(Stomp.Headers.RECEIPT_REQUESTED)); } @@ -164,8 +157,7 @@ public abstract class VersionedStompFrameHandler { try { connection.commitTransaction(txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } return response; @@ -188,19 +180,16 @@ public abstract class VersionedStompFrameHandler { if (frame.hasHeader(Stomp.Headers.CONTENT_LENGTH)) { message.setType(Message.BYTES_TYPE); message.getBodyBuffer().writeBytes(frame.getBodyAsBytes()); - } - else { + } else { message.setType(Message.TEXT_TYPE); String text = frame.getBody(); message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(text)); } connection.sendServerMessage(message, txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQStompException error = BUNDLE.errorHandleSend(e).setHandler(this); response = error.getFrame(); } @@ -218,12 +207,10 @@ public abstract class VersionedStompFrameHandler { if (txID == null) { ActiveMQStompException error = BUNDLE.beginTxNoID().setHandler(this); response = error.getFrame(); - } - else { + } else { try { connection.beginTransaction(txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } } @@ -242,8 +229,7 @@ public abstract class VersionedStompFrameHandler { try { connection.abortTransaction(txID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } @@ -269,8 +255,7 @@ public abstract class VersionedStompFrameHandler { try { connection.subscribe(destination, selector, ack, id, durableSubscriptionName, noLocal); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } @@ -284,8 +269,7 @@ public abstract class VersionedStompFrameHandler { if (request.getCommand().equals(Stomp.Commands.DISCONNECT)) { response.setNeedsDisconnect(true); } - } - else { + } else { //request null, disconnect if so. if (request.getCommand().equals(Stomp.Commands.DISCONNECT)) { this.connection.disconnect(false); @@ -316,13 +300,11 @@ public abstract class VersionedStompFrameHandler { if (serverMessage.containsProperty(Stomp.Headers.CONTENT_LENGTH) || serverMessage.getType() == Message.BYTES_TYPE) { frame.addHeader(Headers.CONTENT_LENGTH, String.valueOf(data.length)); buffer.readBytes(data); - } - else { + } else { SimpleString text = buffer.readNullableSimpleString(); if (text != null) { data = text.toString().getBytes(StandardCharsets.UTF_8); - } - else { + } else { data = new byte[0]; } } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java index 0e32881ee5..4a0cfa1d45 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java @@ -20,8 +20,8 @@ import javax.security.cert.X509Certificate; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; -import org.apache.activemq.artemis.core.protocol.stomp.FrameEventListener; import org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompException; +import org.apache.activemq.artemis.core.protocol.stomp.FrameEventListener; import org.apache.activemq.artemis.core.protocol.stomp.Stomp; import org.apache.activemq.artemis.core.protocol.stomp.StompConnection; import org.apache.activemq.artemis.core.protocol.stomp.StompDecoder; @@ -37,7 +37,9 @@ import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProto public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements FrameEventListener { - public StompFrameHandlerV10(StompConnection connection, ScheduledExecutorService scheduledExecutorService, ExecutorFactory factory) { + public StompFrameHandlerV10(StompConnection connection, + ScheduledExecutorService scheduledExecutorService, + ExecutorFactory factory) { super(connection, scheduledExecutorService, factory); decoder = new StompDecoder(this); decoder.init(); @@ -73,8 +75,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements if (requestID != null) { response.addHeader(Stomp.Headers.Connected.RESPONSE_ID, requestID); } - } - else { + } else { //not valid response = new StompFrameV10(Stomp.Responses.ERROR); String responseText = "Security Error occurred: User name [" + login + "] or password is invalid"; @@ -102,8 +103,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements String subscriptionID = null; if (id != null) { subscriptionID = id; - } - else { + } else { if (destination == null) { ActiveMQStompException error = BUNDLE.needIDorDestination().setHandler(this); response = error.getFrame(); @@ -114,8 +114,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements try { connection.unsubscribe(subscriptionID, durableSubscriptionName); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { return e.getFrame(); } return response; @@ -134,8 +133,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements try { connection.acknowledge(messageID, null); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java index 35de63ceb0..c4a9a61dc7 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java @@ -48,7 +48,9 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements private HeartBeater heartBeater; - public StompFrameHandlerV11(StompConnection connection, ScheduledExecutorService scheduledExecutorService, ExecutorFactory executorFactory) { + public StompFrameHandlerV11(StompConnection connection, + ScheduledExecutorService scheduledExecutorService, + ExecutorFactory executorFactory) { super(connection, scheduledExecutorService, executorFactory); connection.addStompEventListener(this); decoder = new StompDecoderV11(this); @@ -98,13 +100,11 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements handleHeartBeat(heartBeat); if (heartBeater == null) { response.addHeader(Stomp.Headers.Connected.HEART_BEAT, "0,0"); - } - else { + } else { response.addHeader(Stomp.Headers.Connected.HEART_BEAT, heartBeater.serverPingPeriod + "," + heartBeater.clientPingResponse); } } - } - else { + } else { // not valid response = createStompFrame(Stomp.Responses.ERROR); response.setNeedsDisconnect(true); @@ -113,8 +113,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements response.setBody(responseText); response.addHeader(Stomp.Headers.Error.MESSAGE, responseText); } - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } @@ -156,16 +155,14 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements String subscriptionID = null; if (id != null) { subscriptionID = id; - } - else if (durableSubscriptionName == null) { + } else if (durableSubscriptionName == null) { response = BUNDLE.needSubscriptionID().setHandler(this).getFrame(); return response; } try { connection.unsubscribe(subscriptionID, durableSubscriptionName); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } return response; @@ -190,8 +187,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements try { connection.acknowledge(messageID, subscriptionID); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } @@ -222,8 +218,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (reply.needsDisconnect()) { connection.disconnect(false); - } - else { + } else { //update ping if (heartBeater != null) { heartBeater.pinged(); @@ -259,14 +254,17 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements AtomicLong lastPingTimestamp = new AtomicLong(0); ConnectionEntry connectionEntry; - private HeartBeater(ScheduledExecutorService scheduledExecutorService, Executor executor, final long clientPing, final long clientAcceptPing) { + private HeartBeater(ScheduledExecutorService scheduledExecutorService, + Executor executor, + final long clientPing, + final long clientAcceptPing) { super(scheduledExecutorService, executor, clientAcceptPing > MIN_SERVER_PING ? clientAcceptPing : MIN_SERVER_PING, TimeUnit.MILLISECONDS, false); if (clientAcceptPing != 0) { serverPingPeriod = super.getPeriod(); } - connectionEntry = ((RemotingServiceImpl)connection.getManager().getServer().getRemotingService()).getConnectionEntry(connection.getID()); + connectionEntry = ((RemotingServiceImpl) connection.getManager().getServer().getRemotingService()).getConnectionEntry(connection.getID()); if (connectionEntry != null) { String heartBeatToTtlModifierStr = (String) connection.getAcceptorUsed().getConfiguration().get(TransportConstants.HEART_BEAT_TO_CONNECTION_TTL_MODIFIER); @@ -292,8 +290,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (connectionTtl < ttlMin) { connectionTtl = ttlMin; clientPingResponse = (long) (ttlMin / heartBeatToTtlModifier); - } - else if (connectionTtl > ttlMax) { + } else if (connectionTtl > ttlMax) { connectionTtl = ttlMax; clientPingResponse = (long) (ttlMax / heartBeatToTtlModifier); } @@ -375,13 +372,11 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (workingBuffer[offset] == NEW_LINE) { //client ping nextChar = false; - } - else if (workingBuffer[offset] == CR) { + } else if (workingBuffer[offset] == CR) { if (nextChar) throw BUNDLE.invalidTwoCRs().setHandler(handler); nextChar = true; - } - else { + } else { break; } offset++; @@ -417,8 +412,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements // ABORT command = COMMAND_ABORT; - } - else { + } else { if (!tryIncrement(offset + COMMAND_ACK_LENGTH + eolLen)) { return false; } @@ -446,18 +440,14 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements // COMMIT command = COMMAND_COMMIT; - } - /**** added by meddy, 27 april 2011, handle header parser for reply to websocket protocol ****/ - else if (workingBuffer[offset + 7] == E) { + } else if (workingBuffer[offset + 7] == E) { if (!tryIncrement(offset + COMMAND_CONNECTED_LENGTH + eolLen)) { return false; } // CONNECTED command = COMMAND_CONNECTED; - } - /**** end ****/ - else { + } else { if (!tryIncrement(offset + COMMAND_CONNECT_LENGTH + eolLen)) { return false; } @@ -517,16 +507,14 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements // SEND command = COMMAND_SEND; - } - else if (workingBuffer[offset + 1] == U) { + } else if (workingBuffer[offset + 1] == U) { if (!tryIncrement(offset + COMMAND_SUBSCRIBE_LENGTH + eolLen)) { return false; } // SUBSCRIBE command = COMMAND_SUBSCRIBE; - } - else { + } else { if (!tryIncrement(offset + StompDecoder.COMMAND_STOMP_LENGTH + eolLen)) { return false; } @@ -584,8 +572,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements //this is a backslash holder.append(b); isEscaping = false; - } - else { + } else { //begin escaping isEscaping = true; } @@ -610,8 +597,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (isEscaping) { holder.append(StompDecoder.NEW_LINE); isEscaping = false; - } - else { + } else { holder.append(b); } break; @@ -620,8 +606,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (isEscaping) { holder.append(StompDecoder.HEADER_SEPARATOR); isEscaping = false; - } - else { + } else { holder.append(b); } break; @@ -678,8 +663,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements if (contentLength != -1) { if (pos + contentLength + 1 > data) { // Need more bytes - } - else { + } else { content = new byte[contentLength]; System.arraycopy(workingBuffer, pos, content, 0, contentLength); @@ -697,8 +681,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements } } } - } - else { + } else { // Need to scan for terminating NUL if (bodyStart == -1) { @@ -735,8 +718,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements init(); return ret; - } - else { + } else { return null; } } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java index 31c713270b..e6dd5b78ee 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java @@ -51,8 +51,7 @@ public class StompFrameV11 extends StompFrame { if (!headers.containsKey(key)) { headers.put(key, val); allHeaders.add(new Header(key, val)); - } - else if (!key.equals(Stomp.Headers.CONTENT_LENGTH)) { + } else if (!key.equals(Stomp.Headers.CONTENT_LENGTH)) { allHeaders.add(new Header(key, val)); } } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java index 19149bfef6..2149721ee4 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java @@ -34,7 +34,9 @@ import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProto public class StompFrameHandlerV12 extends StompFrameHandlerV11 { - public StompFrameHandlerV12(StompConnection connection, ScheduledExecutorService scheduledExecutorService, ExecutorFactory factory) { + public StompFrameHandlerV12(StompConnection connection, + ScheduledExecutorService scheduledExecutorService, + ExecutorFactory factory) { super(connection, scheduledExecutorService, factory); decoder = new StompDecoderV12(this); decoder.init(); @@ -80,8 +82,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { try { connection.acknowledge(messageID, null); - } - catch (ActiveMQStompException e) { + } catch (ActiveMQStompException e) { response = e.getFrame(); } @@ -110,11 +111,9 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { //either \n or \r\n if (workingBuffer[pos - 2] == NEW_LINE) { pos--; - } - else if (workingBuffer[pos - 2] != CR) { + } else if (workingBuffer[pos - 2] != CR) { throwInvalid(); - } - else if (workingBuffer[pos - 1] != NEW_LINE) { + } else if (workingBuffer[pos - 1] != NEW_LINE) { throwInvalid(); } } @@ -140,8 +139,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { //this is a backslash holder.append(b); isEscaping = false; - } - else { + } else { //begin escaping isEscaping = true; } @@ -166,8 +164,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { if (isEscaping) { holder.append(NEW_LINE); isEscaping = false; - } - else { + } else { holder.append(b); } break; @@ -176,8 +173,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { if (isEscaping) { holder.append(CR); isEscaping = false; - } - else { + } else { holder.append(b); } break; @@ -193,8 +189,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { if (isEscaping) { holder.append(StompDecoder.HEADER_SEPARATOR); isEscaping = false; - } - else { + } else { holder.append(b); } break; @@ -253,8 +248,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { if (contentLength != -1) { if (pos + contentLength + 1 > data) { // Need more bytes - } - else { + } else { content = new byte[contentLength]; System.arraycopy(workingBuffer, pos, content, 0, contentLength); @@ -272,8 +266,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { } } } - } - else { + } else { // Need to scan for terminating NUL if (bodyStart == -1) { @@ -310,8 +303,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 { init(); return ret; - } - else { + } else { return null; } } diff --git a/artemis-protocols/pom.xml b/artemis-protocols/pom.xml index 29289acf72..f853d18de8 100644 --- a/artemis-protocols/pom.xml +++ b/artemis-protocols/pom.xml @@ -15,7 +15,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + artemis-pom org.apache.activemq diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABundle.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABundle.java index 622c2ec527..f2e97227f8 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABundle.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABundle.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.ra; +import javax.jms.JMSRuntimeException; +import javax.resource.NotSupportedException; + import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; - -import javax.jms.JMSRuntimeException; -import javax.resource.NotSupportedException; /** * Logger Code 15 diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java index 667d4a572b..6e38088cce 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.ra; -import java.util.Arrays; - import javax.jms.BytesMessage; import javax.jms.JMSException; +import java.util.Arrays; /** * A wrapper for a message diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java index 2a1b706c02..faf111e16b 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java @@ -83,8 +83,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact if (ActiveMQRAConnectionFactoryImpl.trace) { ActiveMQRALogger.LOGGER.trace("Created new ConnectionManager=" + this.cm); } - } - else { + } else { this.cm = cm; } @@ -120,8 +119,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact if (reference == null) { try { reference = new Reference(this.getClass().getCanonicalName(), new SerializableObjectRefAddr("ActiveMQ-CF", this), ConnectionFactoryObjectFactory.class.getCanonicalName(), null); - } - catch (NamingException e) { + } catch (NamingException e) { ActiveMQRALogger.LOGGER.errorCreatingReference(e); } } @@ -432,13 +430,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact conn.setPassword(password); try { validateUser(conn); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage()); e2.initCause(e); throw e2; - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; @@ -463,13 +459,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact conn.setPassword(password); try { validateUser(conn); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage()); e2.initCause(e); throw e2; - } - catch (JMSException e) { + } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java index bb0d0f3831..f895b59f09 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java @@ -79,8 +79,7 @@ public class ActiveMQRAConnectionManager implements ConnectionManager { for (ManagedConnection conn : connections) { try { conn.destroy(); - } - catch (Throwable e) { + } catch (Throwable e) { } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java index 32b4d0d8c0..88da41c83f 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.ra; +import javax.jms.ConnectionMetaData; import java.util.Enumeration; import java.util.Vector; -import javax.jms.ConnectionMetaData; - /** * This class implements javax.jms.ConnectionMetaData */ diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java index 97350ff09f..29a4c2d1cd 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java @@ -261,8 +261,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { type == you.getType() && transacted == you.isTransacted() && acknowledgeMode == you.getAcknowledgeMode(); - } - else { + } else { return false; } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java index 8a38e45666..ee04949f02 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java @@ -16,16 +16,15 @@ */ package org.apache.activemq.artemis.ra; -import java.io.Serializable; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Set; - import javax.resource.spi.ConnectionRequestInfo; import javax.resource.spi.ManagedConnectionFactory; import javax.resource.spi.SecurityException; import javax.resource.spi.security.PasswordCredential; import javax.security.auth.Subject; +import java.io.Serializable; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Set; /** * Credential information @@ -130,8 +129,7 @@ public class ActiveMQRACredential implements Serializable { if (subject == null && info != null) { jc.setUserName(((ActiveMQRAConnectionRequestInfo) info).getUserName()); jc.setPassword(((ActiveMQRAConnectionRequestInfo) info).getPassword()); - } - else if (subject != null) { + } else if (subject != null) { PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf); if (pwdc == null) { @@ -140,8 +138,7 @@ public class ActiveMQRACredential implements Serializable { jc.setUserName(pwdc.getUserName()); jc.setPassword(new String(pwdc.getPassword())); - } - else { + } else { throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials"); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAJMSContext.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAJMSContext.java index 5d14ba446d..fce9c119a4 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAJMSContext.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAJMSContext.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.ra; +import javax.jms.ExceptionListener; +import javax.jms.JMSContext; + import org.apache.activemq.artemis.jms.client.ActiveMQConnectionForContext; import org.apache.activemq.artemis.jms.client.ActiveMQJMSContext; import org.apache.activemq.artemis.jms.client.ThreadAwareContext; -import javax.jms.ExceptionListener; -import javax.jms.JMSContext; - public class ActiveMQRAJMSContext extends ActiveMQJMSContext { public ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java index 7857255e21..342a27f23b 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java @@ -78,11 +78,9 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { if (mc.getSession().getTransacted()) { mc.getSession().commit(); } - } - catch (JMSException e) { + } catch (JMSException e) { throw new ResourceException("Could not commit LocalTransaction", e); - } - finally { + } finally { //mc.setInManagedTx(false); mc.unlock(); } @@ -104,11 +102,9 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { if (mc.getSession().getTransacted()) { mc.getSession().rollback(); } - } - catch (JMSException ex) { + } catch (JMSException ex) { throw new ResourceException("Could not rollback LocalTransaction", ex); - } - finally { + } finally { //mc.setInManagedTx(false); mc.unlock(); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java index dc363e7e7c..945d4341c7 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.ra; -import java.io.Serializable; - import javax.jms.Queue; import javax.jms.Topic; +import java.io.Serializable; /** * The MCF default properties - these are set in the tx-connection-factory at the jms-ds.xml @@ -121,11 +120,9 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme if (defaultType.equals(ActiveMQRAMCFProperties.QUEUE_TYPE)) { type = ActiveMQRAConnectionFactory.QUEUE_CONNECTION; - } - else if (defaultType.equals(ActiveMQRAMCFProperties.TOPIC_TYPE)) { + } else if (defaultType.equals(ActiveMQRAMCFProperties.TOPIC_TYPE)) { type = ActiveMQRAConnectionFactory.TOPIC_CONNECTION; - } - else { + } else { type = ActiveMQRAConnectionFactory.CONNECTION; } } @@ -142,11 +139,9 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme if (type == ActiveMQRAConnectionFactory.CONNECTION) { return "BOTH"; - } - else if (type == ActiveMQRAConnectionFactory.QUEUE_CONNECTION) { + } else if (type == ActiveMQRAConnectionFactory.QUEUE_CONNECTION) { return ActiveMQRAMCFProperties.TOPIC_TYPE; - } - else { + } else { return ActiveMQRAMCFProperties.QUEUE_TYPE; } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java index 97c603264f..efd8cccd88 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java @@ -161,21 +161,17 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc try { setup(); - } - catch (ResourceException e) { + } catch (ResourceException e) { try { destroy(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } throw e; - } - catch (Throwable t) { + } catch (Throwable t) { try { destroy(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } throw new ResourceException("Error during setup", t); } @@ -232,8 +228,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc if (connection != null) { connection.stop(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Ignored error stopping connection", t); } @@ -263,8 +258,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc try { connection.setExceptionListener(null); - } - catch (JMSException e) { + } catch (JMSException e) { ActiveMQRALogger.LOGGER.debug("Error unsetting the exception listener " + this, e); } if (connection != null) { @@ -296,8 +290,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc if (xaSession != null) { xaSession.close(); } - } - catch (JMSException e) { + } catch (JMSException e) { ActiveMQRALogger.LOGGER.debug("Error closing session " + this, e); } @@ -305,8 +298,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc if (connectionFactory != null) { ra.closeConnectionFactory(mcf.getProperties()); } - } - catch (Throwable e) { + } catch (Throwable e) { throw new ResourceException("Could not properly close the session and connection", e); } } @@ -356,8 +348,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc ActiveMQRASession h = (ActiveMQRASession) obj; h.setManagedConnection(this); handles.add(h); - } - else { + } else { throw new IllegalStateException("ManagedConnection in an illegal state"); } } @@ -376,8 +367,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc throw new javax.jms.IllegalStateException("Transaction " + tx + " not active"); } } - } - catch (SystemException e) { + } catch (SystemException e) { JMSException jmsE = new javax.jms.IllegalStateException("Unexpected exception on the Transaction ManagerTransaction"); jmsE.initCause(e); throw jmsE; @@ -415,8 +405,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc if (lock.tryLock(tryLock.intValue(), TimeUnit.SECONDS) == false) { throw new ResourceAllocationException("Unable to obtain lock in " + tryLock + " seconds: " + this); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ResourceAllocationException("Interrupted attempting lock: " + this); } } @@ -588,8 +577,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc try { connection.setExceptionListener(null); - } - catch (JMSException e) { + } catch (JMSException e) { ActiveMQRALogger.LOGGER.debug("Unable to unset exception listener", e); } @@ -610,8 +598,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc } return xaSession.getSession(); - } - else { + } else { if (ActiveMQRAManagedConnection.trace) { ActiveMQRALogger.LOGGER.trace("getSession() -> non XA session " + nonXAsession); } @@ -764,8 +751,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { if (userName != null && password != null) { connection = (ActiveMQXAConnection) connectionFactory.createXATopicConnection(userName, password); - } - else { + } else { connection = (ActiveMQXAConnection) connectionFactory.createXATopicConnection(); } @@ -774,12 +760,10 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc xaSession = connection.createXATopicSession(); nonXAsession = connection.createNonXATopicSession(transacted, acknowledgeMode); - } - else if (cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION) { + } else if (cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION) { if (userName != null && password != null) { connection = (ActiveMQXAConnection) connectionFactory.createXAQueueConnection(userName, password); - } - else { + } else { connection = (ActiveMQXAConnection) connectionFactory.createXAQueueConnection(); } @@ -788,12 +772,10 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc xaSession = connection.createXAQueueSession(); nonXAsession = connection.createNonXAQueueSession(transacted, acknowledgeMode); - } - else { + } else { if (userName != null && password != null) { connection = (ActiveMQXAConnection) connectionFactory.createXAConnection(userName, password); - } - else { + } else { connection = (ActiveMQXAConnection) connectionFactory.createXAConnection(); } @@ -803,8 +785,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc nonXAsession = connection.createNonXASession(transacted, acknowledgeMode); } - } - catch (JMSException je) { + } catch (JMSException je) { throw new ResourceException(je.getMessage(), je); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java index c46efcac2f..a3541a6ec4 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java @@ -310,8 +310,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti ActiveMQRAManagedConnectionFactory other = (ActiveMQRAManagedConnectionFactory) obj; return mcfProperties.equals(other.getProperties()) && ra.equals(other.getResourceAdapter()); - } - else { + } else { return false; } } @@ -671,8 +670,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti if (info == null) { // Create a default one return new ActiveMQRAConnectionRequestInfo(ra.getProperties(), mcfProperties.getType()); - } - else { + } else { // Fill the one with any defaults info.setDefaults(ra.getProperties()); return info; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java index 0b2cb6111b..70e5005018 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.ra; -import java.util.Arrays; -import java.util.Enumeration; - import javax.jms.JMSException; import javax.jms.MapMessage; +import java.util.Arrays; +import java.util.Enumeration; /** * A wrapper for a message diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java index d0600097ac..9b4946671d 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java @@ -810,8 +810,7 @@ public class ActiveMQRAMessage implements Message { if (object != null && object instanceof ActiveMQRAMessage) { return message.equals(((ActiveMQRAMessage) object).message); - } - else { + } else { return message.equals(object); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java index 73ec6c2757..0e156aa7d3 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java @@ -77,8 +77,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { } try { closeConsumer(); - } - finally { + } finally { session.removeConsumer(this); } } @@ -126,12 +125,10 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { session.checkStrict(); if (listener == null) { consumer.setMessageListener(null); - } - else { + } else { consumer.setMessageListener(wrapMessageListener(listener)); } - } - finally { + } finally { session.unlock(); } } @@ -175,12 +172,10 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { if (message == null) { return null; - } - else { + } else { return wrapMessage(message); } - } - finally { + } finally { session.unlock(); } } @@ -209,12 +204,10 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { if (message == null) { return null; - } - else { + } else { return wrapMessage(message); } - } - finally { + } finally { session.unlock(); } } @@ -242,12 +235,10 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { if (message == null) { return null; - } - else { + } else { return wrapMessage(message); } - } - finally { + } finally { session.unlock(); } } @@ -278,17 +269,13 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { if (message instanceof BytesMessage) { return new ActiveMQRABytesMessage((BytesMessage) message, session); - } - else if (message instanceof MapMessage) { + } else if (message instanceof MapMessage) { return new ActiveMQRAMapMessage((MapMessage) message, session); - } - else if (message instanceof ObjectMessage) { + } else if (message instanceof ObjectMessage) { return new ActiveMQRAObjectMessage((ObjectMessage) message, session); - } - else if (message instanceof StreamMessage) { + } else if (message instanceof StreamMessage) { return new ActiveMQRAStreamMessage((StreamMessage) message, session); - } - else if (message instanceof TextMessage) { + } else if (message instanceof TextMessage) { return new ActiveMQRATextMessage((TextMessage) message, session); } return new ActiveMQRAMessage(message, session); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java index 41337f65a3..74c11cc1e7 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java @@ -73,8 +73,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { } try { closeProducer(); - } - finally { + } finally { session.removeProducer(this); } } @@ -118,8 +117,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { if (ActiveMQRAMessageProducer.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -146,8 +144,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { if (ActiveMQRAMessageProducer.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -187,8 +184,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { if (ActiveMQRAMessageProducer.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -214,8 +210,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { if (ActiveMQRAMessageProducer.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java index c343917a71..a01575cb23 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.ra; -import java.io.Serializable; - import javax.jms.JMSException; import javax.jms.ObjectMessage; +import java.io.Serializable; /** * A wrapper for a message diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java index a1046b9268..95a58d3222 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java @@ -253,8 +253,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements if (password != null) { password = codecInstance.decode(password); } - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQRABundle.BUNDLE.errorDecodingPassword(e); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java index 90fb8eaf0b..47a7acb6b6 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java @@ -98,8 +98,7 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements if (ActiveMQRAQueueSender.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -125,8 +124,7 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements if (ActiveMQRAQueueSender.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAService.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAService.java index 1f4cc29e6f..8efe50e515 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAService.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAService.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.ra; -import java.util.Set; - import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; +import java.util.Set; /** * An ActiveMQRAService ensures that ActiveMQ Artemis Resource Adapter will be stopped *before* the ActiveMQ Artemis server. @@ -57,8 +56,7 @@ public class ActiveMQRAService { mBeanServer.invoke(mbean.getObjectName(), "stop", new Object[0], new String[0]); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRALogger.LOGGER.errorStoppingRA(e); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java index 05006e441c..f123379caf 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java @@ -136,8 +136,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu final ActiveMQRAManagedConnection mcLocal = this.mc; if (mcLocal != null) { mcLocal.tryLock(); - } - else { + } else { throw new IllegalStateException("Connection is not associated with a managed connection. " + this); } } @@ -398,8 +397,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu } session.commit(); - } - finally { + } finally { unlock(); } } @@ -429,8 +427,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu } session.rollback(); - } - finally { + } finally { unlock(); } } @@ -455,8 +452,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu } session.recover(); - } - finally { + } finally { unlock(); } } @@ -516,8 +512,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -559,8 +554,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -597,8 +591,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -644,8 +637,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -677,8 +669,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addProducer(result); return result; - } - finally { + } finally { unlock(); } } @@ -712,8 +703,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu sf.addTemporaryTopic(temp); return temp; - } - finally { + } finally { unlock(); } } @@ -739,8 +729,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu } session.unsubscribe(name); - } - finally { + } finally { unlock(); } } @@ -857,8 +846,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -891,8 +879,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -924,8 +911,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addProducer(result); return result; - } - finally { + } finally { unlock(); } } @@ -959,8 +945,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu sf.addTemporaryQueue(temp); return temp; - } - finally { + } finally { unlock(); } } @@ -992,8 +977,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1031,8 +1015,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1074,8 +1057,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1107,8 +1089,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addProducer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1147,11 +1128,9 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu lock(); return getXAResourceInternal(); - } - catch (Throwable t) { + } catch (Throwable t) { return null; - } - finally { + } finally { unlock(); } } @@ -1187,8 +1166,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu lock(); try { return this; - } - finally { + } finally { unlock(); } } @@ -1213,8 +1191,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu lock(); try { return this; - } - finally { + } finally { unlock(); } } @@ -1239,8 +1216,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu lock(); try { return this; - } - finally { + } finally { unlock(); } } @@ -1266,8 +1242,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1295,8 +1270,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1321,8 +1295,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1351,8 +1324,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1378,8 +1350,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1407,8 +1378,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu addConsumer(result); return result; - } - finally { + } finally { unlock(); } } @@ -1504,8 +1474,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu try { mc.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error stopping managed connection", t); } @@ -1514,8 +1483,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu ActiveMQRAMessageConsumer consumer = (ActiveMQRAMessageConsumer) i.next(); try { consumer.closeConsumer(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error closing consumer", t); } i.remove(); @@ -1527,8 +1495,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu ActiveMQRAMessageProducer producer = (ActiveMQRAMessageProducer) i.next(); try { producer.closeProducer(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error closing producer", t); } i.remove(); @@ -1644,8 +1611,7 @@ public final class ActiveMQRASession implements QueueSession, TopicSession, XAQu } return xares; - } - catch (ResourceException e) { + } catch (ResourceException e) { JMSException jmse = new JMSException("Unable to get XA Resource"); jmse.initCause(e); throw jmse; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java index 832871a9bf..15746ddb9b 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java @@ -137,8 +137,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon if (cm == null) { this.cm = new ActiveMQRAConnectionManager(); - } - else { + } else { this.cm = cm; } @@ -653,8 +652,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon ActiveMQRASession session = i.next(); try { session.closeSession(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error closing session", t); } i.remove(); @@ -669,8 +667,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon ActiveMQRALogger.LOGGER.trace("Closing temporary queue " + temp + " for " + this); } temp.delete(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error deleting temporary queue", t); } i.remove(); @@ -685,8 +682,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon ActiveMQRALogger.LOGGER.trace("Closing temporary topic " + temp + " for " + this); } temp.delete(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.trace("Error deleting temporary queue", t); } i.remove(); @@ -829,10 +825,10 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon // If the session // is transacted, returns SESSION_TRANSACTED. acknowledgeMode = Session.SESSION_TRANSACTED; - } - //In the Java EE web or EJB container, when there is no active JTA transaction in progress - // The argument {@code transacted} is ignored. - else { + } else { + //In the Java EE web or EJB container, when there is no active JTA transaction in progress + // The argument {@code transacted} is ignored. + //The session will always be non-transacted, transacted = false; switch (acknowledgeMode) { @@ -880,23 +876,19 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon sessions.add(session); return session; - } - catch (Throwable t) { + } catch (Throwable t) { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } if (t instanceof Exception) { throw (Exception) t; - } - else { + } else { throw new RuntimeException("Unexpected error: ", t); } } } - } - catch (Exception e) { + } catch (Exception e) { Throwable current = e; while (current != null && !(current instanceof JMSException)) { current = current.getCause(); @@ -904,8 +896,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon if (current != null && current instanceof JMSException) { throw (JMSException) current; - } - else { + } else { JMSException je = new JMSException("Could not create a session: " + e.getMessage()); je.setLinkedException(e); je.initCause(e); @@ -935,8 +926,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon Transaction tx = null; try { tx = tm.getTransaction(); - } - catch (SystemException e) { + } catch (SystemException e) { //assume false } inJtaTx = tx != null; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java index 02cfd738d1..ede85ee84a 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.ra; -import java.util.Arrays; - import javax.jms.JMSException; import javax.jms.StreamMessage; +import java.util.Arrays; /** * A wrapper for a message diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java index 6f37049283..ee40f726a5 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java @@ -95,8 +95,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen if (ActiveMQRATopicPublisher.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -122,8 +121,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen if (ActiveMQRATopicPublisher.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -167,8 +165,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen if (ActiveMQRATopicPublisher.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } @@ -195,8 +192,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen if (ActiveMQRATopicPublisher.trace) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } - } - finally { + } finally { session.unlock(); } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAJMSContext.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAJMSContext.java index bfee4bb61e..f0bf668920 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAJMSContext.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAJMSContext.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.ra; +import javax.jms.XAJMSContext; + import org.apache.activemq.artemis.jms.client.ActiveMQConnectionForContext; import org.apache.activemq.artemis.jms.client.ThreadAwareContext; -import javax.jms.XAJMSContext; - public class ActiveMQRAXAJMSContext extends ActiveMQRAJMSContext implements XAJMSContext { public ActiveMQRAXAJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext) { diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java index 9d485f31f6..3f908c407b 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java @@ -79,8 +79,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { try { //this resets any tx stuff, we assume here that the tm and jca layer are well behaved when it comes to this sessionInternal.resetIfNeeded(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQRALogger.LOGGER.problemResettingXASession(e); XAException xaException = new XAException(XAException.XAER_RMFAIL); @@ -89,8 +88,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { } xaResource.start(xid, flags); - } - finally { + } finally { managedConnection.setInManagedTx(true); managedConnection.unlock(); } @@ -112,8 +110,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { managedConnection.lock(); try { xaResource.end(xid, flags); - } - finally { + } finally { managedConnection.setInManagedTx(false); managedConnection.unlock(); } @@ -181,8 +178,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { managedConnection.lock(); try { xaResource.forget(xid); - } - finally { + } finally { managedConnection.setInManagedTx(true); managedConnection.setInManagedTx(false); managedConnection.unlock(); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java index 6103bc8d0d..f67022e353 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java @@ -239,8 +239,7 @@ public final class ActiveMQRaUtils { Object o = aClass.newInstance(); Method m = aClass.getMethod("locateChannel", new Class[]{String.class}); return (JChannel) m.invoke(o, name); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQRALogger.LOGGER.debug(e.getMessage(), e); return null; } @@ -261,17 +260,14 @@ public final class ActiveMQRaUtils { try { Class clazz = loader.loadClass(className); return clazz.newInstance(); - } - catch (Throwable t) { + } catch (Throwable t) { try { loader = Thread.currentThread().getContextClassLoader(); if (loader != null) return loader.loadClass(className).newInstance(); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { } throw new IllegalArgumentException("Could not find class " + className); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java index 2804de2299..e9b13239f2 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java @@ -166,8 +166,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (!configured.getAndSet(true)) { try { setup(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new ResourceException("Unable to create activation", e); } } @@ -214,8 +213,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (useAutoRecovery) { // let the TM handle the recovery return null; - } - else { + } else { List xaresources = new ArrayList<>(); for (ActivationSpec spec : specs) { ActiveMQActivation activation = activations.get(spec); @@ -248,8 +246,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (!configured.getAndSet(true)) { try { setup(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new ResourceAdapterInternalException("Unable to create activation", e); } } @@ -269,8 +266,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { for (Map.Entry entry : activations.entrySet()) { try { entry.getValue().stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { ActiveMQRALogger.LOGGER.debug("Ignored", ignored); } } @@ -1548,16 +1544,13 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { // as if any transaction times out, we need the ack on the server already if (useLocalTx) { result = parameterFactory.createSession(user, pass, false, false, false, false, 0); - } - else { + } else { result = parameterFactory.createSession(user, pass, true, false, false, false, 0); } - } - else { + } else { if (preAck != null && preAck) { result = parameterFactory.createSession(user, pass, false, true, true, true, -1); - } - else { + } else { // only auto ack and dups ok are supported switch (ackMode) { case Session.AUTO_ACKNOWLEDGE: @@ -1617,8 +1610,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (!configured.getAndSet(true)) { try { setup(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new ResourceException("Unable to create activation", e); } } @@ -1661,8 +1653,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (!knownConnectionFactories.keySet().contains(overrideProperties)) { cf = newConnectionFactory(overrideProperties); knownConnectionFactories.put(overrideProperties, new Pair<>(cf, new AtomicInteger(1))); - } - else { + } else { Pair pair = knownConnectionFactories.get(overrideProperties); cf = pair.getA(); pair.getB().incrementAndGet(); @@ -1703,8 +1694,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { String jchannelRefName = raProperties.getJgroupsChannelRefName(); JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClassName, jchannelRefName); endpointFactory = new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel); - } - else if (discoveryAddress != null) { + } else if (discoveryAddress != null) { Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort(); if (discoveryPort == null) { discoveryPort = ActiveMQClient.DEFAULT_DISCOVERY_PORT; @@ -1712,8 +1702,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() != null ? overrideProperties.getDiscoveryLocalBindAddress() : raProperties.getDiscoveryLocalBindAddress(); endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(discoveryAddress).setGroupPort(discoveryPort).setLocalBindAddress(localBindAddress).setLocalBindPort(-1); - } - else if (jgroupsFileName != null) { + } else if (jgroupsFileName != null) { endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(jgroupsChannel).setFile(jgroupsFileName); } Long refreshTimeout = overrideProperties.getDiscoveryRefreshTimeout() != null ? overrideProperties.getDiscoveryRefreshTimeout() : raProperties.getDiscoveryRefreshTimeout(); @@ -1735,19 +1724,16 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (ha) { cf = ActiveMQJMSClient.createConnectionFactoryWithHA(groupConfiguration, JMSFactoryType.XA_CF); - } - else { + } else { cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfiguration, JMSFactoryType.XA_CF); } - } - else if (connectorClassName != null) { + } else if (connectorClassName != null) { TransportConfiguration[] transportConfigurations = new TransportConfiguration[connectorClassName.size()]; List> connectionParams; if (overrideProperties.getParsedConnectorClassNames() != null) { connectionParams = overrideProperties.getParsedConnectionParameters(); - } - else { + } else { connectionParams = raProperties.getParsedConnectionParameters(); } @@ -1756,8 +1742,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (connectionParams == null || i >= connectionParams.size()) { tc = new TransportConfiguration(connectorClassName.get(i)); ActiveMQRALogger.LOGGER.debug("No connector params provided using default"); - } - else { + } else { tc = new TransportConfiguration(connectorClassName.get(i), connectionParams.get(i)); } @@ -1771,12 +1756,10 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (ha) { cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF, transportConfigurations); - } - else { + } else { cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, transportConfigurations); } - } - else { + } else { throw new IllegalArgumentException("must provide either TransportType or DiscoveryGroupAddress and DiscoveryGroupPort for ResourceAdapter Connection Factory"); } @@ -1804,11 +1787,9 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() != null ? overrideProperties.getDiscoveryLocalBindAddress() : raProperties.getDiscoveryLocalBindAddress(); endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(discoveryAddress).setGroupPort(discoveryPort).setLocalBindAddress(localBindAddress).setLocalBindPort(-1); - } - else if (jgroupsFileName != null) { + } else if (jgroupsFileName != null) { endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(jgroupsChannel).setFile(jgroupsFileName); - } - else { + } else { String jgroupsLocatorClass = raProperties.getJgroupsChannelLocatorClass(); if (jgroupsLocatorClass != null) { String jgroupsChannelRefName = raProperties.getJgroupsChannelRefName(); @@ -1838,15 +1819,13 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfiguration, JMSFactoryType.XA_CF); - } - else { + } else { TransportConfiguration[] transportConfigurations = new TransportConfiguration[connectorClassName.size()]; List> connectionParams; if (overrideProperties.getParsedConnectorClassNames() != null) { connectionParams = overrideProperties.getParsedConnectionParameters(); - } - else { + } else { connectionParams = raProperties.getParsedConnectionParameters(); } @@ -1855,8 +1834,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (connectionParams == null || i >= connectionParams.size()) { tc = new TransportConfiguration(connectorClassName.get(i)); ActiveMQRALogger.LOGGER.debug("No connector params provided using default"); - } - else { + } else { tc = new TransportConfiguration(connectorClassName.get(i), connectionParams.get(i)); } @@ -1965,8 +1943,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { val2 = overrideProperties.getReconnectAttempts() != null ? overrideProperties.getReconnectAttempts() : raProperties.getReconnectAttempts(); if (val2 != null) { cf.setReconnectAttempts(val2); - } - else { + } else { //the global default is 0 but we should always try to reconnect JCA cf.setReconnectAttempts(-1); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java index ff7817eb3f..442952fb37 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java @@ -733,200 +733,167 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { if (this.autoGroup == null) { if (other.autoGroup != null) return false; - } - else if (!this.autoGroup.equals(other.autoGroup)) + } else if (!this.autoGroup.equals(other.autoGroup)) return false; if (this.blockOnAcknowledge == null) { if (other.blockOnAcknowledge != null) return false; - } - else if (!this.blockOnAcknowledge.equals(other.blockOnAcknowledge)) + } else if (!this.blockOnAcknowledge.equals(other.blockOnAcknowledge)) return false; if (this.blockOnDurableSend == null) { if (other.blockOnDurableSend != null) return false; - } - else if (!this.blockOnDurableSend.equals(other.blockOnDurableSend)) + } else if (!this.blockOnDurableSend.equals(other.blockOnDurableSend)) return false; if (this.blockOnNonDurableSend == null) { if (other.blockOnNonDurableSend != null) return false; - } - else if (!this.blockOnNonDurableSend.equals(other.blockOnNonDurableSend)) + } else if (!this.blockOnNonDurableSend.equals(other.blockOnNonDurableSend)) return false; if (this.cacheLargeMessagesClient == null) { if (other.cacheLargeMessagesClient != null) return false; - } - else if (!this.cacheLargeMessagesClient.equals(other.cacheLargeMessagesClient)) + } else if (!this.cacheLargeMessagesClient.equals(other.cacheLargeMessagesClient)) return false; if (this.compressLargeMessage == null) { if (other.compressLargeMessage != null) return false; - } - else if (!this.compressLargeMessage.equals(other.compressLargeMessage)) + } else if (!this.compressLargeMessage.equals(other.compressLargeMessage)) return false; if (this.failoverOnInitialConnection == null) { if (other.failoverOnInitialConnection != null) return false; - } - else if (!this.failoverOnInitialConnection.equals(other.failoverOnInitialConnection)) + } else if (!this.failoverOnInitialConnection.equals(other.failoverOnInitialConnection)) return false; if (this.ha == null) { if (other.ha != null) return false; - } - else if (!this.ha.equals(other.ha)) + } else if (!this.ha.equals(other.ha)) return false; if (this.preAcknowledge == null) { if (other.preAcknowledge != null) return false; - } - else if (!this.preAcknowledge.equals(other.preAcknowledge)) + } else if (!this.preAcknowledge.equals(other.preAcknowledge)) return false; if (this.callFailoverTimeout == null) { if (other.callFailoverTimeout != null) return false; - } - else if (!this.callFailoverTimeout.equals(other.callFailoverTimeout)) + } else if (!this.callFailoverTimeout.equals(other.callFailoverTimeout)) return false; if (this.callTimeout == null) { if (other.callTimeout != null) return false; - } - else if (!this.callTimeout.equals(other.callTimeout)) + } else if (!this.callTimeout.equals(other.callTimeout)) return false; if (this.clientFailureCheckPeriod == null) { if (other.clientFailureCheckPeriod != null) return false; - } - else if (!this.clientFailureCheckPeriod.equals(other.clientFailureCheckPeriod)) + } else if (!this.clientFailureCheckPeriod.equals(other.clientFailureCheckPeriod)) return false; if (this.clientID == null) { if (other.clientID != null) return false; - } - else if (!this.clientID.equals(other.clientID)) + } else if (!this.clientID.equals(other.clientID)) return false; if (this.confirmationWindowSize == null) { if (other.confirmationWindowSize != null) return false; - } - else if (!this.confirmationWindowSize.equals(other.confirmationWindowSize)) + } else if (!this.confirmationWindowSize.equals(other.confirmationWindowSize)) return false; if (this.connectionLoadBalancingPolicyClassName == null) { if (other.connectionLoadBalancingPolicyClassName != null) return false; - } - else if (!this.connectionLoadBalancingPolicyClassName.equals(other.connectionLoadBalancingPolicyClassName)) + } else if (!this.connectionLoadBalancingPolicyClassName.equals(other.connectionLoadBalancingPolicyClassName)) return false; if (this.connectionTTL == null) { if (other.connectionTTL != null) return false; - } - else if (!this.connectionTTL.equals(other.connectionTTL)) + } else if (!this.connectionTTL.equals(other.connectionTTL)) return false; if (this.consumerMaxRate == null) { if (other.consumerMaxRate != null) return false; - } - else if (!this.consumerMaxRate.equals(other.consumerMaxRate)) + } else if (!this.consumerMaxRate.equals(other.consumerMaxRate)) return false; if (this.consumerWindowSize == null) { if (other.consumerWindowSize != null) return false; - } - else if (!this.consumerWindowSize.equals(other.consumerWindowSize)) + } else if (!this.consumerWindowSize.equals(other.consumerWindowSize)) return false; if (this.discoveryAddress == null) { if (other.discoveryAddress != null) return false; - } - else if (!this.discoveryAddress.equals(other.discoveryAddress)) + } else if (!this.discoveryAddress.equals(other.discoveryAddress)) return false; if (this.discoveryInitialWaitTimeout == null) { if (other.discoveryInitialWaitTimeout != null) return false; - } - else if (!this.discoveryInitialWaitTimeout.equals(other.discoveryInitialWaitTimeout)) + } else if (!this.discoveryInitialWaitTimeout.equals(other.discoveryInitialWaitTimeout)) return false; if (this.discoveryLocalBindAddress == null) { if (other.discoveryLocalBindAddress != null) return false; - } - else if (!this.discoveryLocalBindAddress.equals(other.discoveryLocalBindAddress)) + } else if (!this.discoveryLocalBindAddress.equals(other.discoveryLocalBindAddress)) return false; if (this.discoveryPort == null) { if (other.discoveryPort != null) return false; - } - else if (!this.discoveryPort.equals(other.discoveryPort)) + } else if (!this.discoveryPort.equals(other.discoveryPort)) return false; if (this.discoveryRefreshTimeout == null) { if (other.discoveryRefreshTimeout != null) return false; - } - else if (!this.discoveryRefreshTimeout.equals(other.discoveryRefreshTimeout)) + } else if (!this.discoveryRefreshTimeout.equals(other.discoveryRefreshTimeout)) return false; if (this.dupsOKBatchSize == null) { if (other.dupsOKBatchSize != null) return false; - } - else if (!this.dupsOKBatchSize.equals(other.dupsOKBatchSize)) + } else if (!this.dupsOKBatchSize.equals(other.dupsOKBatchSize)) return false; if (this.groupID == null) { if (other.groupID != null) return false; - } - else if (!this.groupID.equals(other.groupID)) + } else if (!this.groupID.equals(other.groupID)) return false; if (this.initialConnectAttempts == null) { if (other.initialConnectAttempts != null) return false; - } - else if (!this.initialConnectAttempts.equals(other.initialConnectAttempts)) + } else if (!this.initialConnectAttempts.equals(other.initialConnectAttempts)) return false; if (this.initialMessagePacketSize == null) { if (other.initialMessagePacketSize != null) return false; - } - else if (!this.initialMessagePacketSize.equals(other.initialMessagePacketSize)) + } else if (!this.initialMessagePacketSize.equals(other.initialMessagePacketSize)) return false; if (this.jgroupsChannelName == null) { if (other.jgroupsChannelName != null) return false; - } - else if (!this.jgroupsChannelName.equals(other.jgroupsChannelName)) + } else if (!this.jgroupsChannelName.equals(other.jgroupsChannelName)) return false; if (this.jgroupsFile == null) { if (other.jgroupsFile != null) return false; - } - else if (!this.jgroupsFile.equals(other.jgroupsFile)) + } else if (!this.jgroupsFile.equals(other.jgroupsFile)) return false; if (this.maxRetryInterval == null) { if (other.maxRetryInterval != null) return false; - } - else if (!this.maxRetryInterval.equals(other.maxRetryInterval)) + } else if (!this.maxRetryInterval.equals(other.maxRetryInterval)) return false; if (this.minLargeMessageSize == null) { if (other.minLargeMessageSize != null) return false; - } - else if (!this.minLargeMessageSize.equals(other.minLargeMessageSize)) + } else if (!this.minLargeMessageSize.equals(other.minLargeMessageSize)) return false; if (this.producerMaxRate == null) { if (other.producerMaxRate != null) return false; - } - else if (!this.producerMaxRate.equals(other.producerMaxRate)) + } else if (!this.producerMaxRate.equals(other.producerMaxRate)) return false; if (this.producerWindowSize == null) { if (other.producerWindowSize != null) return false; - } - else if (!this.producerWindowSize.equals(other.producerWindowSize)) + } else if (!this.producerWindowSize.equals(other.producerWindowSize)) return false; else if (!protocolManagerFactoryStr.equals(other.protocolManagerFactoryStr)) return false; @@ -937,70 +904,59 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { if (this.reconnectAttempts == null) { if (other.reconnectAttempts != null) return false; - } - else if (!this.reconnectAttempts.equals(other.reconnectAttempts)) + } else if (!this.reconnectAttempts.equals(other.reconnectAttempts)) return false; if (this.retryInterval == null) { if (other.retryInterval != null) return false; - } - else if (!this.retryInterval.equals(other.retryInterval)) + } else if (!this.retryInterval.equals(other.retryInterval)) return false; if (this.retryIntervalMultiplier == null) { if (other.retryIntervalMultiplier != null) return false; - } - else if (!this.retryIntervalMultiplier.equals(other.retryIntervalMultiplier)) + } else if (!this.retryIntervalMultiplier.equals(other.retryIntervalMultiplier)) return false; if (this.scheduledThreadPoolMaxSize == null) { if (other.scheduledThreadPoolMaxSize != null) return false; - } - else if (!this.scheduledThreadPoolMaxSize.equals(other.scheduledThreadPoolMaxSize)) + } else if (!this.scheduledThreadPoolMaxSize.equals(other.scheduledThreadPoolMaxSize)) return false; if (this.threadPoolMaxSize == null) { if (other.threadPoolMaxSize != null) return false; - } - else if (!this.threadPoolMaxSize.equals(other.threadPoolMaxSize)) + } else if (!this.threadPoolMaxSize.equals(other.threadPoolMaxSize)) return false; if (this.transactionBatchSize == null) { if (other.transactionBatchSize != null) return false; - } - else if (!this.transactionBatchSize.equals(other.transactionBatchSize)) + } else if (!this.transactionBatchSize.equals(other.transactionBatchSize)) return false; if (this.useGlobalPools == null) { if (other.useGlobalPools != null) return false; - } - else if (!this.useGlobalPools.equals(other.useGlobalPools)) + } else if (!this.useGlobalPools.equals(other.useGlobalPools)) return false; if (connectorClassName == null) { if (other.connectorClassName != null) return false; - } - else if (!connectorClassName.equals(other.connectorClassName)) + } else if (!connectorClassName.equals(other.connectorClassName)) return false; if (this.connectionParameters == null) { if (other.connectionParameters != null) return false; - } - else if (!connectionParameters.equals(other.connectionParameters)) + } else if (!connectionParameters.equals(other.connectionParameters)) return false; if (deserializationBlackList == null) { if (other.deserializationBlackList != null) return false; - } - else if (!deserializationBlackList.equals(other.deserializationBlackList)) + } else if (!deserializationBlackList.equals(other.deserializationBlackList)) return false; if (deserializationWhiteList == null) { if (other.deserializationWhiteList != null) return false; - } - else if (!deserializationWhiteList.equals(other.deserializationWhiteList)) + } else if (!deserializationWhiteList.equals(other.deserializationWhiteList)) return false; return true; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java index b14effcf88..2c42779b70 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java @@ -128,8 +128,7 @@ public class ActiveMQActivation { static { try { ONMESSAGE = MessageListener.class.getMethod("onMessage", new Class[]{Message.class}); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -158,8 +157,7 @@ public class ActiveMQActivation { try { spec.setPassword(codec.decode(pass)); - } - catch (Exception e) { + } catch (Exception e) { throw new ResourceException(e); } } @@ -170,8 +168,7 @@ public class ActiveMQActivation { this.spec = spec; try { isDeliveryTransacted = endpointFactory.isDeliveryTransacted(ActiveMQActivation.ONMESSAGE); - } - catch (Exception e) { + } catch (Exception e) { throw new ResourceException(e); } } @@ -318,8 +315,7 @@ public class ActiveMQActivation { ActiveMQMessageHandler handler = new ActiveMQMessageHandler(factory, this, ra.getTM(), (ClientSessionInternal) session, cf, i); handler.setup(); handlers.add(handler); - } - catch (Exception e) { + } catch (Exception e) { if (cf != null) { cf.close(); } @@ -394,8 +390,7 @@ public class ActiveMQActivation { for (Thread interruptThread : interruptThreads) { try { interruptThread.interrupt(); - } - catch (Exception e) { + } catch (Exception e) { //ok } } @@ -417,8 +412,7 @@ public class ActiveMQActivation { try { threadTearDown.join(timeout); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // nothing to be done on this context.. we will just keep going as we need to send an interrupt to threadTearDown and give up } @@ -426,8 +420,7 @@ public class ActiveMQActivation { try { // closing the factory will help making sure pending threads are closed factory.close(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQRALogger.LOGGER.warn(e); } @@ -439,8 +432,7 @@ public class ActiveMQActivation { try { threadTearDown.join(5000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // nothing to be done here.. we are going down anyways } @@ -460,8 +452,7 @@ public class ActiveMQActivation { Context ctx; if (spec.getParsedJndiParams() == null) { ctx = new InitialContext(); - } - else { + } else { ctx = new InitialContext(spec.getParsedJndiParams()); } Object fac = ctx.lookup(spec.getConnectionFactoryLookup()); @@ -469,12 +460,10 @@ public class ActiveMQActivation { // This will clone the connection factory // to make sure we won't close anyone's connection factory when we stop the MDB factory = ActiveMQJMSClient.createConnectionFactory(((ActiveMQConnectionFactory) fac).toURI().toString(), "internalConnection"); - } - else { + } else { factory = ra.newConnectionFactory(spec); } - } - else { + } else { factory = ra.newConnectionFactory(spec); } } @@ -502,14 +491,12 @@ public class ActiveMQActivation { ActiveMQRALogger.LOGGER.debug("Using queue connection " + result); return result; - } - catch (Throwable t) { + } catch (Throwable t) { try { if (result != null) { result.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRALogger.LOGGER.trace("Ignored error closing connection", e); } if (t instanceof Exception) { @@ -531,8 +518,7 @@ public class ActiveMQActivation { Context ctx; if (spec.getParsedJndiParams() == null) { ctx = new InitialContext(); - } - else { + } else { ctx = new InitialContext(spec.getParsedJndiParams()); } ActiveMQRALogger.LOGGER.debug("Using context " + ctx.getEnvironment() + " for " + spec); @@ -548,8 +534,7 @@ public class ActiveMQActivation { if (Topic.class.getName().equals(destinationTypeString)) { destinationType = Topic.class; isTopic = true; - } - else { + } else { destinationType = Queue.class; } @@ -557,8 +542,7 @@ public class ActiveMQActivation { try { destination = (ActiveMQDestination) ActiveMQRaUtils.lookup(ctx, destinationName, destinationType); - } - catch (Exception e) { + } catch (Exception e) { if (destinationName == null) { throw ActiveMQRABundle.BUNDLE.noDestinationName(); } @@ -572,13 +556,11 @@ public class ActiveMQActivation { // If there is no binding on naming, we will just create a new instance if (isTopic) { destination = (ActiveMQDestination) ActiveMQJMSClient.createTopic(calculatedDestinationName); - } - else { + } else { destination = (ActiveMQDestination) ActiveMQJMSClient.createQueue(calculatedDestinationName); } } - } - else { + } else { ActiveMQRALogger.LOGGER.debug("Destination type not defined in MDB activation configuration."); ActiveMQRALogger.LOGGER.debug("Retrieving " + Destination.class.getName() + " \"" + destinationName + "\" from JNDI"); @@ -587,15 +569,13 @@ public class ActiveMQActivation { isTopic = true; } } - } - else { + } else { ActiveMQRALogger.LOGGER.instantiatingDestination(spec.getDestinationType(), spec.getDestination()); if (Topic.class.getName().equals(spec.getDestinationType())) { destination = (ActiveMQDestination) ActiveMQJMSClient.createTopic(spec.getDestination()); isTopic = true; - } - else { + } else { destination = (ActiveMQDestination) ActiveMQJMSClient.createQueue(spec.getDestination()); } } @@ -647,11 +627,9 @@ public class ActiveMQActivation { if (failure != null) { if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST) { ActiveMQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination()); - } - else if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.NOT_CONNECTED) { + } else if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.NOT_CONNECTED) { ActiveMQRALogger.LOGGER.awaitingJMSServerCreation(); - } - else { + } else { ActiveMQRALogger.LOGGER.failureInActivation(failure, spec); } } @@ -669,8 +647,7 @@ public class ActiveMQActivation { try { Thread.sleep(setupInterval); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQRALogger.LOGGER.debug("Interrupted trying to reconnect " + spec, e); break; } @@ -682,28 +659,24 @@ public class ActiveMQActivation { setup(); ActiveMQRALogger.LOGGER.reconnected(); break; - } - catch (Throwable t) { + } catch (Throwable t) { if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST) { if (lastException == null || !(t instanceof ActiveMQNonExistentQueueException)) { lastException = t; ActiveMQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination()); } - } - else if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.NOT_CONNECTED) { + } else if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.NOT_CONNECTED) { if (lastException == null || !(t instanceof ActiveMQNotConnectedException)) { lastException = t; ActiveMQRALogger.LOGGER.awaitingJMSServerCreation(); } - } - else { + } else { ActiveMQRALogger.LOGGER.errorReconnecting(t, spec); } } ++reconnectCount; } - } - finally { + } finally { // Leaving failure recovery loop inReconnect.set(false); } @@ -722,8 +695,7 @@ public class ActiveMQActivation { public void run() { try { setup(); - } - catch (Throwable t) { + } catch (Throwable t) { reconnect(t); } } @@ -750,8 +722,7 @@ public class ActiveMQActivation { if (lastReceived && newNode) { ActiveMQRALogger.LOGGER.rebalancingConnections("nodeUp " + member.toString()); startReconnectThread("NodeUP Connection Rebalancer"); - } - else if (last) { + } else if (last) { lastReceived = true; } } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java index 4d8b18fbf7..35abba9e75 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java @@ -30,10 +30,10 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import org.apache.activemq.artemis.ra.ConnectionFactoryProperties; import org.apache.activemq.artemis.ra.ActiveMQRALogger; import org.apache.activemq.artemis.ra.ActiveMQRaUtils; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.ConnectionFactoryProperties; /** * The activation spec @@ -364,8 +364,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode) { return "Dups-ok-acknowledge"; - } - else { + } else { return "Auto-acknowledge"; } } @@ -382,11 +381,9 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if ("DUPS_OK_ACKNOWLEDGE".equalsIgnoreCase(value) || "Dups-ok-acknowledge".equalsIgnoreCase(value)) { acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE; - } - else if ("AUTO_ACKNOWLEDGE".equalsIgnoreCase(value) || "Auto-acknowledge".equalsIgnoreCase(value)) { + } else if ("AUTO_ACKNOWLEDGE".equalsIgnoreCase(value) || "Auto-acknowledge".equalsIgnoreCase(value)) { acknowledgeMode = Session.AUTO_ACKNOWLEDGE; - } - else { + } else { throw new IllegalArgumentException("Unsupported acknowledgement mode " + value); } } @@ -414,8 +411,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (subscriptionDurability) { return "Durable"; - } - else { + } else { return "NonDurable"; } } @@ -506,8 +502,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (user == null) { return ra.getUserName(); - } - else { + } else { return user; } } @@ -537,8 +532,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (password == null) { return ra.getPassword(); - } - else { + } else { return password; } } @@ -619,8 +613,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen public Boolean isUseLocalTx() { if (localTx == null) { return ra.getUseLocalTx(); - } - else { + } else { return localTx; } } @@ -644,8 +637,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (setupAttempts == null) { return ra.getSetupAttempts(); - } - else { + } else { return setupAttempts; } } @@ -665,8 +657,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen if (setupInterval == null) { return ra.getSetupInterval(); - } - else { + } else { return setupInterval; } } @@ -713,8 +704,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen propsNotSet.add(new PropertyDescriptor("subscriptionName", ActiveMQActivationSpec.class)); errorMessages.add("If subscription is durable then subscription name must be specified."); } - } - catch (IntrospectionException e) { + } catch (IntrospectionException e) { ActiveMQRALogger.LOGGER.unableToValidateProperties(e); } @@ -830,41 +820,57 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; ActiveMQActivationSpec that = (ActiveMQActivationSpec) o; - if (acknowledgeMode != that.acknowledgeMode) return false; - if (subscriptionDurability != that.subscriptionDurability) return false; - if (shareSubscriptions != that.shareSubscriptions) return false; + if (acknowledgeMode != that.acknowledgeMode) + return false; + if (subscriptionDurability != that.subscriptionDurability) + return false; + if (shareSubscriptions != that.shareSubscriptions) + return false; if (strConnectorClassName != null ? !strConnectorClassName.equals(that.strConnectorClassName) : that.strConnectorClassName != null) return false; if (strConnectionParameters != null ? !strConnectionParameters.equals(that.strConnectionParameters) : that.strConnectionParameters != null) return false; - if (ra != null ? !ra.equals(that.ra) : that.ra != null) return false; + if (ra != null ? !ra.equals(that.ra) : that.ra != null) + return false; if (connectionFactoryLookup != null ? !connectionFactoryLookup.equals(that.connectionFactoryLookup) : that.connectionFactoryLookup != null) return false; - if (destination != null ? !destination.equals(that.destination) : that.destination != null) return false; + if (destination != null ? !destination.equals(that.destination) : that.destination != null) + return false; if (destinationType != null ? !destinationType.equals(that.destinationType) : that.destinationType != null) return false; if (messageSelector != null ? !messageSelector.equals(that.messageSelector) : that.messageSelector != null) return false; if (subscriptionName != null ? !subscriptionName.equals(that.subscriptionName) : that.subscriptionName != null) return false; - if (user != null ? !user.equals(that.user) : that.user != null) return false; - if (password != null ? !password.equals(that.password) : that.password != null) return false; - if (maxSession != null ? !maxSession.equals(that.maxSession) : that.maxSession != null) return false; + if (user != null ? !user.equals(that.user) : that.user != null) + return false; + if (password != null ? !password.equals(that.password) : that.password != null) + return false; + if (maxSession != null ? !maxSession.equals(that.maxSession) : that.maxSession != null) + return false; if (transactionTimeout != null ? !transactionTimeout.equals(that.transactionTimeout) : that.transactionTimeout != null) return false; - if (useJNDI != null ? !useJNDI.equals(that.useJNDI) : that.useJNDI != null) return false; - if (jndiParams != null ? !jndiParams.equals(that.jndiParams) : that.jndiParams != null) return false; + if (useJNDI != null ? !useJNDI.equals(that.useJNDI) : that.useJNDI != null) + return false; + if (jndiParams != null ? !jndiParams.equals(that.jndiParams) : that.jndiParams != null) + return false; if (parsedJndiParams != null ? !parsedJndiParams.equals(that.parsedJndiParams) : that.parsedJndiParams != null) return false; - if (localTx != null ? !localTx.equals(that.localTx) : that.localTx != null) return false; - if (rebalanceConnections != null ? !rebalanceConnections.equals(that.rebalanceConnections) : that.rebalanceConnections != null) return false; - if (setupAttempts != null ? !setupAttempts.equals(that.setupAttempts) : that.setupAttempts != null) return false; + if (localTx != null ? !localTx.equals(that.localTx) : that.localTx != null) + return false; + if (rebalanceConnections != null ? !rebalanceConnections.equals(that.rebalanceConnections) : that.rebalanceConnections != null) + return false; + if (setupAttempts != null ? !setupAttempts.equals(that.setupAttempts) : that.setupAttempts != null) + return false; return !(setupInterval != null ? !setupInterval.equals(that.setupInterval) : that.setupInterval != null); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java index 353bc73d55..c43298bf30 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java @@ -118,15 +118,13 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (!subResponse.isExists()) { session.createQueue(activation.getAddress(), queueName, selectorString, true); - } - else { + } else { // The check for already exists should be done only at the first session // As a deployed MDB could set up multiple instances in order to process messages in parallel. if (sessionNr == 0 && subResponse.getConsumerCount() > 0) { if (!spec.isShareSubscriptions()) { throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)"); - } - else if (ActiveMQRALogger.LOGGER.isDebugEnabled()) { + } else if (ActiveMQRALogger.LOGGER.isDebugEnabled()) { ActiveMQRALogger.LOGGER.debug("the mdb on destination " + queueName + " already had " + subResponse.getConsumerCount() + " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown"); @@ -152,16 +150,14 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList } } consumer = (ClientConsumerInternal) session.createConsumer(queueName, null, false); - } - else { + } else { SimpleString tempQueueName; if (activation.isTopic()) { if (activation.getTopicTemporaryQueue() == null) { tempQueueName = new SimpleString(UUID.randomUUID().toString()); session.createTemporaryQueue(activation.getAddress(), tempQueueName, selectorString); activation.setTopicTemporaryQueue(tempQueueName); - } - else { + } else { tempQueueName = activation.getTopicTemporaryQueue(); QueueQuery queueQuery = session.queueQuery(tempQueueName); if (!queueQuery.isExists()) { @@ -170,8 +166,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList session.createTemporaryQueue(activation.getAddress(), tempQueueName, selectorString); } } - } - else { + } else { tempQueueName = activation.getAddress(); } consumer = (ClientConsumerInternal) session.createConsumer(tempQueueName, selectorString); @@ -191,8 +186,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList endpoint = endpointFactory.createEndpoint(xaResource); useXA = true; - } - else { + } else { endpoint = endpointFactory.createEndpoint(null); useXA = false; } @@ -210,8 +204,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (consumer != null) { return consumer.prepareForClose(future); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQRALogger.LOGGER.errorInterruptingHandler(endpoint.toString(), consumer.toString(), e); } return null; @@ -230,8 +223,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList endpoint.release(); endpoint = null; } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.debug("Error releasing endpoint " + endpoint, t); } @@ -249,8 +241,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList session.deleteQueue(tmpQueue); } } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.debug("Error closing core-queue consumer", t); } @@ -258,27 +249,23 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (session != null) { session.close(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.debug("Error releasing session " + session, t); } try { if (cf != null) { cf.close(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.debug("Error releasing session factory " + session, t); } - } - else { + } else { //otherwise we just clean up try { if (cf != null) { cf.cleanup(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQRALogger.LOGGER.debug("Error releasing session factory " + session, t); } @@ -325,8 +312,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList try { endpoint.afterDelivery(); - } - catch (ResourceException e) { + } catch (ResourceException e) { ActiveMQRALogger.LOGGER.unableToCallAfterDelivery(e); // If we get here, The TX was already rolled back // However we must do some stuff now to make sure the client message buffer is cleared @@ -341,8 +327,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (trace) { ActiveMQRALogger.LOGGER.trace("finished onMessage on " + message); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQRALogger.LOGGER.errorDeliveringMessage(e); // we need to call before/afterDelivery as a pair if (beforeDelivery) { @@ -356,8 +341,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (tx != null) { tx.setRollbackOnly(); } - } - catch (Exception e1) { + } catch (Exception e1) { ActiveMQRALogger.LOGGER.warn("unnable to clear the transaction", e1); } } @@ -368,16 +352,14 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (endToUse != null) { endToUse.afterDelivery(); } - } - catch (ResourceException e1) { + } catch (ResourceException e1) { ActiveMQRALogger.LOGGER.unableToCallAfterDelivery(e1); } } if (useLocalTx || !activation.isDeliveryTransacted()) { try { session.rollback(true); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { ActiveMQRALogger.LOGGER.unableToRollbackTX(); } } @@ -385,12 +367,10 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList // This is to make sure we will issue a rollback after failures // so that would cleanup consumer buffers among other things session.markRollbackOnly(); - } - finally { + } finally { try { session.resetIfNeeded(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQRALogger.LOGGER.unableToResetSession(activation.toString(), e); activation.startReconnectThread("Reset MessageHandler after Failure Thread"); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java index 2eb42ba33b..0e72780ff3 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.ra.recovery; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.Set; + import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.ra.ActiveMQRALogger; import org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQRegistry; @@ -23,10 +27,6 @@ import org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQRegist import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.artemis.utils.ConcurrentHashSet; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; - public final class RecoveryManager { private ActiveMQRegistry registry; @@ -38,13 +38,15 @@ public final class RecoveryManager { public void start(final boolean useAutoRecovery) { if (useAutoRecovery) { locateRecoveryRegistry(); - } - else { + } else { registry = null; } } - public XARecoveryConfig register(ActiveMQConnectionFactory factory, String userName, String password, Map properties) { + public XARecoveryConfig register(ActiveMQConnectionFactory factory, + String userName, + String password, + Map properties) { ActiveMQRALogger.LOGGER.debug("registering recovery for factory : " + factory); XARecoveryConfig config = XARecoveryConfig.newConfig(factory, userName, password, properties); @@ -80,12 +82,10 @@ public final class RecoveryManager { ServiceLoader sl = ServiceLoader.load(ActiveMQRegistry.class); if (sl.iterator().hasNext()) { registry = sl.iterator().next(); - } - else { + } else { registry = ActiveMQRegistryImpl.getInstance(); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQRALogger.LOGGER.debug("unable to load recovery registry " + locatorClasse, e); } if (registry != null) { diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/ActiveMQ.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/ActiveMQ.java index ad8656fa9e..45dd3188b7 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/ActiveMQ.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/ActiveMQ.java @@ -67,8 +67,7 @@ public class ActiveMQ { oos.flush(); data = baos.toByteArray(); - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e); } @@ -153,11 +152,9 @@ public class ActiveMQ { ResteasyProviderFactory.pushContext(Providers.class, factory); try { return reader.readFrom(type, genericType, null, ct, new Headers(), new ByteArrayInputStream(body)); - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e); - } - finally { + } finally { ResteasyProviderFactory.popContextData(Providers.class); if (current != null) ResteasyProviderFactory.pushContext(Providers.class, current); diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java index 692bddbbf6..e5aed5854d 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.rest; -import org.apache.activemq.artemis.rest.util.HttpMessageHelper; -import org.jboss.resteasy.core.Headers; -import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.jboss.resteasy.util.GenericType; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; @@ -31,6 +26,11 @@ import javax.ws.rs.ext.Providers; import java.io.ByteArrayInputStream; import java.lang.reflect.Type; +import org.apache.activemq.artemis.rest.util.HttpMessageHelper; +import org.jboss.resteasy.core.Headers; +import org.jboss.resteasy.spi.ResteasyProviderFactory; +import org.jboss.resteasy.util.GenericType; + public class Jms { /** @@ -43,8 +43,7 @@ public class Jms { public static void setHttpHeader(Message message, String name, String value) { try { message.setStringProperty(HttpHeaderProperty.toPropertyName(name), value); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -59,8 +58,7 @@ public class Jms { public static String getHttpHeader(Message message, String name) { try { return message.getStringProperty(HttpHeaderProperty.toPropertyName(name)); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -110,8 +108,7 @@ public class Jms { public static boolean isHttpMessage(Message message) { try { return message.getBooleanProperty(HttpMessageHelper.POSTED_AS_HTTP_MESSAGE); - } - catch (JMSException e) { + } catch (JMSException e) { return false; } } @@ -135,8 +132,7 @@ public class Jms { if (!isHttpMessage(message)) { try { return (T) ((ObjectMessage) message).getObject(); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -165,14 +161,12 @@ public class Jms { ResteasyProviderFactory.pushContext(Providers.class, factory); try { return reader.readFrom(type, genericType, null, ct, new Headers(), new ByteArrayInputStream(body)); - } - finally { + } finally { ResteasyProviderFactory.popContextData(Providers.class); if (current != null) ResteasyProviderFactory.pushContext(Providers.class, current); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java index 4aaa95decf..110ebb87cc 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.rest; +import javax.xml.bind.JAXBContext; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; @@ -25,8 +26,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import javax.xml.bind.JAXBContext; - import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -120,8 +119,7 @@ public class MessageServiceManager { if (configuration == null || configSet == false) { if (configResourcePath == null) { configuration = new MessageServiceConfiguration(); - } - else { + } else { URL url = getClass().getClassLoader().getResource(configResourcePath); if (url == null) { @@ -166,8 +164,7 @@ public class MessageServiceManager { LinkStrategy linkStrategy = new LinkHeaderLinkStrategy(); if (configuration.isUseLinkHeaders()) { linkStrategy = new LinkHeaderLinkStrategy(); - } - else { + } else { linkStrategy = new CustomHeaderLinkStrategy(); } @@ -210,8 +207,7 @@ public class MessageServiceManager { threadPool.shutdown(); try { threadPool.awaitTermination(5000, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } this.consumerSessionFactory.close(); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ActiveMQBootstrapListener.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ActiveMQBootstrapListener.java index c4b6c341e4..0fb373150c 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ActiveMQBootstrapListener.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ActiveMQBootstrapListener.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.rest.integration; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; - import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; + public class ActiveMQBootstrapListener implements ServletContextListener { private EmbeddedJMS jms; @@ -33,8 +33,7 @@ public class ActiveMQBootstrapListener implements ServletContextListener { jms.setRegistry(new ServletContextBindingRegistry(context)); try { jms.start(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -44,8 +43,7 @@ public class ActiveMQBootstrapListener implements ServletContextListener { try { if (jms != null) jms.stop(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/EmbeddedRestActiveMQ.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/EmbeddedRestActiveMQ.java index fc8ae4eb1b..6c0e079d34 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/EmbeddedRestActiveMQ.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/EmbeddedRestActiveMQ.java @@ -18,8 +18,8 @@ package org.apache.activemq.artemis.rest.integration; import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer; import org.apache.activemq.artemis.rest.MessageServiceManager; +import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer; import org.jboss.resteasy.test.TestPortProvider; public class EmbeddedRestActiveMQ { @@ -68,13 +68,11 @@ public class EmbeddedRestActiveMQ { public void stop() throws Exception { try { tjws.stop(); - } - catch (Exception e) { + } catch (Exception e) { } try { manager.stop(); - } - catch (Exception e) { + } catch (Exception e) { } embeddedActiveMQ.stop(); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/RestMessagingBootstrapListener.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/RestMessagingBootstrapListener.java index 60cea036d3..c68feaf007 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/RestMessagingBootstrapListener.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/RestMessagingBootstrapListener.java @@ -50,8 +50,7 @@ public class RestMessagingBootstrapListener implements ServletContextListener, C manager.start(); registry.addSingletonResource(manager.getQueueManager().getDestination()); registry.addSingletonResource(manager.getTopicManager().getDestination()); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -82,4 +81,4 @@ public class RestMessagingBootstrapListener implements ServletContextListener, C public void setDeserializationWhiteList(String whiteList) { deserializationWhiteList = whiteList; } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java index 8955221d96..22b4690fde 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.integration; -import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; - import javax.servlet.ServletContext; +import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; + public class ServletContextBindingRegistry implements BindingRegistry { private ServletContext servletContext; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java index e0dabc8701..3068f8bae7 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java @@ -34,9 +34,9 @@ import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.rest.util.LinkStrategy; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; public class AcknowledgedQueueConsumer extends QueueConsumer { @@ -136,12 +136,10 @@ public class AcknowledgedQueueConsumer extends QueueConsumer { ack.acknowledge(); //System.out.println("Acknowledge message: " + ack.getMessage()); ack.getMessage().acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } - } - else { + } else { ack.unacknowledge(); unacknowledge(); } @@ -179,22 +177,18 @@ public class AcknowledgedQueueConsumer extends QueueConsumer { try { createSession(); - } - catch (Exception e) { + } catch (Exception e) { shutdown(); throw new RuntimeException(e); - } - finally { + } finally { try { old.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } try { oldSession.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java index 3437a679c5..ce8b24b223 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.api.core.client.ClientMessage; - import javax.ws.rs.core.Response; +import org.apache.activemq.artemis.api.core.client.ClientMessage; + public class ConsumedHttpMessage extends ConsumedMessage { private byte[] data; @@ -36,8 +36,7 @@ public class ConsumedHttpMessage extends ConsumedMessage { if (size > 0) { data = new byte[size]; message.getBodyBuffer().readBytes(data); - } - else { + } else { data = new byte[0]; } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java index 22b8f7ffd6..d30248a49d 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.queue; +import javax.ws.rs.core.Response; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - -import javax.ws.rs.core.Response; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; public abstract class ConsumedMessage { @@ -56,11 +56,9 @@ public abstract class ConsumedMessage { Boolean aBoolean = message.getBooleanProperty(POSTED_AS_HTTP_MESSAGE); if (aBoolean != null && aBoolean.booleanValue()) { return new ConsumedHttpMessage(message); - } - else if (message.getType() == Message.OBJECT_TYPE) { + } else if (message.getType() == Message.OBJECT_TYPE) { return new ConsumedObjectMessage(message, options); - } - else { + } else { throw new IllegalArgumentException("ClientMessage must be an HTTP message or an Object message: " + message + " type: " + message.getType()); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java index ddd7a81a17..2cd5f9fcfd 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.queue; +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; - public class ConsumedObjectMessage extends ConsumedMessage { protected Object readObject; @@ -52,8 +52,7 @@ public class ConsumedObjectMessage extends ConsumedMessage { ois.setBlackList(options.getDeserializationBlackList()); } readObject = ois.readObject(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java index 84dae831de..05849724d8 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java @@ -94,8 +94,7 @@ public class ConsumersResource implements TimeoutTask.Callback { shutdown(consumer); } return true; - } - else { + } else { return false; } } @@ -136,8 +135,7 @@ public class ConsumersResource implements TimeoutTask.Callback { if (autoAck) { consumer = createConsumer(selector); - } - else { + } else { attributes |= ACKNOWLEDGED; consumer = createAcknowledgedConsumer(selector); } @@ -150,18 +148,15 @@ public class ConsumersResource implements TimeoutTask.Callback { if (autoAck) { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/" + attributesSegment + "/" + consumer.getId(), "-1"); - } - else { + } else { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/" + attributesSegment + "/" + consumer.getId(), "-1"); } return builder.build(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { } } @@ -210,13 +205,11 @@ public class ConsumersResource implements TimeoutTask.Callback { Acknowledgement ack = ackedConsumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); - } - else { + } else { ackedConsumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId()); } - } - else { + } else { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } } @@ -242,8 +235,7 @@ public class ConsumersResource implements TimeoutTask.Callback { QueueConsumer tmp = new AcknowledgedQueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); - } - else { + } else { QueueConsumer tmp = new QueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } @@ -256,8 +248,7 @@ public class ConsumersResource implements TimeoutTask.Callback { consumer = queueConsumers.putIfAbsent(consumerId, tmp); if (consumer != null) { tmp.shutdown(); - } - else { + } else { consumer = tmp; serviceManager.getTimeoutTask().add(this, consumer.getId()); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java index 93512d9706..9b0eb1a9a9 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java @@ -17,8 +17,8 @@ package org.apache.activemq.artemis.rest.queue; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; @@ -148,8 +148,7 @@ public abstract class DestinationServiceManager { if (sessionFactory == null) { try { sessionFactory = locator.createSessionFactory(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java index 8c74ea30c6..6f72d81479 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java @@ -38,8 +38,8 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.activemq.artemis.utils.UUID; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -85,12 +85,10 @@ public class PostMessage { producer.send(message); ActiveMQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); - } - catch (Exception ex) { + } catch (Exception ex) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } addPooled(); throw ex; @@ -147,8 +145,7 @@ public class PostMessage { } try { publish(headers, body, dupId, isDurable, ttl, expiration, priority); - } - catch (Exception e) { + } catch (Exception e) { Response error = Response.serverError().entity("Problem posting message: " + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(e, error); } @@ -231,8 +228,7 @@ public class PostMessage { for (Pooled pooled : pool) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } } @@ -253,11 +249,9 @@ public class PostMessage { if (expiration != null) { message.setExpiration(expiration.longValue()); - } - else if (ttl != null) { + } else if (ttl != null) { message.setExpiration(System.currentTimeMillis() + ttl.longValue()); - } - else if (producerTimeToLive > 0) { + } else if (producerTimeToLive > 0) { message.setExpiration(System.currentTimeMillis() + producerTimeToLive); } if (priority != null) { diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java index ef0da88403..e11881d1b9 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.POST; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; @@ -31,6 +26,11 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.net.URI; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientProducer; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; + /** * Implements simple "create" link. Returns 201 with Location of created resource as per HTTP */ @@ -49,12 +49,10 @@ public class PostMessageDupsOk extends PostMessage { producer.send(message); ActiveMQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); - } - catch (Exception ex) { + } catch (Exception ex) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } addPooled(); throw ex; @@ -77,8 +75,7 @@ public class PostMessageDupsOk extends PostMessage { isDurable = durable.booleanValue(); } publish(headers, body, isDurable, ttl, expiration, priority); - } - catch (Exception e) { + } catch (Exception e) { Response error = Response.serverError().entity("Problem posting message: " + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(e, error); } @@ -88,4 +85,4 @@ public class PostMessageDupsOk extends PostMessage { serviceManager.getLinkStrategy().setLinkHeader(builder, "create-next", "create-next", next.toString(), "*/*"); return builder.build(); } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java index 9c3a88d875..a0e3819a6b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.POST; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; + /** * implements reliable "create", "create-next" pattern defined by REST-* Messaging specification */ diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java index 1ebe786af0..d4e0f8705b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java @@ -114,15 +114,13 @@ public class QueueConsumer { try { consumer.close(); ActiveMQRestLogger.LOGGER.debug("Closed consumer: " + consumer); - } - catch (Exception e) { + } catch (Exception e) { } try { session.close(); ActiveMQRestLogger.LOGGER.debug("Closed session: " + session); - } - catch (Exception e) { + } catch (Exception e) { } session = null; consumer = null; @@ -165,8 +163,7 @@ public class QueueConsumer { try { return pollWithIndex(wait, info, basePath, index); - } - finally { + } finally { ping(0); // ping again as we don't want wait time included in timeout. } } @@ -186,10 +183,8 @@ public class QueueConsumer { if (autoAck) message.acknowledge(); return response; - } - catch (Exception e) { - Response errorResponse = Response.serverError().entity(e.getMessage()) - .status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } catch (Exception e) { + Response errorResponse = Response.serverError().entity(e.getMessage()).status(Response.Status.INTERNAL_SERVER_ERROR).build(); return errorResponse; } } @@ -199,8 +194,7 @@ public class QueueConsumer { ActiveMQRestLogger.LOGGER.debug("Created session: " + session); if (selector == null) { consumer = session.createConsumer(destination); - } - else { + } else { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(selector)); } ActiveMQRestLogger.LOGGER.debug("Created consumer: " + consumer); @@ -211,8 +205,7 @@ public class QueueConsumer { ClientMessage m = null; if (timeoutSecs <= 0) { m = consumer.receive(1); - } - else { + } else { m = consumer.receive(timeoutSecs * 1000); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java index 2a74a52a89..fe47680b26 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java @@ -32,14 +32,14 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; -import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; -import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQQueue; import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; +import org.apache.activemq.artemis.rest.util.Constants; import org.w3c.dom.Document; @Path(Constants.PATH_FOR_QUEUES) @@ -68,27 +68,22 @@ public class QueueDestinationsResource { if (!query.isExists()) { if (queue.getSelector() != null) { session.createQueue(queueName, queueName, queue.getSelector(), queue.isDurable()); - } - else { + } else { session.createQueue(queueName, queueName, queue.isDurable()); } - } - else { + } else { throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build()); } - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } URI uri = uriInfo.getRequestUriBuilder().path(queueName).build(); return Response.created(uri).build(); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof WebApplicationException) throw (WebApplicationException) e; throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build()); @@ -114,12 +109,10 @@ public class QueueDestinationsResource { boolean defaultDurable = queueSettings.isDurableSend() || query.isDurable(); queue = createQueueResource(queueName, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed()); - } - finally { + } finally { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -151,8 +144,7 @@ public class QueueDestinationsResource { PostMessage sender = null; if (duplicates) { sender = new PostMessageDupsOk(); - } - else { + } else { sender = new PostMessageNoDups(); } sender.setServiceManager(manager); diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java index 869c38f6b2..74eec85463 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java @@ -29,8 +29,8 @@ import javax.ws.rs.core.UriInfo; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; public class QueueResource extends DestinationResource { @@ -165,14 +165,12 @@ public class QueueResource extends DestinationResource { try { SimpleString queueName = new SimpleString(destination); session.deleteQueue(queueName); - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java index 7779248b1a..a606044c7a 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java @@ -22,8 +22,8 @@ import java.util.List; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.queue.push.FilePushStore; +import org.apache.activemq.artemis.rest.queue.push.PushStore; public class QueueServiceManager extends DestinationServiceManager { @@ -102,8 +102,7 @@ public class QueueServiceManager extends DestinationServiceManager { try { timeoutTask.stop(); sessionFactory.close(); - } - catch (Exception e) { + } catch (Exception e) { } } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java index b3dc1d5d5b..b2a08682c0 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java @@ -68,8 +68,7 @@ public class ActiveMQPushStrategy extends UriTemplateStrategy { try { initialize(); initialized = true; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Failed to initialize.", e); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java index 54d2b50955..d788cefd39 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java @@ -49,8 +49,7 @@ public class FilePushStore implements PushStore { reg.setLoadedFrom(file); ActiveMQRestLogger.LOGGER.addingPushRegistration(reg.getId()); map.put(reg.getId(), reg); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.errorLoadingStore(e, file.getName()); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java index 023e3f086d..9474ec8b13 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.rest.queue.push; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -25,9 +28,6 @@ import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; import org.apache.activemq.artemis.utils.SelectorTranslator; -import java.util.ArrayList; -import java.util.List; - public class PushConsumer { protected PushRegistration registration; @@ -71,12 +71,10 @@ public class PushConsumer { if (registration.getTarget().getClassName() != null) { Class clazz = Thread.currentThread().getContextClassLoader().loadClass(registration.getTarget().getClassName()); strategy = (PushStrategy) clazz.newInstance(); - } - else if (registration.getTarget().getRelationship() != null) { + } else if (registration.getTarget().getRelationship() != null) { if (registration.getTarget().getRelationship().equals("destination")) { strategy = new ActiveMQPushStrategy(); - } - else if (registration.getTarget().getRelationship().equals("template")) { + } else if (registration.getTarget().getRelationship().equals("template")) { strategy = new UriTemplateStrategy(); } } @@ -97,8 +95,7 @@ public class PushConsumer { if (registration.getSelector() != null) { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(registration.getSelector())); - } - else { + } else { consumer = session.createConsumer(destination); } consumer.setMessageHandler(new PushConsumerMessageHandler(this, session)); @@ -116,8 +113,7 @@ public class PushConsumer { if (session != null) { session.close(); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } @@ -126,8 +122,7 @@ public class PushConsumer { if (strategy != null) { strategy.stop(); } - } - catch (Exception e) { + } catch (Exception e) { } } @@ -137,8 +132,7 @@ public class PushConsumer { if (registration.isDurable()) { store.update(registration); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.errorUpdatingStore(e); } stop(); diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java index 4ac2f80f2f..8f38dee675 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java @@ -39,8 +39,7 @@ public class PushConsumerMessageHandler implements MessageHandler { try { clientMessage.acknowledge(); ActiveMQRestLogger.LOGGER.debug(this + ": acknowledged " + clientMessage); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e.getMessage(), e); } @@ -52,16 +51,13 @@ public class PushConsumerMessageHandler implements MessageHandler { ActiveMQRestLogger.LOGGER.debug("Acknowledging: " + clientMessage.getMessageID()); session.commit(); return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } - } - else { + } else { try { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e.getMessage(), e); } if (pushConsumer.getRegistration().isDisableOnFailure()) { diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java index ef183e551a..859b22b8ef 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java @@ -34,8 +34,8 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; public class PushConsumerResource { @@ -89,8 +89,7 @@ public class PushConsumerResource { if (registration.isDurable() && pushStore != null) { pushStore.add(registration); } - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new WebApplicationException(e, Response.serverError().entity("Failed to start consumer.").type("text/plain").build()); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java index e053347f87..d3aae6d78f 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.queue.push; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; - import java.util.List; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; + public interface PushStore { void add(PushRegistration reg) throws Exception; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java index 2df104bc9a..727743a18c 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java @@ -19,9 +19,12 @@ package org.apache.activemq.artemis.rest.queue.push; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.xml.BasicAuth; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; +import org.apache.activemq.artemis.rest.queue.push.xml.XmlHttpHeader; import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.http.HttpException; import org.apache.http.HttpHost; @@ -41,9 +44,6 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpCoreContext; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; -import org.apache.activemq.artemis.rest.queue.push.xml.XmlHttpHeader; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; @@ -140,16 +140,13 @@ public class UriStrategy implements PushStrategy { if (retryAfter != null) { wait = Long.parseLong(retryAfter) * 1000; } - } - else if (status == 307) { + } else if (status == 307) { uri = res.getLocation().toString(); wait = 0; - } - else if ((status >= 200 && status < 299) || status == 303 || status == 304) { + } else if ((status >= 200 && status < 299) || status == 303 || status == 304) { ActiveMQRestLogger.LOGGER.debug("Success"); return true; - } - else if (status >= 400) { + } else if (status >= 400) { switch (status) { case 400: // these usually mean the message you are trying to send is crap, let dead letter logic take over case 411: @@ -177,21 +174,18 @@ public class UriStrategy implements PushStrategy { break; } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.debug("failed to push message to " + uri, e); e.printStackTrace(); return false; - } - finally { + } finally { if (res != null) res.releaseConnection(); } try { if (wait > 0) Thread.sleep(wait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new RuntimeException("Interrupted"); } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java index 037ad8555b..b599dc5adc 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; @XmlRootElement @XmlAccessorType(XmlAccessType.PROPERTY) diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java index b44468f9c2..97df082fee 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; +import java.io.Serializable; @XmlRootElement(name = "header") @XmlAccessorType(XmlAccessType.PROPERTY) diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java index 2cd4c09078..7d2317b1a7 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; @XmlRootElement(name = "link") @XmlAccessorType(XmlAccessType.PROPERTY) diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java index 1f5789f186..997e9772b2 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java @@ -20,9 +20,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.PushConsumer; +import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; public class PushSubscription extends PushConsumer { @@ -50,16 +50,13 @@ public class PushSubscription extends PushConsumer { session = factory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQRestLogger.LOGGER.errorDeletingSubscriberQueue(e); - } - finally { + } finally { try { if (session != null) session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java index 602700797b..ce4e5d2d06 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.rest.topic; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushConsumer; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -39,6 +31,14 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumer; + public class PushSubscriptionsResource { protected Map consumers = new ConcurrentHashMap<>(); @@ -78,13 +78,11 @@ public class PushSubscriptionsResource { if (durable) { session.createQueue(destination, subscriptionName, true); - } - else { + } else { session.createTemporaryQueue(destination, subscriptionName); } return session; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } } @@ -102,12 +100,10 @@ public class PushSubscriptionsResource { PushSubscription consumer = new PushSubscription(sessionFactory, reg.getDestination(), reg.getId(), reg, pushStore, jmsOptions); try { consumer.start(); - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new Exception("Failed starting push subscriber for " + destination + " of push subscriber: " + reg.getTarget(), e); - } - finally { + } finally { closeSession(createSession); closeSession(session); } @@ -120,8 +116,7 @@ public class PushSubscriptionsResource { if (createSession != null) { try { createSession.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -146,8 +141,7 @@ public class PushSubscriptionsResource { if (registration.isDurable() && pushStore != null) { pushStore.add(registration); } - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new WebApplicationException(e, Response.serverError().entity("Failed to start consumer.").type("text/plain").build()); } @@ -156,8 +150,7 @@ public class PushSubscriptionsResource { UriBuilder location = uriInfo.getAbsolutePathBuilder(); location.path(genId); return Response.created(location.build()).build(); - } - finally { + } finally { closeSession(createSession); } } @@ -215,11 +208,9 @@ public class PushSubscriptionsResource { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { - } - finally { + } catch (ActiveMQException e) { + } finally { closeSession(session); } } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java index 56cbab480c..f2c2390e57 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java @@ -37,9 +37,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.rest.queue.Acknowledgement; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.AcknowledgedQueueConsumer; +import org.apache.activemq.artemis.rest.queue.Acknowledgement; import org.apache.activemq.artemis.rest.queue.DestinationServiceManager; import org.apache.activemq.artemis.rest.queue.QueueConsumer; import org.apache.activemq.artemis.rest.util.TimeoutTask; @@ -98,8 +98,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { shutdown(consumer); } return true; - } - else { + } else { return false; } } @@ -172,15 +171,13 @@ public class SubscriptionsResource implements TimeoutTask.Callback { if (autoAck) { headAutoAckSubscriptionResponse(uriInfo, consumer, builder, pathToPullSubscriptions); consumer.setSessionLink(builder, uriInfo, pathToPullSubscriptions + "/auto-ack/" + consumer.getId()); - } - else { + } else { headAcknowledgedConsumerResponse(uriInfo, (AcknowledgedQueueConsumer) consumer, builder); consumer.setSessionLink(builder, uriInfo, pathToPullSubscriptions + "/acknowledged/" + consumer.getId()); } return builder.build(); } - } - else { + } else { subscriptionName = generateSubscriptionName(); } ClientSession session = null; @@ -191,8 +188,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { if (durable) { session.createQueue(destination, subscriptionName, true); - } - else { + } else { session.createTemporaryQueue(destination, subscriptionName); } } @@ -209,23 +205,19 @@ public class SubscriptionsResource implements TimeoutTask.Callback { Response.ResponseBuilder builder = Response.created(location.build()); if (autoAck) { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/auto-ack/" + consumer.getId(), "-1"); - } - else { + } else { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/acknowledged/" + consumer.getId(), "-1"); } return builder.build(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -243,8 +235,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { subscription.setDurable(durable); subscription.setDeleteWhenIdle(deleteWhenIdle); consumer = subscription; - } - else { + } else { AcknowledgedSubscriptionResource subscription = new AcknowledgedSubscriptionResource(sessionFactory, subscriptionName, subscriptionName, serviceManager, selector, durable, timeout); subscription.setDurable(durable); subscription.setDeleteWhenIdle(deleteWhenIdle); @@ -333,8 +324,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { Acknowledgement ack = consumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); - } - else { + } else { consumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId()); } } @@ -356,16 +346,13 @@ public class SubscriptionsResource implements TimeoutTask.Callback { ClientSession.QueueQuery query = session.queueQuery(new SimpleString(subscriptionId)); return query.isExists(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -377,20 +364,17 @@ public class SubscriptionsResource implements TimeoutTask.Callback { QueueConsumer tmp = null; try { tmp = createConsumer(true, autoAck, subscriptionId, null, consumerTimeoutSeconds * 1000L, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } consumer = queueConsumers.putIfAbsent(subscriptionId, tmp); if (consumer == null) { consumer = tmp; serviceManager.getTimeoutTask().add(this, subscriptionId); - } - else { + } else { tmp.shutdown(); } - } - else { + } else { throw new WebApplicationException(Response.status(405).entity("Failed to find subscriber " + subscriptionId + " you will have to reconnect").type("text/plain").build()); } return consumer; @@ -429,17 +413,14 @@ public class SubscriptionsResource implements TimeoutTask.Callback { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { - } - finally { + } catch (ActiveMQException e) { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java index bd3980c3b9..af3e9c7840 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java @@ -32,12 +32,12 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.queue.DestinationSettings; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.apache.activemq.artemis.jms.server.config.TopicConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.DestinationSettings; import org.apache.activemq.artemis.rest.queue.PostMessage; import org.apache.activemq.artemis.rest.queue.PostMessageDupsOk; import org.apache.activemq.artemis.rest.queue.PostMessageNoDups; @@ -69,22 +69,18 @@ public class TopicDestinationsResource { if (!query.isExists()) { session.createQueue(topicName, topicName, "__AMQX=-1", true); - } - else { + } else { throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build()); } - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } URI uri = uriInfo.getRequestUriBuilder().path(topicName).build(); return Response.created(uri).build(); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof WebApplicationException) throw (WebApplicationException) e; throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build()); @@ -106,12 +102,10 @@ public class TopicDestinationsResource { boolean defaultDurable = queueSettings.isDurableSend() || query.isDurable(); topic = createTopicResource(name, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed()); - } - finally { + } finally { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -145,8 +139,7 @@ public class TopicDestinationsResource { PostMessage sender = null; if (duplicates) { sender = new PostMessageDupsOk(); - } - else { + } else { sender = new PostMessageNoDups(); } sender.setDefaultDurable(defaultDurable); @@ -170,4 +163,4 @@ public class TopicDestinationsResource { topicResource.start(); return topicResource; } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java index fd8f51a309..3348ac66dd 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.topic; -import org.apache.activemq.artemis.rest.queue.push.PushStore; - import java.util.List; +import org.apache.activemq.artemis.rest.queue.push.PushStore; + public interface TopicPushStore extends PushStore { List getByTopic(String topic); diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java index 85a8616921..038bf8695e 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java @@ -158,20 +158,17 @@ public class TopicResource extends DestinationResource { try { stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } ClientSession session = serviceManager.getSessionFactory().createSession(false, false, false); try { SimpleString topicName = new SimpleString(destination); session.deleteQueue(topicName); - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -180,4 +177,4 @@ public class TopicResource extends DestinationResource { public void setTopicDestinationsResource(TopicDestinationsResource topicDestinationsResource) { this.topicDestinationsResource = topicDestinationsResource; } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java index 7dbdd238af..1b710ee857 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.topic; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.rest.queue.DestinationServiceManager; -import java.util.ArrayList; -import java.util.List; - public class TopicServiceManager extends DestinationServiceManager { protected TopicPushStore pushStore; @@ -88,8 +88,7 @@ public class TopicServiceManager extends DestinationServiceManager { defaultDurable = topicDeployment.isDurableSend(); if (query.isExists()) { defaultDurable = query.isDurable(); - } - else { + } else { session.createQueue(queueName, queueName, topicDeployment.isDurableSend()); } } @@ -106,8 +105,7 @@ public class TopicServiceManager extends DestinationServiceManager { } try { sessionFactory.close(); - } - catch (Exception e) { + } catch (Exception e) { } } -} \ No newline at end of file +} diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java index 18d9fb77b5..0f590c9dc0 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java @@ -25,11 +25,9 @@ public class CustomHeaderLinkStrategy implements LinkStrategy { String headerName = null; if (title != null) { headerName = title; - } - else if (rel != null) { + } else if (rel != null) { headerName = rel; - } - else { + } else { throw new RuntimeException("Cannot figure out header name"); } headerName = "msg-" + headerName; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java index 7d97eef0cf..05ca387508 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.rest.util; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; -import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -import org.jboss.resteasy.client.ClientRequest; - import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedMap; import java.io.ByteArrayInputStream; import java.util.List; import java.util.Map.Entry; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; +import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; +import org.jboss.resteasy.client.ClientRequest; + public class HttpMessageHelper { public static final String POSTED_AS_HTTP_MESSAGE = "postedAsHttpMessage"; @@ -39,7 +39,10 @@ public class HttpMessageHelper { return lowerKey.toLowerCase().startsWith("content") || lowerKey.toLowerCase().equals("link"); } - public static void buildMessage(ClientMessage message, ClientRequest request, String contentType, ConnectionFactoryOptions jmsOptions) { + public static void buildMessage(ClientMessage message, + ClientRequest request, + String contentType, + ConnectionFactoryOptions jmsOptions) { for (SimpleString key : message.getPropertyNames()) { String k = key.toString(); String headerName = HttpHeaderProperty.fromPropertyName(k); @@ -64,8 +67,7 @@ public class HttpMessageHelper { message.getBodyBuffer().readBytes(body); ActiveMQRestLogger.LOGGER.debug("Building Message from HTTP message"); request.body(contentType, body); - } - else { + } else { // assume posted as a JMS or ActiveMQ Artemis object message size = message.getBodyBuffer().readInt(); byte[] body = new byte[size]; @@ -81,8 +83,7 @@ public class HttpMessageHelper { obj = ois.readObject(); ActiveMQRestLogger.LOGGER.debug("**** Building Message from object: " + obj.toString()); request.body(contentType, obj); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java index ccc7fec7e0..970d3070a4 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.util; -import org.jboss.resteasy.spi.Link; - import javax.ws.rs.core.Response; +import org.jboss.resteasy.spi.Link; + public class LinkHeaderLinkStrategy implements LinkStrategy { /** diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java index 233a533988..e2b9cd5b8f 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java @@ -50,17 +50,14 @@ public class TimeoutTask implements Runnable { if (callbacksLock.tryLock()) { try { callbacks.put(token, callback); - } - finally { + } finally { callbacksLock.unlock(); } - } - else { + } else { pendingCallbacksLock.lock(); try { pendingCallbacks.put(token, callback); - } - finally { + } finally { pendingCallbacksLock.unlock(); } } @@ -70,8 +67,7 @@ public class TimeoutTask implements Runnable { callbacksLock.lock(); try { callbacks.remove(token); - } - finally { + } finally { callbacksLock.unlock(); } } @@ -101,8 +97,7 @@ public class TimeoutTask implements Runnable { while (running) { try { Thread.sleep(interval * 1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { running = false; break; } @@ -127,8 +122,7 @@ public class TimeoutTask implements Runnable { deadConsumers += 1; expiredCallbacks.put(token, callback); callbacks.remove(token); - } - else { + } else { liveConsumers += 1; } } @@ -144,12 +138,10 @@ public class TimeoutTask implements Runnable { callbacks.putAll(pendingCallbacks); pendingCallbacks.clear(); } - } - finally { + } finally { pendingCallbacksLock.unlock(); } - } - finally { + } finally { callbacksLock.unlock(); } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java index baf464f5db..1635a449b1 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java @@ -172,8 +172,7 @@ public class AutoAckTopicTest extends MessageTestBase { System.out.println("NPS response: " + response.getStatus()); Assert.assertEquals(201, response.getStatus()); isFinished = true; - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Exception " + e); failed = true; } @@ -207,8 +206,7 @@ public class AutoAckTopicTest extends MessageTestBase { ClientResponse response = req.post(); response.releaseConnection(); isFinished = true; - } - catch (Exception e) { + } catch (Exception e) { failed = true; } } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java index 4a61d59328..145ddec18b 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.test; -import org.apache.activemq.artemis.rest.util.Constants; -import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.apache.activemq.artemis.rest.queue.QueueDeployment; +import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy; +import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; @@ -370,4 +370,4 @@ public class ClientAckQueueTest extends MessageTestBase { Assert.assertEquals(204, session.request().delete().getStatus()); } -} \ No newline at end of file +} diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java index c4a89f46e4..26c0b5c758 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java @@ -18,8 +18,8 @@ package org.apache.activemq.artemis.rest.test; import org.apache.activemq.artemis.rest.topic.TopicDeployment; import org.apache.activemq.artemis.rest.util.Constants; -import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy; +import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; @@ -312,4 +312,4 @@ public class ClientAckTopicTest extends MessageTestBase { res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); } -} \ No newline at end of file +} diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java index cf4e81edd7..dea9c0e0ed 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java @@ -86,8 +86,7 @@ public class EmbeddedTest { message.setObject(object); producer.send(message); - } - finally { + } finally { conn.close(); } } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java index fbae1a5845..c3228ad81e 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java @@ -30,10 +30,10 @@ import java.io.Serializable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; -import org.apache.activemq.artemis.rest.Jms; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; +import org.apache.activemq.artemis.rest.Jms; import org.apache.activemq.artemis.rest.queue.QueueDeployment; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; @@ -125,8 +125,7 @@ public class JMSTest extends MessageTestBase { message.setObject(object); producer.send(message); - } - finally { + } finally { conn.close(); } } @@ -142,8 +141,7 @@ public class JMSTest extends MessageTestBase { try { order = Jms.getEntity(message, Order.class); messageID = message.getJMSMessageID(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } latch.countDown(); @@ -191,8 +189,7 @@ public class JMSTest extends MessageTestBase { Assert.assertEquals(order, Listener.order); Assert.assertNotNull(Listener.messageID); } - } - finally { + } finally { conn.close(); } } @@ -270,4 +267,4 @@ public class JMSTest extends MessageTestBase { Assert.assertNotNull(consumeNext); } } -} \ No newline at end of file +} diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java index 63491d3632..e20f64549f 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java @@ -37,8 +37,7 @@ public class MessageTestBase { static { try { executorField = BaseClientResponse.class.getDeclaredField("executor"); - } - catch (NoSuchFieldException e) { + } catch (NoSuchFieldException e) { throw new RuntimeException(e); } executorField.setAccessible(true); @@ -61,8 +60,7 @@ public class MessageTestBase { public static Link getLinkByTitle(LinkStrategy strategy, ClientResponse response, String title) { if (strategy instanceof LinkHeaderLinkStrategy) { return response.getLinkHeader().getLinkByTitle(title); - } - else { + } else { String headerName = "msg-" + title; String href = (String) response.getHeaders().getFirst(headerName); if (href == null) @@ -71,8 +69,7 @@ public class MessageTestBase { Link l = new Link(title, null, href, null, null); try { l.setExecutor((ClientExecutor) executorField.get(response)); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } return l; diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java index bc15969a35..0eb3e2f3bf 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java @@ -125,8 +125,7 @@ public class PersistentPushQueueConsumerTest { Assert.assertEquals(204, res.getStatus()); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -194,8 +193,7 @@ public class PersistentPushQueueConsumerTest { response.releaseConnection(); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java index 571bc92ec9..00dc54efab 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java @@ -138,8 +138,7 @@ public class PersistentPushTopicConsumerTest { Assert.assertFalse(query.isExists()); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -196,8 +195,7 @@ public class PersistentPushTopicConsumerTest { Assert.assertEquals("1", Receiver.subscriber2); manager.getTopicManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -236,4 +234,4 @@ public class PersistentPushTopicConsumerTest { manager.getTopicManager().deploy(deployment); } -} \ No newline at end of file +} diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushQueueConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushQueueConsumerTest.java index f6573b6823..077e81e79a 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushQueueConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushQueueConsumerTest.java @@ -16,22 +16,21 @@ */ package org.apache.activemq.artemis.rest.test; -import org.apache.activemq.artemis.rest.util.Constants; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.rest.queue.QueueDeployment; import org.apache.activemq.artemis.rest.queue.push.ActiveMQPushStrategy; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; import org.apache.activemq.artemis.rest.queue.push.xml.XmlLink; +import org.apache.activemq.artemis.rest.util.Constants; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; import org.junit.Assert; import org.junit.Test; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; - -import java.util.concurrent.atomic.AtomicInteger; - import static org.jboss.resteasy.test.TestPortProvider.generateURL; public class PushQueueConsumerTest extends MessageTestBase { @@ -68,8 +67,7 @@ public class PushQueueConsumerTest extends MessageTestBase { sendMessage(destination, messageContent); consumerResponse = consume(destinationForConsumption, messageContent); - } - finally { + } finally { cleanupConsumer(consumerResponse); cleanupSubscription(pushSubscription); } @@ -112,8 +110,7 @@ public class PushQueueConsumerTest extends MessageTestBase { sendMessage(destinationForSend, messageContent); consumerResponse = consume(destinationForConsumption, messageContent); - } - finally { + } finally { cleanupConsumer(consumerResponse); cleanupSubscription(pushSubscription); } @@ -150,8 +147,7 @@ public class PushQueueConsumerTest extends MessageTestBase { sendMessage(destinationForSend, messageContent); consumerResponse = consume(destinationForConsumption, messageContent); - } - finally { + } finally { cleanupConsumer(consumerResponse); cleanupSubscription(pushSubscription); } @@ -184,8 +180,7 @@ public class PushQueueConsumerTest extends MessageTestBase { try { // sleep here so the concurrent invocations can stack up Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } @@ -219,8 +214,7 @@ public class PushQueueConsumerTest extends MessageTestBase { Thread.sleep(100); Assert.assertEquals(messageContent, MyResource.got_it); - } - finally { + } finally { cleanupSubscription(pushSubscription); } } @@ -257,8 +251,7 @@ public class PushQueueConsumerTest extends MessageTestBase { } Assert.assertEquals(CONCURRENT, MyConcurrentResource.maxConcurrentInvocations.get()); - } - finally { + } finally { cleanupSubscription(pushSubscription); } } @@ -319,16 +312,13 @@ public class PushQueueConsumerTest extends MessageTestBase { if (pushRegistrationType == PushRegistrationType.CLASS) { target.setHref(generateURL(Util.getUrlPath(queueToPushTo))); target.setClassName(ActiveMQPushStrategy.class.getName()); - } - else if (pushRegistrationType == PushRegistrationType.BRIDGE) { + } else if (pushRegistrationType == PushRegistrationType.BRIDGE) { target.setHref(generateURL(Util.getUrlPath(queueToPushTo))); target.setRelationship("destination"); - } - else if (pushRegistrationType == PushRegistrationType.TEMPLATE) { + } else if (pushRegistrationType == PushRegistrationType.TEMPLATE) { target.setHref(queueToPushTo); target.setRelationship("template"); - } - else if (pushRegistrationType == PushRegistrationType.URI) { + } else if (pushRegistrationType == PushRegistrationType.URI) { target.setMethod("put"); target.setHref(queueToPushTo); } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushTopicConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushTopicConsumerTest.java index 320567c5d4..104189d0f1 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushTopicConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PushTopicConsumerTest.java @@ -256,8 +256,7 @@ public class PushTopicConsumerTest extends MessageTestBase { try { // sleep here so the concurrent invocations can stack up Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/RawAckTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/RawAckTest.java index 9a4140de81..3b6f598d77 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/RawAckTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/RawAckTest.java @@ -103,8 +103,7 @@ public class RawAckTest { } Assert.assertNull(message); passed = true; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java index 2d6d3f2d8a..176d61efa5 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SelectorTest.java @@ -140,8 +140,7 @@ public class SelectorTest extends MessageTestBase { message.setObject(object); producer.send(message); - } - finally { + } finally { conn.close(); } } @@ -303,4 +302,4 @@ public class SelectorTest extends MessageTestBase { response.releaseConnection(); return consumeNext; } -} \ No newline at end of file +} diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SessionTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SessionTest.java index e9c8386916..c19288f0b9 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SessionTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/SessionTest.java @@ -16,9 +16,9 @@ */ package org.apache.activemq.artemis.rest.test; +import org.apache.activemq.artemis.rest.queue.QueueDeployment; import org.apache.activemq.artemis.rest.topic.TopicDeployment; import org.apache.activemq.artemis.rest.util.Constants; -import org.apache.activemq.artemis.rest.queue.QueueDeployment; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/TransformTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/TransformTest.java index dfb6cc8504..dcb67bde04 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/TransformTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/TransformTest.java @@ -103,13 +103,11 @@ public class TransformTest extends MessageTestBase { ClientMessage message = session.createMessage(Message.OBJECT_TYPE, false); if (contentType == null) { ActiveMQ.setEntity(message, object); - } - else + } else ActiveMQ.setEntity(message, object, contentType); producer.send(message); session.start(); - } - finally { + } finally { session.close(); } @@ -193,8 +191,7 @@ public class TransformTest extends MessageTestBase { System.out.println("onMessage!"); try { order = ActiveMQ.getEntity(clientMessage, Order.class); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } latch.countDown(); @@ -240,8 +237,7 @@ public class TransformTest extends MessageTestBase { Assert.assertNotNull(Listener.order); Assert.assertEquals(order, Listener.order); } - } - finally { + } finally { session.close(); } } diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/XmlTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/XmlTest.java index a3c521c03c..2c0bd9de69 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/XmlTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/XmlTest.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.rest.test; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; -import org.junit.Test; - import javax.xml.bind.JAXBContext; import java.io.StringReader; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; +import org.junit.Test; + public class XmlTest { @Test diff --git a/artemis-selector/pom.xml b/artemis-selector/pom.xml index 8b3fe6477b..45214ea062 100644 --- a/artemis-selector/pom.xml +++ b/artemis-selector/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -66,65 +67,65 @@ - org.codehaus.mojo - javacc-maven-plugin - 2.6 - - - generate-sources - - javacc - - - + org.codehaus.mojo + javacc-maven-plugin + 2.6 + + + generate-sources + + javacc + + + - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${basedir}/target/generated-sources/javacc - - - - + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${basedir}/target/generated-sources/javacc + + + + - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - javacc-maven-plugin - [2.6,) - - javacc - - - - - - - - - - - + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + javacc-maven-plugin + [2.6,) + + javacc + + + + + + + + + + + diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java index 3cff71104e..87759f4e5a 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java @@ -45,8 +45,7 @@ public abstract class ArithmeticExpression extends BinaryExpression { String text = (String) lvalue; String answer = text + rvalue; return answer; - } - else { + } else { return plus(asNumber(lvalue), asNumber(rvalue)); } } @@ -161,11 +160,9 @@ public abstract class ArithmeticExpression extends BinaryExpression { private int numberType(Number left, Number right) { if (isDouble(left) || isDouble(right)) { return DOUBLE; - } - else if (left instanceof Long || right instanceof Long) { + } else if (left instanceof Long || right instanceof Long) { return LONG; - } - else { + } else { return INTEGER; } } @@ -177,19 +174,16 @@ public abstract class ArithmeticExpression extends BinaryExpression { protected Number asNumber(Object value) { if (value instanceof Number) { return (Number) value; - } - else { + } else { if (convertStringExpressions && value instanceof String) { String v = (String) value; try { if (v.contains(".")) { return new Double(v); - } - else { + } else { return new Long(v); } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw new RuntimeException("Cannot convert value: " + value + " into a number"); } } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ComparisonExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ComparisonExpression.java index bc3b3333df..a46dd7ce11 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ComparisonExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ComparisonExpression.java @@ -91,8 +91,7 @@ public abstract class ComparisonExpression extends BinaryExpression implements B char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); - } - else { + } else { append(regexp, c); } } @@ -113,15 +112,12 @@ public abstract class ComparisonExpression extends BinaryExpression implements B private void append(StringBuffer regexp, char c) { if (c == '%') { regexp.append(".*?"); // Do a non-greedy match - } - else if (c == '_') { + } else if (c == '_') { regexp.append("."); // match one - } - else if (REGEXP_CONTROL_CHARS.contains(new Character(c))) { + } else if (REGEXP_CONTROL_CHARS.contains(new Character(c))) { regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & c)); - } - else { + } else { regexp.append(c); } } @@ -385,146 +381,105 @@ public abstract class ComparisonExpression extends BinaryExpression implements B if (lc == Boolean.class) { if (convertStringExpressions && rc == String.class) { rv = Boolean.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Byte.class) { + } else if (lc == Byte.class) { if (rc == Short.class) { lv = ((Number) lv).shortValue(); - } - else if (rc == Integer.class) { + } else if (rc == Integer.class) { lv = ((Number) lv).intValue(); - } - else if (rc == Long.class) { + } else if (rc == Long.class) { lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) { + } else if (rc == Float.class) { lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = ((Number) lv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Byte.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Short.class) { + } else if (lc == Short.class) { if (rc == Integer.class) { lv = ((Number) lv).intValue(); - } - else if (rc == Long.class) { + } else if (rc == Long.class) { lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) { + } else if (rc == Float.class) { lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = ((Number) lv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Short.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Integer.class) { + } else if (lc == Integer.class) { if (rc == Long.class) { lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) { + } else if (rc == Float.class) { lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = ((Number) lv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Integer.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Long.class) { + } else if (lc == Long.class) { if (rc == Integer.class) { rv = ((Number) rv).longValue(); - } - else if (rc == Float.class) { + } else if (rc == Float.class) { lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = ((Number) lv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Long.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Float.class) { + } else if (lc == Float.class) { if (rc == Integer.class || rc == Long.class) { rv = ((Number) rv).floatValue(); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = ((Number) lv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Float.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (lc == Double.class) { + } else if (lc == Double.class) { if (rc == Integer.class || rc == Long.class || rc == Float.class) { rv = ((Number) rv).doubleValue(); - } - else if (convertStringExpressions && rc == String.class) { + } else if (convertStringExpressions && rc == String.class) { rv = Double.valueOf((String) rv); - } - else { + } else { return Boolean.FALSE; } - } - else if (convertStringExpressions && lc == String.class) { + } else if (convertStringExpressions && lc == String.class) { if (rc == Boolean.class) { lv = Boolean.valueOf((String) lv); - } - else if (rc == Byte.class) { + } else if (rc == Byte.class) { lv = Byte.valueOf((String) lv); - } - else if (rc == Short.class) { + } else if (rc == Short.class) { lv = Short.valueOf((String) lv); - } - else if (rc == Integer.class) { + } else if (rc == Integer.class) { lv = Integer.valueOf((String) lv); - } - else if (rc == Long.class) { + } else if (rc == Long.class) { lv = Long.valueOf((String) lv); - } - else if (rc == Float.class) { + } else if (rc == Float.class) { lv = Float.valueOf((String) lv); - } - else if (rc == Double.class) { + } else if (rc == Double.class) { lv = Double.valueOf((String) lv); - } - else { + } else { return Boolean.FALSE; } - } - else { + } else { return Boolean.FALSE; } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { return Boolean.FALSE; } } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ConstantExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ConstantExpression.java index 8d88bbd695..0cdf991070 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ConstantExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ConstantExpression.java @@ -58,8 +58,7 @@ public class ConstantExpression implements Expression { Number value; try { value = new Long(text); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // The number may be too big to fit in a long. value = new BigDecimal(text); } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java index ecdcf2389c..4c106bd050 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java @@ -64,11 +64,9 @@ public abstract class UnaryExpression implements Expression { Collection t; if (elements.size() == 0) { t = null; - } - else if (elements.size() < 5) { + } else if (elements.size() < 5) { t = elements; - } - else { + } else { t = new HashSet<>(elements); } final Collection inList = t; @@ -113,8 +111,7 @@ public abstract class UnaryExpression implements Expression { public String getExpressionSymbol() { if (not) { return "NOT IN"; - } - else { + } else { return "IN"; } } @@ -190,17 +187,13 @@ public abstract class UnaryExpression implements Expression { Class clazz = left.getClass(); if (clazz == Integer.class) { return -left.intValue(); - } - else if (clazz == Long.class) { + } else if (clazz == Long.class) { return -left.longValue(); - } - else if (clazz == Float.class) { + } else if (clazz == Float.class) { return -left.floatValue(); - } - else if (clazz == Double.class) { + } else if (clazz == Double.class) { return -left.doubleValue(); - } - else if (clazz == BigDecimal.class) { + } else if (clazz == BigDecimal.class) { // We ussually get a big deciamal when we have Long.MIN_VALUE // constant in the // Selector. Long.MIN_VALUE is too big to store in a Long as a @@ -215,8 +208,7 @@ public abstract class UnaryExpression implements Expression { return Long.valueOf(Long.MIN_VALUE); } return bd; - } - else { + } else { throw new RuntimeException("Don't know how to negate: " + left); } } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XPathExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XPathExpression.java index 111fce953b..4f0f8e6705 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XPathExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XPathExpression.java @@ -33,8 +33,7 @@ public final class XPathExpression implements BooleanExpression { return new XalanXPathEvaluator(xpath); } }; - } - catch (Throwable e) { + } catch (Throwable e) { } } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XalanXPathEvaluator.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XalanXPathEvaluator.java index 906074e481..3a1714c311 100644 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XalanXPathEvaluator.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/XalanXPathEvaluator.java @@ -66,8 +66,7 @@ public class XalanXPathEvaluator implements XPathExpression.XPathEvaluator { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } - } - catch (Throwable e) { + } catch (Throwable e) { return false; } } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/impl/SelectorParser.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/impl/SelectorParser.java index 1cea9baa89..6812f9ab0d 100644 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/impl/SelectorParser.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/impl/SelectorParser.java @@ -38,11 +38,9 @@ public class SelectorParser { Object result = cache.get(sql); if (result instanceof FilterException) { throw (FilterException) result; - } - else if (result instanceof BooleanExpression) { + } else if (result instanceof BooleanExpression) { return (BooleanExpression) result; - } - else { + } else { String actual = sql; boolean convertStringExpressions = false; boolean hyphenatedProps = false; @@ -78,20 +76,17 @@ public class SelectorParser { if (hyphenatedProps) { HyphenatedParser parser = new HyphenatedParser(new StringReader(actual)); e = parser.JmsSelector(); - } - else { + } else { StrictParser parser = new StrictParser(new StringReader(actual)); e = parser.JmsSelector(); } cache.put(sql, e); return e; - } - catch (Throwable e) { + } catch (Throwable e) { FilterException fe = new FilterException(actual, e); cache.put(sql, fe); throw fe; - } - finally { + } finally { if (convertStringExpressions) { ComparisonExpression.CONVERT_STRING_EXPRESSIONS.remove(); } diff --git a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java index d612db0eb5..a540ed748b 100755 --- a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java +++ b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java @@ -504,8 +504,7 @@ public class SelectorTest { try { SelectorParser.parse(text); Assert.fail("Created a valid selector"); - } - catch (FilterException e) { + } catch (FilterException e) { } } diff --git a/artemis-server-osgi/pom.xml b/artemis-server-osgi/pom.xml index f10a23b930..ce2d2fe7c1 100644 --- a/artemis-server-osgi/pom.xml +++ b/artemis-server-osgi/pom.xml @@ -8,123 +8,124 @@ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - 4.0.0 + + 4.0.0 - - org.apache.activemq - artemis-pom - 1.5.0-SNAPSHOT - + + org.apache.activemq + artemis-pom + 1.5.0-SNAPSHOT + - artemis-server-osgi - bundle - ActiveMQ Artemis Server OSGi + artemis-server-osgi + bundle + ActiveMQ Artemis Server OSGi - - Combines the commons, core-client and server jars as they contain too many duplicate packages - to be deployed separately. - + + Combines the commons, core-client and server jars as they contain too many duplicate packages + to be deployed separately. + - - ${project.basedir}/.. - + + ${project.basedir}/.. + - - - org.apache.activemq - artemis-commons - ${project.version} - - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - org.apache.activemq - artemis-jdbc-store - ${project.version} - - - org.apache.activemq - artemis-journal - ${project.version} - - - org.apache.activemq - artemis-selector - ${project.version} - - - org.apache.activemq - artemis-service-extensions - ${project.version} - - - - org.jboss.modules - jboss-modules - 1.3.1.Final - provided - true - - - - - org.jboss.logmanager - jboss-logmanager - true - - - - junit - junit - 4.11 - test - - - org.easymock - easymock - 3.2 - test - - + + + org.apache.activemq + artemis-commons + ${project.version} + + + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-server + ${project.version} + + + org.apache.activemq + artemis-jms-client + ${project.version} + + + org.apache.activemq + artemis-jms-server + ${project.version} + + + org.apache.activemq + artemis-jdbc-store + ${project.version} + + + org.apache.activemq + artemis-journal + ${project.version} + + + org.apache.activemq + artemis-selector + ${project.version} + + + org.apache.activemq + artemis-service-extensions + ${project.version} + - - - - org.apache.felix - maven-bundle-plugin - 3.0.0 - true - - - *;scope=compile|runtime - - org.postgresql*;resolution:=optional, - * - - <_exportcontents>* - - - - - + + org.jboss.modules + jboss-modules + 1.3.1.Final + provided + true + + + + + org.jboss.logmanager + jboss-logmanager + true + + + + junit + junit + 4.11 + test + + + org.easymock + easymock + 3.2 + test + + + + + + + org.apache.felix + maven-bundle-plugin + 3.0.0 + true + + + *;scope=compile|runtime + + org.postgresql*;resolution:=optional, + * + + <_exportcontents>* + + + + + diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java index 8b43d2329a..e9217687fd 100644 --- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java +++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java @@ -50,6 +50,7 @@ import org.osgi.util.tracker.ServiceTracker; @SuppressWarnings({"unchecked", "rawtypes"}) @Component(configurationPid = "org.apache.activemq.artemis", configurationPolicy = ConfigurationPolicy.REQUIRE) public class OsgiBroker { + private String name; private String configurationUrl; private String rolePrincipalClass; @@ -63,7 +64,7 @@ public class OsgiBroker { final Dictionary properties = cctx.getProperties(); configurationUrl = getMandatory(properties, "config"); name = getMandatory(properties, "name"); - rolePrincipalClass = (String)properties.get("rolePrincipalClass"); + rolePrincipalClass = (String) properties.get("rolePrincipalClass"); String domain = getMandatory(properties, "domain"); ActiveMQJAASSecurityManager security = new ActiveMQJAASSecurityManager(domain); if (rolePrincipalClass != null) { @@ -88,7 +89,7 @@ public class OsgiBroker { components = fileDeploymentManager.buildService(security, ManagementFactory.getPlatformMBeanServer()); - final ActiveMQServer server = (ActiveMQServer)components.get("core"); + final ActiveMQServer server = (ActiveMQServer) components.get("core"); String[] requiredProtocols = getRequiredProtocols(server.getConfiguration().getAcceptorConfigurations()); ProtocolTrackerCallBack callback = new ProtocolTrackerCallBack() { @@ -98,7 +99,6 @@ public class OsgiBroker { server.addProtocolManagerFactory(pmf); } - @Override public void removeFactory(ProtocolManagerFactory pmf) { server.removeProtocolManagerFactory(pmf); @@ -141,7 +141,6 @@ public class OsgiBroker { return value; } - private String[] getRequiredProtocols(Set acceptors) { ArrayList protocols = new ArrayList<>(); for (TransportConfiguration acceptor : acceptors) { @@ -185,7 +184,7 @@ public class OsgiBroker { for (Map.Entry component : getComponents().entrySet()) { String[] classes = getInterfaces(component.getValue()); Hashtable props = new Hashtable<>(); - for (Enumeration keyEnum = properties.keys(); keyEnum.hasMoreElements();) { + for (Enumeration keyEnum = properties.keys(); keyEnum.hasMoreElements(); ) { String key = keyEnum.nextElement(); Object val = properties.get(key); props.put(key, val); diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java index 661024b8f9..545e8970f2 100644 --- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java +++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTracker.java @@ -38,13 +38,17 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; */ @SuppressWarnings("rawtypes") public class ProtocolTracker implements ServiceTrackerCustomizer, ProtocolManagerFactory> { + private static Logger LOG = Logger.getLogger(ProtocolTracker.class.getName()); private String name; private BundleContext context; private Map protocols; private ProtocolTrackerCallBack callback; - public ProtocolTracker(String name, BundleContext context, String[] requiredProtocols, ProtocolTrackerCallBack callback) { + public ProtocolTracker(String name, + BundleContext context, + String[] requiredProtocols, + ProtocolTrackerCallBack callback) { this.name = name; this.context = context; this.callback = callback; @@ -66,14 +70,15 @@ public class ProtocolTracker implements ServiceTrackerCustomizer> reference, ProtocolManagerFactory pmf) { + public void modifiedService(ServiceReference> reference, + ProtocolManagerFactory pmf) { // Not supported } @Override - public void removedService(ServiceReference> reference, ProtocolManagerFactory pmf) { + public void removedService(ServiceReference> reference, + ProtocolManagerFactory pmf) { for (String protocol : pmf.getProtocols()) { protocolRemoved(protocol); } @@ -86,30 +91,26 @@ public class ProtocolTracker implements ServiceTrackerCustomizer missing = getMissing(); LOG.info("Required protocol " + protocol + " was added for broker " + name + ". " + - (missing.isEmpty() ? "Starting broker." : "Still waiting for " + missing)); + (missing.isEmpty() ? "Starting broker." : "Still waiting for " + missing)); if (missing.isEmpty()) { try { callback.start(); - } - catch (Exception e) { + } catch (Exception e) { LOG.log(Level.WARNING, "Error starting broker " + name, e); } } } } - private void protocolRemoved(String protocol) { Boolean present = this.protocols.get(protocol); if (present != null && present) { List missing = getMissing(); - LOG.info("Required protocol " + protocol + " was removed for broker " + name + ". " - + (missing.isEmpty() ? "Stopping broker. " : "")); + LOG.info("Required protocol " + protocol + " was removed for broker " + name + ". " + (missing.isEmpty() ? "Stopping broker. " : "")); if (missing.isEmpty()) { try { callback.stop(); - } - catch (Exception e) { + } catch (Exception e) { LOG.log(Level.WARNING, "Error stopping broker " + name, e); } } diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java index 9614b5323c..44cc5908aa 100644 --- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java +++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/ProtocolTrackerCallBack.java @@ -21,6 +21,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; public interface ProtocolTrackerCallBack extends ActiveMQComponent { + void addFactory(ProtocolManagerFactory pmf); void removeFactory(ProtocolManagerFactory pmf); diff --git a/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java b/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java index 18e1f766d4..744d45bd3d 100644 --- a/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java +++ b/artemis-server-osgi/src/test/java/org/apache/activemq/artemis/osgi/ProtocolTrackerTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.osgi; -import static org.easymock.EasyMock.expect; - import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.easymock.EasyMock; @@ -26,6 +24,8 @@ import org.junit.Test; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import static org.easymock.EasyMock.expect; + @SuppressWarnings({"rawtypes", "unchecked"}) public class ProtocolTrackerTest { @@ -61,6 +61,7 @@ public class ProtocolTrackerTest { } class RefFact { + ServiceReference> ref; ProtocolManagerFactory factory; diff --git a/artemis-server/pom.xml b/artemis-server/pom.xml index 7f9b9db77f..d9eaeadf6a 100644 --- a/artemis-server/pom.xml +++ b/artemis-server/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -47,9 +48,9 @@ jboss-logging - org.jboss.logmanager - jboss-logmanager - test + org.jboss.logmanager + jboss-logmanager + test org.apache.activemq @@ -136,7 +137,8 @@ 512m false true - org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java index 2e21949c46..8339a0fea2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.api.core.management; +import javax.json.JsonObject; import java.text.DateFormat; import java.util.Date; @@ -23,8 +24,6 @@ import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.core.messagecounter.MessageCounter; import org.apache.activemq.artemis.utils.JsonLoader; -import javax.json.JsonObject; - import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe; /** @@ -62,18 +61,7 @@ public final class MessageCounterInfo { DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); String lastAddTimestamp = dateFormat.format(new Date(counter.getLastAddedMessageTime())); String updateTimestamp = dateFormat.format(new Date(counter.getLastUpdate())); - return JsonLoader.createObjectBuilder() - .add("destinationName", nullSafe(counter.getDestinationName())) - .add("destinationSubscription", nullSafe(counter.getDestinationSubscription())) - .add("destinationDurable", counter.isDestinationDurable()) - .add("count", counter.getCount()) - .add("countDelta", counter.getCountDelta()) - .add("messageCount", counter.getMessageCount()) - .add("messageCountDelta", counter.getMessageCountDelta()) - .add("lastAddTimestamp", lastAddTimestamp) - .add("updateTimestamp", updateTimestamp) - .build() - .toString(); + return JsonLoader.createObjectBuilder().add("destinationName", nullSafe(counter.getDestinationName())).add("destinationSubscription", nullSafe(counter.getDestinationSubscription())).add("destinationDurable", counter.isDestinationDurable()).add("count", counter.getCount()).add("countDelta", counter.getCountDelta()).add("messageCount", counter.getMessageCount()).add("messageCountDelta", counter.getMessageCountDelta()).add("lastAddTimestamp", lastAddTimestamp).add("updateTimestamp", updateTimestamp).build().toString(); } /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java index f07fc171e6..68db973fb9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java @@ -401,20 +401,17 @@ public final class BridgeConfiguration implements Serializable { if (discoveryGroupName == null) { if (other.discoveryGroupName != null) return false; - } - else if (!discoveryGroupName.equals(other.discoveryGroupName)) + } else if (!discoveryGroupName.equals(other.discoveryGroupName)) return false; if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (forwardingAddress == null) { if (other.forwardingAddress != null) return false; - } - else if (!forwardingAddress.equals(other.forwardingAddress)) + } else if (!forwardingAddress.equals(other.forwardingAddress)) return false; if (ha != other.ha) return false; @@ -425,20 +422,17 @@ public final class BridgeConfiguration implements Serializable { if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (password == null) { if (other.password != null) return false; - } - else if (!password.equals(other.password)) + } else if (!password.equals(other.password)) return false; if (queueName == null) { if (other.queueName != null) return false; - } - else if (!queueName.equals(other.queueName)) + } else if (!queueName.equals(other.queueName)) return false; if (initialConnectAttempts != other.initialConnectAttempts) return false; @@ -451,22 +445,19 @@ public final class BridgeConfiguration implements Serializable { if (staticConnectors == null) { if (other.staticConnectors != null) return false; - } - else if (!staticConnectors.equals(other.staticConnectors)) + } else if (!staticConnectors.equals(other.staticConnectors)) return false; if (transformerClassName == null) { if (other.transformerClassName != null) return false; - } - else if (!transformerClassName.equals(other.transformerClassName)) + } else if (!transformerClassName.equals(other.transformerClassName)) return false; if (useDuplicateDetection != other.useDuplicateDetection) return false; if (user == null) { if (other.user != null) return false; - } - else if (!user.equals(other.user)) + } else if (!user.equals(other.user)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java index 90c9db5108..2cf8ab86d4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java @@ -62,8 +62,7 @@ public final class ClusterConnectionConfiguration implements Serializable { private boolean duplicateDetection = ActiveMQDefaultConfiguration.isDefaultClusterDuplicateDetection(); - private MessageLoadBalancingType messageLoadBalancingType = Enum.valueOf(MessageLoadBalancingType.class, ActiveMQDefaultConfiguration - .getDefaultClusterMessageLoadBalancingType()); + private MessageLoadBalancingType messageLoadBalancingType = Enum.valueOf(MessageLoadBalancingType.class, ActiveMQDefaultConfiguration.getDefaultClusterMessageLoadBalancingType()); private URISupport.CompositeData compositeMembers; @@ -387,8 +386,7 @@ public final class ClusterConnectionConfiguration implements Serializable { } return list.toArray(new TransportConfiguration[list.size()]); - } - else { + } else { return staticConnectors != null ? configuration.getTransportConfigurations(staticConnectors) : null; } } @@ -405,8 +403,7 @@ public final class ClusterConnectionConfiguration implements Serializable { return null; } return dg; - } - else { + } else { return null; } } @@ -483,8 +480,7 @@ public final class ClusterConnectionConfiguration implements Serializable { if (other.address != null) { return false; } - } - else if (!address.equals(other.address)) { + } else if (!address.equals(other.address)) { return false; } if (allowDirectConnectionsOnly != other.allowDirectConnectionsOnly) { @@ -515,16 +511,14 @@ public final class ClusterConnectionConfiguration implements Serializable { if (other.connectorName != null) { return false; } - } - else if (!connectorName.equals(other.connectorName)) { + } else if (!connectorName.equals(other.connectorName)) { return false; } if (discoveryGroupName == null) { if (other.discoveryGroupName != null) { return false; } - } - else if (!discoveryGroupName.equals(other.discoveryGroupName)) { + } else if (!discoveryGroupName.equals(other.discoveryGroupName)) { return false; } if (duplicateDetection != other.duplicateDetection) { @@ -546,8 +540,7 @@ public final class ClusterConnectionConfiguration implements Serializable { if (other.name != null) { return false; } - } - else if (!name.equals(other.name)) { + } else if (!name.equals(other.name)) { return false; } if (initialConnectAttempts != other.initialConnectAttempts) { @@ -566,8 +559,7 @@ public final class ClusterConnectionConfiguration implements Serializable { if (other.staticConnectors != null) { return false; } - } - else if (!staticConnectors.equals(other.staticConnectors)) { + } else if (!staticConnectors.equals(other.staticConnectors)) { return false; } return true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java index e78479ad57..f486a88e3d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java @@ -196,14 +196,14 @@ public interface Configuration { */ Configuration setJMXDomain(String domain); - /** - * whether or not to use the broker name in the JMX tree - * */ + /** + * whether or not to use the broker name in the JMX tree + */ boolean isJMXUseBrokerName(); /** * whether or not to use the broker name in the JMX tree - * */ + */ ConfigurationImpl setJMXUseBrokerName(boolean jmxUseBrokerName); /** @@ -561,13 +561,16 @@ public interface Configuration { */ Configuration setJournalCompactMinFiles(int minFiles); - /** Number of files that would be acceptable to keep on a pool. Default value is {@link org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_JOURNAL_POOL_FILES}.*/ + /** + * Number of files that would be acceptable to keep on a pool. Default value is {@link org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_JOURNAL_POOL_FILES}. + */ int getJournalPoolFiles(); - /** Number of files that would be acceptable to keep on a pool. Default value is {@link org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_JOURNAL_POOL_FILES}.*/ + /** + * Number of files that would be acceptable to keep on a pool. Default value is {@link org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_JOURNAL_POOL_FILES}. + */ Configuration setJournalPoolFiles(int poolSize); - /** * Returns the percentage of live data before compacting the journal.
* Default value is {@link org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_JOURNAL_COMPACT_PERCENTAGE}. @@ -914,7 +917,7 @@ public interface Configuration { * */ Configuration setResolveProtocols(boolean resolveProtocols); - TransportConfiguration[] getTransportConfigurations(String ...connectorNames); + TransportConfiguration[] getTransportConfigurations(String... connectorNames); TransportConfiguration[] getTransportConfigurations(List connectorNames); @@ -953,7 +956,9 @@ public interface Configuration { Configuration setPopulateValidatedUser(boolean populateValidatedUser); - /** It will return all the connectors in a toString manner for debug purposes. */ + /** + * It will return all the connectors in a toString manner for debug purposes. + */ String debugConnectors(); Configuration setConnectionTtlCheckInterval(long connectionTtlCheckInterval); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java index bd626a5a68..4266860e05 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java @@ -86,8 +86,7 @@ public final class ConfigurationUtils { //if null default to colocated if (liveConf == null) { livePolicy = new ReplicatedPolicy(); - } - else { + } else { livePolicy = getHAPolicy(liveConf); } HAPolicyConfiguration backupConf = pc.getBackupConfig(); @@ -95,20 +94,16 @@ public final class ConfigurationUtils { if (backupConf == null) { if (livePolicy instanceof ReplicatedPolicy) { backupPolicy = new ReplicaPolicy(); - } - else if (livePolicy instanceof SharedStoreMasterPolicy) { + } else if (livePolicy instanceof SharedStoreMasterPolicy) { backupPolicy = new SharedStoreSlavePolicy(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.liveBackupMismatch(); } - } - else { + } else { backupPolicy = (BackupPolicy) getHAPolicy(backupConf); } - if ((livePolicy instanceof ReplicatedPolicy && !(backupPolicy instanceof ReplicaPolicy)) || - (livePolicy instanceof SharedStoreMasterPolicy && !(backupPolicy instanceof SharedStoreSlavePolicy))) { + if ((livePolicy instanceof ReplicatedPolicy && !(backupPolicy instanceof ReplicaPolicy)) || (livePolicy instanceof SharedStoreMasterPolicy && !(backupPolicy instanceof SharedStoreSlavePolicy))) { throw ActiveMQMessageBundle.BUNDLE.liveBackupMismatch(); } return new ColocatedPolicy(pc.isRequestBackup(), pc.getBackupRequestRetries(), pc.getBackupRequestRetryInterval(), pc.getMaxBackups(), pc.getBackupPortOffset(), pc.getExcludedConnectors(), livePolicy, backupPolicy); @@ -122,8 +117,7 @@ public final class ConfigurationUtils { if (scaleDownConfiguration != null) { if (scaleDownConfiguration.getDiscoveryGroup() != null) { return new ScaleDownPolicy(scaleDownConfiguration.getDiscoveryGroup(), scaleDownConfiguration.getGroupName(), scaleDownConfiguration.getClusterName(), scaleDownConfiguration.isEnabled()); - } - else { + } else { return new ScaleDownPolicy(scaleDownConfiguration.getConnectors(), scaleDownConfiguration.getGroupName(), scaleDownConfiguration.getClusterName(), scaleDownConfiguration.isEnabled()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java index daaca811e4..2e7b9ca5a3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java @@ -104,22 +104,19 @@ public class CoreQueueConfiguration implements Serializable { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (durable != other.durable) return false; if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/DivertConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/DivertConfiguration.java index e8d77a3344..a769f1712e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/DivertConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/DivertConfiguration.java @@ -84,8 +84,7 @@ public class DivertConfiguration implements Serializable { public DivertConfiguration setRoutingName(final String routingName) { if (routingName == null) { this.routingName = UUIDGenerator.getInstance().generateStringUUID(); - } - else { + } else { this.routingName = routingName; } return this; @@ -157,40 +156,34 @@ public class DivertConfiguration implements Serializable { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (exclusive != other.exclusive) return false; if (filterString == null) { if (other.filterString != null) return false; - } - else if (!filterString.equals(other.filterString)) + } else if (!filterString.equals(other.filterString)) return false; if (forwardingAddress == null) { if (other.forwardingAddress != null) return false; - } - else if (!forwardingAddress.equals(other.forwardingAddress)) + } else if (!forwardingAddress.equals(other.forwardingAddress)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (routingName == null) { if (other.routingName != null) return false; - } - else if (!routingName.equals(other.routingName)) + } else if (!routingName.equals(other.routingName)) return false; if (transformerClassName == null) { if (other.transformerClassName != null) return false; - } - else if (!transformerClassName.equals(other.transformerClassName)) + } else if (!transformerClassName.equals(other.transformerClassName)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ScaleDownConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ScaleDownConfiguration.java index 25721cad5c..5f58e36bdc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ScaleDownConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ScaleDownConfiguration.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.core.config; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; + public class ScaleDownConfiguration implements Serializable { private List connectors = new ArrayList<>(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ColocatedPolicyConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ColocatedPolicyConfiguration.java index 1c5a903541..5e9309fac4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ColocatedPolicyConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ColocatedPolicyConfiguration.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.core.config.ha; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.core.config.HAPolicyConfiguration; - import java.util.ArrayList; import java.util.List; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.core.config.HAPolicyConfiguration; + public class ColocatedPolicyConfiguration implements HAPolicyConfiguration { private boolean requestBackup = ActiveMQDefaultConfiguration.isDefaultHapolicyRequestBackup(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java index 51b633f501..261392923a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java @@ -1243,8 +1243,7 @@ public class ConfigurationImpl implements Configuration, Serializable { public boolean isCheckForLiveServer() { if (haPolicyConfiguration instanceof ReplicaPolicyConfiguration) { return ((ReplicatedPolicyConfiguration) haPolicyConfiguration).isCheckForLiveServer(); - } - else { + } else { return false; } } @@ -1500,14 +1499,12 @@ public class ConfigurationImpl implements Configuration, Serializable { if (acceptorConfigs == null) { if (other.acceptorConfigs != null) return false; - } - else if (!acceptorConfigs.equals(other.acceptorConfigs)) + } else if (!acceptorConfigs.equals(other.acceptorConfigs)) return false; if (addressesSettings == null) { if (other.addressesSettings != null) return false; - } - else if (!addressesSettings.equals(other.addressesSettings)) + } else if (!addressesSettings.equals(other.addressesSettings)) return false; if (asyncConnectionExecutionEnabled != other.asyncConnectionExecutionEnabled) return false; @@ -1515,52 +1512,44 @@ public class ConfigurationImpl implements Configuration, Serializable { if (bindingsDirectory == null) { if (other.bindingsDirectory != null) return false; - } - else if (!bindingsDirectory.equals(other.bindingsDirectory)) + } else if (!bindingsDirectory.equals(other.bindingsDirectory)) return false; if (bridgeConfigurations == null) { if (other.bridgeConfigurations != null) return false; - } - else if (!bridgeConfigurations.equals(other.bridgeConfigurations)) + } else if (!bridgeConfigurations.equals(other.bridgeConfigurations)) return false; if (broadcastGroupConfigurations == null) { if (other.broadcastGroupConfigurations != null) return false; - } - else if (!broadcastGroupConfigurations.equals(other.broadcastGroupConfigurations)) + } else if (!broadcastGroupConfigurations.equals(other.broadcastGroupConfigurations)) return false; if (clusterConfigurations == null) { if (other.clusterConfigurations != null) return false; - } - else if (!clusterConfigurations.equals(other.clusterConfigurations)) + } else if (!clusterConfigurations.equals(other.clusterConfigurations)) return false; if (clusterPassword == null) { if (other.clusterPassword != null) return false; - } - else if (!clusterPassword.equals(other.clusterPassword)) + } else if (!clusterPassword.equals(other.clusterPassword)) return false; if (clusterUser == null) { if (other.clusterUser != null) return false; - } - else if (!clusterUser.equals(other.clusterUser)) + } else if (!clusterUser.equals(other.clusterUser)) return false; if (connectionTTLOverride != other.connectionTTLOverride) return false; if (connectorConfigs == null) { if (other.connectorConfigs != null) return false; - } - else if (!connectorConfigs.equals(other.connectorConfigs)) + } else if (!connectorConfigs.equals(other.connectorConfigs)) return false; if (connectorServiceConfigurations == null) { if (other.connectorServiceConfigurations != null) return false; - } - else if (!connectorServiceConfigurations.equals(other.connectorServiceConfigurations)) + } else if (!connectorServiceConfigurations.equals(other.connectorServiceConfigurations)) return false; if (createBindingsDir != other.createBindingsDir) return false; @@ -1569,14 +1558,12 @@ public class ConfigurationImpl implements Configuration, Serializable { if (discoveryGroupConfigurations == null) { if (other.discoveryGroupConfigurations != null) return false; - } - else if (!discoveryGroupConfigurations.equals(other.discoveryGroupConfigurations)) + } else if (!discoveryGroupConfigurations.equals(other.discoveryGroupConfigurations)) return false; if (divertConfigurations == null) { if (other.divertConfigurations != null) return false; - } - else if (!divertConfigurations.equals(other.divertConfigurations)) + } else if (!divertConfigurations.equals(other.divertConfigurations)) return false; if (failoverOnServerShutdown != other.failoverOnServerShutdown) return false; @@ -1585,22 +1572,19 @@ public class ConfigurationImpl implements Configuration, Serializable { if (groupingHandlerConfiguration == null) { if (other.groupingHandlerConfiguration != null) return false; - } - else if (!groupingHandlerConfiguration.equals(other.groupingHandlerConfiguration)) + } else if (!groupingHandlerConfiguration.equals(other.groupingHandlerConfiguration)) return false; if (idCacheSize != other.idCacheSize) return false; if (incomingInterceptorClassNames == null) { if (other.incomingInterceptorClassNames != null) return false; - } - else if (!incomingInterceptorClassNames.equals(other.incomingInterceptorClassNames)) + } else if (!incomingInterceptorClassNames.equals(other.incomingInterceptorClassNames)) return false; if (jmxDomain == null) { if (other.jmxDomain != null) return false; - } - else if (!jmxDomain.equals(other.jmxDomain)) + } else if (!jmxDomain.equals(other.jmxDomain)) return false; if (jmxManagementEnabled != other.jmxManagementEnabled) return false; @@ -1619,8 +1603,7 @@ public class ConfigurationImpl implements Configuration, Serializable { if (journalDirectory == null) { if (other.journalDirectory != null) return false; - } - else if (!journalDirectory.equals(other.journalDirectory)) + } else if (!journalDirectory.equals(other.journalDirectory)) return false; if (journalFileSize != other.journalFileSize) return false; @@ -1641,22 +1624,19 @@ public class ConfigurationImpl implements Configuration, Serializable { if (largeMessagesDirectory == null) { if (other.largeMessagesDirectory != null) return false; - } - else if (!largeMessagesDirectory.equals(other.largeMessagesDirectory)) + } else if (!largeMessagesDirectory.equals(other.largeMessagesDirectory)) return false; if (logJournalWriteRate != other.logJournalWriteRate) return false; if (managementAddress == null) { if (other.managementAddress != null) return false; - } - else if (!managementAddress.equals(other.managementAddress)) + } else if (!managementAddress.equals(other.managementAddress)) return false; if (managementNotificationAddress == null) { if (other.managementNotificationAddress != null) return false; - } - else if (!managementNotificationAddress.equals(other.managementNotificationAddress)) + } else if (!managementNotificationAddress.equals(other.managementNotificationAddress)) return false; if (maskPassword != other.maskPassword) return false; @@ -1679,21 +1659,18 @@ public class ConfigurationImpl implements Configuration, Serializable { if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (outgoingInterceptorClassNames == null) { if (other.outgoingInterceptorClassNames != null) return false; - } - else if (!outgoingInterceptorClassNames.equals(other.outgoingInterceptorClassNames)) + } else if (!outgoingInterceptorClassNames.equals(other.outgoingInterceptorClassNames)) return false; if (pagingDirectory == null) { if (other.pagingDirectory != null) return false; - } - else if (!pagingDirectory.equals(other.pagingDirectory)) + } else if (!pagingDirectory.equals(other.pagingDirectory)) return false; if (persistDeliveryCountBeforeDelivery != other.persistDeliveryCountBeforeDelivery) return false; @@ -1704,8 +1681,7 @@ public class ConfigurationImpl implements Configuration, Serializable { if (queueConfigurations == null) { if (other.queueConfigurations != null) return false; - } - else if (!queueConfigurations.equals(other.queueConfigurations)) + } else if (!queueConfigurations.equals(other.queueConfigurations)) return false; if (runSyncSpeedTest != other.runSyncSpeedTest) return false; @@ -1720,8 +1696,7 @@ public class ConfigurationImpl implements Configuration, Serializable { if (securitySettings == null) { if (other.securitySettings != null) return false; - } - else if (!securitySettings.equals(other.securitySettings)) + } else if (!securitySettings.equals(other.securitySettings)) return false; if (serverDumpInterval != other.serverDumpInterval) return false; @@ -1829,8 +1804,7 @@ public class ConfigurationImpl implements Configuration, Serializable { private File subFolder(String subFolder) { try { return getBrokerInstance().toPath().resolve(subFolder).toFile(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileConfiguration.java index b0c7440f87..16e97452a4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileConfiguration.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.core.config.impl; +import javax.management.MBeanServer; import java.net.URL; import java.util.Map; @@ -26,8 +27,6 @@ import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.w3c.dom.Element; -import javax.management.MBeanServer; - /** * A {@code FileConfiguration} reads configuration values from a file. */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileSecurityConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileSecurityConfiguration.java index 8fb14c0a68..d778aa5643 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileSecurityConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/FileSecurityConfiguration.java @@ -69,8 +69,7 @@ public class FileSecurityConfiguration extends SecurityConfiguration { if (maskPassword) { if (passwordCodec != null) { codec = PasswordMaskingUtil.getDefaultCodec(); - } - else { + } else { codec = PasswordMaskingUtil.getCodec(passwordCodec); } } @@ -105,8 +104,7 @@ public class FileSecurityConfiguration extends SecurityConfiguration { String roles = roleProps.getProperty(username); if (roles == null) { ActiveMQServerLogger.LOGGER.cannotFindRoleForUser(username); - } - else { + } else { String[] split = roles.split(","); for (String role : split) { addRole(username, role.trim()); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java index 76b814d0ed..3a94067de8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java @@ -18,16 +18,15 @@ package org.apache.activemq.artemis.core.config.impl; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.Configuration; - -import org.apache.activemq.artemis.core.security.User; -import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; -import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.core.security.User; +import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; +import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule; + public class SecurityConfiguration extends Configuration { /** @@ -110,6 +109,6 @@ public class SecurityConfiguration extends Configuration { map.put(InVMLoginModule.CONFIG_PROP_NAME, this); AppConfigurationEntry appConfigurationEntry = new AppConfigurationEntry(name, AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, map); - return new AppConfigurationEntry[] {appConfigurationEntry}; + return new AppConfigurationEntry[]{appConfigurationEntry}; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java index ae8c5f337f..98bced30c5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java @@ -55,8 +55,7 @@ public final class Validators { Number val = (Number) value; if (val.doubleValue() > 0) { // OK - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.greaterThanZero(name, val); } } @@ -78,8 +77,7 @@ public final class Validators { Number val = (Number) value; if (val.doubleValue() >= 0) { // OK - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.greaterThanZero(name, val); } } @@ -91,8 +89,7 @@ public final class Validators { Number val = (Number) value; if (val.doubleValue() == -1 || val.doubleValue() > 0) { // OK - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.greaterThanMinusOne(name, val); } } @@ -104,8 +101,7 @@ public final class Validators { Number val = (Number) value; if (val.doubleValue() == -1 || val.doubleValue() >= 0) { // OK - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.greaterThanZeroOrMinusOne(name, val); } } @@ -117,8 +113,7 @@ public final class Validators { Number val = (Number) value; if (val.intValue() >= Thread.MIN_PRIORITY && val.intValue() <= Thread.MAX_PRIORITY) { // OK - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.mustbeBetween(name, Thread.MIN_PRIORITY, Thread.MAX_PRIORITY, value); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/Deployable.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/Deployable.java index 20a0c2e8f2..6ee59d6038 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/Deployable.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/Deployable.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.core.deployers; -import org.apache.activemq.artemis.core.server.ActiveMQComponent; -import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; -import org.w3c.dom.Element; - import javax.management.MBeanServer; import java.net.URL; import java.util.Map; +import org.apache.activemq.artemis.core.server.ActiveMQComponent; +import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; +import org.w3c.dom.Element; + /** * A Deployable is an object that can be configured via an xml configuration element in the main configuration file "broker.xml" * It holds all the information needed by the FileDeploymentManager to parse the configuration and build the component diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index f700e32965..d90c3437bb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -303,8 +303,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (maskText) { SensitiveDataCodec codec = PasswordMaskingUtil.getCodec(config.getPasswordCodec()); config.setClusterPassword(codec.decode(passwordText)); - } - else { + } else { config.setClusterPassword(passwordText); } } @@ -469,8 +468,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (s.equals(JournalType.NIO.toString())) { config.setJournalType(JournalType.NIO); - } - else if (s.equals(JournalType.ASYNCIO.toString())) { + } else if (s.equals(JournalType.ASYNCIO.toString())) { // https://jira.jboss.org/jira/browse/HORNETQ-295 // We do the check here to see if AIO is supported so we can use the correct defaults and/or use // correct settings in xml @@ -479,8 +477,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (supportsAIO) { config.setJournalType(JournalType.ASYNCIO); - } - else { + } else { if (validateAIO) { ActiveMQServerLogger.LOGGER.AIONotFound(); } @@ -505,8 +502,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { config.setJournalBufferTimeout_AIO(journalBufferTimeout); config.setJournalBufferSize_AIO(journalBufferSize); config.setJournalMaxIO_AIO(journalMaxIO); - } - else { + } else { config.setJournalBufferTimeout_NIO(journalBufferTimeout); config.setJournalBufferSize_NIO(journalBufferSize); config.setJournalMaxIO_NIO(journalMaxIO); @@ -664,35 +660,25 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { for (String role : roles) { if (SEND_NAME.equals(type)) { send.add(role.trim()); - } - else if (CONSUME_NAME.equals(type)) { + } else if (CONSUME_NAME.equals(type)) { consume.add(role.trim()); - } - else if (CREATEDURABLEQUEUE_NAME.equals(type)) { + } else if (CREATEDURABLEQUEUE_NAME.equals(type)) { createDurableQueue.add(role.trim()); - } - else if (DELETEDURABLEQUEUE_NAME.equals(type)) { + } else if (DELETEDURABLEQUEUE_NAME.equals(type)) { deleteDurableQueue.add(role.trim()); - } - else if (CREATE_NON_DURABLE_QUEUE_NAME.equals(type)) { + } else if (CREATE_NON_DURABLE_QUEUE_NAME.equals(type)) { createNonDurableQueue.add(role.trim()); - } - else if (DELETE_NON_DURABLE_QUEUE_NAME.equals(type)) { + } else if (DELETE_NON_DURABLE_QUEUE_NAME.equals(type)) { deleteNonDurableQueue.add(role.trim()); - } - else if (CREATETEMPQUEUE_NAME.equals(type)) { + } else if (CREATETEMPQUEUE_NAME.equals(type)) { createNonDurableQueue.add(role.trim()); - } - else if (DELETETEMPQUEUE_NAME.equals(type)) { + } else if (DELETETEMPQUEUE_NAME.equals(type)) { deleteNonDurableQueue.add(role.trim()); - } - else if (MANAGE_NAME.equals(type)) { + } else if (MANAGE_NAME.equals(type)) { manageRoles.add(role.trim()); - } - else if (BROWSE_NAME.equals(type)) { + } else if (BROWSE_NAME.equals(type)) { browseRoles.add(role.trim()); - } - else { + } else { ActiveMQServerLogger.LOGGER.rolePermissionConfigurationError(type); } if (!allRoles.contains(role.trim())) { @@ -753,84 +739,62 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (DEAD_LETTER_ADDRESS_NODE_NAME.equalsIgnoreCase(name)) { SimpleString queueName = new SimpleString(getTrimmedTextContent(child)); addressSettings.setDeadLetterAddress(queueName); - } - else if (EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(name)) { + } else if (EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(name)) { SimpleString queueName = new SimpleString(getTrimmedTextContent(child)); addressSettings.setExpiryAddress(queueName); - } - else if (EXPIRY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (EXPIRY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setExpiryDelay(XMLUtil.parseLong(child)); - } - else if (REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setRedeliveryDelay(XMLUtil.parseLong(child)); - } - else if (REDELIVERY_DELAY_MULTIPLIER_NODE_NAME.equalsIgnoreCase(name)) { + } else if (REDELIVERY_DELAY_MULTIPLIER_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setRedeliveryMultiplier(XMLUtil.parseDouble(child)); - } - else if (MAX_REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (MAX_REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setMaxRedeliveryDelay(XMLUtil.parseLong(child)); - } - else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) { + } else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setMaxSizeBytes(XMLUtil.parseLong(child)); - } - else if (PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) { + } else if (PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setPageSizeBytes(XMLUtil.parseLong(child)); - } - else if (PAGE_MAX_CACHE_SIZE_NODE_NAME.equalsIgnoreCase(name)) { + } else if (PAGE_MAX_CACHE_SIZE_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child)); - } - else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) { + } else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setMessageCounterHistoryDayLimit(XMLUtil.parseInt(child)); - } - else if (ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME.equalsIgnoreCase(name)) { String value = getTrimmedTextContent(child); Validators.ADDRESS_FULL_MESSAGE_POLICY_TYPE.validate(ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME, value); AddressFullMessagePolicy policy = Enum.valueOf(AddressFullMessagePolicy.class, value); addressSettings.setAddressFullMessagePolicy(policy); - } - else if (LVQ_NODE_NAME.equalsIgnoreCase(name)) { + } else if (LVQ_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setLastValueQueue(XMLUtil.parseBoolean(child)); - } - else if (MAX_DELIVERY_ATTEMPTS.equalsIgnoreCase(name)) { + } else if (MAX_DELIVERY_ATTEMPTS.equalsIgnoreCase(name)) { addressSettings.setMaxDeliveryAttempts(XMLUtil.parseInt(child)); - } - else if (REDISTRIBUTION_DELAY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (REDISTRIBUTION_DELAY_NODE_NAME.equalsIgnoreCase(name)) { addressSettings.setRedistributionDelay(XMLUtil.parseLong(child)); - } - else if (SEND_TO_DLA_ON_NO_ROUTE.equalsIgnoreCase(name)) { + } else if (SEND_TO_DLA_ON_NO_ROUTE.equalsIgnoreCase(name)) { addressSettings.setSendToDLAOnNoRoute(XMLUtil.parseBoolean(child)); - } - else if (SLOW_CONSUMER_THRESHOLD_NODE_NAME.equalsIgnoreCase(name)) { + } else if (SLOW_CONSUMER_THRESHOLD_NODE_NAME.equalsIgnoreCase(name)) { long slowConsumerThreshold = XMLUtil.parseLong(child); Validators.MINUS_ONE_OR_GT_ZERO.validate(SLOW_CONSUMER_THRESHOLD_NODE_NAME, slowConsumerThreshold); addressSettings.setSlowConsumerThreshold(slowConsumerThreshold); - } - else if (SLOW_CONSUMER_CHECK_PERIOD_NODE_NAME.equalsIgnoreCase(name)) { + } else if (SLOW_CONSUMER_CHECK_PERIOD_NODE_NAME.equalsIgnoreCase(name)) { long slowConsumerCheckPeriod = XMLUtil.parseLong(child); Validators.GT_ZERO.validate(SLOW_CONSUMER_CHECK_PERIOD_NODE_NAME, slowConsumerCheckPeriod); addressSettings.setSlowConsumerCheckPeriod(slowConsumerCheckPeriod); - } - else if (SLOW_CONSUMER_POLICY_NODE_NAME.equalsIgnoreCase(name)) { + } else if (SLOW_CONSUMER_POLICY_NODE_NAME.equalsIgnoreCase(name)) { String value = getTrimmedTextContent(child); Validators.SLOW_CONSUMER_POLICY_TYPE.validate(SLOW_CONSUMER_POLICY_NODE_NAME, value); SlowConsumerPolicy policy = Enum.valueOf(SlowConsumerPolicy.class, value); addressSettings.setSlowConsumerPolicy(policy); - } - else if (AUTO_CREATE_JMS_QUEUES.equalsIgnoreCase(name)) { + } else if (AUTO_CREATE_JMS_QUEUES.equalsIgnoreCase(name)) { addressSettings.setAutoCreateJmsQueues(XMLUtil.parseBoolean(child)); - } - else if (AUTO_DELETE_JMS_QUEUES.equalsIgnoreCase(name)) { + } else if (AUTO_DELETE_JMS_QUEUES.equalsIgnoreCase(name)) { addressSettings.setAutoDeleteJmsQueues(XMLUtil.parseBoolean(child)); - } - else if (AUTO_CREATE_JMS_TOPICS.equalsIgnoreCase(name)) { + } else if (AUTO_CREATE_JMS_TOPICS.equalsIgnoreCase(name)) { addressSettings.setAutoCreateJmsTopics(XMLUtil.parseBoolean(child)); - } - else if (AUTO_DELETE_JMS_TOPICS.equalsIgnoreCase(name)) { + } else if (AUTO_DELETE_JMS_TOPICS.equalsIgnoreCase(name)) { addressSettings.setAutoDeleteJmsTopics(XMLUtil.parseBoolean(child)); - } - else if (MANAGEMENT_BROWSE_PAGE_SIZE.equalsIgnoreCase(name)) { + } else if (MANAGEMENT_BROWSE_PAGE_SIZE.equalsIgnoreCase(name)) { addressSettings.setManagementBrowsePageSize(XMLUtil.parseInt(child)); } } @@ -853,8 +817,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { final String name = child.getNodeName(); if (MAX_CONNECTIONS_NODE_NAME.equalsIgnoreCase(name)) { resourceLimitSettings.setMaxConnections(XMLUtil.parseInt(child)); - } - else if (MAX_QUEUES_NODE_NAME.equalsIgnoreCase(name)) { + } else if (MAX_QUEUES_NODE_NAME.equalsIgnoreCase(name)) { resourceLimitSettings.setMaxQueues(XMLUtil.parseInt(child)); } } @@ -874,11 +837,9 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (child.getNodeName().equals("address")) { address = getTrimmedTextContent(child); - } - else if (child.getNodeName().equals("filter")) { + } else if (child.getNodeName().equals("filter")) { filterString = getAttributeValue(child, "string"); - } - else if (child.getNodeName().equals("durable")) { + } else if (child.getNodeName().equals("durable")) { durable = XMLUtil.parseBoolean(child); } } @@ -969,8 +930,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { Element storeNode = (Element) storeNodeList.item(0); if (storeNode.getTagName().equals("database-store")) { mainConfig.setStoreConfiguration(createDatabaseStoreConfig(storeNode)); - } - else if (storeNode.getTagName().equals("file-store")) { + } else if (storeNode.getTagName().equals("file-store")) { mainConfig.setStoreConfiguration(createFileStoreConfig(storeNode)); } } @@ -998,8 +958,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { Element colocatedNode = (Element) colocatedNodeList.item(0); mainConfig.setHAPolicyConfiguration(createColocatedHaPolicy(colocatedNode, true)); } - } - else if (haNode.getTagName().equals("shared-store")) { + } else if (haNode.getTagName().equals("shared-store")) { NodeList masterNodeList = e.getElementsByTagName("master"); if (masterNodeList.getLength() > 0) { Element masterNode = (Element) masterNodeList.item(0); @@ -1015,8 +974,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { Element colocatedNode = (Element) colocatedNodeList.item(0); mainConfig.setHAPolicyConfiguration(createColocatedHaPolicy(colocatedNode, false)); } - } - else if (haNode.getTagName().equals("live-only")) { + } else if (haNode.getTagName().equals("live-only")) { NodeList noneNodeList = e.getElementsByTagName("live-only"); Element noneNode = (Element) noneNodeList.item(0); mainConfig.setHAPolicyConfiguration(createLiveOnlyHaPolicy(noneNode)); @@ -1228,8 +1186,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (jgroupsFile != null) { endpointFactory = new JGroupsFileBroadcastEndpointFactory().setFile(jgroupsFile).setChannelName(jgroupsChannel); - } - else { + } else { endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort).setLocalBindAddress(localAddress).setLocalBindPort(localBindPort); } @@ -1261,8 +1218,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { BroadcastEndpointFactory endpointFactory; if (jgroupsFile != null) { endpointFactory = new JGroupsFileBroadcastEndpointFactory().setFile(jgroupsFile).setChannelName(jgroupsChannel); - } - else { + } else { endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort).setLocalBindAddress(localBindAddress).setLocalBindPort(localBindPort); } @@ -1272,16 +1228,15 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { ActiveMQServerLogger.LOGGER.discoveryGroupAlreadyDeployed(name); return; - } - else { + } else { mainConfig.getDiscoveryGroupConfigurations().put(name, config); } } - private void parseClusterConnectionConfigurationURI(final Element e, final Configuration mainConfig) throws Exception { + private void parseClusterConnectionConfigurationURI(final Element e, + final Configuration mainConfig) throws Exception { String name = e.getAttribute("name"); - String uri = e.getAttribute("address"); ClusterConnectionConfiguration config = mainConfig.addClusterConfiguration(name, uri); @@ -1304,12 +1259,10 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { boolean forwardWhenNoConsumers = getBoolean(e, "forward-when-no-consumers", ActiveMQDefaultConfiguration.isDefaultClusterForwardWhenNoConsumers()); if (forwardWhenNoConsumers) { messageLoadBalancingType = MessageLoadBalancingType.STRICT; - } - else { + } else { messageLoadBalancingType = MessageLoadBalancingType.ON_DEMAND; } - } - else { + } else { messageLoadBalancingType = Enum.valueOf(MessageLoadBalancingType.class, getString(e, "message-load-balancing", ActiveMQDefaultConfiguration.getDefaultClusterMessageLoadBalancingType(), Validators.MESSAGE_LOAD_BALANCING_TYPE)); } @@ -1359,8 +1312,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (child.getNodeName().equals("discovery-group-ref")) { discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue(); - } - else if (child.getNodeName().equals("static-connectors")) { + } else if (child.getNodeName().equals("static-connectors")) { Node attr = child.getAttributes().getNamedItem("allow-direct-connections-only"); if (attr != null) { allowDirectConnectionsOnly = "true".equalsIgnoreCase(attr.getNodeValue()) || allowDirectConnectionsOnly; @@ -1369,33 +1321,11 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { } } - ClusterConnectionConfiguration config = new ClusterConnectionConfiguration() - .setName(name) - .setAddress(address) - .setConnectorName(connectorName) - .setMinLargeMessageSize(minLargeMessageSize) - .setClientFailureCheckPeriod(clientFailureCheckPeriod) - .setConnectionTTL(connectionTTL) - .setRetryInterval(retryInterval) - .setRetryIntervalMultiplier(retryIntervalMultiplier) - .setMaxRetryInterval(maxRetryInterval) - .setInitialConnectAttempts(initialConnectAttempts) - .setReconnectAttempts(reconnectAttempts) - .setCallTimeout(callTimeout) - .setCallFailoverTimeout(callFailoverTimeout) - .setDuplicateDetection(duplicateDetection) - .setMessageLoadBalancingType(messageLoadBalancingType) - .setMaxHops(maxHops) - .setConfirmationWindowSize(confirmationWindowSize) - .setProducerWindowSize(producerWindowSize) - .setAllowDirectConnectionsOnly(allowDirectConnectionsOnly) - .setClusterNotificationInterval(clusterNotificationInterval) - .setClusterNotificationAttempts(clusterNotificationAttempts); + ClusterConnectionConfiguration config = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(connectorName).setMinLargeMessageSize(minLargeMessageSize).setClientFailureCheckPeriod(clientFailureCheckPeriod).setConnectionTTL(connectionTTL).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setMaxRetryInterval(maxRetryInterval).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setCallTimeout(callTimeout).setCallFailoverTimeout(callFailoverTimeout).setDuplicateDetection(duplicateDetection).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setAllowDirectConnectionsOnly(allowDirectConnectionsOnly).setClusterNotificationInterval(clusterNotificationInterval).setClusterNotificationAttempts(clusterNotificationAttempts); if (discoveryGroupName == null) { config.setStaticConnectors(staticConnectorNames); - } - else { + } else { config.setDiscoveryGroupName(discoveryGroupName); } @@ -1464,8 +1394,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { codec = PasswordMaskingUtil.getCodec(mainConfig.getPasswordCodec()); password = codec.decode(password); } - } - else { + } else { password = ActiveMQDefaultConfiguration.getDefaultClusterPassword(); } @@ -1484,41 +1413,18 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { if (child.getNodeName().equals("filter")) { filterString = child.getAttributes().getNamedItem("string").getNodeValue(); - } - else if (child.getNodeName().equals("discovery-group-ref")) { + } else if (child.getNodeName().equals("discovery-group-ref")) { discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue(); - } - else if (child.getNodeName().equals("static-connectors")) { + } else if (child.getNodeName().equals("static-connectors")) { getStaticConnectors(staticConnectorNames, child); } } - BridgeConfiguration config = new BridgeConfiguration() - .setName(name) - .setQueueName(queueName) - .setForwardingAddress(forwardingAddress) - .setFilterString(filterString) - .setTransformerClassName(transformerClassName) - .setMinLargeMessageSize(minLargeMessageSize) - .setClientFailureCheckPeriod(clientFailureCheckPeriod) - .setConnectionTTL(connectionTTL) - .setRetryInterval(retryInterval) - .setMaxRetryInterval(maxRetryInterval) - .setRetryIntervalMultiplier(retryIntervalMultiplier) - .setInitialConnectAttempts(initialConnectAttempts) - .setReconnectAttempts(reconnectAttempts) - .setReconnectAttemptsOnSameNode(reconnectAttemptsSameNode) - .setUseDuplicateDetection(useDuplicateDetection) - .setConfirmationWindowSize(confirmationWindowSize) - .setProducerWindowSize(producerWindowSize) - .setHA(ha) - .setUser(user) - .setPassword(password); + BridgeConfiguration config = new BridgeConfiguration().setName(name).setQueueName(queueName).setForwardingAddress(forwardingAddress).setFilterString(filterString).setTransformerClassName(transformerClassName).setMinLargeMessageSize(minLargeMessageSize).setClientFailureCheckPeriod(clientFailureCheckPeriod).setConnectionTTL(connectionTTL).setRetryInterval(retryInterval).setMaxRetryInterval(maxRetryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setReconnectAttemptsOnSameNode(reconnectAttemptsSameNode).setUseDuplicateDetection(useDuplicateDetection).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setHA(ha).setUser(user).setPassword(password); if (!staticConnectorNames.isEmpty()) { config.setStaticConnectors(staticConnectorNames); - } - else { + } else { config.setDiscoveryGroupName(discoveryGroupName); } @@ -1594,4 +1500,4 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { return new ConnectorServiceConfiguration().setFactoryClassName(clazz).setParams(params).setName(name); } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java index f807a183d1..b014b8608e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java @@ -17,16 +17,16 @@ package org.apache.activemq.artemis.core.filter.impl; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; -import org.apache.activemq.artemis.selector.filter.BooleanExpression; -import org.apache.activemq.artemis.selector.filter.FilterException; -import org.apache.activemq.artemis.selector.filter.Filterable; -import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.activemq.artemis.api.core.FilterConstants; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.ServerMessage; +import org.apache.activemq.artemis.selector.filter.BooleanExpression; +import org.apache.activemq.artemis.selector.filter.FilterException; +import org.apache.activemq.artemis.selector.filter.Filterable; +import org.apache.activemq.artemis.selector.impl.SelectorParser; /** * This class implements an ActiveMQ Artemis filter @@ -76,8 +76,7 @@ public class FilterImpl implements Filter { BooleanExpression booleanExpression; try { booleanExpression = SelectorParser.parse(filterStr.toString()); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.invalidFilter(filterStr); if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) { ActiveMQServerLogger.LOGGER.debug("Invalid filter", e); @@ -106,8 +105,7 @@ public class FilterImpl implements Filter { try { boolean result = booleanExpression.matches(new FilterableServerMessage(message)); return result; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.invalidFilter(sfilterString); if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) { ActiveMQServerLogger.LOGGER.debug("Invalid filter", e); @@ -136,8 +134,7 @@ public class FilterImpl implements Filter { if (sfilterString == null) { if (other.sfilterString != null) return false; - } - else if (!sfilterString.equals(other.sfilterString)) + } else if (!sfilterString.equals(other.sfilterString)) return false; return true; } @@ -153,26 +150,19 @@ public class FilterImpl implements Filter { if (FilterConstants.ACTIVEMQ_USERID.equals(fieldName)) { // It's the stringified (hex) representation of a user id that can be used in a selector expression return new SimpleString("ID:" + msg.getUserID()); - } - else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) { return Integer.valueOf(msg.getPriority()); - } - else if (FilterConstants.ACTIVEMQ_TIMESTAMP.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_TIMESTAMP.equals(fieldName)) { return msg.getTimestamp(); - } - else if (FilterConstants.ACTIVEMQ_DURABLE.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_DURABLE.equals(fieldName)) { return msg.isDurable() ? FilterConstants.DURABLE : FilterConstants.NON_DURABLE; - } - else if (FilterConstants.ACTIVEMQ_EXPIRATION.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_EXPIRATION.equals(fieldName)) { return msg.getExpiration(); - } - else if (FilterConstants.ACTIVEMQ_SIZE.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_SIZE.equals(fieldName)) { return msg.getEncodeSize(); - } - else if (FilterConstants.ACTIVEMQ_ADDRESS.equals(fieldName)) { + } else if (FilterConstants.ACTIVEMQ_ADDRESS.equals(fieldName)) { return msg.getAddress(); - } - else { + } else { return null; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java index 1a83081e79..021a6cef2c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java @@ -60,8 +60,7 @@ public abstract class AbstractControl extends StandardMBean { try { storageManager.waitOnOperations(); storageManager.clearContext(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AcceptorControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AcceptorControlImpl.java index ae7660b667..ce511eff88 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AcceptorControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AcceptorControlImpl.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.core.management.impl; -import java.util.Map; - import javax.management.MBeanAttributeInfo; import javax.management.MBeanOperationInfo; +import java.util.Map; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.AcceptorControl; @@ -55,8 +54,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { return configuration.getFactoryClassName(); - } - finally { + } finally { blockOnIO(); } } @@ -66,8 +64,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { return configuration.getName(); - } - finally { + } finally { blockOnIO(); } } @@ -77,8 +74,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { return configuration.getParams(); - } - finally { + } finally { blockOnIO(); } } @@ -88,8 +84,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { acceptor.reload(); - } - finally { + } finally { blockOnIO(); } } @@ -99,8 +94,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { return acceptor.isStarted(); - } - finally { + } finally { blockOnIO(); } } @@ -110,8 +104,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { acceptor.start(); - } - finally { + } finally { blockOnIO(); } } @@ -121,8 +114,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont clearIO(); try { acceptor.stop(); - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index 58b21c3104..48f43748bd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -141,8 +141,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.isStarted(); - } - finally { + } finally { blockOnIO(); } } @@ -154,8 +153,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getVersion().getFullVersion(); - } - finally { + } finally { blockOnIO(); } } @@ -167,8 +165,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getHAPolicy().isBackup(); - } - finally { + } finally { blockOnIO(); } } @@ -180,8 +177,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getHAPolicy().isSharedStore(); - } - finally { + } finally { blockOnIO(); } } @@ -193,8 +189,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getBindingsDirectory(); - } - finally { + } finally { blockOnIO(); } } @@ -205,8 +200,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getIncomingInterceptorClassNames().toArray(new String[configuration.getIncomingInterceptorClassNames().size()]); - } - finally { + } finally { blockOnIO(); } } @@ -218,8 +212,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getIncomingInterceptorClassNames().toArray(new String[configuration.getIncomingInterceptorClassNames().size()]); - } - finally { + } finally { blockOnIO(); } } @@ -231,8 +224,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getOutgoingInterceptorClassNames().toArray(new String[configuration.getOutgoingInterceptorClassNames().size()]); - } - finally { + } finally { blockOnIO(); } } @@ -244,8 +236,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalType() == JournalType.ASYNCIO ? configuration.getJournalBufferSize_AIO() : configuration.getJournalBufferSize_NIO(); - } - finally { + } finally { blockOnIO(); } } @@ -257,8 +248,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalType() == JournalType.ASYNCIO ? configuration.getJournalBufferTimeout_AIO() : configuration.getJournalBufferTimeout_NIO(); - } - finally { + } finally { blockOnIO(); } } @@ -273,8 +263,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active if (haPolicy instanceof SharedStoreSlavePolicy) { ((SharedStoreSlavePolicy) haPolicy).setFailoverOnServerShutdown(failoverOnServerShutdown); } - } - finally { + } finally { blockOnIO(); } } @@ -288,12 +277,10 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active HAPolicy haPolicy = server.getHAPolicy(); if (haPolicy instanceof SharedStoreSlavePolicy) { return ((SharedStoreSlavePolicy) haPolicy).isFailoverOnServerShutdown(); - } - else { + } else { return false; } - } - finally { + } finally { blockOnIO(); } } @@ -305,8 +292,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalType() == JournalType.ASYNCIO ? configuration.getJournalMaxIO_AIO() : configuration.getJournalMaxIO_NIO(); - } - finally { + } finally { blockOnIO(); } } @@ -318,8 +304,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalDirectory(); - } - finally { + } finally { blockOnIO(); } } @@ -331,8 +316,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalFileSize(); - } - finally { + } finally { blockOnIO(); } } @@ -344,8 +328,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalMinFiles(); - } - finally { + } finally { blockOnIO(); } } @@ -357,8 +340,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalCompactMinFiles(); - } - finally { + } finally { blockOnIO(); } } @@ -370,8 +352,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalCompactPercentage(); - } - finally { + } finally { blockOnIO(); } } @@ -383,8 +364,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isPersistenceEnabled(); - } - finally { + } finally { blockOnIO(); } } @@ -396,8 +376,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getJournalType().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -409,8 +388,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getPagingDirectory(); - } - finally { + } finally { blockOnIO(); } } @@ -422,8 +400,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getScheduledThreadPoolMaxSize(); - } - finally { + } finally { blockOnIO(); } } @@ -435,8 +412,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getThreadPoolMaxSize(); - } - finally { + } finally { blockOnIO(); } } @@ -448,8 +424,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getSecurityInvalidationInterval(); - } - finally { + } finally { blockOnIO(); } } @@ -461,8 +436,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isClustered(); - } - finally { + } finally { blockOnIO(); } } @@ -474,8 +448,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isCreateBindingsDir(); - } - finally { + } finally { blockOnIO(); } } @@ -487,8 +460,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isCreateJournalDir(); - } - finally { + } finally { blockOnIO(); } } @@ -500,8 +472,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isJournalSyncNonTransactional(); - } - finally { + } finally { blockOnIO(); } } @@ -513,8 +484,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isJournalSyncTransactional(); - } - finally { + } finally { blockOnIO(); } } @@ -526,8 +496,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isSecurityEnabled(); - } - finally { + } finally { blockOnIO(); } } @@ -539,8 +508,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isAsyncConnectionExecutionEnabled(); - } - finally { + } finally { blockOnIO(); } } @@ -552,8 +520,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getDiskScanPeriod(); - } - finally { + } finally { blockOnIO(); } } @@ -565,8 +532,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getMaxDiskUsage(); - } - finally { + } finally { blockOnIO(); } } @@ -578,8 +544,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.getGlobalMaxSize(); - } - finally { + } finally { blockOnIO(); } } @@ -591,8 +556,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { server.deployQueue(SimpleString.toSimpleString(address), new SimpleString(name), new SimpleString(filterString), true, false); - } - finally { + } finally { blockOnIO(); } } @@ -609,8 +573,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active try { server.deployQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false); - } - finally { + } finally { blockOnIO(); } } @@ -622,8 +585,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), null, true, false); - } - finally { + } finally { blockOnIO(); } } @@ -635,8 +597,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), null, durable, false); - } - finally { + } finally { blockOnIO(); } } @@ -656,8 +617,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false); - } - finally { + } finally { blockOnIO(); } } @@ -676,8 +636,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return names; - } - finally { + } finally { blockOnIO(); } } @@ -689,8 +648,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getUptime(); - } - finally { + } finally { blockOnIO(); } } @@ -702,8 +660,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getUptimeMillis(); - } - finally { + } finally { blockOnIO(); } } @@ -715,8 +672,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.isReplicaSync(); - } - finally { + } finally { blockOnIO(); } } @@ -735,8 +691,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return names; - } - finally { + } finally { blockOnIO(); } } @@ -750,8 +705,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active SimpleString queueName = new SimpleString(name); server.destroyQueue(queueName, null, true); - } - finally { + } finally { blockOnIO(); } } @@ -763,8 +717,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getConnectionCount(); - } - finally { + } finally { blockOnIO(); } } @@ -776,8 +729,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getTotalConnectionCount(); - } - finally { + } finally { blockOnIO(); } } @@ -789,8 +741,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getTotalMessageCount(); - } - finally { + } finally { blockOnIO(); } } @@ -802,8 +753,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getTotalMessagesAdded(); - } - finally { + } finally { blockOnIO(); } } @@ -815,8 +765,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getTotalMessagesAcknowledged(); - } - finally { + } finally { blockOnIO(); } } @@ -828,8 +777,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return server.getTotalConsumerCount(); - } - finally { + } finally { blockOnIO(); } } @@ -841,8 +789,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { setMessageCounterEnabled(true); - } - finally { + } finally { blockOnIO(); } } @@ -854,8 +801,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { setMessageCounterEnabled(false); - } - finally { + } finally { blockOnIO(); } } @@ -867,8 +813,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { messageCounterManager.resetAllCounters(); - } - finally { + } finally { blockOnIO(); } } @@ -880,8 +825,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { messageCounterManager.resetAllCounterHistories(); - } - finally { + } finally { blockOnIO(); } } @@ -893,8 +837,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return configuration.isMessageCounterEnabled(); - } - finally { + } finally { blockOnIO(); } } @@ -906,8 +849,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return messageCounterManager.getSamplePeriod(); - } - finally { + } finally { blockOnIO(); } } @@ -927,8 +869,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active if (messageCounterManager != null && newPeriod != messageCounterManager.getSamplePeriod()) { messageCounterManager.reschedule(newPeriod); } - } - finally { + } finally { blockOnIO(); } } @@ -940,8 +881,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { return messageCounterManager.getMaxDayCount(); - } - finally { + } finally { blockOnIO(); } } @@ -956,8 +896,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active throw ActiveMQMessageBundle.BUNDLE.greaterThanZero(count); } messageCounterManager.setMaxDayCount(count); - } - finally { + } finally { blockOnIO(); } } @@ -987,8 +926,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active s[i++] = dateFormat.format(creation) + " base64: " + XidImpl.toBase64String(xid) + " " + xid.toString(); } return s; - } - finally { + } finally { blockOnIO(); } } @@ -1028,8 +966,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active txDetailListJson.add(detail.toJSON()); } return txDetailListJson.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1111,8 +1048,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return html.toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1130,8 +1066,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active s[i++] = XidImpl.toBase64String(xid); } return s; - } - finally { + } finally { blockOnIO(); } } @@ -1149,8 +1084,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active s[i++] = XidImpl.toBase64String(xid); } return s; - } - finally { + } finally { blockOnIO(); } } @@ -1174,8 +1108,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } return false; - } - finally { + } finally { blockOnIO(); } } @@ -1200,8 +1133,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } return false; - } - finally { + } finally { blockOnIO(); } } @@ -1220,8 +1152,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active remoteAddresses[i++] = connection.getRemoteAddress(); } return remoteAddresses; - } - finally { + } finally { blockOnIO(); } @@ -1242,8 +1173,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } return remoteConnections.toArray(new String[remoteConnections.size()]); - } - finally { + } finally { blockOnIO(); } @@ -1267,8 +1197,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return closed; - } - finally { + } finally { blockOnIO(); } @@ -1304,11 +1233,9 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToCloseConsumerConnectionsForAddress(address, e); - } - finally { + } finally { blockOnIO(); } return closed; @@ -1338,8 +1265,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } } - } - finally { + } finally { blockOnIO(); } return closed; @@ -1358,8 +1284,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active connectionIDs[i++] = connection.getID().toString(); } return connectionIDs; - } - finally { + } finally { blockOnIO(); } } @@ -1377,8 +1302,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active sessionIDs[i++] = serverSession.getName(); } return sessionIDs; - } - finally { + } finally { blockOnIO(); } } @@ -1409,17 +1333,11 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active Set connections = server.getRemotingService().getConnections(); for (RemotingConnection connection : connections) { - JsonObjectBuilder obj = JsonLoader.createObjectBuilder() - .add("connectionID", connection.getID().toString()) - .add("clientAddress", connection.getRemoteAddress()) - .add("creationTime", connection.getCreationTime()) - .add("implementation", connection.getClass().getSimpleName()) - .add("sessionCount", server.getSessions(connection.getID().toString()).size()); + JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("connectionID", connection.getID().toString()).add("clientAddress", connection.getRemoteAddress()).add("creationTime", connection.getCreationTime()).add("implementation", connection.getClass().getSimpleName()).add("sessionCount", server.getSessions(connection.getID().toString()).size()); array.add(obj); } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1434,10 +1352,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active try { List sessions = server.getSessions(connectionID); for (ServerSession sess : sessions) { - JsonObjectBuilder obj = JsonLoader.createObjectBuilder() - .add("sessionID", sess.getName()) - .add("creationTime", sess.getCreationTime()) - .add("consumerCount", sess.getServerConsumers().size()); + JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("sessionID", sess.getName()).add("creationTime", sess.getCreationTime()).add("consumerCount", sess.getServerConsumers().size()); if (sess.getValidatedUser() != null) { obj.add("principal", sess.getValidatedUser()); @@ -1445,8 +1360,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active array.add(obj); } - } - finally { + } finally { blockOnIO(); } return array.build().toString(); @@ -1477,8 +1391,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1503,21 +1416,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } private JsonObject toJSONObject(ServerConsumer consumer) throws Exception { - JsonObjectBuilder obj = JsonLoader.createObjectBuilder() - .add("consumerID", consumer.getID()) - .add("connectionID", consumer.getConnectionID().toString()) - .add("sessionID", consumer.getSessionID()) - .add("queueName", consumer.getQueue().getName().toString()) - .add("browseOnly", consumer.isBrowseOnly()) - .add("creationTime", consumer.getCreationTime()) - .add("deliveringCount", consumer.getDeliveringMessages().size()); + JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", consumer.getID()).add("connectionID", consumer.getConnectionID().toString()).add("sessionID", consumer.getSessionID()).add("queueName", consumer.getQueue().getName().toString()).add("browseOnly", consumer.isBrowseOnly()).add("creationTime", consumer.getCreationTime()).add("deliveringCount", consumer.getDeliveringMessages().size()); if (consumer.getFilter() != null) { obj.add("filter", consumer.getFilter().getFilterString().toString()); } @@ -1547,8 +1452,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return ret; - } - finally { + } finally { blockOnIO(); } } @@ -1566,8 +1470,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return array.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1605,8 +1508,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active PersistedRoles persistedRoles = new PersistedRoles(addressMatch, sendRoles, consumeRoles, createDurableQueueRoles, deleteDurableQueueRoles, createNonDurableQueueRoles, deleteNonDurableQueueRoles, manageRoles, browseRoles); storageManager.storeSecurityRoles(persistedRoles); - } - finally { + } finally { blockOnIO(); } } @@ -1619,8 +1521,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active try { server.getSecurityRepository().removeMatch(addressMatch); storageManager.deleteSecurityRoles(new SimpleString(addressMatch)); - } - finally { + } finally { blockOnIO(); } } @@ -1642,8 +1543,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active objRoles[i++] = new Object[]{role.getName(), CheckType.SEND.hasRole(role), CheckType.CONSUME.hasRole(role), CheckType.CREATE_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_DURABLE_QUEUE.hasRole(role), CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), CheckType.MANAGE.hasRole(role)}; } return objRoles; - } - finally { + } finally { blockOnIO(); } } @@ -1661,8 +1561,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active json.add(role.toJson()); } return json.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1681,27 +1580,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active if (addressSettings.getExpiryAddress() != null) { settings.add("expiryAddress", addressSettings.getExpiryAddress().toString()); } - return settings - .add("expiryDelay", addressSettings.getExpiryDelay()) - .add("maxDeliveryAttempts", addressSettings.getMaxDeliveryAttempts()) - .add("pageCacheMaxSize", addressSettings.getPageCacheMaxSize()) - .add("maxSizeBytes", addressSettings.getMaxSizeBytes()) - .add("pageSizeBytes", addressSettings.getPageSizeBytes()) - .add("redeliveryDelay", addressSettings.getRedeliveryDelay()) - .add("redeliveryMultiplier", addressSettings.getRedeliveryMultiplier()) - .add("maxRedeliveryDelay", addressSettings.getMaxRedeliveryDelay()) - .add("redistributionDelay", addressSettings.getRedistributionDelay()) - .add("lastValueQueue", addressSettings.isLastValueQueue()) - .add("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute()) - .add("addressFullMessagePolicy", policy) - .add("slowConsumerThreshold", addressSettings.getSlowConsumerThreshold()) - .add("slowConsumerCheckPeriod", addressSettings.getSlowConsumerCheckPeriod()) - .add("slowConsumerPolicy", consumerPolicy) - .add("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues()) - .add("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues()) - .add("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics()) - .add("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsTopics()) - .build().toString(); + return settings.add("expiryDelay", addressSettings.getExpiryDelay()).add("maxDeliveryAttempts", addressSettings.getMaxDeliveryAttempts()).add("pageCacheMaxSize", addressSettings.getPageCacheMaxSize()).add("maxSizeBytes", addressSettings.getMaxSizeBytes()).add("pageSizeBytes", addressSettings.getPageSizeBytes()).add("redeliveryDelay", addressSettings.getRedeliveryDelay()).add("redeliveryMultiplier", addressSettings.getRedeliveryMultiplier()).add("maxRedeliveryDelay", addressSettings.getMaxRedeliveryDelay()).add("redistributionDelay", addressSettings.getRedistributionDelay()).add("lastValueQueue", addressSettings.isLastValueQueue()).add("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute()).add("addressFullMessagePolicy", policy).add("slowConsumerThreshold", addressSettings.getSlowConsumerThreshold()).add("slowConsumerCheckPeriod", addressSettings.getSlowConsumerCheckPeriod()).add("slowConsumerPolicy", consumerPolicy).add("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues()).add("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues()).add("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics()).add("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsTopics()).build().toString(); } @Override @@ -1754,28 +1633,22 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active addressSettings.setSendToDLAOnNoRoute(sendToDLAOnNoRoute); if (addressFullMessagePolicy == null) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); - } - else if (addressFullMessagePolicy.equalsIgnoreCase("PAGE")) { + } else if (addressFullMessagePolicy.equalsIgnoreCase("PAGE")) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); - } - else if (addressFullMessagePolicy.equalsIgnoreCase("DROP")) { + } else if (addressFullMessagePolicy.equalsIgnoreCase("DROP")) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP); - } - else if (addressFullMessagePolicy.equalsIgnoreCase("BLOCK")) { + } else if (addressFullMessagePolicy.equalsIgnoreCase("BLOCK")) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); - } - else if (addressFullMessagePolicy.equalsIgnoreCase("FAIL")) { + } else if (addressFullMessagePolicy.equalsIgnoreCase("FAIL")) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL); } addressSettings.setSlowConsumerThreshold(slowConsumerThreshold); addressSettings.setSlowConsumerCheckPeriod(slowConsumerCheckPeriod); if (slowConsumerPolicy == null) { addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY); - } - else if (slowConsumerPolicy.equalsIgnoreCase("NOTIFY")) { + } else if (slowConsumerPolicy.equalsIgnoreCase("NOTIFY")) { addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY); - } - else if (slowConsumerPolicy.equalsIgnoreCase("KILL")) { + } else if (slowConsumerPolicy.equalsIgnoreCase("KILL")) { addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.KILL); } addressSettings.setAutoCreateJmsQueues(autoCreateJmsQueues); @@ -1809,8 +1682,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active // on that case we ask the groupinghandler to replay its send in case it's waiting for the information handler.resendPending(); } - } - finally { + } finally { blockOnIO(); } } @@ -1829,8 +1701,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return names; - } - finally { + } finally { blockOnIO(); } } @@ -1849,8 +1720,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active try { DivertConfiguration config = new DivertConfiguration().setName(name).setRoutingName(routingName).setAddress(address).setForwardingAddress(forwardingAddress).setExclusive(exclusive).setFilterString(filterString).setTransformerClassName(transformerClassName); server.deployDivert(config); - } - finally { + } finally { blockOnIO(); } } @@ -1862,8 +1732,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { server.destroyDivert(SimpleString.toSimpleString(name)); - } - finally { + } finally { blockOnIO(); } } @@ -1882,8 +1751,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } return names; - } - finally { + } finally { blockOnIO(); } } @@ -1912,39 +1780,20 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { - BridgeConfiguration config = new BridgeConfiguration() - .setName(name) - .setQueueName(queueName) - .setForwardingAddress(forwardingAddress) - .setFilterString(filterString) - .setTransformerClassName(transformerClassName) - .setClientFailureCheckPeriod(clientFailureCheckPeriod) - .setRetryInterval(retryInterval) - .setRetryIntervalMultiplier(retryIntervalMultiplier) - .setInitialConnectAttempts(initialConnectAttempts) - .setReconnectAttempts(reconnectAttempts) - .setUseDuplicateDetection(useDuplicateDetection) - .setConfirmationWindowSize(confirmationWindowSize) - .setProducerWindowSize(producerWindowSize) - .setHA(ha) - .setUser(user) - .setPassword(password); + BridgeConfiguration config = new BridgeConfiguration().setName(name).setQueueName(queueName).setForwardingAddress(forwardingAddress).setFilterString(filterString).setTransformerClassName(transformerClassName).setClientFailureCheckPeriod(clientFailureCheckPeriod).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setUseDuplicateDetection(useDuplicateDetection).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setHA(ha).setUser(user).setPassword(password); if (useDiscoveryGroup) { config.setDiscoveryGroupName(staticConnectorsOrDiscoveryGroup); - } - else { + } else { config.setStaticConnectors(toList(staticConnectorsOrDiscoveryGroup)); } server.deployBridge(config); - } - finally { + } finally { blockOnIO(); } } - @Override public void createBridge(final String name, final String queueName, @@ -1968,33 +1817,16 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { - BridgeConfiguration config = new BridgeConfiguration() - .setName(name) - .setQueueName(queueName) - .setForwardingAddress(forwardingAddress) - .setFilterString(filterString) - .setTransformerClassName(transformerClassName) - .setClientFailureCheckPeriod(clientFailureCheckPeriod) - .setRetryInterval(retryInterval) - .setRetryIntervalMultiplier(retryIntervalMultiplier) - .setInitialConnectAttempts(initialConnectAttempts) - .setReconnectAttempts(reconnectAttempts) - .setUseDuplicateDetection(useDuplicateDetection) - .setConfirmationWindowSize(confirmationWindowSize) - .setHA(ha) - .setUser(user) - .setPassword(password); + BridgeConfiguration config = new BridgeConfiguration().setName(name).setQueueName(queueName).setForwardingAddress(forwardingAddress).setFilterString(filterString).setTransformerClassName(transformerClassName).setClientFailureCheckPeriod(clientFailureCheckPeriod).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setUseDuplicateDetection(useDuplicateDetection).setConfirmationWindowSize(confirmationWindowSize).setHA(ha).setUser(user).setPassword(password); if (useDiscoveryGroup) { config.setDiscoveryGroupName(staticConnectorsOrDiscoveryGroup); - } - else { + } else { config.setStaticConnectors(toList(staticConnectorsOrDiscoveryGroup)); } server.deployBridge(config); - } - finally { + } finally { blockOnIO(); } } @@ -2006,8 +1838,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { server.destroyBridge(name); - } - finally { + } finally { blockOnIO(); } } @@ -2029,8 +1860,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active for (Object id : ids) { duplicateIDCache.addToCache(((String) id).getBytes(), null); } - } - finally { + } finally { blockOnIO(); } } @@ -2068,8 +1898,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { broadcaster.removeNotificationListener(listener, filter, handback); - } - finally { + } finally { blockOnIO(); } } @@ -2079,8 +1908,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { broadcaster.removeNotificationListener(listener); - } - finally { + } finally { blockOnIO(); } } @@ -2092,8 +1920,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); try { broadcaster.addNotificationListener(listener, filter, handback); - } - finally { + } finally { blockOnIO(); } } @@ -2118,8 +1945,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active if (isStarted()) { if (configuration.isMessageCounterEnabled() && !enable) { stopMessageCounters(); - } - else if (!configuration.isMessageCounterEnabled() && enable) { + } else if (!configuration.isMessageCounterEnabled() && enable) { startMessageCounters(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java index af8abc34f7..bc0797374c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java @@ -88,11 +88,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro } } return queueNames.toArray(new String[queueNames.size()]); - } - catch (Throwable t) { + } catch (Throwable t) { throw new IllegalStateException(t.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -108,11 +106,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro bindingNames[i++] = binding.getUniqueName().toString(); } return bindingNames; - } - catch (Throwable t) { + } catch (Throwable t) { throw new IllegalStateException(t.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -130,8 +126,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro objRoles[i++] = new Object[]{role.getName(), CheckType.SEND.hasRole(role), CheckType.CONSUME.hasRole(role), CheckType.CREATE_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_DURABLE_QUEUE.hasRole(role), CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), CheckType.MANAGE.hasRole(role)}; } return objRoles; - } - finally { + } finally { blockOnIO(); } } @@ -147,8 +142,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro json.add(role.toJson()); } return json.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -158,8 +152,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro clearIO(); try { return pagingManager.getPageStore(address).getPageSizeBytes(); - } - finally { + } finally { blockOnIO(); } } @@ -169,8 +162,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro clearIO(); try { return pagingManager.getPageStore(address).getAddressSize(); - } - finally { + } finally { blockOnIO(); } } @@ -187,11 +179,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro } } return totalMsgs; - } - catch (Throwable t) { + } catch (Throwable t) { throw new IllegalStateException(t.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -201,8 +191,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro clearIO(); try { return pagingManager.getPageStore(address).isPaging(); - } - finally { + } finally { blockOnIO(); } } @@ -215,12 +204,10 @@ public class AddressControlImpl extends AbstractControl implements AddressContro if (!pageStore.isPaging()) { return 0; - } - else { + } else { return pagingManager.getPageStore(address).getNumberOfPages(); } - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java index 3130c86749..c0ef418397 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java @@ -18,14 +18,13 @@ package org.apache.activemq.artemis.core.management.impl; import javax.management.MBeanAttributeInfo; import javax.management.MBeanOperationInfo; +import java.util.List; import org.apache.activemq.artemis.api.core.management.BridgeControl; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.server.cluster.Bridge; -import java.util.List; - public class BridgeControlImpl extends AbstractControl implements BridgeControl { // Constants ----------------------------------------------------- @@ -56,8 +55,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl try { List staticConnectors = configuration.getStaticConnectors(); return staticConnectors.toArray(new String[staticConnectors.size()]); - } - finally { + } finally { blockOnIO(); } } @@ -67,8 +65,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getForwardingAddress(); - } - finally { + } finally { blockOnIO(); } } @@ -78,8 +75,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getQueueName(); - } - finally { + } finally { blockOnIO(); } } @@ -89,8 +85,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getDiscoveryGroupName(); - } - finally { + } finally { blockOnIO(); } } @@ -100,8 +95,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getFilterString(); - } - finally { + } finally { blockOnIO(); } } @@ -111,8 +105,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getReconnectAttempts(); - } - finally { + } finally { blockOnIO(); } } @@ -122,8 +115,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getName(); - } - finally { + } finally { blockOnIO(); } } @@ -133,8 +125,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getRetryInterval(); - } - finally { + } finally { blockOnIO(); } } @@ -144,8 +135,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getRetryIntervalMultiplier(); - } - finally { + } finally { blockOnIO(); } } @@ -155,8 +145,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.getTransformerClassName(); - } - finally { + } finally { blockOnIO(); } } @@ -166,8 +155,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return bridge.isStarted(); - } - finally { + } finally { blockOnIO(); } } @@ -177,8 +165,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.isUseDuplicateDetection(); - } - finally { + } finally { blockOnIO(); } } @@ -188,8 +175,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { return configuration.isHA(); - } - finally { + } finally { blockOnIO(); } } @@ -199,8 +185,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl clearIO(); try { bridge.start(); - } - finally { + } finally { blockOnIO(); } } @@ -211,8 +196,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl try { bridge.stop(); bridge.flushExecutor(); - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java index 7b206e8cdf..ddb8f01bde 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java @@ -20,9 +20,9 @@ import javax.management.MBeanAttributeInfo; import javax.management.MBeanOperationInfo; import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup; @@ -55,8 +55,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { return configuration.getName(); - } - finally { + } finally { blockOnIO(); } } @@ -66,8 +65,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { return configuration.getBroadcastPeriod(); - } - finally { + } finally { blockOnIO(); } } @@ -84,8 +82,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc } return ret; - } - finally { + } finally { blockOnIO(); } } @@ -95,8 +92,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString(); - } - finally { + } finally { blockOnIO(); } } @@ -110,8 +106,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc return ((UDPBroadcastEndpointFactory) configuration.getEndpointFactory()).getGroupAddress(); } throw new Exception("Invalid request because this is not a UDP Broadcast configuration."); - } - finally { + } finally { blockOnIO(); } } @@ -124,8 +119,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc return ((UDPBroadcastEndpointFactory) configuration.getEndpointFactory()).getGroupPort(); } throw new Exception("Invalid request because this is not a UDP Broadcast configuration."); - } - finally { + } finally { blockOnIO(); } } @@ -138,8 +132,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc return ((UDPBroadcastEndpointFactory) configuration.getEndpointFactory()).getLocalBindPort(); } throw new Exception("Invalid request because this is not a UDP Broadcast configuration."); - } - finally { + } finally { blockOnIO(); } } @@ -151,8 +144,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { return broadcastGroup.isStarted(); - } - finally { + } finally { blockOnIO(); } } @@ -162,8 +154,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { broadcastGroup.start(); - } - finally { + } finally { blockOnIO(); } } @@ -173,8 +164,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc clearIO(); try { broadcastGroup.stop(); - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java index f374c3f627..9186dbbf13 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java @@ -21,8 +21,8 @@ import javax.management.MBeanOperationInfo; import java.util.List; import java.util.Map; -import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl; import org.apache.activemq.artemis.api.core.JsonUtil; +import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl; import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; @@ -56,8 +56,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getAddress(); - } - finally { + } finally { blockOnIO(); } @@ -68,8 +67,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getDiscoveryGroupName(); - } - finally { + } finally { blockOnIO(); } @@ -80,8 +78,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getMaxHops(); - } - finally { + } finally { blockOnIO(); } @@ -92,8 +89,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getName(); - } - finally { + } finally { blockOnIO(); } @@ -104,8 +100,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getRetryInterval(); - } - finally { + } finally { blockOnIO(); } @@ -116,8 +111,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return clusterConnection.getNodeID(); - } - finally { + } finally { blockOnIO(); } } @@ -129,12 +123,10 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu List staticConnectors = configuration.getStaticConnectors(); if (staticConnectors == null) { return null; - } - else { + } else { return staticConnectors.toArray(new String[staticConnectors.size()]); } - } - finally { + } finally { blockOnIO(); } } @@ -144,8 +136,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return JsonUtil.toJsonArray(configuration.getStaticConnectors()).toString(); - } - finally { + } finally { blockOnIO(); } } @@ -155,8 +146,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.isDuplicateDetection(); - } - finally { + } finally { blockOnIO(); } } @@ -166,8 +156,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return configuration.getMessageLoadBalancingType().getType(); - } - finally { + } finally { blockOnIO(); } } @@ -177,8 +166,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return clusterConnection.getTopology().describe(); - } - finally { + } finally { blockOnIO(); } } @@ -188,8 +176,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return clusterConnection.getNodes(); - } - finally { + } finally { blockOnIO(); } } @@ -199,8 +186,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu clearIO(); try { return clusterConnection.isStarted(); - } - finally { + } finally { blockOnIO(); } } @@ -211,8 +197,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu try { clusterConnection.start(); clusterConnection.flushExecutor(); - } - finally { + } finally { blockOnIO(); } } @@ -223,8 +208,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu try { clusterConnection.stop(); clusterConnection.flushExecutor(); - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/DivertControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/DivertControlImpl.java index aacf8344b5..6c4777822f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/DivertControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/DivertControlImpl.java @@ -53,8 +53,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return configuration.getAddress(); - } - finally { + } finally { blockOnIO(); } } @@ -64,8 +63,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return configuration.getFilterString(); - } - finally { + } finally { blockOnIO(); } } @@ -75,8 +73,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return configuration.getForwardingAddress(); - } - finally { + } finally { blockOnIO(); } } @@ -86,8 +83,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return divert.getRoutingName().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -97,8 +93,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return configuration.getTransformerClassName(); - } - finally { + } finally { blockOnIO(); } } @@ -108,8 +103,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return divert.getUniqueName().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -119,8 +113,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl clearIO(); try { return divert.isExclusive(); - } - finally { + } finally { blockOnIO(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/MBeanInfoHelper.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/MBeanInfoHelper.java index eb6194e96a..07fc9a83ab 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/MBeanInfoHelper.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/MBeanInfoHelper.java @@ -69,12 +69,7 @@ public class MBeanInfoHelper { MBeanAttributeInfo infoToCopy = info1; for (MBeanAttributeInfo info2 : tempAttributes) { if (info1.getName().equals(info2.getName()) && !info1.equals(info2)) { - infoToCopy = new MBeanAttributeInfo(info1.getName(), - info1.getType().equals("void") ? info2.getType() : info1.getType(), - info1.getDescription(), - (info1.isReadable() || info2.isReadable()), - (info1.isWritable() || info2.isWritable()), - (info1.isIs() || info2.isIs())); + infoToCopy = new MBeanAttributeInfo(info1.getName(), info1.getType().equals("void") ? info2.getType() : info1.getType(), info1.getDescription(), (info1.isReadable() || info2.isReadable()), (info1.isWritable() || info2.isWritable()), (info1.isIs() || info2.isIs())); } } if (!alreadyAdded.contains(infoToCopy.getName())) { @@ -107,8 +102,7 @@ public class MBeanInfoHelper { method.getParameterTypes().length == 1 && method.getReturnType().equals(void.class)) { return true; - } - else { + } else { return false; } } @@ -118,8 +112,7 @@ public class MBeanInfoHelper { method.getParameterTypes().length == 0 && method.getReturnType().equals(boolean.class)) { return true; - } - else { + } else { return false; } } @@ -149,7 +142,7 @@ public class MBeanInfoHelper { description = operation.getAnnotation(Attribute.class).desc(); } - MBeanAttributeInfo info = new MBeanAttributeInfo(getAttributeName(operation), operation.getReturnType().getName(), description, (isGetterMethod(operation) || isIsBooleanMethod(operation)), isSetterMethod(operation), isIsBooleanMethod(operation)); + MBeanAttributeInfo info = new MBeanAttributeInfo(getAttributeName(operation), operation.getReturnType().getName(), description, (isGetterMethod(operation) || isIsBooleanMethod(operation)), isSetterMethod(operation), isIsBooleanMethod(operation)); return info; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java index e1e9628675..7275ea4fb0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java @@ -137,8 +137,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getName().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -159,8 +158,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { Filter filter = queue.getFilter(); return filter != null ? filter.getFilterString().toString() : null; - } - finally { + } finally { blockOnIO(); } } @@ -172,8 +170,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.isDurable(); - } - finally { + } finally { blockOnIO(); } } @@ -185,8 +182,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.isTemporary(); - } - finally { + } finally { blockOnIO(); } } @@ -198,8 +194,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getMessageCount(); - } - finally { + } finally { blockOnIO(); } } @@ -211,8 +206,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getConsumerCount(); - } - finally { + } finally { blockOnIO(); } } @@ -224,8 +218,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getDeliveringCount(); - } - finally { + } finally { blockOnIO(); } } @@ -237,8 +230,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getMessagesAdded(); - } - finally { + } finally { blockOnIO(); } } @@ -250,8 +242,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getMessagesAcknowledged(); - } - finally { + } finally { blockOnIO(); } } @@ -263,8 +254,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getMessagesExpired(); - } - finally { + } finally { blockOnIO(); } } @@ -276,8 +266,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getMessagesKilled(); - } - finally { + } finally { blockOnIO(); } } @@ -289,8 +278,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getID(); - } - finally { + } finally { blockOnIO(); } } @@ -302,8 +290,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.getScheduledCount(); - } - finally { + } finally { blockOnIO(); } } @@ -320,8 +307,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { return addressSettings.getDeadLetterAddress().toString(); } return null; - } - finally { + } finally { blockOnIO(); } } @@ -336,12 +322,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { if (addressSettings != null && addressSettings.getExpiryAddress() != null) { return addressSettings.getExpiryAddress().toString(); - } - else { + } else { return null; } - } - finally { + } finally { blockOnIO(); } } @@ -354,8 +338,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { try { List refs = queue.getScheduledMessages(); return convertMessagesToMaps(refs); - } - finally { + } finally { blockOnIO(); } } @@ -367,8 +350,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return QueueControlImpl.toJSON(listScheduledMessages()); - } - finally { + } finally { blockOnIO(); } } @@ -401,8 +383,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { msgRet.put(entry.getKey(), convertMessagesToMaps(entry.getValue())); } return msgRet; - } - finally { + } finally { blockOnIO(); } @@ -415,8 +396,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return QueueControlImpl.toJSON(listDeliveringMessages()); - } - finally { + } finally { blockOnIO(); } } @@ -440,11 +420,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { } return messages.toArray(new Map[messages.size()]); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -456,8 +434,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return QueueControlImpl.toJSON(listMessages(filter)); - } - finally { + } finally { blockOnIO(); } } @@ -478,8 +455,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { } return messages.toArray(new Map[1]); } - } - finally { + } finally { blockOnIO(); } @@ -522,8 +498,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { Filter filter = FilterImpl.createFilter(filterStr); if (filter == null) { return getMessageCount(); - } - else { + } else { try (LinkedListIterator iterator = queue.totalIterator()) { int count = 0; while (iterator.hasNext()) { @@ -535,8 +510,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { return count; } } - } - finally { + } finally { blockOnIO(); } } @@ -548,11 +522,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.deleteReference(messageID); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -571,8 +543,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { Filter filter = FilterImpl.createFilter(filterStr); return queue.deleteMatchingReferences(flushLimit, filter); - } - finally { + } finally { blockOnIO(); } } @@ -584,8 +555,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.expireReference(messageID); - } - finally { + } finally { blockOnIO(); } } @@ -598,11 +568,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { try { Filter filter = FilterImpl.createFilter(filterStr); return queue.expireReferences(filter); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -627,8 +595,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { }; return queue.retryMessages(singleMessageFilter) > 0; - } - finally { + } finally { blockOnIO(); } } @@ -640,8 +607,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { try { return queue.retryMessages(null); - } - finally { + } finally { blockOnIO(); } } @@ -666,8 +632,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { } return queue.moveReference(messageID, binding.getAddress(), rejectDuplicates); - } - finally { + } finally { blockOnIO(); } @@ -698,8 +663,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { int retValue = queue.moveReferences(flushLimit, filter, binding.getAddress(), rejectDuplicates); return retValue; - } - finally { + } finally { blockOnIO(); } @@ -721,8 +685,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { Filter filter = FilterImpl.createFilter(filterStr); return queue.sendMessagesToDeadLetterAddress(filter); - } - finally { + } finally { blockOnIO(); } } @@ -732,7 +695,8 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { final int type, final String body, final String userID, - boolean durable, final String user, + boolean durable, + final String user, final String password) throws Exception { securityStore.check(queue.getAddress(), CheckType.SEND, new SecurityAuth() { @Override @@ -763,7 +727,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { } message.setAddress(queue.getAddress()); postOffice.route(message, null, true); - return "" + message.getMessageID(); + return "" + message.getMessageID(); } @Override @@ -773,8 +737,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.sendMessageToDeadLetterAddress(messageID); - } - finally { + } finally { blockOnIO(); } } @@ -791,8 +754,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { Filter filter = FilterImpl.createFilter(filterStr); return queue.changeReferencesPriority(filter, (byte) newPriority); - } - finally { + } finally { blockOnIO(); } } @@ -807,8 +769,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { throw ActiveMQMessageBundle.BUNDLE.invalidNewPriority(newPriority); } return queue.changeReferencePriority(messageID, (byte) newPriority); - } - finally { + } finally { blockOnIO(); } } @@ -820,11 +781,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return MessageCounterInfo.toJSon(counter); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); - } - finally { + } finally { blockOnIO(); } } @@ -836,8 +795,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { counter.resetCounter(); - } - finally { + } finally { blockOnIO(); } } @@ -849,8 +807,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return MessageCounterHelper.listMessageCounterAsHTML(new MessageCounter[]{counter}); - } - finally { + } finally { blockOnIO(); } } @@ -862,8 +819,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return MessageCounterHelper.listMessageCounterHistory(counter); - } - finally { + } finally { blockOnIO(); } } @@ -875,8 +831,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return MessageCounterHelper.listMessageCounterHistoryAsHTML(new MessageCounter[]{counter}); - } - finally { + } finally { blockOnIO(); } } @@ -888,8 +843,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.pause(); - } - finally { + } finally { blockOnIO(); } } @@ -901,8 +855,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.resume(); - } - finally { + } finally { blockOnIO(); } } @@ -914,8 +867,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { return queue.isPaused(); - } - finally { + } finally { blockOnIO(); } } @@ -943,11 +895,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { c.toArray(rc); return rc; } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new IllegalStateException(e.getMessage()); - } - finally { + } finally { blockOnIO(); } } @@ -959,8 +909,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.flushExecutor(); - } - finally { + } finally { blockOnIO(); } } @@ -980,12 +929,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { if (consumer instanceof ServerConsumer) { ServerConsumer serverConsumer = (ServerConsumer) consumer; - JsonObjectBuilder obj = JsonLoader.createObjectBuilder() - .add("consumerID", serverConsumer.getID()) - .add("connectionID", serverConsumer.getConnectionID().toString()) - .add("sessionID", serverConsumer.getSessionID()) - .add("browseOnly", serverConsumer.isBrowseOnly()) - .add("creationTime", serverConsumer.getCreationTime()); + JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", serverConsumer.getID()).add("connectionID", serverConsumer.getConnectionID().toString()).add("sessionID", serverConsumer.getSessionID()).add("browseOnly", serverConsumer.isBrowseOnly()).add("creationTime", serverConsumer.getCreationTime()); jsonArray.add(obj); } @@ -993,8 +937,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { } return jsonArray.build().toString(); - } - finally { + } finally { blockOnIO(); } } @@ -1016,8 +959,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.resetMessagesAdded(); - } - finally { + } finally { blockOnIO(); } @@ -1030,8 +972,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.resetMessagesAcknowledged(); - } - finally { + } finally { blockOnIO(); } @@ -1044,8 +985,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.resetMessagesExpired(); - } - finally { + } finally { blockOnIO(); } @@ -1058,8 +998,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl { clearIO(); try { queue.resetMessagesKilled(); - } - finally { + } finally { blockOnIO(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/CompositeDataConstants.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/CompositeDataConstants.java index d34165e0f1..6d85d893ee 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/CompositeDataConstants.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/CompositeDataConstants.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -43,7 +42,6 @@ public interface CompositeDataConstants { String BODY_DESCRIPTION = "The message body"; String PROPERTIES_DESCRIPTION = "The properties text"; - // User properties String STRING_PROPERTIES = "StringProperties"; String BOOLEAN_PROPERTIES = "BooleanProperties"; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java index 7bb37647df..41e26327b3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.core.management.impl.openmbean; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.server.MessageReference; - import javax.management.openmbean.ArrayType; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataSupport; @@ -36,6 +31,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.server.MessageReference; + public final class OpenTypeSupport { private static MessageOpenTypeFactory FACTORY = new MessageOpenTypeFactory(); @@ -49,8 +49,8 @@ public final class OpenTypeSupport { return new CompositeDataSupport(ct, fields); } - static class MessageOpenTypeFactory { + private CompositeType compositeType; private final List itemNamesList = new ArrayList<>(); private final List itemDescriptionsList = new ArrayList<>(); @@ -123,8 +123,7 @@ public final class OpenTypeSupport { rc.put(CompositeDataConstants.MESSAGE_ID, "" + m.getMessageID()); if (m.getUserID() != null) { rc.put(CompositeDataConstants.USER_ID, "ID:" + m.getUserID().toString()); - } - else { + } else { rc.put(CompositeDataConstants.USER_ID, ""); } rc.put(CompositeDataConstants.ADDRESS, m.getAddress().toString()); @@ -146,50 +145,42 @@ public final class OpenTypeSupport { try { rc.put(CompositeDataConstants.STRING_PROPERTIES, createTabularData(propertyMap, stringPropertyTabularType, String.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.STRING_PROPERTIES, new TabularDataSupport(stringPropertyTabularType)); } try { rc.put(CompositeDataConstants.BOOLEAN_PROPERTIES, createTabularData(propertyMap, booleanPropertyTabularType, Boolean.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.BOOLEAN_PROPERTIES, new TabularDataSupport(booleanPropertyTabularType)); } try { rc.put(CompositeDataConstants.BYTE_PROPERTIES, createTabularData(propertyMap, bytePropertyTabularType, Byte.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.BYTE_PROPERTIES, new TabularDataSupport(bytePropertyTabularType)); } try { rc.put(CompositeDataConstants.SHORT_PROPERTIES, createTabularData(propertyMap, shortPropertyTabularType, Short.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.SHORT_PROPERTIES, new TabularDataSupport(shortPropertyTabularType)); } try { rc.put(CompositeDataConstants.INT_PROPERTIES, createTabularData(propertyMap, intPropertyTabularType, Integer.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.INT_PROPERTIES, new TabularDataSupport(intPropertyTabularType)); } try { rc.put(CompositeDataConstants.LONG_PROPERTIES, createTabularData(propertyMap, longPropertyTabularType, Long.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.LONG_PROPERTIES, new TabularDataSupport(longPropertyTabularType)); } try { rc.put(CompositeDataConstants.FLOAT_PROPERTIES, createTabularData(propertyMap, floatPropertyTabularType, Float.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.FLOAT_PROPERTIES, new TabularDataSupport(floatPropertyTabularType)); } try { rc.put(CompositeDataConstants.DOUBLE_PROPERTIES, createTabularData(propertyMap, doublePropertyTabularType, Double.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.DOUBLE_PROPERTIES, new TabularDataSupport(doublePropertyTabularType)); } return rc; @@ -221,7 +212,9 @@ public final class OpenTypeSupport { return new TabularType(typeName, typeName, rowType, new String[]{"key"}); } - protected TabularDataSupport createTabularData(Map entries, TabularType type, Class valueType) throws IOException, OpenDataException { + protected TabularDataSupport createTabularData(Map entries, + TabularType type, + Class valueType) throws IOException, OpenDataException { TabularDataSupport answer = new TabularDataSupport(type); for (String key : entries.keySet()) { @@ -229,8 +222,7 @@ public final class OpenTypeSupport { if (valueType.isInstance(value)) { CompositeDataSupport compositeData = createTabularRowValue(type, key, value); answer.put(compositeData); - } - else if (valueType == String.class && value instanceof SimpleString) { + } else if (valueType == String.class && value instanceof SimpleString) { CompositeDataSupport compositeData = createTabularRowValue(type, key, value.toString()); answer.put(compositeData); } @@ -238,14 +230,15 @@ public final class OpenTypeSupport { return answer; } - protected CompositeDataSupport createTabularRowValue(TabularType type, String key, Object value) throws OpenDataException { + protected CompositeDataSupport createTabularRowValue(TabularType type, + String key, + Object value) throws OpenDataException { Map fields = new HashMap<>(); fields.put("key", key); fields.put("value", value); return new CompositeDataSupport(type.getRowType(), fields); } - protected void addItem(String name, String description, OpenType type) { itemNamesList.add(name); itemDescriptionsList.add(description); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java index 9ceb8eaf13..522445dea0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java @@ -232,12 +232,10 @@ public class MessageCounter { // create initial day counter when empty bInitialize = dayCounters.isEmpty(); - } - else if (dayCounterMax == 0) { + } else if (dayCounterMax == 0) { // disable history dayCounters.clear(); - } - else { + } else { // unlimited day history // create initial day counter when empty @@ -418,12 +416,10 @@ public class MessageCounter { if (i < hour) { if (isStartDay) { counters[i] = -1; - } - else { + } else { counters[i] = 0; } - } - else { + } else { counters[i] = -1; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java index 9cf41adaee..1688985b29 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java @@ -141,8 +141,7 @@ public class MessageCounterHelper { if (value == -1) { ret.append(""); - } - else { + } else { ret.append("" + value + ""); total += value; @@ -172,8 +171,7 @@ public class MessageCounterHelper { private static String asDate(final long time) { if (time > 0) { return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(time)); - } - else { + } else { return "-"; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java index a5c1be40d3..1fd4fbe802 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java @@ -48,7 +48,7 @@ public class MessageCounterManagerImpl implements MessageCounterManager { public MessageCounterManagerImpl(final ScheduledExecutorService scheduledThreadPool, Executor executor) { messageCounters = new HashMap<>(); - messageCountersPinger = new MessageCountersPinger(scheduledThreadPool, executor, MessageCounterManagerImpl.DEFAULT_SAMPLE_PERIOD, TimeUnit.MILLISECONDS, false); + messageCountersPinger = new MessageCountersPinger(scheduledThreadPool, executor, MessageCounterManagerImpl.DEFAULT_SAMPLE_PERIOD, TimeUnit.MILLISECONDS, false); } @Override @@ -129,10 +129,10 @@ public class MessageCounterManagerImpl implements MessageCounterManager { private class MessageCountersPinger extends ActiveMQScheduledComponent { MessageCountersPinger(ScheduledExecutorService scheduledExecutorService, - Executor executor, - long checkPeriod, - TimeUnit timeUnit, - boolean onDemand) { + Executor executor, + long checkPeriod, + TimeUnit timeUnit, + boolean onDemand) { super(scheduledExecutorService, executor, checkPeriod, timeUnit, onDemand); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java index b70626a27b..5505412254 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java @@ -95,8 +95,10 @@ public interface PagingManager extends ActiveMQComponent, HierarchicalRepository */ void unlock(); - /** Add size at the global count level. - * if totalSize > globalMaxSize it will return true */ + /** + * Add size at the global count level. + * if totalSize > globalMaxSize it will return true + */ PagingManager addSize(int size); boolean isUsingGlobalSize(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java index a4a41efabc..3ae7f75414 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java @@ -130,7 +130,9 @@ public interface PagingStore extends ActiveMQComponent { boolean isRejectingMessages(); - /** It will return true if the destination is leaving blocking. */ + /** + * It will return true if the destination is leaving blocking. + */ boolean checkReleasedMemory(); /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java index 942ff80500..a90fd447e8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java @@ -34,7 +34,10 @@ public interface PagingStoreFactory { PagingStore newStore(SimpleString address, AddressSettings addressSettings); - PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, Executor executor); + PageCursorProvider newCursorProvider(PagingStore store, + StorageManager storageManager, + AddressSettings addressSettings, + Executor executor); void stop() throws InterruptedException; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java index 73a22cea3a..9b4c41e57e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java @@ -17,9 +17,11 @@ package org.apache.activemq.artemis.core.paging.cursor; -/** This is an internal exception. - * In certain cases AfterCommit could try to decrease the reference counting on large messages. - * But if the whole page is cleaned an exception could happen, which is ok on that path, and we need to identify it. */ +/** + * This is an internal exception. + * In certain cases AfterCommit could try to decrease the reference counting on large messages. + * But if the whole page is cleaned an exception could happen, which is ok on that path, and we need to identify it. + */ public class NonExistentPage extends RuntimeException { public NonExistentPage() { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java index b2a6affc7b..fd20952690 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java @@ -24,7 +24,9 @@ import org.apache.activemq.artemis.core.paging.PagedMessage; */ public interface PageCursorProvider { - /** Used on tests, to simulate a scenario where the VM cleared space */ + /** + * Used on tests, to simulate a scenario where the VM cleared space + */ void clearCache(); PageCache getPageCache(long pageNr); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java index a447569caa..768b43fb64 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java @@ -96,8 +96,7 @@ public class PagedReferenceImpl implements PagedReference { if (message == null) { this.messageEstimate = -1; - } - else { + } else { this.messageEstimate = message.getMessage().getMemoryEstimate(); } this.message = new WeakReference<>(message); @@ -124,8 +123,7 @@ public class PagedReferenceImpl implements PagedReference { if (messageEstimate < 0) { try { messageEstimate = getMessage().getMemoryEstimate(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -144,12 +142,10 @@ public class PagedReferenceImpl implements PagedReference { ServerMessage msg = getMessage(); if (msg.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) { deliveryTime = getMessage().getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME); - } - else { + } else { deliveryTime = 0L; } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return 0L; } @@ -223,8 +219,7 @@ public class PagedReferenceImpl implements PagedReference { public void acknowledge(Transaction tx, AckReason reason) throws Exception { if (tx == null) { getQueue().acknowledge(this, reason); - } - else { + } else { getQueue().acknowledge(tx, this, reason); } } @@ -237,8 +232,7 @@ public class PagedReferenceImpl implements PagedReference { String msgToString; try { msgToString = getPagedMessage().toString(); - } - catch (Throwable e) { + } catch (Throwable e) { // in case of an exception because of a missing page, we just want toString to return null msgToString = "error:" + e.getMessage(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java index 0d63cf028e..57d2e27608 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java @@ -64,8 +64,7 @@ public class LivePageCacheImpl implements LivePageCache { public synchronized PagedMessage getMessage(int messageNumber) { if (messageNumber < messages.size()) { return messages.get(messageNumber); - } - else { + } else { return null; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java index 8fd59d7c80..5925caf620 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java @@ -47,8 +47,7 @@ class PageCacheImpl implements PageCache { public PagedMessage getMessage(final int messageNumber) { if (messageNumber < messages.length) { return messages[messageNumber]; - } - else { + } else { return null; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java index b7c3e2e505..76ad26b255 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java @@ -154,8 +154,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { } return cache; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -170,14 +169,12 @@ public class PageCursorProviderImpl implements PageCursorProvider { List pgdMessages = page.read(storageManager); cache.setMessages(pgdMessages.toArray(new PagedMessage[pgdMessages.size()])); - } - finally { + } finally { try { if (page != null) { page.close(false); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } storageManager.afterPageRead(); } @@ -293,8 +290,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (cleanupEnabled) { cleanup(); } - } - finally { + } finally { storageManager.clearContext(); scheduledCleanup.decrementAndGet(); } @@ -316,16 +312,14 @@ public class PageCursorProviderImpl implements PageCursorProvider { for (PageSubscription sub : subscriptions) { try { sub.onPageModeCleared(tx); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while cleaning paging on queue " + sub.getQueue().getName(), e); } } try { tx.commit(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while cleaning page, during the commit", e); } } @@ -402,35 +396,31 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (pagingStore.getNumberOfPages() == 0 || pagingStore.getNumberOfPages() == 1 && pagingStore.getCurrentPage().getNumberOfMessages() == 0) { pagingStore.stopPaging(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("Couldn't cleanup page on address " + this.pagingStore.getAddress() + - " as numberOfPages == " + - pagingStore.getNumberOfPages() + - " and currentPage.numberOfMessages = " + - pagingStore.getCurrentPage().getNumberOfMessages()); + " as numberOfPages == " + + pagingStore.getNumberOfPages() + + " and currentPage.numberOfMessages = " + + pagingStore.getCurrentPage().getNumberOfMessages()); } } - } - catch (Exception ex) { + } catch (Exception ex) { ActiveMQServerLogger.LOGGER.problemCleaningPageAddress(ex, pagingStore.getAddress()); return; - } - finally { + } finally { pagingStore.unlock(); } } finishCleanup(depagedPages); - } // Protected as a way to inject testing protected void cleanupComplete(ArrayList cursorList) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Address " + pagingStore.getAddress() + - " is leaving page mode as all messages are consumed and acknowledged from the page store"); + " is leaving page mode as all messages are consumed and acknowledged from the page store"); } pagingStore.forceAnotherPage(); @@ -467,20 +457,17 @@ public class PageCursorProviderImpl implements PageCursorProvider { try { depagedPage.open(); pgdMessagesList = depagedPage.read(storageManager); - } - finally { + } finally { try { depagedPage.close(false); - } - catch (Exception e) { + } catch (Exception e) { } storageManager.afterPageRead(); } depagedPage.close(false); pgdMessages = pgdMessagesList.toArray(new PagedMessage[pgdMessagesList.size()]); - } - else { + } else { pgdMessages = cache.getMessages(); } @@ -491,8 +478,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { softCache.remove((long) depagedPage.getPageId()); } } - } - catch (Exception ex) { + } catch (Exception ex) { ActiveMQServerLogger.LOGGER.problemCleaningPageAddress(ex, pagingStore.getAddress()); return; } @@ -513,8 +499,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { complete = false; break; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Cursor " + cursor + " was considered **complete** at pageNr=" + minPage); } @@ -553,8 +538,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { while (!storageManager.waitOnOperations(5000)) { ActiveMQServerLogger.LOGGER.problemCompletingOperations(storageManager.getContext()); } - } - finally { + } finally { for (PageSubscription cursor : cursorList) { cursor.enableAutoCleanup(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java index fbf3bd60e3..076f87218c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java @@ -86,17 +86,13 @@ public class PagePositionImpl implements PagePosition { public int compareTo(PagePosition o) { if (pageNr > o.getPageNr()) { return 1; - } - else if (pageNr < o.getPageNr()) { + } else if (pageNr < o.getPageNr()) { return -1; - } - else if (recordID > o.getRecordID()) { + } else if (recordID > o.getRecordID()) { return 1; - } - else if (recordID < o.getRecordID()) { + } else if (recordID < o.getRecordID()) { return -1; - } - else { + } else { return 0; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java index 54dc7e99a8..92f313bb2a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java @@ -118,8 +118,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { long id = storage.storePendingCounter(this.subscriptionID, page.getPageId(), increment); pendingInfo = new Pair<>(id, new AtomicInteger(1)); pendingCounters.put((long) page.getPageId(), pendingInfo); - } - else { + } else { pendingInfo.getB().addAndGet(increment); } @@ -165,18 +164,15 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { if (persistent) { long id = storage.storePageCounterInc(this.subscriptionID, add); incrementProcessed(id, add); - } - else { + } else { incrementProcessed(-1, add); } - } - else { + } else { if (persistent) { tx.setContainsPersistent(); long id = storage.storePageCounterInc(tx.getID(), this.subscriptionID, add); applyIncrementOnTX(tx, id, add); - } - else { + } else { applyIncrementOnTX(tx, -1, add); } } @@ -249,8 +245,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { value.set(0); incrementRecords.clear(); } - } - finally { + } finally { storage.readUnLock(); } } @@ -333,18 +328,15 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { } storage.commit(txCleanup); - } - catch (Exception e) { + } catch (Exception e) { newRecordID = recordID; ActiveMQServerLogger.LOGGER.problemCleaningPagesubscriptionCounter(e); try { storage.rollback(txCleanup); + } catch (Exception ignored) { } - catch (Exception ignored) { - } - } - finally { + } finally { recordID = newRecordID; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java index c89161a36a..c1c54a26b2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java @@ -172,8 +172,7 @@ final class PageSubscriptionImpl implements PageSubscription { public long getMessageCount() { if (empty) { return 0; - } - else { + } else { return counter.getValue() - deliveredCount.get(); } } @@ -222,11 +221,9 @@ final class PageSubscriptionImpl implements PageSubscription { if (autoCleanup) { cleanupEntries(false); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.problemCleaningCursorPages(e); - } - finally { + } finally { scheduledCleanupCount.decrementAndGet(); } } @@ -276,9 +273,8 @@ final class PageSubscriptionImpl implements PageSubscription { if (currentPage != null && entry.getKey() == pageStore.getCurrentPage().getPageId() && currentPage.isLive()) { logger.trace("We can't clear page " + entry.getKey() + - " now since it's the current page"); - } - else { + " now since it's the current page"); + } else { info.setPendingDelete(); completedPages.add(entry.getValue()); } @@ -375,14 +371,12 @@ final class PageSubscriptionImpl implements PageSubscription { if (cache == null) { // it will be null in the case of the current writing page return null; - } - else { + } else { PagedMessage serverMessage = cache.getMessage(retPos.getMessageNr()); if (serverMessage != null) { return cursorProvider.newReference(retPos, serverMessage, this); - } - else { + } else { return null; } } @@ -463,8 +457,7 @@ final class PageSubscriptionImpl implements PageSubscription { } if (!routed) { return false; - } - else { + } else { // if it's been routed here, we have to verify if it was acked return !getPageInfo(ref.getPosition()).isAck(ref.getPosition()); } @@ -533,8 +526,7 @@ final class PageSubscriptionImpl implements PageSubscription { PageCursorInfo pageInfo = consumedPages.get(position.getPageNr()); if (pageInfo != null) { pageInfo.decrementPendingTX(); - } - else { + } else { // this shouldn't really happen. } } @@ -590,8 +582,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (info == null && empty) { logger.tracef("isComplete(%d)::::Couldn't find info and it is empty", page); return true; - } - else { + } else { boolean isDone = info != null && info.isDone(); if (logger.isTraceEnabled()) { logger.tracef("isComplete(%d):: found info=%s, isDone=%s", (Object) page, info, isDone); @@ -632,12 +623,10 @@ final class PageSubscriptionImpl implements PageSubscription { } cursorProvider.close(this); - } - catch (Exception e) { + } catch (Exception e) { try { store.rollback(tx); - } - catch (Exception ignored) { + } catch (Exception ignored) { // exception of the exception.. nothing that can be done here } } @@ -673,8 +662,7 @@ final class PageSubscriptionImpl implements PageSubscription { txDeleteCursorOnReload = store.generateID(); } store.deleteCursorAcknowledgeTransactional(txDeleteCursorOnReload, pos.getRecordID()); - } - else { + } else { pageInfo.loadACK(pos); } } @@ -725,8 +713,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (completeInfo != null) { try { store.deletePageComplete(completeInfo.getRecordID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while deleting page-complete-record", e); } info.setCompleteInfo(null); @@ -735,8 +722,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (deleteInfo.getRecordID() >= 0) { try { store.deleteCursorAcknowledge(deleteInfo.getRecordID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while deleting page-complete-record", e); } } @@ -783,8 +769,7 @@ final class PageSubscriptionImpl implements PageSubscription { private boolean match(final ServerMessage message) { if (filter == null) { return true; - } - else { + } else { return filter.match(message); } } @@ -817,8 +802,7 @@ final class PageSubscriptionImpl implements PageSubscription { // This could become null if the page file was deleted, or if the queue was removed maybe? // it's better to diagnose it (based on support tickets) instead of NPE ActiveMQServerLogger.LOGGER.nullPageCursorInfo(this.getPagingStore().getAddress().toString(), pos.toString(), cursorId); - } - else { + } else { info.addACK(pos); } @@ -856,8 +840,7 @@ final class PageSubscriptionImpl implements PageSubscription { private PageTransactionInfo getPageTransaction(final PagedReference reference) throws ActiveMQException { if (reference.getPagedMessage().getTransactionID() >= 0) { return pageStore.getPagingManager().getTransaction(reference.getPagedMessage().getTransactionID()); - } - else { + } else { return null; } } @@ -930,8 +913,7 @@ final class PageSubscriptionImpl implements PageSubscription { ", isDone=" + this.isDone() + " wasLive = " + wasLive; - } - catch (Exception e) { + } catch (Exception e) { return "PageCursorInfo::pageNr=" + pageId + " numberOfMessage = " + numberOfMessages + @@ -949,8 +931,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (cache != null) { wasLive = cache.isLive(); this.cache = new WeakReference<>(cache); - } - else { + } else { wasLive = false; } } @@ -1012,13 +993,12 @@ final class PageSubscriptionImpl implements PageSubscription { if (logger.isTraceEnabled()) { try { logger.trace("numberOfMessages = " + getNumberOfMessages() + - " confirmed = " + - (confirmed.get() + 1) + - " pendingTX = " + pendingTX + - ", pageNr = " + - pageId + " posACK = " + posACK); - } - catch (Throwable ignored) { + " confirmed = " + + (confirmed.get() + 1) + + " pendingTX = " + pendingTX + + ", pageNr = " + + pageId + " posACK = " + posACK); + } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } } @@ -1064,8 +1044,7 @@ final class PageSubscriptionImpl implements PageSubscription { } return localcache.getNumberOfMessages(); - } - else { + } else { return numberOfMessages; } } @@ -1146,12 +1125,10 @@ final class PageSubscriptionImpl implements PageSubscription { synchronized (redeliveries) { cachedNext = lastRedelivery; } - } - else { + } else { if (lastOperation == null) { position = null; - } - else { + } else { position = lastOperation; } } @@ -1194,8 +1171,7 @@ final class PageSubscriptionImpl implements PageSubscription { lastRedelivery = redeliveredMsg; return redeliveredMsg; - } - else { + } else { lastRedelivery = null; isredelivery = false; } @@ -1234,8 +1210,7 @@ final class PageSubscriptionImpl implements PageSubscription { ActiveMQServerLogger.LOGGER.pageSubscriptionCouldntLoad(message.getPagedMessage().getTransactionID(), message.getPosition(), pageStore.getAddress(), queue.getName()); valid = false; ignored = true; - } - else { + } else { if (tx.deliverAfterCommit(CursorIterator.this, PageSubscriptionImpl.this, message.getPosition())) { valid = false; ignored = false; @@ -1265,8 +1240,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (!match) { processACK(message.getPosition()); } - } - else if (ignored) { + } else if (ignored) { positionIgnored(message.getPosition()); } } while (!match); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java index 0888416476..4993d0cede 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java @@ -146,20 +146,17 @@ public final class Page implements Comparable { logger.trace("Reading message " + msg + " on pageId=" + this.pageId + " for address=" + storeName); } messages.add(msg); - } - else { + } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } - } - else { + } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } - } - finally { + } finally { if (fileBuffer != null) { fileBuffer.byteBuf().unwrap().release(); } @@ -220,8 +217,10 @@ public final class Page implements Comparable { close(false); } - /** sendEvent means it's a close happening from a major event such moveNext. - * While reading the cache we don't need (and shouldn't inform the backup */ + /** + * sendEvent means it's a close happening from a major event such moveNext. + * While reading the cache we don't need (and shouldn't inform the backup + */ public synchronized void close(boolean sendEvent) throws Exception { if (sendEvent && storageManager != null) { storageManager.pageClosed(storeName, pageId); @@ -271,14 +270,12 @@ public final class Page implements Comparable { if (suspiciousRecords) { ActiveMQServerLogger.LOGGER.pageInvalid(file.getFileName(), file.getFileName()); file.renameTo(file.getFileName() + ".invalidPage"); - } - else { + } else { file.delete(); } return true; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageDeleteError(e); return false; } @@ -308,8 +305,7 @@ public final class Page implements Comparable { if (file != null && file.isOpen()) { file.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageFinaliseError(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java index b0f4615010..f833b5af9c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java @@ -95,13 +95,11 @@ final class PageSyncTimer extends ActiveMQScheduledComponent { if (pendingSyncsArray.length != 0) { store.ioSync(); } - } - catch (Exception e) { + } catch (Exception e) { for (OperationContext ctx : pendingSyncsArray) { ctx.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getMessage()); } - } - finally { + } finally { // In case of failure, The context should propagate an exception to the client // We send an exception to the client even on the case of a failure // to avoid possible locks and the client not getting the exception back diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java index 1dde3092ca..b793aec558 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java @@ -94,8 +94,7 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo { if (sizeAfterUpdate == 0 && storageManager != null) { try { storageManager.deletePageTransactional(this.recordID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageTxDeleteError(e, recordID); } @@ -254,21 +253,18 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo { cursor.addPendingDelivery(cursorPos); cursor.redeliver(iterator, cursorPos); return true; - } - else if (committed) { + } else if (committed) { if (logger.isTraceEnabled()) { logger.trace("committed on " + cursor + ", position=" + cursorPos + ", ignoring position"); } return false; - } - else if (rolledback) { + } else if (rolledback) { if (logger.isTraceEnabled()) { logger.trace("rolled back, position ignored on " + cursor + ", position=" + cursorPos); } cursor.positionIgnored(cursorPos); return true; - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("deliverAftercommit/else, marking useRedelivery on " + cursor + ", position " + cursorPos); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java index b4e6f386dd..e40d107df4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java @@ -99,8 +99,7 @@ public class PagedMessageImpl implements PagedMessage { largeMessageLazyData = new byte[largeMessageHeaderSize]; buffer.readBytes(largeMessageLazyData); - } - else { + } else { buffer.readInt(); // This value is only used on LargeMessages for now message = new ServerMessageImpl(-1, 50); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java index 99074f3f0b..01fce263f5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java @@ -187,8 +187,7 @@ public final class PagingManagerImpl implements PagingManager { for (PagingStore store : stores.values()) { store.disableCleanup(); } - } - finally { + } finally { unlock(); } } @@ -205,8 +204,7 @@ public final class PagingManagerImpl implements PagingManager { for (PagingStore store : stores.values()) { store.enableCleanup(); } - } - finally { + } finally { unlock(); } } @@ -234,8 +232,7 @@ public final class PagingManagerImpl implements PagingManager { store.start(); stores.put(store.getStoreName(), store); } - } - finally { + } finally { unlock(); } @@ -249,8 +246,7 @@ public final class PagingManagerImpl implements PagingManager { if (store != null) { store.stop(); } - } - finally { + } finally { syncLock.readLock().unlock(); } } @@ -315,8 +311,7 @@ public final class PagingManagerImpl implements PagingManager { reloadStores(); started = true; - } - finally { + } finally { unlock(); } } @@ -336,8 +331,7 @@ public final class PagingManagerImpl implements PagingManager { } pagingStoreFactory.stop(); - } - finally { + } finally { unlock(); } } @@ -362,8 +356,7 @@ public final class PagingManagerImpl implements PagingManager { stores.put(address, store); } return store; - } - finally { + } finally { syncLock.readLock().unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java index 50930331ce..e0f3a2226c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java @@ -102,7 +102,10 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory { } @Override - public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, Executor executor) { + public PageCursorProvider newCursorProvider(PagingStore store, + StorageManager storageManager, + AddressSettings addressSettings, + Executor executor) { return new PageCursorProviderImpl(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); } @@ -144,8 +147,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory { if (files == null) { return Collections.emptyList(); - } - else { + } else { ArrayList storesReturn = new ArrayList<>(files.length); for (File file : files) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java index df603be7a4..f756eddf76 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java @@ -171,8 +171,7 @@ public class PagingStoreImpl implements PagingStore { if (scheduledExecutor != null && syncTimeout > 0) { this.syncTimer = new PageSyncTimer(this, scheduledExecutor, executor, syncTimeout); - } - else { + } else { this.syncTimer = null; } @@ -212,8 +211,7 @@ public class PagingStoreImpl implements PagingStore { } try { return lock.writeLock().tryLock(timeout, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } } @@ -248,8 +246,7 @@ public class PagingStoreImpl implements PagingStore { if (maxSize < 0) { // if maxSize < 0, we will return 2 pages for depage purposes return pageSize * 2; - } - else { + } else { return maxSize; } } @@ -269,8 +266,7 @@ public class PagingStoreImpl implements PagingStore { SequentialFileFactory factoryUsed = this.fileFactory; if (factoryUsed != null) { return factoryUsed.getDirectory(); - } - else { + } else { return null; } } @@ -290,8 +286,7 @@ public class PagingStoreImpl implements PagingStore { return isFull(); } return paging; - } - finally { + } finally { lock.readLock().unlock(); } } @@ -315,8 +310,7 @@ public class PagingStoreImpl implements PagingStore { public void sync() throws Exception { if (syncTimer != null) { syncTimer.addSync(storageManager.getContext()); - } - else { + } else { ioSync(); } @@ -330,8 +324,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPage != null) { currentPage.sync(); } - } - finally { + } finally { lock.readLock().unlock(); } } @@ -393,8 +386,7 @@ public class PagingStoreImpl implements PagingStore { // and having both threads calling init. One of the calls should just // need to be ignored return; - } - else { + } else { running = true; firstPageId = Integer.MAX_VALUE; @@ -453,8 +445,7 @@ public class PagingStoreImpl implements PagingStore { } } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -465,8 +456,7 @@ public class PagingStoreImpl implements PagingStore { try { paging = false; this.cursorProvider.onPageModeCleared(); - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -488,8 +478,7 @@ public class PagingStoreImpl implements PagingStore { if (paging) { return false; } - } - finally { + } finally { lock.readLock().unlock(); } @@ -506,8 +495,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPage == null) { try { openNewPage(); - } - catch (Exception e) { + } catch (Exception e) { // If not possible to starting page due to an IO error, we will just consider it non paging. // This shouldn't happen anyway ActiveMQServerLogger.LOGGER.pageStoreStartIOError(e); @@ -518,8 +506,7 @@ public class PagingStoreImpl implements PagingStore { paging = true; return true; - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -585,8 +572,7 @@ public class PagingStoreImpl implements PagingStore { if (numberOfPages == 0) { return null; - } - else { + } else { numberOfPages--; final Page returnPage; @@ -614,22 +600,19 @@ public class PagingStoreImpl implements PagingStore { // This will trigger this address to exit the page mode, // and this will make ActiveMQ Artemis start using the journal again return null; - } - else { + } else { // We need to create a new page, as we can't lock the address until we finish depaging. openNewPage(); } return returnPage; - } - else { + } else { returnPage = createPage(firstPageId++); } return returnPage; } - } - finally { + } finally { lock.writeLock().unlock(); } @@ -679,8 +662,7 @@ public class PagingStoreImpl implements PagingStore { if (isFull()) { return false; } - } - else if (pagingManager.isDiskFull() || addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK && (maxSize != -1 || usingGlobalMaxSize)) { + } else if (pagingManager.isDiskFull() || addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK && (maxSize != -1 || usingGlobalMaxSize)) { if (pagingManager.isDiskFull() || maxSize > 0 && sizeInBytes.get() > maxSize || pagingManager.isGlobalFull()) { OverSizedRunnable ourRunnable = new OverSizedRunnable(runWhenAvailable); @@ -693,8 +675,7 @@ public class PagingStoreImpl implements PagingStore { if (!pagingManager.isGlobalFull() && (sizeInBytes.get() <= maxSize || maxSize < 0)) { // run it now ourRunnable.run(); - } - else { + } else { if (usingGlobalMaxSize || pagingManager.isDiskFull()) { pagingManager.addBlockedStore(this); } @@ -726,8 +707,7 @@ public class PagingStoreImpl implements PagingStore { } return; - } - else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) { + } else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) { if (size > 0) { if (maxSize != -1 && newSize > maxSize || globalFull) { if (startPaging()) { @@ -790,12 +770,10 @@ public class PagingStoreImpl implements PagingStore { // Address is full, we just pretend we are paging, and drop the data return true; - } - else { + } else { return false; } - } - else if (addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK) { + } else if (addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK) { return false; } @@ -807,8 +785,7 @@ public class PagingStoreImpl implements PagingStore { if (!paging) { return false; } - } - finally { + } finally { lock.readLock().unlock(); } @@ -859,16 +836,14 @@ public class PagingStoreImpl implements PagingStore { if (logger.isTraceEnabled()) { logger.trace("Paging message " + pagedMessage + " on pageStore " + this.getStoreName() + - " pageNr=" + currentPage.getPageId()); + " pageNr=" + currentPage.getPageId()); } return true; - } - finally { + } finally { lock.writeLock().unlock(); } - } - finally { + } finally { managerLock.unlock(); } } @@ -924,8 +899,7 @@ public class PagingStoreImpl implements PagingStore { // non transactional writes need an intermediate place // to avoid the counter getting out of sync q.getPageSubscription().getCounter().pendingCounter(page, 1); - } - else { + } else { // null tx is treated through pending counters q.getPageSubscription().getCounter().increment(tx, 1); } @@ -1074,8 +1048,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPageId < firstPageId) { firstPageId = currentPageId; } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -1131,8 +1104,7 @@ public class PagingStoreImpl implements PagingStore { } replicator.syncPages(sFile, id, getAddress()); } - } - finally { + } finally { lock.writeLock().unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java index e893a1072d..104a79c257 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java @@ -29,7 +29,8 @@ public interface OperationContext extends IOCompletion { /** * Execute the task when all IO operations are complete, * Or execute it immediately if nothing is pending. - * @param runnable the tas to be executed. + * + * @param runnable the tas to be executed. * @param storeOnly There are tasks that won't need to wait on replication or paging and will need to * be completed as soon as the response from the journal is received. An example would be the * DuplicateCache @@ -39,11 +40,11 @@ public interface OperationContext extends IOCompletion { /** * Execute the task when all IO operations are complete, * Or execute it immediately if nothing is pending. + * * @param runnable the tas to be executed. */ void executeOnCompletion(IOCallback runnable); - void replicationLineUp(); void replicationDone(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java index 7dcd9d3912..e82066416a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java @@ -26,9 +26,9 @@ import java.util.concurrent.Executor; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.io.IOCallback; +import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.JournalLoadInformation; -import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.message.impl.MessageInternal; import org.apache.activemq.artemis.core.paging.PageTransactionInfo; import org.apache.activemq.artemis.core.paging.PagedMessage; @@ -101,8 +101,11 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { void afterCompleteOperations(IOCallback run); - /** This is similar to afterComplete, however this only cares about the journal part. */ + /** + * This is similar to afterComplete, however this only cares about the journal part. + */ void afterStoreOperations(IOCallback run); + /** * Block until the operations are done. * Warning: Don't use it inside an ordered executor, otherwise the system may lock up @@ -415,6 +418,5 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { */ void persistIdGenerator(); - void injectMonitor(FileStoreMonitor monitor) throws Exception; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java index 256a0a6594..383a75f3e4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java @@ -232,56 +232,47 @@ public class PersistedRoles implements EncodingSupport { if (addressMatch == null) { if (other.addressMatch != null) return false; - } - else if (!addressMatch.equals(other.addressMatch)) + } else if (!addressMatch.equals(other.addressMatch)) return false; if (consumeRoles == null) { if (other.consumeRoles != null) return false; - } - else if (!consumeRoles.equals(other.consumeRoles)) + } else if (!consumeRoles.equals(other.consumeRoles)) return false; if (createDurableQueueRoles == null) { if (other.createDurableQueueRoles != null) return false; - } - else if (!createDurableQueueRoles.equals(other.createDurableQueueRoles)) + } else if (!createDurableQueueRoles.equals(other.createDurableQueueRoles)) return false; if (createNonDurableQueueRoles == null) { if (other.createNonDurableQueueRoles != null) return false; - } - else if (!createNonDurableQueueRoles.equals(other.createNonDurableQueueRoles)) + } else if (!createNonDurableQueueRoles.equals(other.createNonDurableQueueRoles)) return false; if (deleteDurableQueueRoles == null) { if (other.deleteDurableQueueRoles != null) return false; - } - else if (!deleteDurableQueueRoles.equals(other.deleteDurableQueueRoles)) + } else if (!deleteDurableQueueRoles.equals(other.deleteDurableQueueRoles)) return false; if (deleteNonDurableQueueRoles == null) { if (other.deleteNonDurableQueueRoles != null) return false; - } - else if (!deleteNonDurableQueueRoles.equals(other.deleteNonDurableQueueRoles)) + } else if (!deleteNonDurableQueueRoles.equals(other.deleteNonDurableQueueRoles)) return false; if (manageRoles == null) { if (other.manageRoles != null) return false; - } - else if (!manageRoles.equals(other.manageRoles)) + } else if (!manageRoles.equals(other.manageRoles)) return false; if (browseRoles == null) { if (other.browseRoles != null) return false; - } - else if (!browseRoles.equals(other.browseRoles)) + } else if (!browseRoles.equals(other.browseRoles)) return false; if (sendRoles == null) { if (other.sendRoles != null) return false; - } - else if (!sendRoles.equals(other.sendRoles)) + } else if (!sendRoles.equals(other.sendRoles)) return false; if (storeId != other.storeId) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java index 6b75e74118..cd86191aa6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java @@ -184,7 +184,9 @@ public abstract class AbstractJournalStorageManager implements StorageManager { protected final Set largeMessagesToDelete = new HashSet<>(); - public AbstractJournalStorageManager(final Configuration config, final ExecutorFactory executorFactory, final ScheduledExecutorService scheduledExecutorService) { + public AbstractJournalStorageManager(final Configuration config, + final ExecutorFactory executorFactory, + final ScheduledExecutorService scheduledExecutorService) { this(config, executorFactory, scheduledExecutorService, null); } @@ -212,6 +214,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { /** * Called during initialization. Used by implementations to setup Journals, Stores etc... + * * @param config * @param criticalErrorListener */ @@ -241,8 +244,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { digest = md.digest(); } return Base64.encodeBytes(digest); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -315,15 +317,13 @@ public abstract class AbstractJournalStorageManager implements StorageManager { // Non transactional operations - @Override public void confirmPendingLargeMessageTX(final Transaction tx, long messageID, long recordID) throws Exception { readLock(); try { installLargeMessageConfirmationOnTX(tx, recordID); messageJournal.appendDeleteRecordTransactional(tx.getID(), recordID, new DeleteEncoding(JournalRecordIds.ADD_LARGE_MESSAGE_PENDING, messageID)); - } - finally { + } finally { readUnLock(); } } @@ -336,8 +336,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecord(recordID, true, getContext()); - } - finally { + } finally { readUnLock(); } } @@ -356,12 +355,10 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (message.isLargeMessage()) { messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, new LargeMessageEncoding((LargeServerMessage) message), false, getContext(false)); - } - else { + } else { messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_MESSAGE, message, false, getContext(false)); } - } - finally { + } finally { readUnLock(); } } @@ -371,8 +368,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecord(messageID, JournalRecordIds.ADD_REF, new RefEncoding(queueID), last && syncNonTransactional, getContext(last && syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -392,8 +388,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecord(messageID, JournalRecordIds.ACKNOWLEDGE_REF, new RefEncoding(queueID), syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -405,8 +400,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { long ackID = idGenerator.generateID(); position.setRecordID(ackID); messageJournal.appendAddRecord(ackID, JournalRecordIds.ACKNOWLEDGE_CURSOR, new CursorAckRecordEncoding(queueID, position), syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -420,8 +414,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { // increasing chances of losing deletes. // The StorageManager should verify messages without references messageJournal.appendDeleteRecord(messageID, false, getContext(false)); - } - finally { + } finally { readUnLock(); } } @@ -432,8 +425,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecord(ref.getMessage().getMessageID(), JournalRecordIds.SET_SCHEDULED_DELIVERY_TIME, encoding, syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -445,8 +437,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { DuplicateIDEncoding encoding = new DuplicateIDEncoding(address, duplID); messageJournal.appendAddRecord(recordID, JournalRecordIds.DUPLICATE_ID, encoding, syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -456,8 +447,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecord(recordID, syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -474,13 +464,11 @@ public abstract class AbstractJournalStorageManager implements StorageManager { try { if (message.isLargeMessage()) { messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, new LargeMessageEncoding(((LargeServerMessage) message))); - } - else { + } else { messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_MESSAGE, message); } - } - finally { + } finally { readUnLock(); } } @@ -491,8 +479,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { try { pageTransaction.setRecordID(generateID()); messageJournal.appendAddRecordTransactional(txID, pageTransaction.getRecordID(), JournalRecordIds.PAGE_TRANSACTION, pageTransaction); - } - finally { + } finally { readUnLock(); } } @@ -504,8 +491,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecordTransactional(txID, pageTransaction.getRecordID(), JournalRecordIds.PAGE_TRANSACTION, new PageUpdateTXEncoding(pageTransaction.getTransactionID(), depages)); - } - finally { + } finally { readUnLock(); } } @@ -515,8 +501,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecord(pageTransaction.getRecordID(), JournalRecordIds.PAGE_TRANSACTION, new PageUpdateTXEncoding(pageTransaction.getTransactionID(), depages), syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -526,8 +511,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecordTransactional(txID, messageID, JournalRecordIds.ADD_REF, new RefEncoding(queueID)); - } - finally { + } finally { readUnLock(); } } @@ -539,8 +523,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecordTransactional(txID, messageID, JournalRecordIds.ACKNOWLEDGE_REF, new RefEncoding(queueID)); - } - finally { + } finally { readUnLock(); } } @@ -552,8 +535,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { long ackID = idGenerator.generateID(); position.setRecordID(ackID); messageJournal.appendAddRecordTransactional(txID, ackID, JournalRecordIds.ACKNOWLEDGE_CURSOR, new CursorAckRecordEncoding(queueID, position)); - } - finally { + } finally { readUnLock(); } } @@ -575,8 +557,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecordTransactional(txID, ackID); - } - finally { + } finally { readUnLock(); } } @@ -594,8 +575,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { messageJournal.appendAddRecord(id, JournalRecordIds.HEURISTIC_COMPLETION, new HeuristicCompletionEncoding(xid, isCommit), true, getContext(true)); return id; - } - finally { + } finally { readUnLock(); } } @@ -606,8 +586,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { try { messageJournal.appendDeleteRecord(id, true, getContext(true)); - } - finally { + } finally { readUnLock(); } } @@ -617,8 +596,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecord(recordID, false); - } - finally { + } finally { readUnLock(); } } @@ -630,8 +608,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { try { messageJournal.appendUpdateRecordTransactional(txID, ref.getMessage().getMessageID(), JournalRecordIds.SET_SCHEDULED_DELIVERY_TIME, encoding); - } - finally { + } finally { readUnLock(); } } @@ -641,8 +618,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendPrepareRecord(txID, new XidEncoding(xid), syncTransactional, getContext(syncTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -678,8 +654,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { */ getContext(true).done(); } - } - finally { + } finally { readUnLock(); } } @@ -689,8 +664,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendRollbackRecord(txID, syncTransactional, getContext(syncTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -705,8 +679,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendAddRecordTransactional(txID, recordID, JournalRecordIds.DUPLICATE_ID, encoding); - } - finally { + } finally { readUnLock(); } } @@ -721,8 +694,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecordTransactional(txID, recordID, JournalRecordIds.DUPLICATE_ID, encoding); - } - finally { + } finally { readUnLock(); } } @@ -732,8 +704,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecordTransactional(txID, recordID); - } - finally { + } finally { readUnLock(); } } @@ -754,8 +725,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendUpdateRecord(ref.getMessage().getMessageID(), JournalRecordIds.UPDATE_DELIVERY_COUNT, updateInfo, syncNonTransactional, getContext(syncNonTransactional)); - } - finally { + } finally { readUnLock(); } } @@ -769,8 +739,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { addressSetting.setStoreId(id); bindingsJournal.appendAddRecord(id, JournalRecordIds.ADDRESS_SETTING_RECORD, addressSetting, true); mapPersistedAddressSettings.put(addressSetting.getAddressMatch(), addressSetting); - } - finally { + } finally { readUnLock(); } } @@ -795,8 +764,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { persistedRoles.setStoreId(id); bindingsJournal.appendAddRecord(id, JournalRecordIds.SECURITY_RECORD, persistedRoles, true); mapPersistedRoles.put(persistedRoles.getAddressMatch(), persistedRoles); - } - finally { + } finally { readUnLock(); } } @@ -806,8 +774,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendAddRecord(journalID, JournalRecordIds.ID_COUNTER_RECORD, BatchingIDGenerator.createIDEncodingSupport(id), true); - } - finally { + } finally { readUnLock(); } } @@ -817,8 +784,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendDeleteRecord(journalD, false); - } - finally { + } finally { readUnLock(); } } @@ -830,8 +796,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendDeleteRecord(oldSetting.getStoreId(), false); - } - finally { + } finally { readUnLock(); } } @@ -844,8 +809,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendDeleteRecord(oldRoles.getStoreId(), false); - } - finally { + } finally { readUnLock(); } } @@ -942,8 +906,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (message == null) { ActiveMQServerLogger.LOGGER.cannotFindMessage(record.id); - } - else { + } else { queueMessages.put(messageID, new AddMessageRecord(message)); } @@ -960,8 +923,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (queueMessages == null) { ActiveMQServerLogger.LOGGER.journalCannotFindQueue(encoding.queueID, messageID); - } - else { + } else { AddMessageRecord rec = queueMessages.remove(messageID); if (rec == null) { @@ -982,14 +944,12 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (queueMessages == null) { ActiveMQServerLogger.LOGGER.journalCannotFindQueueDelCount(encoding.queueID); - } - else { + } else { AddMessageRecord rec = queueMessages.get(messageID); if (rec == null) { ActiveMQServerLogger.LOGGER.journalCannotFindMessageDelCount(messageID); - } - else { + } else { rec.setDeliveryCount(encoding.count); } } @@ -1005,8 +965,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { PageTransactionInfo pageTX = pagingManager.getTransaction(pageUpdate.pageTX); pageTX.onUpdate(pageUpdate.recods, null, null); - } - else { + } else { PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl(); pageTransactionInfo.decode(buff); @@ -1029,15 +988,13 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (queueMessages == null) { ActiveMQServerLogger.LOGGER.journalCannotFindQueueScheduled(encoding.queueID, messageID); - } - else { + } else { AddMessageRecord rec = queueMessages.get(messageID); if (rec == null) { ActiveMQServerLogger.LOGGER.cannotFindMessage(messageID); - } - else { + } else { rec.setScheduledDeliveryTime(encoding.scheduledDeliveryTime); } } @@ -1077,8 +1034,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.reloadACK(encoding.position); - } - else { + } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloading(encoding.queueID); messageJournal.appendDeleteRecord(record.id, false); @@ -1095,8 +1051,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.getCounter().loadValue(record.id, encoding.getValue()); - } - else { + } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingPage(encoding.getQueueID()); messageJournal.appendDeleteRecord(record.id, false); } @@ -1113,8 +1068,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.getCounter().loadInc(record.id, encoding.getValue()); - } - else { + } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingPageCursor(encoding.getQueueID()); messageJournal.appendDeleteRecord(record.id, false); } @@ -1132,8 +1086,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.reloadPageCompletion(encoding.position); - } - else { + } else { ActiveMQServerLogger.LOGGER.cantFindQueueOnPageComplete(encoding.queueID); messageJournal.appendDeleteRecord(record.id, false); } @@ -1200,8 +1153,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { journalLoader.postLoad(messageJournal, resourceManager, duplicateIDMap); journalLoaded = true; return info; - } - finally { + } finally { readUnLock(); } } @@ -1239,8 +1191,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendAddRecord(groupBinding.getId(), JournalRecordIds.GROUP_RECORD, groupingEncoding, true); - } - finally { + } finally { readUnLock(); } } @@ -1250,8 +1201,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendDeleteRecordTransactional(tx, groupBinding.getId()); - } - finally { + } finally { readUnLock(); } } @@ -1271,8 +1221,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendAddRecordTransactional(tx, binding.getID(), JournalRecordIds.QUEUE_BINDING_RECORD, bindingEncoding); - } - finally { + } finally { readUnLock(); } } @@ -1282,8 +1231,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { bindingsJournal.appendDeleteRecordTransactional(tx, queueBindingID); - } - finally { + } finally { readUnLock(); } } @@ -1295,8 +1243,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { long recordID = idGenerator.generateID(); messageJournal.appendAddRecordTransactional(txID, recordID, JournalRecordIds.PAGE_CURSOR_COUNTER_INC, new PageCountRecordInc(queueID, value)); return recordID; - } - finally { + } finally { readUnLock(); } } @@ -1308,8 +1255,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { final long recordID = idGenerator.generateID(); messageJournal.appendAddRecord(recordID, JournalRecordIds.PAGE_CURSOR_COUNTER_INC, new PageCountRecordInc(queueID, value), true, getContext()); return recordID; - } - finally { + } finally { readUnLock(); } } @@ -1321,8 +1267,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { final long recordID = idGenerator.generateID(); messageJournal.appendAddRecordTransactional(txID, recordID, JournalRecordIds.PAGE_CURSOR_COUNTER_VALUE, new PageCountRecord(queueID, value)); return recordID; - } - finally { + } finally { readUnLock(); } } @@ -1337,8 +1282,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { // on the counter messageJournal.appendAddRecord(recordID, JournalRecordIds.PAGE_CURSOR_PENDING_COUNTER, pendingInc, true); return recordID; - } - finally { + } finally { readUnLock(); } } @@ -1348,8 +1292,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecordTransactional(txID, recordID); - } - finally { + } finally { readUnLock(); } } @@ -1359,8 +1302,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecordTransactional(txID, recordID); - } - finally { + } finally { readUnLock(); } } @@ -1370,8 +1312,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.appendDeleteRecordTransactional(txID, recordID); - } - finally { + } finally { readUnLock(); } } @@ -1396,23 +1337,18 @@ public abstract class AbstractJournalStorageManager implements StorageManager { PersistentQueueBindingEncoding bindingEncoding = newBindingEncoding(id, buffer); queueBindingInfos.add(bindingEncoding); - } - else if (rec == JournalRecordIds.ID_COUNTER_RECORD) { + } else if (rec == JournalRecordIds.ID_COUNTER_RECORD) { idGenerator.loadState(record.id, buffer); - } - else if (rec == JournalRecordIds.GROUP_RECORD) { + } else if (rec == JournalRecordIds.GROUP_RECORD) { GroupingEncoding encoding = newGroupEncoding(id, buffer); groupingInfos.add(encoding); - } - else if (rec == JournalRecordIds.ADDRESS_SETTING_RECORD) { + } else if (rec == JournalRecordIds.ADDRESS_SETTING_RECORD) { PersistedAddressSetting setting = newAddressEncoding(id, buffer); mapPersistedAddressSettings.put(setting.getAddressMatch(), setting); - } - else if (rec == JournalRecordIds.SECURITY_RECORD) { + } else if (rec == JournalRecordIds.SECURITY_RECORD) { PersistedRoles roles = newSecurityRecord(id, buffer); mapPersistedRoles.put(roles.getAddressMatch(), roles); - } - else { + } else { throw new IllegalStateException("Invalid record type " + rec); } } @@ -1428,8 +1364,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { readLock(); try { messageJournal.lineUpContext(getContext()); - } - finally { + } finally { readUnLock(); } } @@ -1533,8 +1468,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { info[1] = messageJournal.loadInternalOnly(); return info; - } - finally { + } finally { readUnLock(); } } @@ -1572,8 +1506,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { try { confirmPendingLargeMessage(largeServerMessage.getPendingRecordID()); largeServerMessage.setPendingRecordID(-1); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -1666,8 +1599,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (record.isUpdate) { PageTransactionInfo pgTX = pagingManager.getTransaction(pageTransactionInfo.getTransactionID()); pgTX.reloadUpdate(this, pagingManager, tx, pageTransactionInfo.getNumberOfMessages()); - } - else { + } else { pageTransactionInfo.setCommitted(false); tx.putProperty(TransactionPropertyIndexes.PAGE_TRANSACTION, pageTransactionInfo); @@ -1709,8 +1641,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.reloadPreparedACK(tx, encoding.position); referencesToAck.add(new PagedReferenceImpl(encoding.position, null, sub)); - } - else { + } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingACK(encoding.queueID); } break; @@ -1731,8 +1662,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { if (sub != null) { sub.getCounter().applyIncrementOnTX(tx, record.id, encoding.getValue()); sub.notEmpty(); - } - else { + } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingACK(encoding.getQueueID()); } @@ -1775,8 +1705,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { OperationContext getContext(final boolean sync) { if (sync) { return getContext(); - } - else { + } else { return DummyOperationContext.getInstance(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java index cdcb4fa431..c61bf64f5b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java @@ -128,8 +128,7 @@ public final class BatchingIDGenerator implements IDGenerator { // If the ID is intended to the journal you would know soon enough // so we just ignore this for now logger.debug("The journalStorageManager is not loaded. " + "This is probably ok as long as it's a notification being sent after shutdown"); - } - else { + } else { storeID(counter.getAndIncrement(), nextID); } } @@ -146,8 +145,7 @@ public final class BatchingIDGenerator implements IDGenerator { private void storeID(final long journalID, final long id) { try { storageManager.storeID(journalID, id); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.batchingIdError(e); } } @@ -155,8 +153,7 @@ public final class BatchingIDGenerator implements IDGenerator { private void deleteID(final long journalID) { try { storageManager.deleteID(journalID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.batchingIdError(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java index 741053f01e..34a47bfb16 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java @@ -212,13 +212,11 @@ public final class DescribeJournal { out.print("#Counter queue " + queueIDForCounter + " value=" + subsCounter.getValue() + ", result=" + subsCounter.getValue()); if (subsCounter.getValue() < 0) { out.println(" #NegativeCounter!!!!"); - } - else { + } else { out.println(); } out.println(); - } - else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_INC) { + } else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_INC) { PageCountRecordInc encoding = (PageCountRecordInc) newObjectEncoding(info); long queueIDForCounter = encoding.getQueueID(); @@ -229,8 +227,7 @@ public final class DescribeJournal { out.print("#Counter queue " + queueIDForCounter + " value=" + subsCounter.getValue() + " increased by " + encoding.getValue()); if (subsCounter.getValue() < 0) { out.println(" #NegativeCounter!!!!"); - } - else { + } else { out.println(); } out.println(); @@ -286,29 +283,24 @@ public final class DescribeJournal { Object o = newObjectEncoding(info); if (info.getUserRecordType() == JournalRecordIds.ADD_MESSAGE) { messageCount++; - } - else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) { + } else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) { ReferenceDescribe ref = (ReferenceDescribe) o; Integer count = messageRefCounts.get(ref.refEncoding.queueID); if (count == null) { count = 1; messageRefCounts.put(ref.refEncoding.queueID, count); - } - else { + } else { messageRefCounts.put(ref.refEncoding.queueID, count + 1); } - } - else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { + } else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { AckDescribe ref = (AckDescribe) o; Integer count = messageRefCounts.get(ref.refEncoding.queueID); if (count == null) { messageRefCounts.put(ref.refEncoding.queueID, 0); - } - else { + } else { messageRefCounts.put(ref.refEncoding.queueID, count - 1); } - } - else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_VALUE) { + } else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_VALUE) { PageCountRecord encoding = (PageCountRecord) o; queueIDForCounter = encoding.getQueueID(); @@ -316,8 +308,7 @@ public final class DescribeJournal { subsCounter.loadValue(info.id, encoding.getValue()); subsCounter.processReload(); - } - else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_INC) { + } else if (info.getUserRecordType() == JournalRecordIds.PAGE_CURSOR_COUNTER_INC) { PageCountRecordInc encoding = (PageCountRecordInc) o; queueIDForCounter = encoding.getQueueID(); @@ -350,15 +341,13 @@ public final class DescribeJournal { out.println("- " + describeRecord(info, o)); if (info.getUserRecordType() == 31) { preparedMessageCount++; - } - else if (info.getUserRecordType() == 32) { + } else if (info.getUserRecordType() == 32) { ReferenceDescribe ref = (ReferenceDescribe) o; Integer count = preparedMessageRefCount.get(ref.refEncoding.queueID); if (count == null) { count = 1; preparedMessageRefCount.put(ref.refEncoding.queueID, count); - } - else { + } else { preparedMessageRefCount.put(ref.refEncoding.queueID, count + 1); } } @@ -428,8 +417,7 @@ public final class DescribeJournal { private static Xid toXid(final byte[] data) { try { return XidCodecSupport.decodeXid(ActiveMQBuffers.wrappedBuffer(data)); - } - catch (Exception e) { + } catch (Exception e) { return null; } } @@ -492,8 +480,7 @@ public final class DescribeJournal { pageUpdate.decode(buffer); return pageUpdate; - } - else { + } else { PageTransactionInfoImpl pageTransactionInfo = new PageTransactionInfoImpl(); pageTransactionInfo.decode(buffer); @@ -655,8 +642,7 @@ public final class DescribeJournal { if (refEncoding == null) { if (other.refEncoding != null) return false; - } - else if (!refEncoding.equals(other.refEncoding)) + } else if (!refEncoding.equals(other.refEncoding)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java index 3c313fea06..5d30b48aa7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java @@ -57,41 +57,17 @@ public class JDBCJournalStorageManager extends JournalStorageManager { if (sqlProviderFactory == null) { sqlProviderFactory = new GenericSQLProvider.Factory(); } - bindingsJournal = new JDBCJournalImpl(dbConf.getDataSource(), - sqlProviderFactory.create(dbConf.getBindingsTableName()), - dbConf.getBindingsTableName(), - scheduledExecutorService, - executorFactory.getExecutor()); - messageJournal = new JDBCJournalImpl(dbConf.getDataSource(), - sqlProviderFactory.create(dbConf.getMessageTableName()), - dbConf.getMessageTableName(), - scheduledExecutorService, - executorFactory.getExecutor()); - largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), - sqlProviderFactory.create(dbConf.getLargeMessageTableName()), - dbConf.getLargeMessageTableName(), - executor); - } - else { + bindingsJournal = new JDBCJournalImpl(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getBindingsTableName()), dbConf.getBindingsTableName(), scheduledExecutorService, executorFactory.getExecutor()); + messageJournal = new JDBCJournalImpl(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getMessageTableName()), dbConf.getMessageTableName(), scheduledExecutorService, executorFactory.getExecutor()); + largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getLargeMessageTableName()), dbConf.getLargeMessageTableName(), executor); + } else { String driverClassName = dbConf.getJdbcDriverClassName(); - bindingsJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), - driverClassName, - JDBCUtils.getSQLProvider(driverClassName, dbConf.getBindingsTableName()), - scheduledExecutorService, - executorFactory.getExecutor()); - messageJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), - driverClassName, - JDBCUtils.getSQLProvider(driverClassName, dbConf.getMessageTableName()), - scheduledExecutorService, - executorFactory.getExecutor()); - largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), - driverClassName, - JDBCUtils.getSQLProvider(driverClassName, dbConf.getLargeMessageTableName()), - executor); + bindingsJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getBindingsTableName()), scheduledExecutorService, executorFactory.getExecutor()); + messageJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getMessageTableName()), scheduledExecutorService, executorFactory.getExecutor()); + largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getLargeMessageTableName()), executor); } largeMessagesFactory.start(); - } - catch (Exception e) { + } catch (Exception e) { criticalErrorListener.onIOException(e, e.getMessage(), null); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java index 2aefbefc39..9eaa203824 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java @@ -66,6 +66,7 @@ import org.apache.activemq.artemis.utils.ExecutorFactory; import org.jboss.logging.Logger; public class JournalStorageManager extends AbstractJournalStorageManager { + private static final Logger logger = Logger.getLogger(JournalStorageManager.class); private SequentialFileFactory journalFF; @@ -82,7 +83,9 @@ public class JournalStorageManager extends AbstractJournalStorageManager { private ReplicationManager replicator; - public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory, final ScheduledExecutorService scheduledExecutorService) { + public JournalStorageManager(final Configuration config, + final ExecutorFactory executorFactory, + final ScheduledExecutorService scheduledExecutorService) { this(config, executorFactory, scheduledExecutorService, null); } @@ -121,12 +124,10 @@ public class JournalStorageManager extends AbstractJournalStorageManager { ActiveMQServerLogger.LOGGER.journalUseAIO(); journalFF = new AIOSequentialFileFactory(config.getJournalLocation(), config.getJournalBufferSize_AIO(), config.getJournalBufferTimeout_AIO(), config.getJournalMaxIO_AIO(), config.isLogJournalWriteRate(), criticalErrorListener); - } - else if (config.getJournalType() == JournalType.NIO) { + } else if (config.getJournalType() == JournalType.NIO) { ActiveMQServerLogger.LOGGER.journalUseNIO(); journalFF = new NIOSequentialFileFactory(config.getJournalLocation(), true, config.getJournalBufferSize_NIO(), config.getJournalBufferTimeout_NIO(), config.getJournalMaxIO_NIO(), config.isLogJournalWriteRate(), criticalErrorListener); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.invalidJournalType2(config.getJournalType()); } @@ -142,8 +143,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { if (config.getPageMaxConcurrentIO() != 1) { pageMaxConcurrentIO = new Semaphore(config.getPageMaxConcurrentIO()); - } - else { + } else { pageMaxConcurrentIO = null; } } @@ -215,8 +215,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { if (token != null) { try { token.waitCompletion(5000); - } - catch (Exception e) { + } catch (Exception e) { // ignore it } } @@ -242,8 +241,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { SequentialFile msg = createFileForLargeMessage(largeMsgId, LargeMessageExtension.DURABLE); try { msg.delete(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeMsgId); } if (replicator != null) { @@ -256,8 +254,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { protected SequentialFile createFileForLargeMessage(final long messageID, final boolean durable) { if (durable) { return createFileForLargeMessage(messageID, LargeMessageExtension.DURABLE); - } - else { + } else { return createFileForLargeMessage(messageID, LargeMessageExtension.TEMPORARY); } } @@ -268,9 +265,8 @@ public class JournalStorageManager extends AbstractJournalStorageManager { * @param buff * @return * @throws Exception - */ - protected LargeServerMessage parseLargeMessage(final Map messages, - final ActiveMQBuffer buff) throws Exception { + */ protected LargeServerMessage parseLargeMessage(final Map messages, + final ActiveMQBuffer buff) throws Exception { LargeServerMessage largeMessage = createLargeMessage(); LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage); @@ -304,8 +300,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { try { if (isReplicated()) replicator.pageClosed(storeName, pageNumber); - } - finally { + } finally { readUnLock(); } } @@ -318,8 +313,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { try { if (isReplicated()) replicator.pageDeleted(storeName, pageNumber); - } - finally { + } finally { readUnLock(); } } @@ -338,8 +332,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { try { if (isReplicated()) replicator.pageWrite(message, pageNumber); - } - finally { + } finally { readUnLock(); } } @@ -363,8 +356,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { messageJournal.appendAddRecord(recordID, JournalRecordIds.ADD_LARGE_MESSAGE_PENDING, new PendingLargeMessageEncoding(messageID), true, getContext(true)); return recordID; - } - finally { + } finally { readUnLock(); } } @@ -378,8 +370,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { // We set a temporary record (short lived) on the journal // to avoid a situation where the server is restarted and pending large message stays on forever largeServerMessage.setPendingRecordID(storePendingLargeMessage(largeServerMessage.getMessageID())); - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQInternalErrorException(e.getMessage(), e); } } @@ -398,8 +389,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { } return; } - } - finally { + } finally { readUnLock(); } } @@ -416,12 +406,10 @@ public class JournalStorageManager extends AbstractJournalStorageManager { // The confirm could only be done after the actual delete is done confirmLargeMessage(largeServerMessage); - } - finally { + } finally { readUnLock(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeServerMessage.getMessageID()); } } @@ -430,8 +418,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { if (executor == null) { deleteAction.run(); - } - else { + } else { executor.execute(deleteAction); } } @@ -467,8 +454,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { } return largeMessage; - } - finally { + } finally { readUnLock(); } } @@ -549,12 +535,10 @@ public class JournalStorageManager extends AbstractJournalStorageManager { bindingsFiles = prepareJournalForCopy(originalBindingsJournal, JournalContent.BINDINGS, nodeID, autoFailBack); pageFilesToSync = getPageInformationForSync(pagingManager); pendingLargeMessages = recoverPendingLargeMessages(); - } - finally { + } finally { pagingManager.unlock(); } - } - finally { + } finally { originalMessageJournal.synchronizationUnlock(); originalBindingsJournal.synchronizationUnlock(); } @@ -564,8 +548,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { // We need to send the list while locking otherwise part of the body might get sent too soon // it will send a list of IDs that we are allocating replicator.sendLargeMessageIdListMessage(pendingLargeMessages); - } - finally { + } finally { storageManagerLock.writeLock().unlock(); } @@ -580,17 +563,14 @@ public class JournalStorageManager extends AbstractJournalStorageManager { replicator.sendSynchronizationDone(nodeID, initialReplicationSyncTimeout); performCachedLargeMessageDeletes(); } - } - finally { + } finally { storageManagerLock.writeLock().unlock(); } - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); stopReplication(); throw e; - } - finally { + } finally { pagingManager.resumeCleanup(); // Re-enable compact and reclaim of journal files originalBindingsJournal.replicationSyncFinished(); @@ -610,8 +590,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { continue; if (replicator != null) { replicator.syncLargeMessageFile(seqFile, size, id); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.replicatorIsNull(); } } @@ -632,15 +611,13 @@ public class JournalStorageManager extends AbstractJournalStorageManager { return info; } - private void checkAndCreateDir(final File dir, final boolean create) { if (!dir.exists()) { if (create) { if (!dir.mkdirs()) { throw new IllegalStateException("Failed to create directory " + dir); } - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.cannotCreateDir(dir.getAbsolutePath()); } } @@ -708,8 +685,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { messageJournal = originalMessageJournal; try { replicator.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingReplicationManager(e); } replicator = null; @@ -717,8 +693,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { // startReplication. // This method should not be called under normal circumstances performCachedLargeMessageDeletes(); - } - finally { + } finally { storageManagerLock.writeLock().unlock(); } } @@ -736,8 +711,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { if (isReplicated()) { replicator.largeMessageWrite(messageId, bytes); } - } - finally { + } finally { readUnLock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java index 045be4674f..89532911a4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java @@ -54,8 +54,7 @@ public class LargeMessageTXFailureCallback implements TransactionFailureCallback try { LargeServerMessage serverMessage = journalStorageManager.parseLargeMessage(messages, buff); serverMessage.decrementDelayDeletionCount(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.journalError(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java index fd7eeeb4f3..90b1fddf8e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java @@ -131,8 +131,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L bufferOut.writeBytes(bufferRead.array(), 0, bytesRead); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -159,8 +158,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L delayDeletionCount.incrementAndGet(); try { incrementRefCount(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorIncrementDelayDeletionCount(e); } } @@ -190,8 +188,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L try { deleteFile(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.error(e.getMessage(), e); } } @@ -244,8 +241,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L if (file != null && file.isOpen()) { try { file.close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.largeMessageErrorReleasingResources(e); } } @@ -281,7 +277,6 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L validateFile(); - byte[] bufferBytes = new byte[100 * 1024]; ByteBuffer buffer = ByteBuffer.wrap(bufferBytes); @@ -300,11 +295,9 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L byte[] bufferToWrite; if (bytesRead <= 0) { break; - } - else if (bytesRead == bufferBytes.length) { + } else if (bytesRead == bufferBytes.length) { bufferToWrite = bufferBytes; - } - else { + } else { bufferToWrite = new byte[bytesRead]; System.arraycopy(bufferBytes, 0, bufferToWrite, 0, bytesRead); } @@ -325,9 +318,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L return newMessage; - - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.lareMessageErrorCopying(e, this); return null; } @@ -349,14 +340,12 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L private static String toDate(long timestamp) { if (timestamp == 0) { return "0"; - } - else { + } else { return new java.util.Date(timestamp).toString(); } } - // Package protected --------------------------------------------- // Protected ----------------------------------------------------- @@ -382,8 +371,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L bodySize = file.size(); } - } - catch (Exception e) { + } catch (Exception e) { // TODO: There is an IO_ERROR on trunk now, this should be used here instead throw new ActiveMQInternalErrorException(e.getMessage(), e); } @@ -399,8 +387,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L protected void openFile() throws Exception { if (file == null) { validateFile(); - } - else if (!file.isOpen()) { + } else if (!file.isOpen()) { file.open(); } } @@ -425,8 +412,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L } cFile = file.cloneFile(); cFile.open(); - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQException(ActiveMQExceptionType.INTERNAL_ERROR, e.getMessage(), e); } } @@ -437,8 +423,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L if (cFile != null) { cFile.close(); } - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQInternalErrorException(e.getMessage(), e); } } @@ -447,8 +432,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L public int encode(final ByteBuffer bufferRead) throws ActiveMQException { try { return cFile.read(bufferRead); - } - catch (Exception e) { + } catch (Exception e) { throw new ActiveMQInternalErrorException(e.getMessage(), e); } } @@ -477,8 +461,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L if (bodySize < 0) { try { bodySize = file.size(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java index 0c95b754b2..42126d44b6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java @@ -33,7 +33,6 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { private static final Logger logger = Logger.getLogger(LargeServerMessageInSync.class); - private final LargeServerMessage mainLM; private final StorageManager storageManager; private SequentialFile appendFile; @@ -64,14 +63,12 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { FileIOUtil.copyData(appendFile, mainSeqFile, buffer); deleteAppendFile(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("joinSyncedData, appendFile is null, ignoring joinSyncedData on " + mainLM); } } - } - catch (Throwable e) { + } catch (Throwable e) { logger.warn("Error while sincing data on largeMessageInSync::" + mainLM); } @@ -79,8 +76,6 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { logger.trace("joinedSyncData on " + mainLM + " finished with " + mainSeqFile.size()); } - - syncDone = true; } @@ -109,8 +104,7 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { if (appendFile != null && appendFile.isOpen()) { try { appendFile.close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.largeMessageErrorReleasingResources(e); } } @@ -121,8 +115,7 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { deleted = true; try { mainLM.deleteFile(); - } - finally { + } finally { deleteAppendFile(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/OperationContextImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/OperationContextImpl.java index 06e07f7323..ea96ce1367 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/OperationContextImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/OperationContextImpl.java @@ -58,8 +58,7 @@ public class OperationContextImpl implements OperationContext { if (token == null) { if (executorFactory == null) { return null; - } - else { + } else { token = new OperationContextImpl(executorFactory.getExecutor()); OperationContextImpl.threadLocalContext.set(token); } @@ -145,8 +144,7 @@ public class OperationContextImpl implements OperationContext { if (storeOnlyTasks == null) { storeOnlyTasks = new LinkedList<>(); } - } - else { + } else { if (tasks == null) { tasks = new LinkedList<>(); minimalReplicated = replicationLineUp.intValue(); @@ -166,16 +164,13 @@ public class OperationContextImpl implements OperationContext { // No need to use an executor here or a context switch // there are no actions pending.. hence we can just execute the task directly on the same thread executeNow = true; - } - else { + } else { execute(completion); } - } - else { + } else { if (storeOnly) { storeOnlyTasks.add(new TaskHolder(completion)); - } - else { + } else { tasks.add(new TaskHolder(completion)); } } @@ -218,8 +213,7 @@ public class OperationContextImpl implements OperationContext { execute(holder.task); iter.remove(); - } - else { + } else { // End of list here. No other task will be completed after this break; } @@ -240,14 +234,12 @@ public class OperationContextImpl implements OperationContext { // If any IO is done inside the callback, it needs to be done on a new context OperationContextImpl.clearContext(); task.done(); - } - finally { + } finally { executorsPending.decrementAndGet(); } } }); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorExecutingAIOCallback(e); executorsPending.decrementAndGet(); task.onError(ActiveMQExceptionType.INTERNAL_ERROR.getCode(), "It wasn't possible to complete IO operation - " + e.getMessage()); @@ -317,8 +309,7 @@ public class OperationContextImpl implements OperationContext { if (timeout == 0) { waitCallback.waitCompletion(); return true; - } - else { + } else { return waitCallback.waitCompletion(timeout); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/TXLargeMessageConfirmationOperation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/TXLargeMessageConfirmationOperation.java index bac83e673b..9e252e97d8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/TXLargeMessageConfirmationOperation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/TXLargeMessageConfirmationOperation.java @@ -37,8 +37,7 @@ public final class TXLargeMessageConfirmationOperation extends TransactionOperat for (Long msg : confirmedMessages) { try { journalStorageManager.confirmPendingLargeMessage(msg); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.journalErrorConfirmingLargeMessage(e, msg); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/DuplicateIDEncoding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/DuplicateIDEncoding.java index fccc2e2c41..1dd41ff04e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/DuplicateIDEncoding.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/DuplicateIDEncoding.java @@ -91,8 +91,7 @@ public class DuplicateIDEncoding implements EncodingSupport { long id = buff.getLong(); bridgeRepresentation = "nodeUUID=" + uuid.toString() + " messageID=" + id; - } - catch (Throwable ignored) { + } catch (Throwable ignored) { bridgeRepresentation = null; } } @@ -100,8 +99,7 @@ public class DuplicateIDEncoding implements EncodingSupport { if (bridgeRepresentation != null) { return "DuplicateIDEncoding [address=" + address + ", duplID=" + ByteUtil.bytesToHex(duplID, 2) + " / " + bridgeRepresentation + "]"; - } - else { + } else { return "DuplicateIDEncoding [address=" + address + ", duplID=" + ByteUtil.bytesToHex(duplID, 2) + "]"; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/BindingType.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/BindingType.java index 4576dea926..35f96f8868 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/BindingType.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/BindingType.java @@ -30,14 +30,11 @@ public enum BindingType { public int toInt() { if (equals(BindingType.LOCAL_QUEUE)) { return BindingType.LOCAL_QUEUE_INDEX; - } - else if (equals(BindingType.REMOTE_QUEUE)) { + } else if (equals(BindingType.REMOTE_QUEUE)) { return BindingType.REMOTE_QUEUE_INDEX; - } - else if (equals(BindingType.DIVERT)) { + } else if (equals(BindingType.DIVERT)) { return BindingType.DIVERT_INDEX; - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.cannotConvertToInt(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java index c6b0e9eb69..4c0c4b01cb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java @@ -70,24 +70,27 @@ public interface PostOffice extends ActiveMQComponent { RoutingStatus route(ServerMessage message, QueueCreator queueCreator, boolean direct) throws Exception; - RoutingStatus route(ServerMessage message, QueueCreator queueCreator, Transaction tx, boolean direct) throws Exception; + RoutingStatus route(ServerMessage message, + QueueCreator queueCreator, + Transaction tx, + boolean direct) throws Exception; RoutingStatus route(ServerMessage message, - QueueCreator queueCreator, - Transaction tx, - boolean direct, - boolean rejectDuplicates) throws Exception; + QueueCreator queueCreator, + Transaction tx, + boolean direct, + boolean rejectDuplicates) throws Exception; RoutingStatus route(ServerMessage message, - QueueCreator queueCreator, - RoutingContext context, - boolean direct) throws Exception; + QueueCreator queueCreator, + RoutingContext context, + boolean direct) throws Exception; RoutingStatus route(ServerMessage message, - QueueCreator queueCreator, - RoutingContext context, - boolean direct, - boolean rejectDuplicates) throws Exception; + QueueCreator queueCreator, + RoutingContext context, + boolean direct, + boolean rejectDuplicates) throws Exception; MessageReference reroute(ServerMessage message, Queue queue, Transaction tx) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/AddressImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/AddressImpl.java index d569a8cc62..e67011a643 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/AddressImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/AddressImpl.java @@ -93,19 +93,15 @@ public class AddressImpl implements Address { if (currMatch.equals(WildcardAddressManager.SINGLE_WORD_SIMPLESTRING)) { pos++; matchPos++; - } - else if (currMatch.equals(WildcardAddressManager.ANY_WORDS_SIMPLESTRING)) { + } else if (currMatch.equals(WildcardAddressManager.ANY_WORDS_SIMPLESTRING)) { if (matchPos == addressParts.length - 1) { pos++; matchPos++; - } - else if (next == null) { + } else if (next == null) { return false; - } - else if (matchPos == add.getAddressParts().length - 1) { + } else if (matchPos == add.getAddressParts().length - 1) { return true; - } - else { + } else { nextToMatch = add.getAddressParts()[matchPos + 1]; while (curr != null) { if (curr.equals(nextToMatch)) { @@ -120,8 +116,7 @@ public class AddressImpl implements Address { } matchPos++; } - } - else { + } else { if (!curr.equals(currMatch)) { return false; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java index c86b722a66..e5df737c70 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java @@ -98,8 +98,7 @@ public final class BindingsImpl implements Bindings { } if (binding.isExclusive()) { exclusiveBindings.add(binding); - } - else { + } else { SimpleString routingName = binding.getRoutingName(); List bindings = routingNameBindingMap.get(routingName); @@ -131,8 +130,7 @@ public final class BindingsImpl implements Bindings { public void removeBinding(final Binding binding) { if (binding.isExclusive()) { exclusiveBindings.remove(binding); - } - else { + } else { SimpleString routingName = binding.getRoutingName(); List bindings = routingNameBindingMap.get(routingName); @@ -190,8 +188,7 @@ public final class BindingsImpl implements Bindings { Binding binding; try { binding = bindings.get(pos); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // This can occur if binding is removed while in route if (!bindings.isEmpty()) { pos = 0; @@ -199,8 +196,7 @@ public final class BindingsImpl implements Bindings { length = bindings.size(); continue; - } - else { + } else { break; } } @@ -228,8 +224,7 @@ public final class BindingsImpl implements Bindings { theBinding.route(message, context); return true; - } - else { + } else { return false; } } @@ -283,11 +278,9 @@ public final class BindingsImpl implements Bindings { if (ids != null) { routeFromCluster(message, context, ids); - } - else if (groupingHandler != null && groupRouting && groupId != null) { + } else if (groupingHandler != null && groupRouting && groupId != null) { routeUsingStrictOrdering(message, context, groupingHandler, groupId, 0); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("Routing message " + message + " on binding=" + this); } @@ -344,8 +337,7 @@ public final class BindingsImpl implements Bindings { Binding binding; try { binding = bindings.get(pos); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // This can occur if binding is removed while in route if (!bindings.isEmpty()) { pos = 0; @@ -353,8 +345,7 @@ public final class BindingsImpl implements Bindings { length = bindings.size(); continue; - } - else { + } else { break; } } @@ -370,8 +361,7 @@ public final class BindingsImpl implements Bindings { pos = incrementPos(pos, length); break; - } - else { + } else { //https://issues.jboss.org/browse/HORNETQ-1254 When !routeWhenNoConsumers, // the localQueue should always have the priority over the secondary bindings if (lastLowPriorityBinding == -1 || messageLoadBalancingType.equals(MessageLoadBalancingType.ON_DEMAND) && binding instanceof LocalQueueBinding) { @@ -388,8 +378,7 @@ public final class BindingsImpl implements Bindings { if (lastLowPriorityBinding != -1) { try { theBinding = bindings.get(lastLowPriorityBinding); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // This can occur if binding is removed while in route if (!bindings.isEmpty()) { pos = 0; @@ -397,8 +386,7 @@ public final class BindingsImpl implements Bindings { lastLowPriorityBinding = -1; continue; - } - else { + } else { break; } } @@ -465,8 +453,7 @@ public final class BindingsImpl implements Bindings { } routeAndCheckNull(message, context, resp, theBinding, groupId, tries); - } - else { + } else { // ok, we need to find the binding and route it Binding chosen = locateBinding(resp.getChosenClusterName(), bindings); @@ -494,8 +481,7 @@ public final class BindingsImpl implements Bindings { // and let's route it if (theBinding != null) { theBinding.route(message, context); - } - else { + } else { if (resp != null) { groupingHandler.forceRemove(resp.getGroupId(), resp.getClusterName()); } @@ -504,8 +490,7 @@ public final class BindingsImpl implements Bindings { //in this case all we can do is remove it and try again. if (tries < MAX_GROUP_RETRY) { routeUsingStrictOrdering(message, context, groupingHandler, groupId, tries + 1); - } - else { + } else { ActiveMQServerLogger.LOGGER.impossibleToRouteGrouped(); route(message, context, false); } @@ -590,12 +575,10 @@ public final class BindingsImpl implements Bindings { if (binding != null) { if (idsToAckList.contains(bindingID)) { binding.routeWithAck(message, context); - } - else { + } else { binding.route(message, context); } - } - else { + } else { ActiveMQServerLogger.LOGGER.bindingNotFound(bindingID, message.toString(), this.toString()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java index 28896c3eac..ce3c7820de 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java @@ -95,8 +95,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { storageManager.deleteDuplicateIDTransactional(txID, id.getB()); deleteCount--; - } - else { + } else { ByteArrayHolder bah = new ByteArrayHolder(id.getA()); Pair pair = new Pair<>(bah, id.getB()); @@ -155,8 +154,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { private String describeID(byte[] duplicateID, long id) { if (id != 0) { return ByteUtil.bytesToHex(duplicateID, 4) + ", simpleString=" + ByteUtil.toSimpleString(duplicateID); - } - else { + } else { return ByteUtil.bytesToHex(duplicateID, 4) + ", simpleString=" + ByteUtil.toSimpleString(duplicateID) + ", id=" + id; } } @@ -189,8 +187,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { tx.markAsRollbackOnly(new ActiveMQDuplicateIdException()); } return false; - } - else { + } else { addToCache(duplID, tx, true); return true; } @@ -208,8 +205,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { } addToCacheInMemory(duplID, recordID); - } - else { + } else { if (persist) { recordID = storageManager.generateID(); storageManager.storeDuplicateIDTransactional(tx.getID(), address, duplID, recordID); @@ -219,8 +215,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { if (instantAdd) { addToCacheInMemory(duplID, recordID); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("DuplicateIDCacheImpl(" + this.address + ")::addToCache Adding duplicateID TX operation for " + describeID(duplID, recordID) + ", tx=" + tx); } @@ -266,8 +261,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { if (id.getB() != null) { try { storageManager.deleteDuplicateID(id.getB()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorDeletingDuplicateCache(e); } } @@ -284,8 +278,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { } holder.pos = pos; - } - else { + } else { id = new Pair<>(holder, recordID >= 0 ? recordID : null); if (logger.isTraceEnabled()) { @@ -389,8 +382,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache { } return true; - } - else { + } else { return false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index c8a6966ed9..cc06603b13 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -156,8 +156,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (enableWildCardRouting) { addressManager = new WildcardAddressManager(this); - } - else { + } else { addressManager = new SimpleAddressManager(this); } @@ -480,8 +479,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (binding.getType() == BindingType.LOCAL_QUEUE) { managementService.unregisterQueue(uniqueName, binding.getAddress()); - } - else if (binding.getType() == BindingType.DIVERT) { + } else if (binding.getType() == BindingType.DIVERT) { managementService.unregisterDivert(uniqueName); } @@ -500,8 +498,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (binding.getFilter() == null) { props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, null); - } - else { + } else { props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, binding.getFilter().getFilterString()); } @@ -565,32 +562,34 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding } @Override - public RoutingStatus route(final ServerMessage message, QueueCreator queueCreator, final boolean direct) throws Exception { + public RoutingStatus route(final ServerMessage message, + QueueCreator queueCreator, + final boolean direct) throws Exception { return route(message, queueCreator, (Transaction) null, direct); } @Override public RoutingStatus route(final ServerMessage message, - QueueCreator queueCreator, - final Transaction tx, - final boolean direct) throws Exception { + QueueCreator queueCreator, + final Transaction tx, + final boolean direct) throws Exception { return route(message, queueCreator, new RoutingContextImpl(tx), direct); } @Override public RoutingStatus route(final ServerMessage message, - final QueueCreator queueCreator, - final Transaction tx, - final boolean direct, - final boolean rejectDuplicates) throws Exception { + final QueueCreator queueCreator, + final Transaction tx, + final boolean direct, + final boolean rejectDuplicates) throws Exception { return route(message, queueCreator, new RoutingContextImpl(tx), direct, rejectDuplicates); } @Override public RoutingStatus route(final ServerMessage message, - final QueueCreator queueCreator, - final RoutingContext context, - final boolean direct) throws Exception { + final QueueCreator queueCreator, + final RoutingContext context, + final boolean direct) throws Exception { return route(message, queueCreator, context, direct, true); } @@ -638,8 +637,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (bindings != null) { bindings.route(message, context); - } - else { + } else { // this is a debug and not warn because this could be a regular scenario on publish-subscribe queues (or topic subscriptions on JMS) if (logger.isDebugEnabled()) { logger.debug("Couldn't find any bindings for address=" + address + " on message=" + message); @@ -669,8 +667,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (dlaAddress == null) { result = RoutingStatus.NO_BINDINGS; ActiveMQServerLogger.LOGGER.noDLA(address); - } - else { + } else { message.setOriginalHeaders(message, null, false); message.setAddress(dlaAddress); @@ -678,8 +675,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding route(message, null, context.getTransaction(), false); result = RoutingStatus.NO_BINDINGS_DLA; } - } - else { + } else { result = RoutingStatus.NO_BINDINGS; if (logger.isDebugEnabled()) { @@ -690,16 +686,13 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding ((LargeServerMessage) message).deleteFile(); } } - } - else { + } else { try { processRoute(message, context, direct); - } - catch (ActiveMQAddressFullException e) { + } catch (ActiveMQAddressFullException e) { if (startedTX.get()) { context.getTransaction().rollback(); - } - else if (context.getTransaction() != null) { + } else if (context.getTransaction() != null) { context.getTransaction().markAsRollbackOnly(e); } throw e; @@ -744,8 +737,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (tx == null) { queue.reload(reference); - } - else { + } else { List refs = new ArrayList<>(1); refs.add(reference); @@ -1033,8 +1025,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (durableRefCount == 1) { if (tx != null) { storageManager.storeMessageTransactional(tx.getID(), message); - } - else { + } else { storageManager.storeMessage(message); } @@ -1047,16 +1038,14 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding storageManager.storeReferenceTransactional(tx.getID(), queue.getID(), message.getMessageID()); tx.setContainsPersistent(); - } - else { + } else { storageManager.storeReference(queue.getID(), message.getMessageID(), !iter.hasNext()); } if (message.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) { if (tx != null) { storageManager.updateScheduledDeliveryTimeTransactional(tx.getID(), reference); - } - else { + } else { storageManager.updateScheduledDeliveryTime(reference); } } @@ -1068,8 +1057,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (tx != null) { tx.addOperation(new AddOperation(refs)); - } - else { + } else { // This will use the same thread if there are no pending operations // avoiding a context switch on this case storageManager.afterCompleteOperations(new IOCallback() { @@ -1096,8 +1084,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (largeServerMessage.getPendingRecordID() >= 0) { if (tx == null) { storageManager.confirmPendingLargeMessage(largeServerMessage.getPendingRecordID()); - } - else { + } else { storageManager.confirmPendingLargeMessageTX(tx, largeServerMessage.getMessageID(), largeServerMessage.getPendingRecordID()); } largeServerMessage.setPendingRecordID(-1); @@ -1121,8 +1108,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding delivery.addQueues(entry.getValue().getDurableQueues()); delivery.addQueues(entry.getValue().getNonDurableQueues()); - } - else { + } else { List durableQueues = entry.getValue().getDurableQueues(); List nonDurableQueues = entry.getValue().getNonDurableQueues(); @@ -1175,8 +1161,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding } message.removeProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID); - } - else { + } else { // if used BridgeDuplicate, it's not going to use the regular duplicate // since this will would break redistribution (re-setting the duplicateId) byte[] duplicateIDBytes = message.getDuplicateIDBytes(); @@ -1261,10 +1246,10 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding private final class Reaper extends ActiveMQScheduledComponent { Reaper(ScheduledExecutorService scheduledExecutorService, - Executor executor, - long checkPeriod, - TimeUnit timeUnit, - boolean onDemand) { + Executor executor, + long checkPeriod, + TimeUnit timeUnit, + boolean onDemand) { super(scheduledExecutorService, executor, checkPeriod, timeUnit, onDemand); } @@ -1287,8 +1272,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding for (Queue queue : queues) { try { queue.expireReferences(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorExpiringMessages(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java index bbfdcc154a..9f26b0b236 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java @@ -37,6 +37,7 @@ import org.jboss.logging.Logger; * A simple address manager that maintains the addresses and bindings. */ public class SimpleAddressManager implements AddressManager { + private static final Logger logger = Logger.getLogger(Page.class); /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/WildcardAddressManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/WildcardAddressManager.java index 7609355318..7838e934a4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/WildcardAddressManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/WildcardAddressManager.java @@ -94,8 +94,7 @@ public class WildcardAddressManager extends SimpleAddressManager { for (Address destAdd : add.getLinkedAddresses()) { super.addMappingInternal(destAdd.getAddress(), binding); } - } - else { + } else { for (Address destAdd : add.getLinkedAddresses()) { Bindings bindings = super.getBindingsForRoutingAddress(destAdd.getAddress()); for (Binding b : bindings.getBindings()) { @@ -141,8 +140,7 @@ public class WildcardAddressManager extends SimpleAddressManager { Address actualAddress; if (add.containsWildCard()) { actualAddress = wildCardAddresses.get(address); - } - else { + } else { actualAddress = addresses.get(address); } return actualAddress != null ? actualAddress : add; @@ -153,8 +151,7 @@ public class WildcardAddressManager extends SimpleAddressManager { Address actualAddress; if (add.containsWildCard()) { actualAddress = wildCardAddresses.get(address); - } - else { + } else { actualAddress = addresses.get(address); } if (actualAddress == null) { @@ -168,8 +165,7 @@ public class WildcardAddressManager extends SimpleAddressManager { actualAddress.addLinkedAddress(destAdd); } } - } - else { + } else { for (Address destAdd : wildCardAddresses.values()) { if (actualAddress.matches(destAdd)) { destAdd.addLinkedAddress(actualAddress); @@ -184,8 +180,7 @@ public class WildcardAddressManager extends SimpleAddressManager { private void addAddress(final SimpleString address, final Address actualAddress) { if (actualAddress.containsWildCard()) { wildCardAddresses.put(address, actualAddress); - } - else { + } else { addresses.put(address, actualAddress); } } @@ -209,8 +204,7 @@ public class WildcardAddressManager extends SimpleAddressManager { private void removeAddress(final Address add) { if (add.containsWildCard()) { wildCardAddresses.remove(add.getAddress()); - } - else { + } else { addresses.remove(add.getAddress()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ProtocolHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ProtocolHandler.java index b4d8de5562..340861be55 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ProtocolHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ProtocolHandler.java @@ -121,14 +121,11 @@ public class ProtocolHandler { ctx.pipeline().remove(this); ctx.pipeline().remove("http-handler"); ctx.fireChannelRead(msg); - } - // HORNETQ-1391 - else if (upgrade != null && upgrade.equalsIgnoreCase(NettyConnector.ACTIVEMQ_REMOTING)) { + } else if (upgrade != null && upgrade.equalsIgnoreCase(NettyConnector.ACTIVEMQ_REMOTING)) { // HORNETQ-1391 // Send the response and close the connection if necessary. ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)).addListener(ChannelFutureListener.CLOSE); } - } - else { + } else { super.channelRead(ctx, msg); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java index 44578085a9..2869e3844d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java @@ -16,11 +16,44 @@ */ package org.apache.activemq.artemis.core.protocol; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.core.protocol.core.Packet; +import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequestMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectReplyMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NodeAnnounceMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteReplyMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageBeginMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageEndMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageWriteMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPrepareMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessageV2; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationStartSyncMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ScaleDownAnnounceMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendLargeMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage; +import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; + +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST_RESPONSE; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_CONNECT; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CLUSTER_CONNECT_REPLY; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.NODE_ANNOUNCE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST_RESPONSE; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.QUORUM_VOTE; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.QUORUM_VOTE_REPLY; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REPLICATION_APPEND; @@ -36,42 +69,9 @@ import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REP import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REPLICATION_PREPARE; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REPLICATION_RESPONSE; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.REPLICATION_RESPONSE_V2; +import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SCALEDOWN_ANNOUNCEMENT; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_SEND; import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_SEND_LARGE; -import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SCALEDOWN_ANNOUNCEMENT; - -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.core.protocol.core.Packet; -import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterConnectReplyMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NodeAnnounceMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequestMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.QuorumVoteReplyMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageBeginMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageEndMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageWriteMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPrepareMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessageV2; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationStartSyncMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ScaleDownAnnounceMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendLargeMessage; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage; -import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; public class ServerPacketDecoder extends ClientPacketDecoder { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java index f12fd0baab..b52534cb37 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java @@ -145,8 +145,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { if (conn instanceof NettyConnection) { direct = ((NettyConnection) conn).isDirectDeliver(); - } - else { + } else { direct = false; } } @@ -164,8 +163,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { try { session.close(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSession(e); } @@ -177,8 +175,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { try { session.close(false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSession(e); } } @@ -215,8 +212,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { QueueQueryResult queueQueryResult = session.executeQueueQuery(request.getQueueName()); if (channel.supports(PacketImpl.SESS_QUEUEQUERY_RESP_V2)) { response = new SessionQueueQueryResponseMessage_V2(queueQueryResult); - } - else { + } else { response = new SessionQueueQueryResponseMessage(queueQueryResult); } } @@ -254,8 +250,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { QueueQueryResult result = session.executeQueueQuery(request.getQueueName()); if (channel.supports(PacketImpl.SESS_QUEUEQUERY_RESP_V2)) { response = new SessionQueueQueryResponseMessage_V2(result); - } - else { + } else { response = new SessionQueueQueryResponseMessage(result); } break; @@ -266,11 +261,9 @@ public class ServerSessionPacketHandler implements ChannelHandler { BindingQueryResult result = session.executeBindingQuery(request.getAddress()); if (channel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V3)) { response = new SessionBindingQueryResponseMessage_V3(result.isExists(), result.getQueueNames(), result.isAutoCreateJmsQueues(), result.isAutoCreateJmsTopics()); - } - else if (channel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V2)) { + } else if (channel.supports(PacketImpl.SESS_BINDINGQUERY_RESP_V2)) { response = new SessionBindingQueryResponseMessage_V2(result.isExists(), result.getQueueNames(), result.isAutoCreateJmsQueues()); - } - else { + } else { response = new SessionBindingQueryResponseMessage(result.isExists(), result.getQueueNames()); } break; @@ -480,63 +473,52 @@ public class ServerSessionPacketHandler implements ChannelHandler { SessionUniqueAddMetaDataMessage message = (SessionUniqueAddMetaDataMessage) packet; if (session.addUniqueMetaData(message.getKey(), message.getData())) { response = new NullResponseMessage(); - } - else { + } else { response = new ActiveMQExceptionMessage(ActiveMQMessageBundle.BUNDLE.duplicateMetadata(message.getKey(), message.getData())); } break; } } - } - catch (ActiveMQIOErrorException e) { + } catch (ActiveMQIOErrorException e) { getSession().markTXFailed(e); if (requiresResponse) { logger.debug("Sending exception to client", e); response = new ActiveMQExceptionMessage(e); - } - else { + } else { ActiveMQServerLogger.LOGGER.caughtException(e); } - } - catch (ActiveMQXAException e) { + } catch (ActiveMQXAException e) { if (requiresResponse) { logger.debug("Sending exception to client", e); response = new SessionXAResponseMessage(true, e.errorCode, e.getMessage()); - } - else { + } else { ActiveMQServerLogger.LOGGER.caughtXaException(e); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (requiresResponse) { logger.debug("Sending exception to client", e); response = new ActiveMQExceptionMessage(e); - } - else { + } else { if (e.getType() == ActiveMQExceptionType.QUEUE_EXISTS) { logger.debug("Caught exception", e); - } - else { + } else { ActiveMQServerLogger.LOGGER.caughtException(e); } } - } - catch (Throwable t) { + } catch (Throwable t) { getSession().markTXFailed(t); if (requiresResponse) { ActiveMQServerLogger.LOGGER.warn("Sending unexpected exception to the client", t); ActiveMQException activeMQInternalErrorException = new ActiveMQInternalErrorException(); activeMQInternalErrorException.initCause(t); response = new ActiveMQExceptionMessage(activeMQInternalErrorException); - } - else { + } else { ActiveMQServerLogger.LOGGER.caughtException(t); } } sendResponse(packet, response, flush, closeChannel); - } - finally { + } finally { storageManager.clearContext(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java index 59120d3cf9..149c0112eb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java @@ -138,8 +138,7 @@ public class ActiveMQPacketHandler implements ChannelHandler { if (connection.getClientVersion() == 0) { connection.setClientVersion(request.getVersion()); - } - else if (connection.getClientVersion() != request.getVersion()) { + } else if (connection.getClientVersion() != request.getVersion()) { ActiveMQServerLogger.LOGGER.incompatibleVersionAfterConnect(request.getVersion(), connection.getClientVersion()); } @@ -151,8 +150,7 @@ public class ActiveMQPacketHandler implements ChannelHandler { activeMQPrincipal = connection.getDefaultActiveMQPrincipal(); } - ServerSession session = server.createSession(request.getName(), activeMQPrincipal == null ? request.getUsername() : activeMQPrincipal.getUserName(), activeMQPrincipal == null ? request.getPassword() : activeMQPrincipal.getPassword(), request.getMinLargeMessageSize(), connection, request.isAutoCommitSends(), request.isAutoCommitAcks(), request.isPreAcknowledge(), request.isXA(), request.getDefaultAddress(), - new CoreSessionCallback(request.getName(), protocolManager, channel, connection), true); + ServerSession session = server.createSession(request.getName(), activeMQPrincipal == null ? request.getUsername() : activeMQPrincipal.getUserName(), activeMQPrincipal == null ? request.getPassword() : activeMQPrincipal.getPassword(), request.getMinLargeMessageSize(), connection, request.isAutoCommitSends(), request.isAutoCommitAcks(), request.isPreAcknowledge(), request.isXA(), request.getDefaultAddress(), new CoreSessionCallback(request.getName(), protocolManager, channel, connection), true); ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session, server.getStorageManager(), channel); channel.setHandler(handler); @@ -161,19 +159,16 @@ public class ActiveMQPacketHandler implements ChannelHandler { protocolManager.addSessionHandler(request.getName(), handler); response = new CreateSessionResponseMessage(server.getVersion().getIncrementingVersion()); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS) { incompatibleVersion = true; logger.debug("Sending ActiveMQException after Incompatible client", e); - } - else { + } else { ActiveMQServerLogger.LOGGER.failedToCreateSession(e); } response = new ActiveMQExceptionMessage(e); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToCreateSession(e); response = new ActiveMQExceptionMessage(new ActiveMQInternalErrorException()); @@ -184,8 +179,7 @@ public class ActiveMQPacketHandler implements ChannelHandler { // are not compatible if (incompatibleVersion) { channel1.sendAndFlush(response); - } - else { + } else { channel1.send(response); } } @@ -206,8 +200,7 @@ public class ActiveMQPacketHandler implements ChannelHandler { // HORNETQ-720 XXX ataylor? if (/*!server.checkActivate() || */ sessionHandler == null) { response = new ReattachSessionResponseMessage(-1, false); - } - else { + } else { if (sessionHandler.getChannel().getConfirmationWindowSize() == -1) { // Even though session exists, we can't reattach since confi window size == -1, // i.e. we don't have a resend cache for commands, so we just close the old session @@ -219,16 +212,14 @@ public class ActiveMQPacketHandler implements ChannelHandler { sessionHandler.close(); response = new ReattachSessionResponseMessage(-1, false); - } - else { + } else { // Reconnect the channel to the new connection int serverLastConfirmedCommandID = sessionHandler.transferConnection(connection, request.getLastConfirmedCommandID()); response = new ReattachSessionResponseMessage(serverLastConfirmedCommandID, true); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToReattachSession(e); response = new ActiveMQExceptionMessage(new ActiveMQInternalErrorException()); @@ -240,9 +231,8 @@ public class ActiveMQPacketHandler implements ChannelHandler { private void handleCreateQueue(final CreateQueueMessage request) { try { server.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(), request.isTemporary()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToHandleCreateQueue(e); } } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java index 69db679bbd..3fb642ab4a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java @@ -236,8 +236,7 @@ public class CoreProtocolManager implements ProtocolManager { // Just send a ping back channel0.send(packet); - } - else if (packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY || packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY_V2) { + } else if (packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY || packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY_V2) { SubscribeClusterTopologyUpdatesMessage msg = (SubscribeClusterTopologyUpdatesMessage) packet; if (packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY_V2) { @@ -259,17 +258,14 @@ public class CoreProtocolManager implements ProtocolManager { public void run() { if (channel0.supports(PacketImpl.CLUSTER_TOPOLOGY_V3)) { channel0.send(new ClusterTopologyChangeMessage_V3(topologyMember.getUniqueEventID(), nodeID, topologyMember.getBackupGroupName(), topologyMember.getScaleDownGroupName(), connectorPair, last)); - } - else if (channel0.supports(PacketImpl.CLUSTER_TOPOLOGY_V2)) { + } else if (channel0.supports(PacketImpl.CLUSTER_TOPOLOGY_V2)) { channel0.send(new ClusterTopologyChangeMessage_V2(topologyMember.getUniqueEventID(), nodeID, topologyMember.getBackupGroupName(), connectorPair, last)); - } - else { + } else { channel0.send(new ClusterTopologyChangeMessage(nodeID, connectorPair, last)); } } }); - } - catch (RejectedExecutionException ignored) { + } catch (RejectedExecutionException ignored) { // this could happen during a shutdown and we don't care, if we lost a nodeDown during a shutdown // what can we do anyways? } @@ -287,14 +283,12 @@ public class CoreProtocolManager implements ProtocolManager { public void run() { if (channel0.supports(PacketImpl.CLUSTER_TOPOLOGY_V2)) { channel0.send(new ClusterTopologyChangeMessage_V2(uniqueEventID, nodeID)); - } - else { + } else { channel0.send(new ClusterTopologyChangeMessage(nodeID)); } } }); - } - catch (RejectedExecutionException ignored) { + } catch (RejectedExecutionException ignored) { // this could happen during a shutdown and we don't care, if we lost a nodeDown during a shutdown // what can we do anyways? } @@ -315,8 +309,7 @@ public class CoreProtocolManager implements ProtocolManager { acceptorUsed.getClusterConnection().removeClusterTopologyListener(listener); } }); - } - else { + } else { // if not clustered, we send a single notification to the client containing the node-id where the server is connected to // This is done this way so Recovery discovery could also use the node-id for non-clustered setups entry.connectionExecutor.execute(new Runnable() { @@ -326,8 +319,7 @@ public class CoreProtocolManager implements ProtocolManager { Pair emptyConfig = new Pair<>(null, null); if (channel0.supports(PacketImpl.CLUSTER_TOPOLOGY_V2)) { channel0.send(new ClusterTopologyChangeMessage_V2(System.currentTimeMillis(), nodeId, null, emptyConfig, true)); - } - else { + } else { channel0.send(new ClusterTopologyChangeMessage(nodeId, emptyConfig, true)); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java index f4d69d1b6e..e35771effa 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java @@ -44,7 +44,10 @@ public final class CoreSessionCallback implements SessionCallback { private String name; - public CoreSessionCallback(String name, ProtocolManager protocolManager, Channel channel, RemotingConnection connection) { + public CoreSessionCallback(String name, + ProtocolManager protocolManager, + Channel channel, + RemotingConnection connection) { this.name = name; this.protocolManager = protocolManager; this.channel = channel; @@ -62,7 +65,11 @@ public final class CoreSessionCallback implements SessionCallback { } @Override - public int sendLargeMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, long bodySize, int deliveryCount) { + public int sendLargeMessage(MessageReference ref, + ServerMessage message, + ServerConsumer consumer, + long bodySize, + int deliveryCount) { Packet packet = new SessionReceiveLargeMessage(consumer.getID(), message, bodySize, deliveryCount); channel.send(packet); @@ -130,8 +137,7 @@ public final class CoreSessionCallback implements SessionCallback { public void disconnect(ServerConsumer consumerId, String queueName) { if (channel.supports(PacketImpl.DISCONNECT_CONSUMER)) { channel.send(new DisconnectConsumerMessage(consumerId.getID())); - } - else { + } else { ActiveMQServerLogger.LOGGER.warnDisconnectOldClient(queueName); } } @@ -142,4 +148,4 @@ public final class CoreSessionCallback implements SessionCallback { // as the flow control is done by activemq return true; } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java index f444f688f6..8b61fccc23 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java @@ -110,20 +110,17 @@ public final class BackupRegistrationMessage extends PacketImpl { if (clusterPassword == null) { if (other.clusterPassword != null) return false; - } - else if (!clusterPassword.equals(other.clusterPassword)) + } else if (!clusterPassword.equals(other.clusterPassword)) return false; if (clusterUser == null) { if (other.clusterUser != null) return false; - } - else if (!clusterUser.equals(other.clusterUser)) + } else if (!clusterUser.equals(other.clusterUser)) return false; if (connector == null) { if (other.connector != null) return false; - } - else if (!connector.equals(other.connector)) + } else if (!connector.equals(other.connector)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/NodeAnnounceMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/NodeAnnounceMessage.java index 714c21fe29..074e7b454b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/NodeAnnounceMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/NodeAnnounceMessage.java @@ -114,15 +114,13 @@ public class NodeAnnounceMessage extends PacketImpl { if (connector != null) { buffer.writeBoolean(true); connector.encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } if (backupConnector != null) { buffer.writeBoolean(true); backupConnector.encode(buffer); - } - else { + } else { buffer.writeBoolean(false); } buffer.writeNullableString(scaleDownGroupName); @@ -189,16 +187,14 @@ public class NodeAnnounceMessage extends PacketImpl { if (other.backupConnector != null) { return false; } - } - else if (!backupConnector.equals(other.backupConnector)) { + } else if (!backupConnector.equals(other.backupConnector)) { return false; } if (connector == null) { if (other.connector != null) { return false; } - } - else if (!connector.equals(other.connector)) { + } else if (!connector.equals(other.connector)) { return false; } if (currentEventID != other.currentEventID) { @@ -208,11 +204,9 @@ public class NodeAnnounceMessage extends PacketImpl { if (other.nodeID != null) { return false; } - } - else if (!nodeID.equals(other.nodeID)) { + } else if (!nodeID.equals(other.nodeID)) { return false; - } - else if (!scaleDownGroupName.equals(other.scaleDownGroupName)) { + } else if (!scaleDownGroupName.equals(other.scaleDownGroupName)) { return false; } return true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java index eebc29aed5..89d28630e7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java @@ -138,8 +138,7 @@ public final class ReplicationAddMessage extends PacketImpl { if (encodingData == null) { if (other.encodingData != null) return false; - } - else if (!encodingData.equals(other.encodingData)) + } else if (!encodingData.equals(other.encodingData)) return false; if (id != other.id) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java index c4d7e79e2f..59475e060e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java @@ -148,8 +148,7 @@ public class ReplicationAddTXMessage extends PacketImpl { if (encodingData == null) { if (other.encodingData != null) return false; - } - else if (!encodingData.equals(other.encodingData)) + } else if (!encodingData.equals(other.encodingData)) return false; if (id != other.id) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationDeleteTXMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationDeleteTXMessage.java index 82f652514d..0d7552396b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationDeleteTXMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationDeleteTXMessage.java @@ -120,8 +120,7 @@ public class ReplicationDeleteTXMessage extends PacketImpl { if (encodingData == null) { if (other.encodingData != null) return false; - } - else if (!encodingData.equals(other.encodingData)) + } else if (!encodingData.equals(other.encodingData)) return false; if (id != other.id) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageEventMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageEventMessage.java index 78555dbc6d..31680daf49 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageEventMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageEventMessage.java @@ -109,8 +109,7 @@ public class ReplicationPageEventMessage extends PacketImpl { if (storeName == null) { if (other.storeName != null) return false; - } - else if (!storeName.equals(other.storeName)) + } else if (!storeName.equals(other.storeName)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java index 4199cb088f..7307151993 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java @@ -89,8 +89,7 @@ public class ReplicationPageWriteMessage extends PacketImpl { if (pagedMessage == null) { if (other.pagedMessage != null) return false; - } - else if (!pagedMessage.equals(other.pagedMessage)) + } else if (!pagedMessage.equals(other.pagedMessage)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java index cf8c413f84..ebdc1c4e2a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java @@ -110,8 +110,7 @@ public final class ReplicationPrepareMessage extends PacketImpl { if (other.encodingData != null) { return false; } - } - else if (!encodingData.equals(other.encodingData)) { + } else if (!encodingData.equals(other.encodingData)) { return false; } if (journalID != other.journalID) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationResponseMessageV2.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationResponseMessageV2.java index 146a3de8dc..f9001c641d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationResponseMessageV2.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationResponseMessageV2.java @@ -20,6 +20,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; public final class ReplicationResponseMessageV2 extends ReplicationResponseMessage { + boolean synchronizationIsFinishedAcknowledgement = false; public ReplicationResponseMessageV2(final boolean synchronizationIsFinishedAcknowledgement) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java index 157e02ba1b..a44707f017 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationStartSyncMessage.java @@ -196,8 +196,7 @@ public class ReplicationStartSyncMessage extends PacketImpl { if (nodeID == null) { if (other.nodeID != null) return false; - } - else if (!nodeID.equals(other.nodeID)) + } else if (!nodeID.equals(other.nodeID)) return false; if (synchronizationIsFinished != other.synchronizationIsFinished) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java index 208e86bca2..de7f73e0c7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java @@ -91,11 +91,9 @@ public final class ReplicationSyncFileMessage extends PacketImpl { private void determineType() { if (journalType != null) { fileType = FileType.JOURNAL; - } - else if (pageStoreName != null) { + } else if (pageStoreName != null) { fileType = FileType.PAGE; - } - else { + } else { fileType = FileType.LARGE_MESSAGE; } } @@ -209,8 +207,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl { if (other.byteBuffer != null) { return false; } - } - else if (!byteBuffer.equals(other.byteBuffer)) { + } else if (!byteBuffer.equals(other.byteBuffer)) { return false; } if (dataSize != other.dataSize) { @@ -229,8 +226,7 @@ public final class ReplicationSyncFileMessage extends PacketImpl { if (other.pageStoreName != null) { return false; } - } - else if (!pageStoreName.equals(other.pageStoreName)) { + } else if (!pageStoreName.equals(other.pageStoreName)) { return false; } return true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/registry/JndiBindingRegistry.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/registry/JndiBindingRegistry.java index d22fda852c..be4661cac0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/registry/JndiBindingRegistry.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/registry/JndiBindingRegistry.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.registry; -import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; -import org.apache.activemq.artemis.utils.JNDIUtil; - import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; +import org.apache.activemq.artemis.utils.JNDIUtil; + public class JndiBindingRegistry implements BindingRegistry { private Context context; @@ -40,12 +40,10 @@ public class JndiBindingRegistry implements BindingRegistry { try { if (context == null) { return null; - } - else { + } else { return context.lookup(name); } - } - catch (NamingException e) { + } catch (NamingException e) { return null; } } @@ -54,8 +52,7 @@ public class JndiBindingRegistry implements BindingRegistry { public boolean bind(String name, Object obj) { try { return bindToJndi(name, obj); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -66,8 +63,7 @@ public class JndiBindingRegistry implements BindingRegistry { if (context != null) { context.unbind(name); } - } - catch (NamingException e) { + } catch (NamingException e) { } } @@ -77,8 +73,7 @@ public class JndiBindingRegistry implements BindingRegistry { if (context != null) { context.close(); } - } - catch (NamingException e) { + } catch (NamingException e) { } } @@ -89,8 +84,7 @@ public class JndiBindingRegistry implements BindingRegistry { int sepIndex = jndiName.lastIndexOf('/'); if (sepIndex == -1) { parentContext = ""; - } - else { + } else { parentContext = jndiName.substring(0, sepIndex); } jndiNameInContext = jndiName.substring(sepIndex + 1); @@ -99,8 +93,7 @@ public class JndiBindingRegistry implements BindingRegistry { //JMSServerManagerImpl.log.warn("Binding for " + jndiName + " already exists"); return false; - } - catch (Throwable e) { + } catch (Throwable e) { // OK } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/AbstractAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/AbstractAcceptor.java index 4004df6cf7..a2f30f3f62 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/AbstractAcceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/AbstractAcceptor.java @@ -28,15 +28,16 @@ public abstract class AbstractAcceptor implements Acceptor { protected final Map protocolMap; - public AbstractAcceptor(Map protocolMap) { this.protocolMap = protocolMap; } + /** * This will update the list of interceptors for each ProtocolManager inside the acceptor. - * */ + */ @Override - public void updateInterceptors(List incomingInterceptors, List outgoingInterceptors) { + public void updateInterceptors(List incomingInterceptors, + List outgoingInterceptors) { for (ProtocolManager manager : protocolMap.values()) { manager.updateInterceptors(incomingInterceptors, outgoingInterceptors); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java index d30b564dab..9c26b4717c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java @@ -72,7 +72,6 @@ public final class InVMAcceptor extends AbstractAcceptor { private static final Logger logger = Logger.getLogger(InVMAcceptor.class); - public InVMAcceptor(final String name, final ClusterConnection clusterConnection, final Map configuration, @@ -166,9 +165,8 @@ public final class InVMAcceptor extends AbstractAcceptor { Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { - logger.warn("failed to send notification",e.getMessage(),e); + } catch (Exception e) { + logger.warn("failed to send notification", e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java index 169ea3c3a1..27fc5440ed 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java @@ -193,13 +193,11 @@ public class InVMConnection implements Connection { futureListener.operationComplete(null); } } - } - catch (Exception e) { + } catch (Exception e) { final String msg = "Failed to write to handler on connector " + this; ActiveMQServerLogger.LOGGER.errorWritingToInvmConnector(e, this); throw new IllegalStateException(msg, e); - } - finally { + } finally { if (logger.isTraceEnabled()) { logger.trace(InVMConnection.this + "::packet sent done"); } @@ -220,13 +218,11 @@ public class InVMConnection implements Connection { if (!latch.await(10, TimeUnit.SECONDS)) { ActiveMQServerLogger.LOGGER.timedOutFlushingInvmChannel(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } - } - catch (RejectedExecutionException e) { + } catch (RejectedExecutionException e) { // Ignore - this can happen if server/client is shutdown and another request comes in } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java index e239466f9c..907fb403e8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java @@ -39,8 +39,8 @@ import org.apache.activemq.artemis.spi.core.remoting.ClientConnectionLifeCycleLi import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; -import org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; +import org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor; import org.apache.activemq.artemis.utils.ConfigurationHelper; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.jboss.logging.Logger; @@ -108,8 +108,7 @@ public class InVMConnector extends AbstractConnector { if (threadPoolExecutor == null) { if (ActiveMQClient.getGlobalThreadPoolSize() <= -1) { threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), ActiveMQThreadFactory.defaultThreadFactory()); - } - else { + } else { threadPoolExecutor = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.getGlobalThreadPoolSize(), 60L, TimeUnit.SECONDS, ActiveMQThreadFactory.defaultThreadFactory()); } } @@ -181,8 +180,7 @@ public class InVMConnector extends AbstractConnector { acceptor.connect((String) conn.getID(), handler, this, executorFactory.getExecutor()); return conn; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug(new StringBuilder().append("Connection limit of ").append(acceptor.getConnectionsAllowed()).append(" reached. Refusing connection.")); } @@ -239,8 +237,7 @@ public class InVMConnector extends AbstractConnector { if (listener instanceof ConnectionLifeCycleListener) { listener.connectionCreated(component, connection, protocol.getName()); - } - else { + } else { listener.connectionCreated(component, connection, protocol); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMRegistry.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMRegistry.java index f166a50dba..fe74a91450 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMRegistry.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMRegistry.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.remoting.impl.invm; -import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; - import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; + public final class InVMRegistry { public static final InVMRegistry instance = new InVMRegistry(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/HttpAcceptorHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/HttpAcceptorHandler.java index f92a303064..a910941d5e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/HttpAcceptorHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/HttpAcceptorHandler.java @@ -90,8 +90,7 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { // we are either a channel buffer, which gets delayed until a response is available, or we are the actual response if (msg instanceof ByteBuf) { executor.execute(new ResponseRunner((ByteBuf) msg, promise)); - } - else { + } else { ctx.write(msg, promise); } } @@ -102,8 +101,7 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { for (ResponseHolder response : responses) { if (response.timeReceived < time) { lateResponses++; - } - else { + } else { break; } } @@ -141,8 +139,7 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { do { try { responseHolder = responses.take(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { if (executor.isShutdown()) return; // otherwise ignore, we'll just try again @@ -152,8 +149,7 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { piggyBackResponses(responseHolder.response.content()); responseHolder.response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(responseHolder.response.content().readableBytes())); channel.writeAndFlush(responseHolder.response, promise); - } - else { + } else { responseHolder.response.content().writeBytes(buffer); responseHolder.response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(responseHolder.response.content().readableBytes())); channel.writeAndFlush(responseHolder.response, promise); @@ -176,8 +172,7 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { } buf.writeBytes(responseRunner.buffer); responseRunner.buffer.release(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { break; } } while (responses.isEmpty()); @@ -192,11 +187,9 @@ public class HttpAcceptorHandler extends ChannelDuplexHandler { executor.shutdown(); try { executor.awaitTermination(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // no-op - } - finally { + } finally { executor.shutdownNow(); } responses.clear(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java index 8cff70b4b4..3fda5ceb39 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java @@ -178,7 +178,6 @@ public class NettyAcceptor extends AbstractAcceptor { private static final Logger logger = Logger.getLogger(NettyAcceptor.class); - public NettyAcceptor(final String name, final ClusterConnection clusterConnection, final Map configuration, @@ -230,8 +229,7 @@ public class NettyAcceptor extends AbstractAcceptor { needClientAuth = ConfigurationHelper.getBooleanProperty(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, TransportConstants.DEFAULT_NEED_CLIENT_AUTH, configuration); verifyHost = ConfigurationHelper.getBooleanProperty(TransportConstants.VERIFY_HOST_PROP_NAME, TransportConstants.DEFAULT_VERIFY_HOST, configuration); - } - else { + } else { keyStoreProvider = TransportConstants.DEFAULT_KEYSTORE_PROVIDER; keyStorePath = TransportConstants.DEFAULT_KEYSTORE_PATH; keyStorePassword = TransportConstants.DEFAULT_KEYSTORE_PASSWORD; @@ -269,16 +267,14 @@ public class NettyAcceptor extends AbstractAcceptor { if (useInvm) { channelClazz = LocalServerChannel.class; eventLoopGroup = new LocalEventLoopGroup(); - } - else { + } else { int threadsToUse; if (nioRemotingThreads == -1) { // Default to number of cores * 3 threadsToUse = Runtime.getRuntime().availableProcessors() * 3; - } - else { + } else { threadsToUse = this.nioRemotingThreads; } channelClazz = NioServerSocketChannel.class; @@ -329,8 +325,7 @@ public class NettyAcceptor extends AbstractAcceptor { if (httpUpgradeEnabled) { // the channel will be bound by the Web container and hand over after the HTTP Upgrade // handshake is successful - } - else { + } else { startServerChannels(); paused = false; @@ -389,11 +384,10 @@ public class NettyAcceptor extends AbstractAcceptor { try { if (keyStorePath == null && TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER.equals(keyStoreProvider)) throw new IllegalArgumentException("If \"" + TransportConstants.SSL_ENABLED_PROP_NAME + - "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null " + - "unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified."); + "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null " + + "unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified."); context = SSLSupport.createContext(keyStoreProvider, keyStorePath, keyStorePassword, trustStoreProvider, trustStorePath, trustStorePassword); - } - catch (Exception e) { + } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Unable to create NettyAcceptor for " + host + ":" + port); ise.initCause(e); throw ise; @@ -401,8 +395,7 @@ public class NettyAcceptor extends AbstractAcceptor { SSLEngine engine; if (verifyHost) { engine = context.createSSLEngine(host, port); - } - else { + } else { engine = context.createSSLEngine(); } @@ -419,8 +412,7 @@ public class NettyAcceptor extends AbstractAcceptor { if (enabledCipherSuites != null) { try { engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; } @@ -429,13 +421,11 @@ public class NettyAcceptor extends AbstractAcceptor { if (enabledProtocols != null) { try { engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e; } - } - else { + } else { engine.setEnabledProtocols(originalProtocols); } @@ -468,8 +458,7 @@ public class NettyAcceptor extends AbstractAcceptor { SocketAddress address; if (useInvm) { address = new LocalAddress(h); - } - else { + } else { address = new InetSocketAddress(h, port); } Channel serverChannel = bootstrap.bind(address).syncUninterruptibly().channel(); @@ -541,9 +530,8 @@ public class NettyAcceptor extends AbstractAcceptor { Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { - logger.warn("failed to send notification",e.getMessage(),e); + } catch (Exception e) { + logger.warn("failed to send notification", e.getMessage(), e); } } @@ -657,19 +645,16 @@ public class NettyAcceptor extends AbstractAcceptor { public void operationComplete(final io.netty.util.concurrent.Future future) throws Exception { if (future.isSuccess()) { active = true; - } - else { + } else { future.getNow().close(); } } }); - } - else { + } else { active = true; } return nc; - } - else { + } else { ActiveMQServerLogger.LOGGER.connectionLimitReached(connectionsAllowed, ctx.channel().remoteAddress().toString()); ctx.channel().close(); return null; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java index 4ff356e56e..50bc90d880 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java @@ -256,11 +256,10 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif } Map selectedProtocols = new ConcurrentHashMap<>(); - for (Entry entry: selectedProtocolFactories.entrySet()) { + for (Entry entry : selectedProtocolFactories.entrySet()) { selectedProtocols.put(entry.getKey(), entry.getValue().createProtocolManager(server, info.getExtraParams(), incomingInterceptors, outgoingInterceptors)); } - acceptor = factory.createAcceptor(info.getName(), clusterConnection, info.getParams(), new DelegatingBufferHandler(), this, threadPool, scheduledThreadPool, selectedProtocols); if (defaultInvmSecurityPrincipal != null && acceptor.isUnsecurable()) { @@ -274,8 +273,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif managementService.registerAcceptor(acceptor, info); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorCreatingAcceptor(e, info.getFactoryClassName()); } @@ -320,8 +318,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif for (Acceptor acceptor : acceptors.values()) { try { acceptor.pause(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName()); } } @@ -374,8 +371,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif try { acceptor.pause(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName()); } @@ -402,8 +398,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif for (Acceptor acceptor : acceptors.values()) { try { acceptor.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName()); } } @@ -445,8 +440,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (entry != null) { return entry.connection; - } - else { + } else { ActiveMQServerLogger.LOGGER.errorRemovingConnection(); return null; @@ -458,8 +452,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (entry != null) { return entry; - } - else { + } else { return null; } } @@ -472,8 +465,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif logger.debug("RemotingServiceImpl::removing connection ID " + remotingConnectionID); connectionCountLatch.countDown(); return entry.connection; - } - else { + } else { logger.debug("The connectionID::" + remotingConnectionID + " was already removed by some other module"); return null; @@ -575,8 +567,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (incomingInterceptors.remove(interceptor)) { updateProtocols(); return true; - } - else { + } else { return false; } } @@ -597,8 +588,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (outgoingInterceptors.remove(interceptor)) { updateProtocols(); return true; - } - else { + } else { return false; } } @@ -629,8 +619,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (conn != null) { conn.connection.bufferReceived(connectionID, buffer); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("ConnectionID = " + connectionID + " was already closed, so ignoring packet"); } @@ -659,8 +648,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (!criticalError) { try { join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -686,8 +674,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif flush = false; } - } - else { + } else { entry.lastCheck = now; } } @@ -701,8 +688,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif // as if anything wrong happens on flush // failure detection could be affected conn.flush(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } @@ -729,8 +715,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (latch.await(pauseInterval, TimeUnit.MILLISECONDS)) return; - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorOnFailureCheck(e); } } @@ -749,7 +734,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif * @param protocolList * @param transportConfig * @param protocolMap - */ + */ private void locateProtocols(String protocolList, Object transportConfig, Map protocolMap) { @@ -760,8 +745,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif if (protocolManagerFactory == null) { ActiveMQServerLogger.LOGGER.noProtocolManagerFound(protocolItem, transportConfig.toString()); - } - else { + } else { protocolMap.put(protocolItem, protocolManagerFactory); } } @@ -769,8 +753,9 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif /** * Finds protocol support from a given classloader. + * * @param loader - */ + */ private void resolveProtocols(ClassLoader loader) { ServiceLoader serviceLoader = ServiceLoader.load(ProtocolManagerFactory.class, loader); loadProtocolManagerFactories(serviceLoader); @@ -778,8 +763,9 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif /** * Loads the protocols found into a map. + * * @param protocolManagerFactoryCollection - */ + */ private void loadProtocolManagerFactories(Iterable protocolManagerFactoryCollection) { for (ProtocolManagerFactory next : protocolManagerFactoryCollection) { String[] protocols = next.getProtocols(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java index 036be12518..6668c7145c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java @@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.replication; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.IOCompletion; import org.apache.activemq.artemis.core.journal.Journal; @@ -26,7 +27,6 @@ import org.apache.activemq.artemis.core.journal.JournalLoadInformation; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java index 18c68d792c..1a07adc40f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java @@ -35,10 +35,10 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.io.IOCriticalErrorListener; +import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.Journal.JournalState; import org.apache.activemq.artemis.core.journal.JournalLoadInformation; -import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.impl.FileWrapperJournal; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.paging.PagedMessage; @@ -53,8 +53,8 @@ import org.apache.activemq.artemis.core.protocol.core.Channel; import org.apache.activemq.artemis.core.protocol.core.ChannelHandler; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; -import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage; +import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage; @@ -90,7 +90,6 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon private static final Logger logger = Logger.getLogger(ReplicationEndpoint.class); - private final IOCriticalErrorListener criticalErrorListener; private final ActiveMQServerImpl server; private final boolean wantedFailBack; @@ -172,58 +171,41 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon if (type == PacketImpl.REPLICATION_APPEND) { handleAppendAddRecord((ReplicationAddMessage) packet); - } - else if (type == PacketImpl.REPLICATION_APPEND_TX) { + } else if (type == PacketImpl.REPLICATION_APPEND_TX) { handleAppendAddTXRecord((ReplicationAddTXMessage) packet); - } - else if (type == PacketImpl.REPLICATION_DELETE) { + } else if (type == PacketImpl.REPLICATION_DELETE) { handleAppendDelete((ReplicationDeleteMessage) packet); - } - else if (type == PacketImpl.REPLICATION_DELETE_TX) { + } else if (type == PacketImpl.REPLICATION_DELETE_TX) { handleAppendDeleteTX((ReplicationDeleteTXMessage) packet); - } - else if (type == PacketImpl.REPLICATION_PREPARE) { + } else if (type == PacketImpl.REPLICATION_PREPARE) { handlePrepare((ReplicationPrepareMessage) packet); - } - else if (type == PacketImpl.REPLICATION_COMMIT_ROLLBACK) { + } else if (type == PacketImpl.REPLICATION_COMMIT_ROLLBACK) { handleCommitRollback((ReplicationCommitMessage) packet); - } - else if (type == PacketImpl.REPLICATION_PAGE_WRITE) { + } else if (type == PacketImpl.REPLICATION_PAGE_WRITE) { handlePageWrite((ReplicationPageWriteMessage) packet); - } - else if (type == PacketImpl.REPLICATION_PAGE_EVENT) { + } else if (type == PacketImpl.REPLICATION_PAGE_EVENT) { handlePageEvent((ReplicationPageEventMessage) packet); - } - else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_BEGIN) { + } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_BEGIN) { handleLargeMessageBegin((ReplicationLargeMessageBeginMessage) packet); - } - else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_WRITE) { + } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_WRITE) { handleLargeMessageWrite((ReplicationLargeMessageWriteMessage) packet); - } - else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_END) { + } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_END) { handleLargeMessageEnd((ReplicationLargeMessageEndMessage) packet); - } - else if (type == PacketImpl.REPLICATION_START_FINISH_SYNC) { + } else if (type == PacketImpl.REPLICATION_START_FINISH_SYNC) { response = handleStartReplicationSynchronization((ReplicationStartSyncMessage) packet); - } - else if (type == PacketImpl.REPLICATION_SYNC_FILE) { + } else if (type == PacketImpl.REPLICATION_SYNC_FILE) { handleReplicationSynchronization((ReplicationSyncFileMessage) packet); - } - else if (type == PacketImpl.REPLICATION_SCHEDULED_FAILOVER) { + } else if (type == PacketImpl.REPLICATION_SCHEDULED_FAILOVER) { handleLiveStopping((ReplicationLiveIsStoppingMessage) packet); - } - else if (type == PacketImpl.BACKUP_REGISTRATION_FAILED) { + } else if (type == PacketImpl.BACKUP_REGISTRATION_FAILED) { handleFatalError((BackupReplicationStartFailedMessage) packet); - } - else { + } else { ActiveMQServerLogger.LOGGER.invalidPacketForReplication(packet); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet); response = new ActiveMQExceptionMessage(e); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet); response = new ActiveMQExceptionMessage(ActiveMQMessageBundle.BUNDLE.replicationUnhandledError(e)); } @@ -274,8 +256,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon pageManager.start(); started = true; - } - catch (Exception e) { + } catch (Exception e) { if (server.isStarted()) throw e; } @@ -316,8 +297,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon try { page.sync(); page.close(false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingPageOnReplication(e); } } @@ -363,8 +343,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon journal.stop(); journal.start(); journal.loadSyncOnly(JournalState.SYNCING_UP_TO_DATE); - } - finally { + } finally { journal.synchronizationUnlock(); } } @@ -507,8 +486,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon logger.trace("Deleting LargeMessage " + packet.getMessageId() + " on the executor @ handleLargeMessageEnd"); } message.deleteFile(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorDeletingLargeMessage(e, packet.getMessageId()); } } @@ -533,15 +511,13 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon if (delete) { message = largeMessages.remove(messageId); - } - else { + } else { message = largeMessages.get(messageId); if (message == null) { if (createIfNotExists) { createLargeMessage(messageId, false); message = largeMessages.get(messageId); - } - else { + } else { // No warnings if it's a delete, as duplicate deletes may be sent repeatedly. ActiveMQServerLogger.LOGGER.largeMessageNotAvailable(messageId); } @@ -567,8 +543,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon ReplicatedLargeMessage msg; if (liveToBackupSync) { msg = new LargeServerMessageInSync(storageManager); - } - else { + } else { msg = storageManager.createLargeMessage(); } @@ -584,8 +559,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon Journal journalToUse = getJournal(packet.getJournalID()); if (packet.isRollback()) { journalToUse.appendRollbackRecord(packet.getTxId(), noSync); - } - else { + } else { journalToUse.appendCommitRecord(packet.getTxId(), noSync); } } @@ -623,8 +597,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon if (packet.getOperation() == ADD_OPERATION_TYPE.UPDATE) { journalToUse.appendUpdateRecordTransactional(packet.getTxId(), packet.getId(), packet.getRecordType(), packet.getRecordData()); - } - else { + } else { journalToUse.appendAddRecordTransactional(packet.getTxId(), packet.getId(), packet.getRecordType(), packet.getRecordData()); } } @@ -640,8 +613,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon logger.trace("Endpoint appendUpdate id = " + packet.getId()); } journalToUse.appendUpdateRecord(packet.getId(), packet.getJournalRecordType(), packet.getRecordData(), noSync); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("Endpoint append id = " + packet.getId()); } @@ -666,8 +638,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon if (deletePages) { page.delete(null); } - } - else { + } else { page.close(false); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java index b254d9ac54..d0468d19d2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java @@ -82,7 +82,6 @@ import org.jboss.logging.Logger; */ public final class ReplicationManager implements ActiveMQComponent, ReadyListener { - private static final Logger logger = Logger.getLogger(ReplicationManager.class); public enum ADD_OPERATION_TYPE { @@ -135,7 +134,9 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene /** * @param remotingConnection */ - public ReplicationManager(CoreRemotingConnection remotingConnection, final long timeout, final ExecutorFactory executorFactory) { + public ReplicationManager(CoreRemotingConnection remotingConnection, + final long timeout, + final ExecutorFactory executorFactory) { this.executorFactory = executorFactory; this.replicatingChannel = remotingConnection.getChannel(CHANNEL_ID.REPLICATION.id, -1); this.remotingConnection = remotingConnection; @@ -312,8 +313,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene logger.trace("Calling ctx.replicationDone()"); try { ctx.replicationDone(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorCompletingCallbackOnReplicationManager(e); } } @@ -360,8 +360,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene return repliToken; } replicatingChannel.send(packet); - } - else { + } else { // Already replicating channel failed, so just play the action now runItNow = true; } @@ -376,8 +375,10 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene return repliToken; } - /** This was written as a refactoring of sendReplicatePacket. - * In case you refactor this in any way, this method must hold a lock on replication lock. .*/ + /** + * This was written as a refactoring of sendReplicatePacket. + * In case you refactor this in any way, this method must hold a lock on replication lock. . + */ private boolean flowControl() { // synchronized (replicationLock) { -- I'm not adding this because the caller already has it // future maintainers of this code please be aware that the intention here is hold the lock on replication lock @@ -388,7 +389,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene //don't wait for ever as this may hang tests etc, we've probably been closed anyway long now = System.currentTimeMillis(); long deadline = now + timeout; - while (!writable.get() && now < deadline) { + while (!writable.get() && now < deadline) { replicationLock.wait(deadline - now); now = System.currentTimeMillis(); } @@ -399,14 +400,12 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene logger.tracef("There was no response from replication backup after %s seconds, server being stopped now", System.currentTimeMillis() - now); try { stop(); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } return false; } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); } } @@ -445,15 +444,13 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene if (me.getType() == ActiveMQExceptionType.DISCONNECTED) { // Backup has shut down - no need to log a stack trace ActiveMQServerLogger.LOGGER.replicationStopOnBackupShutdown(); - } - else { + } else { ActiveMQServerLogger.LOGGER.replicationStopOnBackupFail(me); } try { stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingReplication(e); } } @@ -517,8 +514,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene try { ActiveMQServerLogger.LOGGER.journalSynch(jf, file.size(), file); sendLargeFile(content, null, jf.getFileID(), file, Long.MAX_VALUE); - } - finally { + } finally { if (file.isOpen()) file.close(); } @@ -570,8 +566,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene if (bytesRead >= maxBytesToSend) { toSend = (int) maxBytesToSend; maxBytesToSend = 0; - } - else { + } else { maxBytesToSend = maxBytesToSend - bytesRead; } buffer.limit(toSend); @@ -584,8 +579,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene break; } } - } - finally { + } finally { if (file.isOpen()) file.close(); } @@ -628,8 +622,7 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene logger.trace("sendSynchronizationDone wasn't finished in time"); throw ActiveMQMessageBundle.BUNDLE.replicationSynchronizationTimeout(initialReplicationSyncTimeout); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { logger.debug(e); } inSync = false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java index 208d0cc19f..e6c8e4e80c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java @@ -100,7 +100,9 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC } @Override - public String authenticate(final String user, final String password, X509Certificate[] certificates) throws Exception { + public String authenticate(final String user, + final String password, + X509Certificate[] certificates) throws Exception { if (securityEnabled) { if (managementClusterUser.equals(user)) { @@ -114,8 +116,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC */ if (!managementClusterPassword.equals(password)) { throw ActiveMQMessageBundle.BUNDLE.unableToValidateClusterUser(user); - } - else { + } else { return managementClusterUser; } } @@ -124,12 +125,10 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC boolean userIsValid = false; if (securityManager instanceof ActiveMQSecurityManager3) { - validatedUser = ((ActiveMQSecurityManager3)securityManager).validateUser(user, password, certificates); - } - else if (securityManager instanceof ActiveMQSecurityManager2) { - userIsValid = ((ActiveMQSecurityManager2)securityManager).validateUser(user, password, certificates); - } - else { + validatedUser = ((ActiveMQSecurityManager3) securityManager).validateUser(user, password, certificates); + } else if (securityManager instanceof ActiveMQSecurityManager2) { + userIsValid = ((ActiveMQSecurityManager2) securityManager).validateUser(user, password, certificates); + } else { userIsValid = securityManager.validateUser(user, password); } @@ -179,12 +178,10 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC if (securityManager instanceof ActiveMQSecurityManager3) { final ActiveMQSecurityManager3 securityManager3 = (ActiveMQSecurityManager3) securityManager; validated = securityManager3.validateUserAndRole(user, session.getPassword(), roles, checkType, saddress, session.getRemotingConnection()) != null; - } - else if (securityManager instanceof ActiveMQSecurityManager2) { + } else if (securityManager instanceof ActiveMQSecurityManager2) { final ActiveMQSecurityManager2 securityManager2 = (ActiveMQSecurityManager2) securityManager; validated = securityManager2.validateUserAndRole(user, session.getPassword(), roles, checkType, saddress, session.getRemotingConnection()); - } - else { + } else { validated = securityManager.validateUserAndRole(user, session.getPassword(), roles, checkType); } @@ -239,8 +236,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC invalidateCache(); lastCheck = now; - } - else { + } else { ConcurrentHashSet act = cache.get(user + "." + checkType.name()); if (act != null) { granted = act.contains(dest); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java index d416a979bb..b293406955 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java @@ -311,7 +311,7 @@ public interface ActiveMQMessageBundle { @Message(id = 119083, value = "Queue {0} has a different filter than requested", format = Message.Format.MESSAGE_FORMAT) ActiveMQInvalidTransientQueueUseException queueSubscriptionBelongsToDifferentFilter(SimpleString queueName); - // this code has to match with version 2.3.x as it's used on integration tests at Wildfly and JBoss EAP + // this code has to match with version 2.3.x as it's used on integration tests at Wildfly and JBoss EAP @Message(id = 119099, value = "Unable to authenticate cluster user: {0}", format = Message.Format.MESSAGE_FORMAT) ActiveMQClusterSecurityException unableToValidateClusterUser(String user); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index a8dc14e9aa..6e32b351b6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -780,7 +780,6 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void broadcastGroupClosed(@Cause Exception e); - @LogMessage(level = Logger.Level.WARN) @Message(id = 222109, value = "Timed out waiting for write lock on consumer. Check the Thread dump", format = Message.Format.MESSAGE_FORMAT) void timeoutLockingConsumer(); @@ -1037,7 +1036,7 @@ public interface ActiveMQServerLogger extends BasicLogger { @SuppressWarnings("deprecation") @LogMessage(level = Logger.Level.WARN) @Message(id = 222168, value = "The ''" + TransportConstants.PROTOCOL_PROP_NAME + "'' property is deprecated. If you want this Acceptor to support multiple protocols, use the ''" + TransportConstants.PROTOCOLS_PROP_NAME + "'' property, e.g. with value ''CORE,AMQP,STOMP''", - format = Message.Format.MESSAGE_FORMAT) + format = Message.Format.MESSAGE_FORMAT) void warnDeprecatedProtocol(); @LogMessage(level = Logger.Level.WARN) @@ -1140,7 +1139,6 @@ public interface ActiveMQServerLogger extends BasicLogger { @Message(id = 222190, value = "Deleting old data directory {0} as the max folders is set to 0", format = Message.Format.MESSAGE_FORMAT) void backupDeletingData(String oldPath); - @LogMessage(level = Logger.Level.WARN) @Message(id = 222191, value = "Could not find any configured role for user {0}.", diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ConnectorServiceFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ConnectorServiceFactory.java index 0c37ade294..23c3cc37a7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ConnectorServiceFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ConnectorServiceFactory.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server; -import org.apache.activemq.artemis.core.persistence.StorageManager; -import org.apache.activemq.artemis.core.postoffice.PostOffice; - import java.util.Map; import java.util.Set; import java.util.concurrent.ScheduledExecutorService; +import org.apache.activemq.artemis.core.persistence.StorageManager; +import org.apache.activemq.artemis.core.postoffice.PostOffice; + public interface ConnectorServiceFactory { ConnectorService createConnectorService(String connectorName, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LiveNodeLocator.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LiveNodeLocator.java index 88a85dae50..56fef7c77c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LiveNodeLocator.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LiveNodeLocator.java @@ -70,8 +70,7 @@ public abstract class LiveNodeLocator implements ClusterTopologyListener { if (backupQuorum != null) { if (alreadyReplicating) { backupQuorum.notifyAlreadyReplicating(); - } - else { + } else { backupQuorum.notifyRegistrationFailed(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java index 74e527e4cc..ecd87f8d2e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java @@ -61,8 +61,8 @@ public class MemoryManager implements ActiveMQComponent { @Override public synchronized void start() { logger.debug("Starting MemoryManager with MEASURE_INTERVAL: " + measureInterval + - " FREE_MEMORY_PERCENT: " + - memoryWarningThreshold); + " FREE_MEMORY_PERCENT: " + + memoryWarningThreshold); if (started) { // Already started @@ -91,8 +91,7 @@ public class MemoryManager implements ActiveMQComponent { try { thread.join(); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } } @@ -107,8 +106,7 @@ public class MemoryManager implements ActiveMQComponent { } Thread.sleep(measureInterval); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { if (!started) { return; } @@ -138,8 +136,7 @@ public class MemoryManager implements ActiveMQComponent { ActiveMQServerLogger.LOGGER.memoryError(memoryWarningThreshold, info.toString()); low = true; - } - else { + } else { low = false; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java index 8c80eb0471..a1e6a20940 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java @@ -38,12 +38,16 @@ public interface MessageReference { */ int getMessageMemoryEstimate(); - /** To be used on holding protocol specific data during the delivery. - * This will be only valid while the message is on the delivering queue at the consumer */ + /** + * To be used on holding protocol specific data during the delivery. + * This will be only valid while the message is on the delivering queue at the consumer + */ Object getProtocolData(); - /** To be used on holding protocol specific data during the delivery. - * This will be only valid while the message is on the delivering queue at the consumer */ + /** + * To be used on holding protocol specific data during the delivery. + * This will be only valid while the message is on the delivering queue at the consumer + */ void setProtocolData(Object data); MessageReference copy(Queue queue); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/NodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/NodeManager.java index 331851da90..28f05b2365 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/NodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/NodeManager.java @@ -155,20 +155,17 @@ public abstract class NodeManager implements ActiveMQComponent { while (!serverLockFile.exists()) { try { fileCreated = serverLockFile.createNewFile(); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { ActiveMQServerLogger.LOGGER.nodeManagerCantOpenFile(e, serverLockFile); throw e; - } - catch (IOException e) { + } catch (IOException e) { /* * on some OS's this may fail weirdly even tho the parent dir exists, retrying will work, some weird timing issue i think * */ if (count < 5) { try { Thread.sleep(100); - } - catch (InterruptedException e1) { + } catch (InterruptedException e1) { } count++; continue; @@ -216,15 +213,13 @@ public abstract class NodeManager implements ActiveMQComponent { id.position(0); channel.write(id, 3); channel.force(true); - } - else if (read != 16) { + } else if (read != 16) { setUUID(UUIDGenerator.getInstance().generateUUID()); id.put(getUUID().asBytes(), 0, 16); id.position(0); channel.write(id, 3); channel.force(true); - } - else { + } else { byte[] bytes = new byte[16]; id.position(0); id.get(bytes); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/QueueConfig.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/QueueConfig.java index ce338fe82d..f750f6ca10 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/QueueConfig.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/QueueConfig.java @@ -81,7 +81,6 @@ public final class QueueConfig { return this; } - public Builder pagingManager(final PagingManager pagingManager) { this.pagingManager = pagingManager; return this; @@ -107,7 +106,6 @@ public final class QueueConfig { return this; } - /** * Returns a new {@link QueueConfig} using the parameters configured on the {@link Builder}. *
@@ -123,12 +121,10 @@ public final class QueueConfig { if (pagingManager != null && !FilterUtils.isTopicIdentification(filter)) { try { pageSubscription = this.pagingManager.getPageStore(address).getCursorProvider().createSubscription(id, filter, durable); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } - } - else { + } else { pageSubscription = null; } return new QueueConfig(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated); @@ -142,7 +138,7 @@ public final class QueueConfig { * The {@code address} is defaulted to the {@code name} value. * The reference parameters aren't defensively copied. * - * @param id the id of the queue to be created + * @param id the id of the queue to be created * @param name the name of the queue to be created * @throws IllegalStateException if {@code name} is {@code null} or empty */ @@ -155,8 +151,8 @@ public final class QueueConfig { *
* The reference parameters aren't defensively copied. * - * @param id the id of the queue to be created - * @param name the name of the queue to be created + * @param id the id of the queue to be created + * @param name the name of the queue to be created * @param address the address of the queue to be created * @throws IllegalStateException if {@code name} or {@code address} are {@code null} or empty */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ScheduledDeliveryHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ScheduledDeliveryHandler.java index 826050748d..460e135d57 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ScheduledDeliveryHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ScheduledDeliveryHandler.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.server; +import java.util.List; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.filter.Filter; -import java.util.List; - public interface ScheduledDeliveryHandler { boolean checkAndSchedule(MessageReference ref, final boolean tail); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SecuritySettingPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SecuritySettingPlugin.java index 7b22b61812..5d62c31662 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SecuritySettingPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SecuritySettingPlugin.java @@ -24,6 +24,7 @@ import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.settings.HierarchicalRepository; public interface SecuritySettingPlugin extends Serializable { + /** * Initialize the plugin with the given configuration options. This method is called by the broker when the file-based * configuration is read (see {@code org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser#parseSecurity(org.w3c.dom.Element, org.apache.activemq.artemis.core.config.Configuration)}. diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java index d157a8c10b..ce9c489a41 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java @@ -31,10 +31,14 @@ public interface ServerConsumer extends Consumer { void fireSlowConsumer(); - /** this is to be used with anything specific on a protocol head. */ + /** + * this is to be used with anything specific on a protocol head. + */ Object getProtocolData(); - /** this is to be used with anything specific on a protocol head. */ + /** + * this is to be used with anything specific on a protocol head. + */ void setProtocolData(Object protocolData); /** @@ -74,11 +78,15 @@ public interface ServerConsumer extends Consumer { MessageReference removeReferenceByID(long messageID) throws Exception; - /** Some protocols may choose to send the message back to delivering instead of redeliver. - * For example openwire will redeliver through the client, so messages will go back to delivering list after rollback. */ + /** + * Some protocols may choose to send the message back to delivering instead of redeliver. + * For example openwire will redeliver through the client, so messages will go back to delivering list after rollback. + */ void backToDelivering(MessageReference reference); - List getDeliveringReferencesBasedOnProtocol(boolean remove, Object protocolDataStart, Object protocolDataEnd); + List getDeliveringReferencesBasedOnProtocol(boolean remove, + Object protocolDataStart, + Object protocolDataEnd); void acknowledge(Transaction tx, long messageID) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java index 3521d71764..0df506047d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java @@ -133,7 +133,10 @@ public interface ServerSession extends SecurityAuth { void sendContinuations(int packetSize, long totalBodySize, byte[] body, boolean continues) throws Exception; - RoutingStatus send(Transaction tx, ServerMessage message, boolean direct, boolean noAutoCreateQueue) throws Exception; + RoutingStatus send(Transaction tx, + ServerMessage message, + boolean direct, + boolean noAutoCreateQueue) throws Exception; RoutingStatus send(ServerMessage message, boolean direct, boolean noAutoCreateQueue) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServiceRegistry.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServiceRegistry.java index dfa86b7622..4f2ef9d667 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServiceRegistry.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServiceRegistry.java @@ -16,17 +16,17 @@ */ package org.apache.activemq.artemis.core.server; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ScheduledExecutorService; + import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.server.cluster.Transformer; import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ScheduledExecutorService; - /** * A holder for common services leveraged by the broker. */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java index 0c60f25de5..6b933a9a1b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java @@ -18,5 +18,6 @@ package org.apache.activemq.artemis.core.server; public interface SlowConsumerDetectionListener { + void onSlowConsumer(ServerConsumer consumer); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java index 918dd0d963..3c9791e11d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java @@ -28,7 +28,6 @@ import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManagerFactor */ public class ActiveMQServerSideProtocolManagerFactory implements ClientProtocolManagerFactory { - ServerLocator locator; @Override @@ -64,4 +63,4 @@ public class ActiveMQServerSideProtocolManagerFactory implements ClientProtocolM return ServerPacketDecoder.INSTANCE; } } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java index 105bea365a..58a05f40a6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java @@ -139,8 +139,7 @@ public class BackupManager implements ActiveMQComponent { DiscoveryBackupConnector backupConnector = new DiscoveryBackupConnector(dg, config.getName(), connector, config.getRetryInterval(), clusterManager); backupConnectors.add(backupConnector); - } - else { + } else { TransportConfiguration[] tcConfigs = config.getTransportConfigurations(configuration); StaticBackupConnector backupConnector = new StaticBackupConnector(tcConfigs, config.getName(), connector, config.getRetryInterval(), clusterManager); @@ -253,11 +252,9 @@ public class BackupManager implements ActiveMQComponent { ActiveMQServerLogger.LOGGER.backupAnnounced(); backupAnnounced = true; } - } - catch (RejectedExecutionException e) { + } catch (RejectedExecutionException e) { // assumption is that the whole server is being stopped. So the exception is ignored. - } - catch (Exception e) { + } catch (Exception e) { if (scheduledExecutor.isShutdown()) return; if (stopping) @@ -271,8 +268,7 @@ public class BackupManager implements ActiveMQComponent { } }, retryInterval, TimeUnit.MILLISECONDS); - } - finally { + } finally { announcingBackup = false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java index c6a9b735db..7e8cacb41b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java @@ -17,8 +17,8 @@ package org.apache.activemq.artemis.core.server.cluster; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.ActiveMQComponent; +import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.management.NotificationService; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterConnection.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterConnection.java index c47ff48b0b..9392ed59e2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterConnection.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterConnection.java @@ -80,5 +80,4 @@ public interface ClusterConnection extends ActiveMQComponent, ClusterTopologyLis long getCallTimeout(); - } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java index 0956bc5879..b37b9d5139 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java @@ -163,8 +163,7 @@ public class ClusterControl implements AutoCloseable { QuorumVoteHandler voteHandler = server.getClusterManager().getQuorumManager().getVoteHandler(replyMessage.getHandler()); replyMessage.decodeRest(voteHandler); return replyMessage.getVote(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { return null; } } @@ -178,8 +177,7 @@ public class ClusterControl implements AutoCloseable { BackupResponseMessage packet; try { packet = (BackupResponseMessage) clusterChannel.sendBlocking(backupRequestMessage, PacketImpl.BACKUP_REQUEST_RESPONSE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { return false; } return packet.isBackupStarted(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java index ce8b14c05c..15595f83a6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java @@ -103,8 +103,7 @@ public class ClusterController implements ActiveMQComponent { ActiveMQServerLogger.LOGGER.noClusterConnectionForReplicationCluster(); replicationLocator = defaultLocator; } - } - else { + } else { replicationLocator = defaultLocator; } //latch so we know once we are connected @@ -331,22 +330,19 @@ public class ClusterController implements ActiveMQComponent { if (server.getConfiguration().isSecurityEnabled() && !clusterConnection.verify(msg.getClusterUser(), msg.getClusterPassword())) { clusterChannel.send(new ClusterConnectReplyMessage(false)); - } - else { + } else { authorized = true; clusterChannel.send(new ClusterConnectReplyMessage(true)); } } - } - else { + } else { if (packet.getType() == PacketImpl.NODE_ANNOUNCE) { NodeAnnounceMessage msg = (NodeAnnounceMessage) packet; Pair pair; if (msg.isBackup()) { pair = new Pair<>(null, msg.getConnector()); - } - else { + } else { pair = new Pair<>(msg.getConnector(), msg.getBackupConnector()); } if (logger.isTraceEnabled()) { @@ -358,30 +354,25 @@ public class ClusterController implements ActiveMQComponent { if (clusterConn != null) { String scaleDownGroupName = msg.getScaleDownGroupName(); clusterConn.nodeAnnounced(msg.getCurrentEventID(), msg.getNodeID(), msg.getBackupGroupName(), scaleDownGroupName, pair, msg.isBackup()); - } - else { + } else { logger.debug("Cluster connection is null on acceptor = " + acceptorUsed); } - } - else { + } else { logger.debug("there is no acceptor used configured at the CoreProtocolManager " + this); } - } - else if (packet.getType() == PacketImpl.QUORUM_VOTE) { + } else if (packet.getType() == PacketImpl.QUORUM_VOTE) { QuorumVoteMessage quorumVoteMessage = (QuorumVoteMessage) packet; QuorumVoteHandler voteHandler = quorumManager.getVoteHandler(quorumVoteMessage.getHandler()); quorumVoteMessage.decode(voteHandler); Vote vote = quorumManager.vote(quorumVoteMessage.getHandler(), quorumVoteMessage.getVote()); clusterChannel.send(new QuorumVoteReplyMessage(quorumVoteMessage.getHandler(), vote)); - } - else if (packet.getType() == PacketImpl.SCALEDOWN_ANNOUNCEMENT) { + } else if (packet.getType() == PacketImpl.SCALEDOWN_ANNOUNCEMENT) { ScaleDownAnnounceMessage message = (ScaleDownAnnounceMessage) packet; //we don't really need to check as it should always be true if (server.getNodeID().equals(message.getTargetNodeId())) { server.addScaledDownNode(message.getScaledDownNodeId()); } - } - else if (channelHandler != null) { + } else if (channelHandler != null) { channelHandler.handlePacket(packet); } } @@ -407,8 +398,7 @@ public class ClusterController implements ActiveMQComponent { if (serverLocator == replicationLocator) { replicationClusterConnectedLatch.countDown(); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (!started) { return; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java index 17eaae091e..96fad97aec 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java @@ -200,11 +200,9 @@ public final class ClusterManager implements ActiveMQComponent { if (acceptorConfig == null) { // if the parameter is null, we just return whatever is defined on defaultClusterConnection return defaultClusterConnection; - } - else if (defaultClusterConnection != null && defaultClusterConnection.getConnector().isEquivalent(acceptorConfig)) { + } else if (defaultClusterConnection != null && defaultClusterConnection.getConnector().isEquivalent(acceptorConfig)) { return defaultClusterConnection; - } - else { + } else { for (ClusterConnection conn : cloneClusterConnections()) { if (conn.getConnector().isEquivalent(acceptorConfig)) { return conn; @@ -234,8 +232,7 @@ public final class ClusterManager implements ActiveMQComponent { public synchronized void deploy() throws Exception { if (state == State.STOPPED) { state = State.DEPLOYED; - } - else { + } else { throw new IllegalStateException(); } @@ -264,8 +261,7 @@ public final class ClusterManager implements ActiveMQComponent { for (BroadcastGroup group : broadcastGroups.values()) { try { group.start(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToStartBroadcastGroup(e, group.getName()); } } @@ -273,8 +269,7 @@ public final class ClusterManager implements ActiveMQComponent { for (ClusterConnection conn : clusterConnections.values()) { try { conn.start(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToStartClusterConnection(e, conn.getName()); } } @@ -284,8 +279,7 @@ public final class ClusterManager implements ActiveMQComponent { for (Bridge bridge : bridges.values()) { try { bridge.start(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToStartBridge(e, bridge.getName()); } } @@ -336,8 +330,7 @@ public final class ClusterManager implements ActiveMQComponent { for (ServerLocatorInternal clusterLocator : clusterLocators) { try { clusterLocator.close(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingServerLocator(e, clusterLocator); } } @@ -428,13 +421,11 @@ public final class ClusterManager implements ActiveMQComponent { if (config.isHA()) { serverLocator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(discoveryGroupConfiguration); - } - else { + } else { serverLocator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(discoveryGroupConfiguration); } - } - else { + } else { TransportConfiguration[] tcConfigs = configuration.getTransportConfigurations(config.getStaticConnectors()); if (tcConfigs == null) { @@ -444,8 +435,7 @@ public final class ClusterManager implements ActiveMQComponent { if (config.isHA()) { serverLocator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(tcConfigs); - } - else { + } else { serverLocator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(tcConfigs); } @@ -477,7 +467,7 @@ public final class ClusterManager implements ActiveMQComponent { if (!config.isUseDuplicateDetection()) { logger.debug("Bridge " + config.getName() + - " is configured to not use duplicate detecion, it will send messages synchronously"); + " is configured to not use duplicate detecion, it will send messages synchronously"); } clusterLocators.add(serverLocator); @@ -518,8 +508,7 @@ public final class ClusterManager implements ActiveMQComponent { public void run() { try { manager.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -551,8 +540,7 @@ public final class ClusterManager implements ActiveMQComponent { for (Bridge bridge : bridges.values()) { try { bridge.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -560,8 +548,7 @@ public final class ClusterManager implements ActiveMQComponent { for (ClusterConnection clusterConnection : clusterConnections.values()) { try { clusterConnection.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -609,16 +596,15 @@ public final class ClusterManager implements ActiveMQComponent { if (logger.isDebugEnabled()) { logger.debug(this + " Starting a Discovery Group Cluster Connection, name=" + - config.getDiscoveryGroupName() + - ", dg=" + - dg); + config.getDiscoveryGroupName() + + ", dg=" + + dg); } clusterConnection = new ClusterConnectionImpl(this, dg, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress()), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts()); clusterController.addClusterConnection(clusterConnection.getName(), dg, config); - } - else { + } else { TransportConfiguration[] tcConfigs = config.getTransportConfigurations(configuration); if (logger.isDebugEnabled()) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java index 249f60f776..e730c71167 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java @@ -68,8 +68,7 @@ public class ColocatedHAManager implements HAManager { for (ActiveMQServer activeMQServer : backupServers.values()) { try { activeMQServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -93,8 +92,7 @@ public class ColocatedHAManager implements HAManager { } if (haPolicy.getBackupPolicy().isSharedStore()) { return activateSharedStoreBackup(journalDirectory, bindingsDirectory, largeMessagesDirectory, pagingDirectory); - } - else { + } else { return activateReplicatedBackup(nodeID); } } @@ -129,8 +127,7 @@ public class ColocatedHAManager implements HAManager { clusterControl.authorize(); if (replicated) { return clusterControl.requestReplicatedBackup(backupSize, server.getNodeID()); - } - else { + } else { return clusterControl.requestSharedStoreBackup(backupSize, server.getConfiguration().getJournalLocation().getAbsolutePath(), server.getConfiguration().getBindingsLocation().getAbsolutePath(), server.getConfiguration().getLargeMessagesLocation().getAbsolutePath(), server.getConfiguration().getPagingLocation().getAbsolutePath()); } @@ -154,8 +151,7 @@ public class ColocatedHAManager implements HAManager { backupServers.put(configuration.getName(), backup); backup.start(); - } - catch (Exception e) { + } catch (Exception e) { backup.stop(); ActiveMQServerLogger.LOGGER.activateSharedStoreSlaveFailed(e); return false; @@ -188,8 +184,7 @@ public class ColocatedHAManager implements HAManager { backup.addActivationParam(ActivationParams.REPLICATION_ENDPOINT, member); backupServers.put(configuration.getName(), backup); backup.start(); - } - catch (Exception e) { + } catch (Exception e) { backup.stop(); ActiveMQServerLogger.LOGGER.activateReplicatedBackupFailed(e); return false; @@ -267,8 +262,7 @@ public class ColocatedHAManager implements HAManager { updatebackupParams(backupConfiguration.getName(), portOffset, entry.getValue().getParams()); } } - } - else { + } else { //if we are scaling down then we wont need any acceptors but clear anyway for belts and braces backupConfiguration.getAcceptorConfigurations().clear(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java index e507356b50..b1ace20d85 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java @@ -16,15 +16,15 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.core.server.impl.ColocatedActivation; -import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; -import org.apache.activemq.artemis.core.server.impl.LiveActivation; - import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; +import org.apache.activemq.artemis.core.server.impl.ColocatedActivation; +import org.apache.activemq.artemis.core.server.impl.LiveActivation; + public class ColocatedPolicy implements HAPolicy { /*live stuff*/ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/HAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/HAManager.java index 74107fc443..d32d829a72 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/HAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/HAManager.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.ActiveMQServer; -import java.util.Map; - /* * An HAManager takes care of any colocated backups in a VM. * */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/LiveOnlyPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/LiveOnlyPolicy.java index 9161e06433..442c22dd25 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/LiveOnlyPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/LiveOnlyPolicy.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.core.server.impl.Activation; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation; -import java.util.Map; - public class LiveOnlyPolicy implements HAPolicy { private ScaleDownPolicy scaleDownPolicy; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicaPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicaPolicy.java index d7f15b0ef7..ba12677554 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicaPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicaPolicy.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.server.impl.Activation; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation; -import java.util.Map; - public class ReplicaPolicy extends BackupPolicy { private String clusterName; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicatedPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicatedPolicy.java index e627eb9683..9b64d81c16 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicatedPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ReplicatedPolicy.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.LiveActivation; import org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation; -import java.util.Map; - public class ReplicatedPolicy implements HAPolicy { private boolean checkForLiveServer = ActiveMQDefaultConfiguration.isDefaultCheckForLiveServer(); @@ -48,7 +48,10 @@ public class ReplicatedPolicy implements HAPolicy { replicaPolicy = new ReplicaPolicy(clusterName, -1, groupName, this); } - public ReplicatedPolicy(boolean checkForLiveServer, String groupName, String clusterName, long initialReplicationSyncTimeout) { + public ReplicatedPolicy(boolean checkForLiveServer, + String groupName, + String clusterName, + long initialReplicationSyncTimeout) { this.checkForLiveServer = checkForLiveServer; this.groupName = groupName; this.clusterName = clusterName; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ScaleDownPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ScaleDownPolicy.java index 1fcbd4d277..0ef96d5322 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ScaleDownPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ScaleDownPolicy.java @@ -102,16 +102,14 @@ public class ScaleDownPolicy { ActiveMQServer activeMQServer) throws ActiveMQException { if (!scaleDownPolicy.getConnectors().isEmpty()) { return (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(connectorNameListToArray(scaleDownPolicy.getConnectors(), activeMQServer)); - } - else if (scaleDownPolicy.getDiscoveryGroup() != null) { + } else if (scaleDownPolicy.getDiscoveryGroup() != null) { DiscoveryGroupConfiguration dg = activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(scaleDownPolicy.getDiscoveryGroup()); if (dg == null) { throw ActiveMQMessageBundle.BUNDLE.noDiscoveryGroupFound(dg); } return (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(dg); - } - else { + } else { Map connectorConfigurations = activeMQServer.getConfiguration().getConnectorConfigurations(); for (TransportConfiguration transportConfiguration : connectorConfigurations.values()) { if (transportConfiguration.getFactoryClassName().equals(InVMConnectorFactory.class.getName())) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreMasterPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreMasterPolicy.java index d1fcb65470..c2e669c3ce 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreMasterPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreMasterPolicy.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.LiveActivation; import org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation; -import java.util.Map; - public class SharedStoreMasterPolicy implements HAPolicy { private boolean failoverOnServerShutdown = ActiveMQDefaultConfiguration.isDefaultFailoverOnServerShutdown(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreSlavePolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreSlavePolicy.java index af6a95538a..5fa576b866 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreSlavePolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/SharedStoreSlavePolicy.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.server.impl.Activation; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation; -import java.util.Map; - public class SharedStoreSlavePolicy extends BackupPolicy { private boolean failoverOnServerShutdown = ActiveMQDefaultConfiguration.isDefaultFailoverOnServerShutdown(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/StandaloneHAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/StandaloneHAManager.java index 3b0b9083b1..3fe192e717 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/StandaloneHAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/StandaloneHAManager.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.server.cluster.ha; -import org.apache.activemq.artemis.core.server.ActiveMQServer; - import java.util.HashMap; import java.util.Map; +import org.apache.activemq.artemis.core.server.ActiveMQServer; + /* * this implementation doesn't really do anything at the minute but this may change so Im leaving it here, Andy... * */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java index 803c6f05f1..ac30c53e11 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java @@ -309,8 +309,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { refqueue.cancel(ref, timeBase); - } - catch (Exception e) { + } catch (Exception e) { // There isn't much we can do besides log an error ActiveMQServerLogger.LOGGER.errorCancellingRefOnBridge(e, ref); } @@ -339,8 +338,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (session != null) { try { session.cleanUp(false); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare.getMessage(), dontcare); } session = null; @@ -348,8 +346,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (sessionConsumer != null) { try { sessionConsumer.cleanUp(false); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare.getMessage(), dontcare); } sessionConsumer = null; @@ -395,8 +392,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.broadcastBridgeStoppedError(e); } } @@ -416,8 +412,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.notificationBridgeStoppedError(e); } } @@ -465,8 +460,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled public RemotingConnection getForwardingConnection() { if (session == null) { return null; - } - else { + } else { return session.getConnection(); } } @@ -493,14 +487,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } ref.getQueue().acknowledge(ref); pendingAcks.countDown(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("BridgeImpl::sendAcknowledged bridge " + this + " could not find reference for message " + message); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.bridgeFailedToAck(e); } } @@ -524,14 +516,13 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (transformedMessage != message) { if (logger.isDebugEnabled()) { logger.debug("The transformer " + transformer + - " made a copy of the message " + - message + - " as transformedMessage"); + " made a copy of the message " + + message + + " as transformedMessage"); } } return transformedMessage; - } - else { + } else { return message; } } @@ -575,8 +566,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (forwardingAddress != null) { dest = forwardingAddress; - } - else { + } else { // Preserve the original address dest = message.getAddress(); } @@ -588,12 +578,10 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled deliveringLargeMessage = true; deliverLargeMessage(dest, ref, (LargeServerMessage) message); return HandleStatus.HANDLED; - } - else { + } else { return deliverStandardMessage(dest, ref, message); } - } - catch (Exception e) { + } catch (Exception e) { // If an exception happened, we must count down immediately pendingAcks.countDown(); throw e; @@ -627,14 +615,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } cleanUpSessionFactory(csf); - } - catch (Throwable dontCare) { + } catch (Throwable dontCare) { } try { session.cleanUp(false); - } - catch (Throwable dontCare) { + } catch (Throwable dontCare) { } if (scaleDownTargetNodeID != null && !scaleDownTargetNodeID.equals(nodeUUID.toString())) { @@ -645,18 +631,15 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled // stop the bridge from trying to reconnect and clean up all the bindings fail(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } - } - else if (scaleDownTargetNodeID != null) { + } else if (scaleDownTargetNodeID != null) { // the disconnected node is scaling down to me, no need to reconnect to it logger.debug("Received scaleDownTargetNodeID: " + scaleDownTargetNodeID + "; cancelling reconnect."); fail(true); - } - else { + } else { logger.debug("Received invalid scaleDownTargetNodeID: " + scaleDownTargetNodeID); fail(me.getType() == ActiveMQExceptionType.DISCONNECTED); @@ -692,8 +675,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (queue != null) { queue.deliverAsync(); } - } - catch (final ActiveMQException e) { + } catch (final ActiveMQException e) { unsetLargeMessageDelivery(); ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); @@ -720,8 +702,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { producer.send(dest, message); - } - catch (final ActiveMQException e) { + } catch (final ActiveMQException e) { ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); synchronized (refs) { @@ -789,8 +770,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled logger.trace("Removing consumer on fail " + this + " from queue " + queue); } queue.removeConsumer(this); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare); } } @@ -815,8 +795,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled protected ClientSessionFactoryInternal createSessionFactory() throws Exception { if (targetNodeID != null && (this.reconnectAttemptsSameNode < 0 || retryCount <= this.reconnectAttemptsSameNode)) { csf = reconnectOnOriginalNode(); - } - else { + } else { serverLocator.resetToInitialConnectors(); csf = (ClientSessionFactoryInternal) serverLocator.createSessionFactory(); } @@ -891,8 +870,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { query = session.addressQuery(forwardingAddress); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorQueryingBridge(e, name); // This was an issue during startup, we will not count this retry retryCount--; @@ -907,8 +885,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scheduleRetryConnect(); return; } - } - else { + } else { if (!query.isExists()) { ActiveMQServerLogger.LOGGER.bridgeNoBindings(getName(), getForwardingAddress(), getForwardingAddress()); } @@ -936,8 +913,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled keepConnecting = false; return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // the session was created while its server was starting, retry it: if (e.getType() == ActiveMQExceptionType.SESSION_CREATION_REJECTED) { ActiveMQServerLogger.LOGGER.errorStartingBridge(name); @@ -947,26 +923,22 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scheduleRetryConnectFixedTimeout(this.retryInterval); return; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Bridge " + this + " is unable to connect to destination. Retrying", e); } scheduleRetryConnect(); } - } - catch (ActiveMQInterruptedException | InterruptedException e) { + } catch (ActiveMQInterruptedException | InterruptedException e) { ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); if (csf != null) { try { csf.close(); csf = null; - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } fail(false); @@ -1001,12 +973,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } logger.debug("Bridge " + this + - " retrying connection #" + - retryCount + - ", maxRetry=" + - reconnectAttemptsInUse + - ", timeout=" + - timeout); + " retrying connection #" + + retryCount + + ", maxRetry=" + + reconnectAttemptsInUse + + ", timeout=" + + timeout); scheduleRetryConnectFixedTimeout(timeout); } @@ -1016,8 +988,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled protected void scheduleRetryConnectFixedTimeout(final long milliseconds) { try { cleanUpSessionFactory(csf); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } if (stopping) @@ -1105,8 +1076,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { session.close(); session = null; - } - catch (ActiveMQException dontcare) { + } catch (ActiveMQException dontcare) { } } @@ -1115,8 +1085,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { sessionConsumer.close(); sessionConsumer = null; - } - catch (ActiveMQException dontcare) { + } catch (ActiveMQException dontcare) { } } @@ -1134,8 +1103,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue); } ActiveMQServerLogger.LOGGER.bridgeStopped(name); - } - catch (InterruptedException | RuntimeException e) { + } catch (InterruptedException | RuntimeException e) { ActiveMQServerLogger.LOGGER.error("Failed to stop bridge", e); } } @@ -1160,8 +1128,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled internalCancelReferences(); ActiveMQServerLogger.LOGGER.bridgePaused(name); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorPausingBridge(e); } } @@ -1179,8 +1146,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (member != null && BridgeImpl.this.targetNodeID != null && BridgeImpl.this.targetNodeID.equals(member.getNodeId())) { // this could be an update of the topology say after a backup started BridgeImpl.this.targetNode = member; - } - else { + } else { // we don't need synchronization here, but we need to make sure we won't get a NPE on races if (connectionToUse != null && member.isMember(connectionToUse)) { BridgeImpl.this.targetNode = member; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java index 45063571b6..4700b6de65 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java @@ -128,8 +128,7 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { try { endpoint.close(true); - } - catch (Exception e1) { + } catch (Exception e1) { ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e1); } @@ -141,8 +140,7 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.BROADCAST_GROUP_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e); } } @@ -210,14 +208,12 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { try { broadcastConnectors(); loggedBroadcastException = false; - } - catch (Exception e) { + } catch (Exception e) { // only log the exception at ERROR level once, even if it fails multiple times in a row - HORNETQ-919 if (!loggedBroadcastException) { ActiveMQServerLogger.LOGGER.errorBroadcastingConnectorConfigs(e); loggedBroadcastException = true; - } - else { + } else { logger.debug("Failed to broadcast connector configs...again", e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java index 425e26a22a..3b35c14133 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java @@ -57,6 +57,7 @@ import org.jboss.logging.Logger; * Such as such adding extra properties and setting up notifications between the nodes. */ public class ClusterConnectionBridge extends BridgeImpl { + private static final Logger logger = Logger.getLogger(ClusterConnectionBridge.class); private final ClusterConnection clusterConnection; @@ -184,12 +185,12 @@ public class ClusterConnectionBridge extends BridgeImpl { private void setupNotificationConsumer() throws Exception { if (logger.isDebugEnabled()) { logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + - " and " + - flowRecord.getBridge().getForwardingConnection() + - " clusterConnection = " + - this.clusterConnection.getName() + - " on server " + - clusterConnection.getServer()); + " and " + + flowRecord.getBridge().getForwardingConnection() + + " clusterConnection = " + + this.clusterConnection.getName() + + " on server " + + clusterConnection.getServer()); } if (flowRecord != null) { flowRecord.reset(); @@ -197,13 +198,12 @@ public class ClusterConnectionBridge extends BridgeImpl { if (notifConsumer != null) { try { logger.debug("Closing notification Consumer for reopening " + notifConsumer + - " on bridge " + - this.getName()); + " on bridge " + + this.getName()); notifConsumer.close(); notifConsumer = null; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.errorClosingConsumer(e); } } @@ -279,8 +279,7 @@ public class ClusterConnectionBridge extends BridgeImpl { if (!address.contains(",")) { if (address.startsWith("!")) { stringBuilder.append(ManagementHelper.HDR_ADDRESS + " NOT LIKE '" + address.substring(1, address.length()) + "%'"); - } - else { + } else { stringBuilder.append(ManagementHelper.HDR_ADDRESS + " LIKE '" + address + "%'"); } return stringBuilder.toString(); @@ -298,8 +297,7 @@ public class ClusterConnectionBridge extends BridgeImpl { for (String s : list) { if (s.startsWith("!")) { excludes.add(s.substring(1, s.length())); - } - else { + } else { includes.add(s); } } @@ -355,8 +353,7 @@ public class ClusterConnectionBridge extends BridgeImpl { if (permanently) { logger.debug("cluster node for bridge " + this.getName() + " is permanently down"); clusterConnection.removeRecord(targetNodeID); - } - else { + } else { clusterConnection.disconnectRecord(targetNodeID); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java index 77f25e9e8a..4b9f0b7714 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java @@ -76,9 +76,11 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn private static final Logger logger = Logger.getLogger(ClusterConnectionImpl.class); - /** When getting member on node-up and down we have to remove the name from the transport config - * as the setting we build here doesn't need to consider the name, so use the same name on all - * the instances. */ + /** + * When getting member on node-up and down we have to remove the name from the transport config + * as the setting we build here doesn't need to consider the name, so use the same name on all + * the instances. + */ private static final String TRANSPORT_CONFIG_NAME = "topology-member"; private final ExecutorFactory executorFactory; @@ -414,17 +416,16 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } logger.debug("Cluster connection being stopped for node" + nodeManager.getNodeId() + - ", server = " + - this.server + - " serverLocator = " + - serverLocator); + ", server = " + + this.server + + " serverLocator = " + + serverLocator); synchronized (this) { for (MessageFlowRecord record : records.values()) { try { record.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } } @@ -493,8 +494,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn newMember.setUniqueEventID(uniqueEventID); if (backup) { topology.updateBackup(new TopologyMemberImpl(nodeID, backupGroupName, scaleDownGroupName, live, backupTC)); - } - else { + } else { topology.updateMember(uniqueEventID, nodeID, newMember); } } @@ -507,12 +507,10 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { clusterControl.authorize(); clusterControl.sendNodeAnnounce(localMember.getUniqueEventID(), manager.getNodeId(), manager.getBackupGroupName(), manager.getScaleDownGroupName(), false, localMember.getLive(), localMember.getBackup()); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.clusterControlAuthfailure(); } - } - else { + } else { ActiveMQServerLogger.LOGGER.noLocalMemborOnClusterConnection(this); } @@ -668,7 +666,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (nodeID.equals(nodeManager.getNodeId().toString())) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing about backup to itself, nodeUUID=" + - nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this); + nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -687,7 +685,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (topologyMember.getLive() == null) { if (logger.isTraceEnabled()) { logger.trace(this + " ignoring call with nodeID=" + nodeID + ", topologyMember=" + - topologyMember + ", last=" + last); + topologyMember + ", last=" + last); } return; } @@ -699,7 +697,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record == null) { if (logger.isDebugEnabled()) { logger.debug(this + "::Creating record for nodeID=" + nodeID + ", topologyMember=" + - topologyMember); + topologyMember); } // New node - create a new flow record @@ -712,8 +710,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (queueBinding != null) { queue = (Queue) queueBinding.getBindable(); - } - else { + } else { // Add binding in storage so the queue will get reloaded on startup and we can find it - it's never // actually routed to at that address though queue = server.createQueue(queueName, queueName, null, true, false); @@ -724,15 +721,13 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn queue.setInternalQueue(true); createNewRecord(topologyMember.getUniqueEventID(), nodeID, topologyMember.getLive(), queueName, queue, true); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + " ignored nodeUp record for " + topologyMember + " on nodeID=" + - nodeID + " as the record already existed"); + nodeID + " as the record already existed"); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorUpdatingTopology(e); } } @@ -956,12 +951,10 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { if (disconnected) { targetLocator.cleanup(); - } - else { + } else { targetLocator.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { logger.debug(ignored.getMessage(), ignored); } } @@ -998,8 +991,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn reset = true; return; - } - else if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE)) { + } else if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE)) { clearDisconnectedBindings(); return; } @@ -1010,8 +1002,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } handleNotificationMessage(message); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorHandlingMessage(e); } } @@ -1227,8 +1218,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { postOffice.addBinding(binding); - } - catch (Exception ignore) { + } catch (Exception ignore) { } Bindings theBindings = postOffice.getBindingsForAddress(queueAddress); @@ -1481,8 +1471,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record != null) { record.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e); } } @@ -1495,9 +1484,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record != null) { record.disconnectBindings(); } - } - catch (Exception e) { - ActiveMQServerLogger.LOGGER.warn(e.getMessage(),e); + } catch (Exception e) { + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java index cb48b49dda..e1486cf140 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java @@ -48,15 +48,12 @@ public enum MessageLoadBalancingType { public static MessageLoadBalancingType getType(String string) { if (string.equals(OFF.getType())) { return MessageLoadBalancingType.OFF; - } - else if (string.equals(STRICT.getType())) { + } else if (string.equals(STRICT.getType())) { return MessageLoadBalancingType.STRICT; - } - else if (string.equals(ON_DEMAND.getType())) { + } else if (string.equals(ON_DEMAND.getType())) { return MessageLoadBalancingType.ON_DEMAND; - } - else { + } else { return null; } } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java index 339293b114..c58540517a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java @@ -22,13 +22,13 @@ import java.util.concurrent.Executor; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.filter.Filter; +import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.postoffice.PostOffice; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.HandleStatus; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RoutingContext; @@ -122,8 +122,7 @@ public class Redistributor implements Consumer { try { boolean ok = pendingRuns.await(10000); return ok; - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return false; } @@ -133,9 +132,8 @@ public class Redistributor implements Consumer { public synchronized HandleStatus handle(final MessageReference reference) throws Exception { if (!active) { return HandleStatus.BUSY; - } - //we shouldn't redistribute with message groups return NO_MATCH so other messages can be delivered - else if (reference.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID) != null) { + } else if (reference.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID) != null) { + //we shouldn't redistribute with message groups return NO_MATCH so other messages can be delivered return HandleStatus.NO_MATCH; } @@ -152,8 +150,7 @@ public class Redistributor implements Consumer { postOffice.processRoute(routingInfo.getB(), routingInfo.getA(), false); ackRedistribution(reference, tx); - } - else { + } else { active = false; executor.execute(new Runnable() { @Override @@ -171,12 +168,10 @@ public class Redistributor implements Consumer { queue.deliverAsync(); } - } - catch (Exception e) { + } catch (Exception e) { try { tx.rollback(); - } - catch (Exception e2) { + } catch (Exception e2) { // Nothing much we can do now // TODO log @@ -202,8 +197,7 @@ public class Redistributor implements Consumer { public void run() { try { runnable.run(); - } - finally { + } finally { pendingRuns.countDown(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java index d5921039cc..8f54b2ad32 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java @@ -156,8 +156,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { if (filters.isEmpty()) { return true; - } - else { + } else { for (Filter filter : filters) { if (filter.match(message)) { return true; @@ -210,8 +209,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { filterCounts.put(filterString, 1); filters.add(FilterImpl.createFilter(filterString)); - } - else { + } else { filterCounts.put(filterString, i + 1); } } @@ -231,8 +229,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { filterCounts.remove(filterString); filters.remove(FilterImpl.createFilter(filterString)); - } - else { + } else { filterCounts.put(filterString, ii); } } @@ -323,8 +320,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { if (ids == null) { ids = new byte[8]; - } - else { + } else { byte[] newIds = new byte[ids.length + 8]; System.arraycopy(ids, 0, newIds, 8, ids.length); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java index 69c8068c34..cbc70e7073 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; - import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; + /** * a simple yes.no vote */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java index 6b01b96403..dad772b8d7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java @@ -199,8 +199,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom for (VoteRunnable runnable : runnables) { executor.submit(runnable); } - } - else { + } else { quorumVote.allVotesCast(clusterController.getDefaultClusterTopology()); } } @@ -302,22 +301,18 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom if (vote.isRequestServerVote()) { vote = clusterControl.sendQuorumVote(quorumVote.getName(), vote); quorumVote.vote(vote); - } - else { + } else { quorumVote.vote(vote); } - } - catch (Exception e) { + } catch (Exception e) { Vote vote = quorumVote.notConnected(); quorumVote.vote(vote); - } - finally { + } finally { try { if (clusterControl != null) { clusterControl.close(); } - } - catch (Exception e) { + } catch (Exception e) { //ignore } QuorumManager.this.votingComplete(quorumVote); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java index 352e5e34f3..8eac44426c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.persistence.StorageManager; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * A Qourum Vote for deciding if a replicated backup should become live. */ @@ -39,23 +39,22 @@ public class QuorumVoteServerConnect extends QuorumVote { /** * live nodes | remaining nodes | majority | votes needed - * 1 | 0 | 0 | 0 - * 2 | 1 | 1 | 1 - * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded - * 3 | 2 | 2.5 | 2 - * 4 | 3 | 3 | 3 - * 5 | 4 | 3.5 | 3 - * 6 | 5 | 4 | 4 + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 */ public QuorumVoteServerConnect(int size, StorageManager storageManager) { super(LIVE_FAILOVER_VOTE); double majority; if (size <= 2) { - majority = ((double)size) / 2; - } - else { + majority = ((double) size) / 2; + } else { //even - majority = ((double)size) / 2 + 1; + majority = ((double) size) / 2 + 1; } //votes needed could be say 2.5 so we add 1 in this case votesNeeded = (int) majority; @@ -87,13 +86,13 @@ public class QuorumVoteServerConnect extends QuorumVote { /** * live nodes | remaining nodes | majority | votes needed - * 1 | 0 | 0 | 0 - * 2 | 1 | 1 | 1 - * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded - * 3 | 2 | 2.5 | 2 - * 4 | 3 | 3 | 3 - * 5 | 4 | 3.5 | 3 - * 6 | 5 | 4 | 4 + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 * * @param vote the vote to make. */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java index 5a95791119..707849d4f2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java @@ -97,8 +97,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener // no point in repeating all the reconnection logic sessionFactory.connect(RECONNECT_ATTEMPTS, false); return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() != ActiveMQExceptionType.NOT_CONNECTED) ActiveMQServerLogger.LOGGER.errorReConnecting(e); } @@ -223,8 +222,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener public BACKUP_ACTIVATION waitForStatusChange() { try { latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return BACKUP_ACTIVATION.STOP; } return signal; @@ -260,8 +258,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener try { quorumVote.await(LATCH_TIMEOUT, TimeUnit.SECONDS); - } - catch (InterruptedException interruption) { + } catch (InterruptedException interruption) { // No-op. The best the quorum can do now is to return the latest number it has } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java index 5ceb0b2351..916c63e913 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; - import java.util.HashMap; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; + /** * the vote itself */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java index e3a583fff3..1065a49e57 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.core.server.embedded; import javax.management.MBeanServer; - import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.config.Configuration; @@ -62,15 +61,15 @@ public class EmbeddedActiveMQ { /** * It will iterate the cluster connections until you have at least the number of expected servers - * @param timeWait Time to wait on each iteration - * @param unit unit of time to wait + * + * @param timeWait Time to wait on each iteration + * @param unit unit of time to wait * @param iterations number of iterations - * @param servers number of minimal servers + * @param servers number of minimal servers * @return */ public boolean waitClusterForming(long timeWait, TimeUnit unit, int iterations, int servers) throws Exception { - if (activeMQServer.getClusterManager().getClusterConnections() == null || - activeMQServer.getClusterManager().getClusterConnections().size() == 0) { + if (activeMQServer.getClusterManager().getClusterConnections() == null || activeMQServer.getClusterManager().getClusterConnections().size() == 0) { return servers == 0; } @@ -132,8 +131,7 @@ public class EmbeddedActiveMQ { } if (mbeanServer == null) { activeMQServer = new ActiveMQServerImpl(configuration, securityManager); - } - else { + } else { activeMQServer = new ActiveMQServerImpl(configuration, mbeanServer, securityManager); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java index 2cd5632edd..32587e5ffc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java @@ -32,6 +32,7 @@ import org.jboss.logging.Logger; * We may control the maximum number of folders so we remove old ones. */ public class FileMoveManager { + private static final Logger logger = Logger.getLogger(FileMoveManager.class); private final File folder; @@ -46,8 +47,7 @@ public class FileMoveManager { if (prefixed) { try { Integer.parseInt(name.substring(PREFIX.length())); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // This function is not really used a lot // so I don't really mind about performance here // this is good enough for what we need @@ -66,7 +66,6 @@ public class FileMoveManager { } }; - public FileMoveManager(File folder) { this(folder, -1); } @@ -105,8 +104,7 @@ public class FileMoveManager { logger.tracef("deleting %s", fileFrom); deleteTree(fileFrom); } - } - else { + } else { File folderTo = getFolder(whereToMove); folderTo.mkdirs(); @@ -157,7 +155,6 @@ public class FileMoveManager { return folder.list(notPrefix); } - public int getNumberOfFolders() { return getFolders().length; } @@ -169,11 +166,9 @@ public class FileMoveManager { list = new String[0]; } - return list; } - public int getMinID() { int[] list = getIDlist(); @@ -194,7 +189,6 @@ public class FileMoveManager { return list[list.length - 1]; } - public int[] getIDlist() { String[] list = getFolders(); int[] ids = new int[list.length]; @@ -211,12 +205,10 @@ public class FileMoveManager { return Integer.parseInt(folderName.substring(PREFIX.length())); } - public File getFolder(int id) { return new File(folder, PREFIX + id); } - private void deleteTree(File file) { File[] files = file.listFiles(); @@ -229,5 +221,4 @@ public class FileMoveManager { file.delete(); } - } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java index f4ab032fc7..972cbdde4a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java @@ -30,12 +30,13 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent; import org.jboss.logging.Logger; -/** This will keep a list of fileStores. It will make a comparisson on all file stores registered. if any is over the limit, - * all Callbacks will be called with over. +/** + * This will keep a list of fileStores. It will make a comparisson on all file stores registered. if any is over the limit, + * all Callbacks will be called with over. * - * For instance: if Large Messages folder is registered on a different folder and it's over capacity, - * the whole system will be waiting it to be released. - * */ + * For instance: if Large Messages folder is registered on a different folder and it's over capacity, + * the whole system will be waiting it to be released. + */ public class FileStoreMonitor extends ActiveMQScheduledComponent { private static final Logger logger = Logger.getLogger(FileStoreMonitor.class); @@ -71,7 +72,6 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { return this; } - @Override public void run() { tick(); @@ -87,12 +87,11 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { try { lastStore = store; usage = calculateUsage(store); - over = usage > maxUsage; + over = usage > maxUsage; if (over) { break; } - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -102,8 +101,7 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { if (over) { callback.over(lastStore, usage); - } - else { + } else { callback.under(lastStore, usage); } } @@ -119,12 +117,15 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { } protected double calculateUsage(FileStore store) throws IOException { - return 1.0 - (double)store.getUsableSpace() / (double)store.getTotalSpace(); + return 1.0 - (double) store.getUsableSpace() / (double) store.getTotalSpace(); } public interface Callback { + void tick(FileStore store, double usage); + void over(FileStore store, double usage); + void under(FileStore store, double usage); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java index 3c32c92d96..b68b59e89b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java @@ -55,8 +55,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { public void addListener(final UnproposalListener listener) { if (executor == null) { listeners.add(listener); - } - else { + } else { executor.execute(new Runnable() { @Override public void run() { @@ -78,8 +77,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { }; if (executor != null) { executor.execute(runnable); - } - else { + } else { // for tests only, where we don't need an executor runnable.run(); } @@ -101,8 +99,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { Notification notification = new Notification(null, CoreNotificationType.UNPROPOSAL, props); try { managementService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorHandlingMessage(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java index f6b7fccf02..4ee82690e8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java @@ -138,14 +138,12 @@ public final class GroupingHandlerConfiguration implements Serializable { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (timeout != other.timeout) return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java index 383321e6a3..aa707f71d1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java @@ -119,8 +119,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (original != null) { original.use(); return new Response(proposal.getGroupId(), original.getClusterName()); - } - else { + } else { return null; } } @@ -135,8 +134,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { groupBinding.use(); // Returning with an alternate cluster name, as it's been already grouped return new Response(groupBinding.getGroupId(), proposal.getClusterName(), groupBinding.getClusterName()); - } - else { + } else { addRecord = true; groupBinding = new GroupBinding(proposal.getGroupId(), proposal.getClusterName()); groupBinding.setId(storageManager.generateID()); @@ -148,8 +146,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { newList.add(groupBinding); map.put(groupBinding.getGroupId(), groupBinding); } - } - finally { + } finally { lock.unlock(); } // Storing the record outside of any locks @@ -157,8 +154,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { storageManager.addGrouping(groupBinding); } return new Response(groupBinding.getGroupId(), groupBinding.getClusterName()); - } - finally { + } finally { storageManager.setContext(originalCtx); } } @@ -217,8 +213,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { original.use(); } return new Response(fullID, original.getClusterName()); - } - else { + } else { return null; } } @@ -233,8 +228,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { long tx = storageManager.generateID(); storageManager.deleteGrouping(tx, groupBinding); storageManager.commitBindings(tx); - } - catch (Exception e) { + } catch (Exception e) { // nothing we can do being log ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } @@ -253,8 +247,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (expectedBindings == null) { bindingsAlreadyAdded = Collections.emptyList(); expectedBindings = new LinkedList<>(); - } - else { + } else { bindingsAlreadyAdded = new ArrayList<>(expectedBindings); //clear the bindings expectedBindings.clear(); @@ -274,8 +267,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { } } } - } - finally { + } finally { expectedBindings = null; waitingForBindings = false; lock.unlock(); @@ -290,8 +282,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (notification.getType() == CoreNotificationType.BINDING_REMOVED) { SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); removeGrouping(clusterName); - } - else if (notification.getType() == CoreNotificationType.BINDING_ADDED) { + } else if (notification.getType() == CoreNotificationType.BINDING_ADDED) { SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); try { lock.lock(); @@ -300,12 +291,10 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (waitingForBindings) { if (expectedBindings.remove(clusterName)) { logger.debug("OnNotification for waitForbindings::Removed clusterName=" + clusterName + " from lis succesffully"); - } - else { + } else { logger.debug("OnNotification for waitForbindings::Couldn't remove clusterName=" + clusterName + " as it wasn't on the original list"); } - } - else { + } else { expectedBindings.add(clusterName); logger.debug("Notification for waitForbindings::Adding previously known item clusterName=" + clusterName); } @@ -320,8 +309,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { awaitCondition.signal(); } } - } - finally { + } finally { lock.unlock(); } } @@ -382,8 +370,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { txID = storageManager.generateID(); } storageManager.deleteGrouping(txID, val); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, val.getGroupId()); } } @@ -392,8 +379,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (txID >= 0) { try { storageManager.commitBindings(txID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, SimpleString.toSimpleString("TX:" + txID)); } } @@ -448,8 +434,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { expiredGroups = 0; txID = -1; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, groupBinding.getGroupId()); } } @@ -458,8 +443,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (txID >= 0) { try { storageManager.commitBindings(txID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, SimpleString.toSimpleString("TX:" + txID)); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java index 26841e4931..058e897cd9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java @@ -117,8 +117,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { for (Notification notification : pendingNotifications) { managementService.sendNotification(notification); } - } - finally { + } finally { lock.unlock(); } } @@ -159,8 +158,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { break; } } while (timeLimit > System.currentTimeMillis()); - } - finally { + } finally { if (notification != null) { pendingNotifications.remove(notification); } @@ -185,8 +183,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { response.use(); try { managementService.sendNotification(createProposalNotification(response.getGroupId(), response.getClusterName())); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -249,8 +246,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { // We could have more than one Requests waiting in case you have multiple producers // using different groups sendCondition.signalAll(); - } - finally { + } finally { lock.unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java index 471b7c125d..0892a11fc5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java @@ -76,12 +76,10 @@ public final class AIOFileLockNodeManager extends FileLockNodeManager { FileLock lockFile = tryLock(liveLockPos); if (lockFile != null) { return lockFile; - } - else { + } else { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return null; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 5323d986ae..2c3add24d4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -358,8 +358,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final ServiceRegistry serviceRegistry) { if (configuration == null) { configuration = new ConfigurationImpl(); - } - else { + } else { ConfigurationUtils.validateConfiguration(configuration); } @@ -406,11 +405,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { NodeManager manager; if (!configuration.isPersistenceEnabled()) { manager = new InVMNodeManager(replicatingBackup); - } - else if (configuration.getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { + } else if (configuration.getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { manager = new AIOFileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); - } - else { + } else { manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); } return manager; @@ -457,8 +454,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (haPolicy.isBackup()) { if (haPolicy.isSharedStore()) { activation = haPolicy.createActivation(this, false, activationParams, shutdownOnCriticalIO); - } - else { + } else { activation = haPolicy.createActivation(this, wasLive, activationParams, shutdownOnCriticalIO); } @@ -467,15 +463,13 @@ public class ActiveMQServerImpl implements ActiveMQServer { } backupActivationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); backupActivationThread.start(); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverStarted(getVersion().getFullVersion(), configuration.getName(), nodeManager.getNodeId(), identity != null ? identity : ""); } // start connector service connectorsService = new ConnectorsService(configuration, storageManager, scheduledPool, postOffice, serviceRegistry); connectorsService.start(); - } - finally { + } finally { // this avoids embedded applications using dirty contexts from startup OperationContextImpl.clearContext(); } @@ -490,8 +484,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public void lockActivation() { try { activationLock.acquire(); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -590,8 +583,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public void run() { try { ActiveMQServerImpl.this.stop(false, criticalIOError, false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingServer(e); } } @@ -667,15 +659,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { SimpleString filterString = filter == null ? null : filter.getFilterString(); response = new QueueQueryResult(name, binding.getAddress(), queue.isDurable(), queue.isTemporary(), filterString, queue.getConsumerCount(), queue.getMessageCount(), autoCreateJmsQueues); - } - // make an exception for the management address (see HORNETQ-29) - else if (name.equals(managementAddress)) { + } else if (name.equals(managementAddress)) { + // make an exception for the management address (see HORNETQ-29) response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1, autoCreateJmsQueues); - } - else if (autoCreateJmsQueues) { + } else if (autoCreateJmsQueues) { response = new QueueQueryResult(name, name, true, false, null, 0, 0, true, false); - } - else { + } else { response = new QueueQueryResult(null, null, false, false, null, 0, 0, false, false); } @@ -740,15 +729,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (replicationManager == null) { return false; - } - else { + } else { return !replicationManager.isSynchronizing(); } - } - else if (activation instanceof SharedNothingBackupActivation) { + } else if (activation instanceof SharedNothingBackupActivation) { return ((SharedNothingBackupActivation) activation).isRemoteBackupUpToDate(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.methodNotApplicable(); } } @@ -793,12 +779,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { if (timeout == -1) { remotingService.getConnectionCountLatch().await(); - } - else { + } else { remotingService.getConnectionCountLatch().await(timeout); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(remotingService.getClass().getName()); } } @@ -829,8 +813,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { activation.preStorageClose(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName()); } @@ -839,8 +822,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (storageManager != null) try { storageManager.stop(criticalIOError); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, storageManager.getClass().getName()); } @@ -849,8 +831,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (remotingService != null) try { remotingService.stop(criticalIOError); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, remotingService.getClass().getName()); } @@ -858,8 +839,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (managementService != null) try { managementService.unregisterServer(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, managementService.getClass().getName()); } @@ -887,8 +867,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { logger.debug("Cancelled the execution of " + r); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(threadPool.getClass().getName()); } } @@ -901,8 +880,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (securityStore != null) { try { securityStore.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, managementService.getClass().getName()); } } @@ -929,8 +907,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (activation != null) { try { activation.close(failoverOnServerShutdown, restarting); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName()); } } @@ -938,8 +915,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (backupActivationThread != null) { try { backupActivationThread.join(30000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(backupActivationThread.getClass().getName()); } @@ -962,16 +938,14 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ActiveMQComponent externalComponent : externalComponents) { try { externalComponent.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(e, externalComponent.getClass().getName()); } } if (identity != null) { ActiveMQServerLogger.LOGGER.serverStopped("identity=" + identity + ",version=" + getVersion().getFullVersion(), tempNodeID, getUptime()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverStopped(getVersion().getFullVersion(), tempNodeID, getUptime()); } } @@ -979,8 +953,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public boolean checkLiveIsNotColocated(String nodeId) { if (parentServer == null) { return true; - } - else { + } else { return !parentServer.getNodeID().toString().equals(nodeId); } } @@ -998,8 +971,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession serverSession : sessions.values()) { try { serverSession.close(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSession(e); } } @@ -1018,8 +990,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession session : sessions.values()) { try { session.close(true); - } - catch (Exception e) { + } catch (Exception e) { // If anything went wrong with closing sessions.. we should ignore it // such as transactions.. etc. ActiveMQServerLogger.LOGGER.errorClosingSessionsWhileStoppingServer(e); @@ -1029,8 +1000,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession session : sessions.values()) { try { session.waitContextCompletion(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSessionsWhileStoppingServer(e); } } @@ -1043,8 +1013,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (component != null) { component.stop(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, component.getClass().getName()); } } @@ -1086,8 +1055,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { session.close(true); sessions.remove(session.getName()); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -1099,8 +1067,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { operationsExecuted.append("**************************************************************************************************"); return operationsExecuted.toString(); - } - finally { + } finally { // This operation is critical for the knowledge of the admin, so we need to add info logs for later knowledge ActiveMQServerLogger.LOGGER.info(operationsExecuted.toString()); } @@ -1230,8 +1197,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (limits.getMaxConnections() == -1) { return; - } - else if (limits.getMaxConnections() == 0 || getSessionCountForUser(username) >= limits.getMaxConnections()) { + } else if (limits.getMaxConnections() == 0 || getSessionCountForUser(username) >= limits.getMaxConnections()) { throw ActiveMQMessageBundle.BUNDLE.sessionLimitReached(username, limits.getMaxConnections()); } } @@ -1256,8 +1222,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (limits.getMaxQueues() == -1) { return; - } - else if (limits.getMaxQueues() == 0 || getQueueCountForUser(username) >= limits.getMaxQueues()) { + } else if (limits.getMaxQueues() == 0 || getQueueCountForUser(username) >= limits.getMaxQueues()) { throw ActiveMQMessageBundle.BUNDLE.queueLimitReached(username, limits.getMaxQueues()); } } @@ -1292,11 +1257,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { SessionCallback callback, OperationContext context, boolean autoCreateJMSQueues) throws Exception { - return new ServerSessionImpl(name, username, password, validatedUser, minLargeMessageSize, autoCommitSends, - autoCommitAcks, preAcknowledge, configuration.isPersistDeliveryCountBeforeDelivery(), xa, - connection, storageManager, postOffice, resourceManager, securityStore, managementService, - this, configuration.getManagementAddress(), defaultAddress == null ? null : new SimpleString(defaultAddress), - callback, context, autoCreateJMSQueues ? jmsQueueCreator : null, pagingManager); + return new ServerSessionImpl(name, username, password, validatedUser, minLargeMessageSize, autoCommitSends, autoCommitAcks, preAcknowledge, configuration.isPersistDeliveryCountBeforeDelivery(), xa, connection, storageManager, postOffice, resourceManager, securityStore, managementService, this, configuration.getManagementAddress(), defaultAddress == null ? null : new SimpleString(defaultAddress), callback, context, autoCreateJMSQueues ? jmsQueueCreator : null, pagingManager); } @Override @@ -1526,8 +1487,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (resourceName.toString().toLowerCase().startsWith("jms.topic")) { ActiveMQServerLogger.LOGGER.deployTopic(resourceName); - } - else { + } else { ActiveMQServerLogger.LOGGER.deployQueue(resourceName); } @@ -1581,8 +1541,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (queue.isDurable()) { // make sure the user has privileges to delete this queue securityStore.check(address, CheckType.DELETE_DURABLE_QUEUE, session); - } - else { + } else { securityStore.check(address, CheckType.DELETE_NON_DURABLE_QUEUE, session); } } @@ -1796,9 +1755,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (configuration.isPersistenceEnabled()) { if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) { return new JDBCJournalStorageManager(configuration, getScheduledPool(), executorFactory, shutdownOnCriticalIO); - } - // Default to File Based Storage Manager, (Legacy default configuration). - else { + } else { + // Default to File Based Storage Manager, (Legacy default configuration). return new JournalStorageManager(configuration, executorFactory, scheduledPool, shutdownOnCriticalIO); } } @@ -1821,8 +1779,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ActivateCallback callback : activateCallbacks) { try { callback.deActivate(); - } - catch (Throwable e) { + } catch (Throwable e) { // https://bugzilla.redhat.com/show_bug.cgi?id=1009530: // we won't interrupt the shutdown sequence because of a failed callback here ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); @@ -1852,12 +1809,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { }); if (configuration.getThreadPoolMaxSize() == -1) { threadPool = Executors.newCachedThreadPool(tFactory); - } - else { + } else { threadPool = Executors.newFixedThreadPool(configuration.getThreadPoolMaxSize(), tFactory); } - } - else { + } else { threadPool = serviceRegistry.getExecutorService(); this.threadPoolSupplied = true; } @@ -1874,8 +1829,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { } }); scheduledPool = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), tFactory); - } - else { + } else { this.scheduledPoolSupplied = true; this.scheduledPool = serviceRegistry.getScheduledExecutorService(); } @@ -1905,8 +1859,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (!AIOSequentialFileFactory.isSupported()) { ActiveMQServerLogger.LOGGER.switchingNIO(); configuration.setJournalType(JournalType.NIO); - } - else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) { + } else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) { ActiveMQServerLogger.LOGGER.switchingNIOonPath(configuration.getJournalLocation().getAbsolutePath()); configuration.setJournalType(JournalType.NIO); } @@ -2036,8 +1989,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { groupingHandler.awaitBindings(); remotingService.start(); - } - else { + } else { remotingService.start(); clusterManager.start(); @@ -2053,8 +2005,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { injectMonitor(new FileStoreMonitor(getScheduledPool(), executorFactory.getExecutor(), configuration.getDiskScanPeriod(), TimeUnit.MILLISECONDS, configuration.getMaxDiskUsage() / 100f)); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -2157,8 +2108,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (pendingNonTXPageCounter.size() != 0) { try { journalLoader.recoverPendingPageCounters(pendingNonTXPageCounter); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorRecoveringPageCounter(e); } } @@ -2199,8 +2149,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (binding != null) { if (ignoreIfExists) { return binding.getQueue(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.queueAlreadyExists(queueName); } } @@ -2213,8 +2162,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final QueueConfig.Builder queueConfigBuilder; if (address == null) { queueConfigBuilder = QueueConfig.builderWith(queueID, queueName); - } - else { + } else { queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, address); } @@ -2222,8 +2170,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final Queue queue = queueFactory.createQueueWith(queueConfig); if (transientQueue) { queue.setConsumersRefCount(new TransientQueueManagerImpl(this, queue.getName())); - } - else if (queue.isAutoCreated()) { + } else if (queue.isAutoCreated()) { queue.setConsumersRefCount(new AutoCreatedQueueManagerImpl(this.getJMSQueueDeleter(), queue.getName())); } @@ -2238,8 +2185,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (queue.isDurable()) { storageManager.commitBindings(txID); } - } - catch (Exception e) { + } catch (Exception e) { try { if (durable) { storageManager.rollbackBindings(txID); @@ -2247,14 +2193,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { final PageSubscription pageSubscription = queue.getPageSubscription(); try { queue.close(); - } - finally { + } finally { if (pageSubscription != null) { pageSubscription.destroy(); } } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } throw e; @@ -2279,8 +2223,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { GroupingHandler groupingHandler1; if (config.getType() == GroupingHandlerConfiguration.TYPE.LOCAL) { groupingHandler1 = new LocalGroupingHandler(executorFactory, scheduledPool, managementService, config.getName(), config.getAddress(), getStorageManager(), config.getTimeout(), config.getGroupTimeout(), config.getReaperPeriod()); - } - else { + } else { groupingHandler1 = new RemoteGroupingHandler(executorFactory, managementService, config.getName(), config.getAddress(), config.getTimeout(), config.getGroupTimeout()); } @@ -2299,8 +2242,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (!journalDir.exists() && configuration.isPersistenceEnabled()) { if (configuration.isCreateJournalDir()) { journalDir.mkdirs(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.cannotCreateDir(journalDir.getAbsolutePath()); } } @@ -2320,8 +2262,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (file == null) { ActiveMQServerLogger.LOGGER.ioCriticalIOError(message, "NULL", cause); - } - else { + } else { ActiveMQServerLogger.LOGGER.ioCriticalIOError(message, file.toString(), cause); } @@ -2401,8 +2342,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (i != null) { if (unique && i.get() != 0) { return false; - } - else if (i.incrementAndGet() > 0) { + } else if (i.incrementAndGet() > 0) { connectedClientIds.put(clientId, i); } } @@ -2431,8 +2371,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { lockActivation(); try { runnable.run(); - } - finally { + } finally { unlockActivation(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java index 60506d8a10..a446b2e701 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java @@ -64,19 +64,16 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { try { if (timeout != -1L) { ConcurrentUtil.await(condition, timeout); - } - else { + } else { while (untriedConnectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } - } - finally { + } finally { lock.unlock(); } } @@ -91,8 +88,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { untriedConnectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -112,8 +108,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { if (untriedConnectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -133,8 +128,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { nodeID = iterator.next(); } return untriedConnectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -148,8 +142,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { if (tc != null) { triedConnectors.put(nodeID, tc); } - } - finally { + } finally { lock.unlock(); } super.notifyRegistrationFailed(alreadyReplicating); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java index 189e8cf973..3141b6cbdc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java @@ -68,19 +68,16 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (!ConcurrentUtil.await(condition, timeout)) { throw new ActiveMQException("Timeout elapsed while waiting for cluster node"); } - } - else { + } else { while (connectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } - } - finally { + } finally { lock.unlock(); } } @@ -94,7 +91,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -103,8 +100,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { connectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -117,8 +113,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (connectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -138,8 +133,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { nodeID = iterator.next(); } return connectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -149,8 +143,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { try { lock.lock(); connectors.remove(nodeID); - } - finally { + } finally { lock.unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java index 10f9f56bfa..535e53b0b4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java @@ -35,8 +35,7 @@ public class AutoCreatedQueueManagerImpl implements AutoCreatedQueueManager { if (deleter != null) { deleter.delete(queueName); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingAutoCreatedQueue(e, queueName); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java index 9b70f27e7e..1a589089ab 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java @@ -59,8 +59,7 @@ final class BackupTopologyListener implements ClusterTopologyListener { boolean waitForBackup() { try { return latch.await(WAIT_TIMEOUT, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java index be2011f810..73770e5abb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; @@ -38,12 +44,6 @@ import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteHandler; import org.apache.activemq.artemis.core.server.cluster.qourum.Vote; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.concurrent.TimeUnit; - public class ColocatedActivation extends LiveActivation { private static final SimpleString REQUEST_BACKUP_QUORUM_VOTE = new SimpleString("RequestBackupQuorumVote"); @@ -125,13 +125,11 @@ public class ColocatedActivation extends LiveActivation { boolean started = false; try { started = colocatedHAManager.activateBackup(backupRequestMessage.getBackupSize(), backupRequestMessage.getJournalDirectory(), backupRequestMessage.getBindingsDirectory(), backupRequestMessage.getLargeMessagesDirectory(), backupRequestMessage.getPagingDirectory(), backupRequestMessage.getNodeID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } channel.send(new BackupResponseMessage(started)); - } - else if (activationChannelHandler != null) { + } else if (activationChannelHandler != null) { activationChannelHandler.handlePacket(packet); } } @@ -221,12 +219,10 @@ public class ColocatedActivation extends LiveActivation { } }, colocatedPolicy.getBackupRequestRetryInterval(), TimeUnit.MILLISECONDS); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } - } - else { + } else { nodes.clear(); server.getScheduledPool().schedule(new Runnable() { @Override diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java index 912f7213eb..1397070768 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; + import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; @@ -28,11 +33,6 @@ import org.apache.activemq.artemis.core.server.ConnectorServiceFactory; import org.apache.activemq.artemis.core.server.ServiceRegistry; import org.apache.activemq.artemis.utils.ConfigurationHelper; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - /** * ConnectorsService will pool some resource for updates, e.g. Twitter, then the changes are picked * and converted into a ServerMessage for a given destination (queue). @@ -79,8 +79,7 @@ public final class ConnectorsService implements ActiveMQComponent { for (ConnectorService connector : connectors) { try { connector.start(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorStartingConnectorService(e, connector.getName()); } } @@ -113,8 +112,7 @@ public final class ConnectorsService implements ActiveMQComponent { for (ConnectorService connector : connectors) { try { connector.stop(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorStoppingConnectorService(e, connector.getName()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java index ad24a44e3f..e583fc03c4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java @@ -100,8 +100,7 @@ public class DivertImpl implements Divert { if (transformer != null) { copy = transformer.transform(copy); } - } - else { + } else { copy = message; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java index 1ebf82c986..694b112298 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java @@ -88,8 +88,7 @@ public class FileLockNodeManager extends NodeManager { liveAttemptLock = tryLock(FileLockNodeManager.LIVE_LOCK_POS); if (liveAttemptLock == null) { return true; - } - else { + } else { liveAttemptLock.release(); return false; } @@ -132,13 +131,11 @@ public class FileLockNodeManager extends NodeManager { liveLock.release(); logger.debug("awaiting live node restarting"); Thread.sleep(2000); - } - else if (state == FileLockNodeManager.FAILINGBACK) { + } else if (state == FileLockNodeManager.FAILINGBACK) { liveLock.release(); logger.debug("awaiting live node failing back"); Thread.sleep(2000); - } - else if (state == FileLockNodeManager.LIVE) { + } else if (state == FileLockNodeManager.LIVE) { logger.debug("acquired live node lock state = " + (char) state); break; } @@ -185,8 +182,7 @@ public class FileLockNodeManager extends NodeManager { public void activationComplete() { try { setLive(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -248,8 +244,7 @@ public class FileLockNodeManager extends NodeManager { read = channel.read(bb, 0); if (read <= 0) { return FileLockNodeManager.NOT_STARTED; - } - else { + } else { return bb.get(0); } } @@ -271,8 +266,7 @@ public class FileLockNodeManager extends NodeManager { protected FileLock tryLock(final int lockPos) throws Exception { try { return channel.tryLock(lockPos, LOCK_LENGTH, false); - } - catch (java.nio.channels.OverlappingFileLockException ex) { + } catch (java.nio.channels.OverlappingFileLockException ex) { // This just means that another object on the same JVM is holding the lock return null; } @@ -285,24 +279,21 @@ public class FileLockNodeManager extends NodeManager { FileLock lock = null; try { lock = channel.tryLock(liveLockPos, 1, false); - } - catch (java.nio.channels.OverlappingFileLockException ex) { + } catch (java.nio.channels.OverlappingFileLockException ex) { // This just means that another object on the same JVM is holding the lock } if (lock == null) { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return null; } if (lockAcquisitionTimeout != -1 && (System.currentTimeMillis() - start) > lockAcquisitionTimeout) { throw new Exception("timed out waiting for lock"); } - } - else { + } else { return lock; } } @@ -315,8 +306,7 @@ public class FileLockNodeManager extends NodeManager { if (lock == null) { try { Thread.sleep(500); - } - catch (InterruptedException e1) { + } catch (InterruptedException e1) { // } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java index d735852cb3..ade34807a4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java @@ -78,12 +78,10 @@ public final class InVMNodeManager extends NodeManager { if (state == PAUSED) { liveLock.release(); Thread.sleep(2000); - } - else if (state == FAILING_BACK) { + } else if (state == FAILING_BACK) { liveLock.release(); Thread.sleep(2000); - } - else if (state == LIVE) { + } else if (state == LIVE) { break; } } while (true); @@ -125,8 +123,7 @@ public final class InVMNodeManager extends NodeManager { public void activationComplete() { try { state = LIVE; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java index 906a43e63b..453f588fee 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java @@ -81,16 +81,14 @@ public class LastValueQueue extends QueueImpl { replaceLVQMessage(ref, hr); - } - else { + } else { hr = new HolderReference(prop, ref); map.put(prop, hr); super.addTail(hr, direct); } - } - else { + } else { super.addTail(ref, direct); } } @@ -107,29 +105,25 @@ public class LastValueQueue extends QueueImpl { // We need to overwrite the old ref with the new one and ack the old one replaceLVQMessage(ref, hr); - } - else { + } else { // We keep the current ref and ack the one we are returning super.referenceHandled(); try { super.acknowledge(ref); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorAckingOldReference(e); } } - } - else { + } else { hr = new HolderReference(prop, ref); map.put(prop, hr); super.addHead(hr, scheduling); } - } - else { + } else { super.addHead(ref, scheduling); } } @@ -141,15 +135,13 @@ public class LastValueQueue extends QueueImpl { try { oldRef.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorAckingOldReference(e); } hr.setReference(ref); } - @Override protected void refRemoved(MessageReference ref) { synchronized (this) { @@ -339,8 +331,7 @@ public class LastValueQueue extends QueueImpl { if (other.map != null) { return false; } - } - else if (!map.equals(other.map)) { + } else if (!map.equals(other.map)) { return false; } return true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java index 4397eb48b1..8468115b05 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java @@ -238,8 +238,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { try { context.getAttributes(""); alive = true; - } - catch (Exception e) { + } catch (Exception e) { } } return alive; @@ -267,14 +266,12 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); if (connectionUsername != null && !"".equals(connectionUsername)) { env.put(Context.SECURITY_PRINCIPAL, connectionUsername); - } - else { + } else { throw new NamingException("Empty username is not allowed"); } if (connectionPassword != null && !"".equals(connectionPassword)) { env.put(Context.SECURITY_CREDENTIALS, connectionPassword); - } - else { + } else { throw new NamingException("Empty password is not allowed"); } env.put(Context.SECURITY_PROTOCOL, connectionProtocol); @@ -295,8 +292,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { ActiveMQServerLogger.LOGGER.populatingSecurityRolesFromLDAP(connectionURL); try { open(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorOpeningContextForLDAP(e); return this; } @@ -311,8 +307,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { while (searchResults.hasMore()) { processSearchResult(securityRoles, searchResults.next()); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorPopulatingSecurityRolesFromLDAP(e); } @@ -324,7 +319,8 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { this.securityRepository = securityRepository; } - private void processSearchResult(Map> securityRoles, SearchResult searchResult) throws NamingException { + private void processSearchResult(Map> securityRoles, + SearchResult searchResult) throws NamingException { Attributes attrs = searchResult.getAttributes(); if (attrs == null || attrs.size() == 0) { return; @@ -347,8 +343,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { String rawDestinationType = rdn.getValue().toString(); if (rawDestinationType.toLowerCase().contains("queue")) { destinationType = "queue"; - } - else if (rawDestinationType.toLowerCase().contains("topic")) { + } else if (rawDestinationType.toLowerCase().contains("topic")) { destinationType = "topic"; } logger.debug("\tDestination type: " + destinationType); @@ -361,8 +356,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { boolean exists = false; if (roles == null) { roles = new HashSet<>(); - } - else { + } else { exists = true; } @@ -372,14 +366,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { Rdn rdn = ldapname.getRdn(ldapname.size() - 1); String roleName = rdn.getValue().toString(); logger.debug("\tRole name: " + roleName); - Role role = new Role(roleName, - permissionType.equalsIgnoreCase(writePermissionValue), - permissionType.equalsIgnoreCase(readPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - false, // there is no permission from ActiveMQ 5.x that corresponds to the "manage" permission in ActiveMQ Artemis + Role role = new Role(roleName, permissionType.equalsIgnoreCase(writePermissionValue), permissionType.equalsIgnoreCase(readPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), false, // there is no permission from ActiveMQ 5.x that corresponds to the "manage" permission in ActiveMQ Artemis permissionType.equalsIgnoreCase(readPermissionValue)); // the "browse" permission matches "read" from ActiveMQ 5.x roles.add(role); } @@ -393,8 +380,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { public SecuritySettingPlugin stop() { try { eventContext.close(); - } - catch (NamingException e) { + } catch (NamingException e) { // ignore } @@ -402,8 +388,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { if (context != null) { context.close(); } - } - catch (NamingException e) { + } catch (NamingException e) { // ignore } @@ -413,8 +398,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for new policy entries in the directory. * - * @param namingEvent - * the new entry event that occurred + * @param namingEvent the new entry event that occurred */ public void objectAdded(NamingEvent namingEvent) { Map> newRoles = new HashMap<>(); @@ -427,8 +411,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { existingRoles.add(role); } } - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } @@ -436,8 +419,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for removed policy entries in the directory. * - * @param namingEvent - * the removed entry event that occurred + * @param namingEvent the removed entry event that occurred */ public void objectRemoved(NamingEvent namingEvent) { try { @@ -461,16 +443,14 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { rolesToRemove.add(role); } } - } - else if (rdn.getValue().equals(readPermissionValue)) { + } else if (rdn.getValue().equals(readPermissionValue)) { logger.debug("Removing read permission"); for (Role role : roles) { if (role.isConsume()) { rolesToRemove.add(role); } } - } - else if (rdn.getValue().equals(adminPermissionValue)) { + } else if (rdn.getValue().equals(adminPermissionValue)) { logger.debug("Removing admin permission"); for (Role role : roles) { if (role.isCreateDurableQueue() || role.isCreateNonDurableQueue() || role.isDeleteDurableQueue() || role.isDeleteNonDurableQueue()) { @@ -483,15 +463,13 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { roles.remove(roleToRemove); } } - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } /** - * @param namingEvent - * the renaming entry event that occurred + * @param namingEvent the renaming entry event that occurred */ public void objectRenamed(NamingEvent namingEvent) { @@ -500,8 +478,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for changed policy entries in the directory. * - * @param namingEvent - * the changed entry event that occurred + * @param namingEvent the changed entry event that occurred */ public void objectChanged(NamingEvent namingEvent) { objectRemoved(namingEvent); @@ -511,8 +488,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for exception events from the registry. * - * @param namingExceptionEvent - * the exception event + * @param namingExceptionEvent the exception event */ public void namingExceptionThrown(NamingExceptionEvent namingExceptionEvent) { context = null; @@ -520,6 +496,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { } protected class LDAPNamespaceChangeListener implements NamespaceChangeListener, ObjectChangeListener { + @Override public void namingExceptionThrown(NamingExceptionEvent evt) { LegacyLDAPSecuritySettingPlugin.this.namingExceptionThrown(evt); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java index de7f59889c..7ffb817964 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java @@ -39,6 +39,7 @@ import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy; import org.jboss.logging.Logger; public class LiveOnlyActivation extends Activation { + private static final Logger logger = Logger.getLogger(LiveOnlyActivation.class); //this is how we act when we initially start as live @@ -66,12 +67,10 @@ public class LiveOnlyActivation extends Activation { if (activeMQServer.getIdentity() != null) { ActiveMQServerLogger.LOGGER.serverIsLive(activeMQServer.getIdentity()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverIsLive(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.initializationError(e); activeMQServer.callActivationFailureListeners(e); } @@ -105,11 +104,9 @@ public class LiveOnlyActivation extends Activation { if (liveOnlyPolicy.getScaleDownPolicy() != null && liveOnlyPolicy.getScaleDownPolicy().isEnabled() && scaleDownClientSessionFactory != null) { try { scaleDown(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToScaleDown(e); - } - finally { + } finally { scaleDownClientSessionFactory.close(); scaleDownServerLocator.close(); } @@ -136,8 +133,7 @@ public class LiveOnlyActivation extends Activation { if (possibleLive == null) // we've tried every connector break; clientSessionFactory = (ClientSessionFactoryInternal) scaleDownServerLocator.createSessionFactory(possibleLive.getA(), 0, false); - } - catch (Exception e) { + } catch (Exception e) { logger.trace("Failed to connect to " + possibleLive.getA()); nodeLocator.notifyRegistrationFailed(false); if (clientSessionFactory != null) { @@ -149,12 +145,10 @@ public class LiveOnlyActivation extends Activation { } if (clientSessionFactory != null) { scaleDownClientSessionFactory = clientSessionFactory; - } - else { + } else { throw new ActiveMQException("Unable to connect to server for scale-down"); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToScaleDown(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java index 866265ecb5..6d9030e084 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java @@ -57,8 +57,7 @@ public class MessageReferenceImpl implements MessageReference { if (MemorySize.is64bitArch()) { memoryOffset = 48; - } - else { + } else { memoryOffset = 32; } } @@ -199,8 +198,7 @@ public class MessageReferenceImpl implements MessageReference { public void acknowledge(Transaction tx, AckReason reason) throws Exception { if (tx == null) { getQueue().acknowledge(this, reason); - } - else { + } else { getQueue().acknowledge(tx, this, reason); } } @@ -249,4 +247,4 @@ public class MessageReferenceImpl implements MessageReference { public int hashCode() { return this.getMessage().hashCode(); } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java index e669ec7971..101ae3b438 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java @@ -60,19 +60,16 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { try { if (timeout != -1L) { ConcurrentUtil.await(condition, timeout); - } - else { + } else { while (liveConfiguration == null) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - finally { + } finally { lock.unlock(); } } @@ -86,8 +83,7 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { nodeID = topologyMember.getNodeId(); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -113,8 +109,7 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { lock.lock(); liveConfiguration = null; super.notifyRegistrationFailed(alreadyReplicating); - } - finally { + } finally { lock.unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java index 97d97b8367..32c6392e43 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java @@ -69,19 +69,16 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (!ConcurrentUtil.await(condition, timeout)) { throw new ActiveMQException("Timeout elapsed while waiting for cluster node"); } - } - else { + } else { while (connectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - finally { + } finally { lock.unlock(); } } @@ -95,7 +92,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -105,8 +102,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { connectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -119,8 +115,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (connectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -140,8 +135,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { nodeID = iterator.next(); } return connectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -151,8 +145,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { try { lock.lock(); connectors.remove(nodeID); - } - finally { + } finally { lock.unlock(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java index ff93ffe7b6..ccb00cb313 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java @@ -128,8 +128,7 @@ public class PostOfficeJournalLoader implements JournalLoader { storageManager.deleteQueueBinding(tx, queueBindingInfo.getId()); storageManager.commitBindings(tx); continue; - } - else { + } else { final SimpleString newName = queueBindingInfo.getQueueName().concat("-" + (duplicateID++)); ActiveMQServerLogger.LOGGER.queueDuplicatedRenaming(queueBindingInfo.getQueueName().toString(), newName.toString()); queueBindingInfo.replaceQueueName(newName); @@ -138,8 +137,7 @@ public class PostOfficeJournalLoader implements JournalLoader { final QueueConfig.Builder queueConfigBuilder; if (queueBindingInfo.getAddress() == null) { queueConfigBuilder = QueueConfig.builderWith(queueBindingInfo.getId(), queueBindingInfo.getQueueName()); - } - else { + } else { queueConfigBuilder = QueueConfig.builderWith(queueBindingInfo.getId(), queueBindingInfo.getQueueName(), queueBindingInfo.getAddress()); } queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(queueBindingInfo.getUser()).durable(true).temporary(false).autoCreated(queueBindingInfo.isAutoCreated()); @@ -213,8 +211,7 @@ public class PostOfficeJournalLoader implements JournalLoader { ActiveMQServerLogger.LOGGER.journalUnreferencedMessage(msg.getMessageID()); try { storageManager.deleteMessage(msg.getMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(ignored, msg.getMessageID()); } } @@ -281,8 +278,7 @@ public class PostOfficeJournalLoader implements JournalLoader { if (removed == null) { ActiveMQServerLogger.LOGGER.journalErrorRemovingRef(messageID); - } - else { + } else { referencesToAck.add(removed); } } @@ -363,14 +359,12 @@ public class PostOfficeJournalLoader implements JournalLoader { if (value == null) { logger.debug("Page " + entry.getKey() + " wasn't open, so we will just ignore"); - } - else { + } else { logger.debug("Replacing counter " + value.get()); counter.increment(txRecoverCounter, value.get()); } } - } - else { + } else { // on this case the page file didn't exist, we just remove all the records since the page is already gone logger.debug("Page " + pageId + " didn't exist on address " + addressPageMapEntry.getKey() + ", so we are just removing records"); for (List records : perQueue.values()) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java index d8f772dd6b..5686c7beb5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java @@ -72,8 +72,7 @@ public class QueueFactoryImpl implements QueueFactory { final Queue queue; if (addressSettings.isLastValueQueue()) { queue = new LastValueQueue(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); - } - else { + } else { queue = new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); } return queue; @@ -95,8 +94,7 @@ public class QueueFactoryImpl implements QueueFactory { Queue queue; if (addressSettings.isLastValueQueue()) { queue = new LastValueQueue(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); - } - else { + } else { queue = new QueueImpl(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index f449788a2d..d60dc56b14 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -254,8 +254,7 @@ public class QueueImpl implements Queue { }); try { flush.await(10, TimeUnit.SECONDS); - } - catch (Exception ignored) { + } catch (Exception ignored) { } synchronized (this) { @@ -361,16 +360,14 @@ public class QueueImpl implements Queue { if (addressSettingsRepository != null) { addressSettingsRepositoryListener = new AddressSettingsRepositoryListener(); addressSettingsRepository.registerListener(addressSettingsRepositoryListener); - } - else { + } else { expiryAddress = null; } if (pageSubscription != null) { pageSubscription.setQueue(this); this.pageIterator = pageSubscription.iterator(); - } - else { + } else { this.pageIterator = null; } @@ -477,8 +474,7 @@ public class QueueImpl implements Queue { synchronized (QueueImpl.this) { if (groups.remove(groupIDToRemove) != null) { logger.debug("Removing group after unproposal " + groupID + " from queue " + QueueImpl.this); - } - else { + } else { logger.debug("Couldn't remove Removing group " + groupIDToRemove + " after unproposal on queue " + QueueImpl.this); } } @@ -593,13 +589,11 @@ public class QueueImpl implements Queue { if (deliveriesInTransit.await(DELIVERY_TIMEOUT)) { return true; - } - else { + } else { ActiveMQServerLogger.LOGGER.timeoutFlushInTransit(getName().toString(), getAddress().toString()); return false; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return false; } @@ -627,8 +621,7 @@ public class QueueImpl implements Queue { scheduledRunners.incrementAndGet(); try { getExecutor().execute(deliverRunner); - } - catch (RejectedExecutionException ignored) { + } catch (RejectedExecutionException ignored) { // no-op scheduledRunners.decrementAndGet(); } @@ -649,8 +642,7 @@ public class QueueImpl implements Queue { public void run() { try { cancelRedistributor(); - } - catch (Exception e) { + } catch (Exception e) { // nothing that could be done anyway.. just logging ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } @@ -667,8 +659,7 @@ public class QueueImpl implements Queue { if (pageSubscription != null && pageSubscription.isPaging()) { // When in page mode, we don't want to have concurrent IO on the same PageStore return pageSubscription.getExecutor(); - } - else { + } else { return executor; } } @@ -796,8 +787,7 @@ public class QueueImpl implements Queue { futures.add(redistributorFuture); } - } - else { + } else { internalAddRedistributor(executor); } } @@ -853,8 +843,7 @@ public class QueueImpl implements Queue { if (filter1 == null) { return true; - } - else { + } else { if (filter1.match(message)) { return true; } @@ -926,8 +915,7 @@ public class QueueImpl implements Queue { return messageReferences.size() + getScheduledCount() + deliveringCount.get() + pageSubscription.getMessageCount(); - } - else { + } else { return messageReferences.size() + getScheduledCount() + deliveringCount.get(); } } @@ -975,8 +963,7 @@ public class QueueImpl implements Queue { if (ref.isPaged()) { pageSubscription.ack((PagedReference) ref); postAcknowledge(ref); - } - else { + } else { ServerMessage message = ref.getMessage(); boolean durableRef = message.isDurable() && durable; @@ -989,11 +976,9 @@ public class QueueImpl implements Queue { if (reason == AckReason.EXPIRED) { messagesExpired++; - } - else if (reason == AckReason.KILLED) { + } else if (reason == AckReason.KILLED) { messagesKilled++; - } - else { + } else { messagesAcknowledged++; } @@ -1010,8 +995,7 @@ public class QueueImpl implements Queue { pageSubscription.ackTx(tx, (PagedReference) ref); getRefsOperation(tx).addAck(ref); - } - else { + } else { ServerMessage message = ref.getMessage(); boolean durableRef = message.isDurable() && durable; @@ -1027,11 +1011,9 @@ public class QueueImpl implements Queue { if (reason == AckReason.EXPIRED) { messagesExpired++; - } - else if (reason == AckReason.KILLED) { + } else if (reason == AckReason.KILLED) { messagesKilled++; - } - else { + } else { messagesAcknowledged++; } } @@ -1094,8 +1076,7 @@ public class QueueImpl implements Queue { } resetAllIterators(); - } - else { + } else { decDelivering(); } } @@ -1112,8 +1093,7 @@ public class QueueImpl implements Queue { logger.trace("moving expired reference " + ref + " to address = " + messageExpiryAddress + " from queue=" + this.getName()); } move(null, messageExpiryAddress, ref, false, AckReason.EXPIRED); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("expiry is null, just acking expired message for reference " + ref + " from queue=" + this.getName()); } @@ -1148,13 +1128,11 @@ public class QueueImpl implements Queue { private SimpleString extractAddress(ServerMessage message) { if (message.containsProperty(Message.HDR_ORIG_MESSAGE_ID)) { return message.getSimpleStringProperty(Message.HDR_ORIGINAL_ADDRESS); - } - else { + } else { return message.getAddress(); } } - @Override public SimpleString getExpiryAddress() { return this.expiryAddress; @@ -1186,8 +1164,7 @@ public class QueueImpl implements Queue { public long getMessagesAdded() { if (pageSubscription != null) { return messagesAdded + pageSubscription.getCounter().getValue() - pagedReferences.get(); - } - else { + } else { return messagesAdded; } } @@ -1302,8 +1279,7 @@ public class QueueImpl implements Queue { count++; txCount++; messageAction.actMessage(tx, reference); - } - else { + } else { addTail(reference, false); } @@ -1404,8 +1380,7 @@ public class QueueImpl implements Queue { } tx.commit(); - } - catch (Exception e) { + } catch (Exception e) { tx.rollback(); throw e; } @@ -1514,8 +1489,7 @@ public class QueueImpl implements Queue { iter.remove(); refRemoved(ref); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorExpiringReferencesOnQueue(e, ref); } @@ -1525,12 +1499,10 @@ public class QueueImpl implements Queue { if ((!hasElements || expired) && pageIterator != null && pageIterator.hasNext()) { scheduleDepage(true); } - } - finally { + } finally { try { iter.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } scannerRunning.decrementAndGet(); } @@ -1592,8 +1564,7 @@ public class QueueImpl implements Queue { incDelivering(); try { move(null, toAddress, ref, rejectDuplicate, AckReason.NORMAL); - } - catch (Exception e) { + } catch (Exception e) { decDelivering(); throw e; } @@ -1681,8 +1652,7 @@ public class QueueImpl implements Queue { if (targetQueue != null) { move(originalMessageAddress, tx, ref, false, false, targetQueue.longValue()); - } - else { + } else { move(originalMessageAddress, tx, ref, false, false); } @@ -1744,8 +1714,7 @@ public class QueueImpl implements Queue { public synchronized void pause() { try { this.flushDeliveriesInTransit(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } paused = true; @@ -1834,8 +1803,7 @@ public class QueueImpl implements Queue { private int getPriority(MessageReference ref) { try { return ref.getMessage().getPriority(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return 4; // the default one in case of failure } @@ -1939,14 +1907,12 @@ public class QueueImpl implements Queue { if (holder.iter.hasNext()) { ref = holder.iter.next(); - } - else { + } else { ref = null; } if (ref == null) { noDelivery++; - } - else { + } else { if (checkExpired(ref)) { if (logger.isTraceEnabled()) { logger.trace("Reference " + ref + " being expired"); @@ -1993,13 +1959,11 @@ public class QueueImpl implements Queue { } handled++; - } - else if (status == HandleStatus.BUSY) { + } else if (status == HandleStatus.BUSY) { holder.iter.repeat(); noDelivery++; - } - else if (status == HandleStatus.NO_MATCH) { + } else if (status == HandleStatus.NO_MATCH) { // nothing to be done on this case, the iterators will just jump next } } @@ -2012,8 +1976,7 @@ public class QueueImpl implements Queue { // this shouldn't really happen, // however I'm keeping this as an assertion case future developers ever change the logic here on this class ActiveMQServerLogger.LOGGER.nonDeliveryHandled(); - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug(this + "::All the consumers were busy, giving up now"); } @@ -2064,13 +2027,11 @@ public class QueueImpl implements Queue { private SimpleString extractGroupID(MessageReference ref) { if (internalQueue) { return null; - } - else { + } else { try { // But we don't use the groupID on internal queues (clustered queues) otherwise the group map would leak forever return ref.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return null; } @@ -2137,14 +2098,14 @@ public class QueueImpl implements Queue { if (logger.isDebugEnabled()) { logger.debug("Queue Memory Size after depage on queue=" + this.getName() + - " is " + - queueMemorySize.get() + - " with maxSize = " + - maxSize + - ". Depaged " + - depaged + - " messages, pendingDelivery=" + messageReferences.size() + ", intermediateMessageReferences= " + intermediateMessageReferences.size() + - ", queueDelivering=" + deliveringCount.get()); + " is " + + queueMemorySize.get() + + " with maxSize = " + + maxSize + + ". Depaged " + + depaged + + " messages, pendingDelivery=" + messageReferences.size() + ", intermediateMessageReferences= " + intermediateMessageReferences.size() + + ", queueDelivering=" + deliveringCount.get()); } } @@ -2207,8 +2168,7 @@ public class QueueImpl implements Queue { sendToDeadLetterAddress(null, reference, addressSettings.getDeadLetterAddress()); return false; - } - else { + } else { // Second check Redelivery Delay if (!ignoreRedeliveryDelay && redeliveryDelay > 0) { redeliveryDelay = calculateRedeliveryDelay(addressSettings, deliveryCount); @@ -2299,8 +2259,7 @@ public class QueueImpl implements Queue { if (targetBinding == null) { ActiveMQServerLogger.LOGGER.unableToFindTargetQueue(targetNodeID); - } - else { + } else { logger.debug("Routing on binding: " + targetBinding); targetBinding.route(copyMessage, routingContext); } @@ -2364,8 +2323,7 @@ public class QueueImpl implements Queue { logger.debug("Message now destined for " + remoteQueueBinding.getRoutingName() + " with ID: " + remoteQueueBinding.getRemoteQueueID() + " on address " + copyMessage.getAddress() + " on node " + targetNodeID); } break; - } - else { + } else { logger.debug("Failed to match: " + remoteQueueBinding); } } @@ -2408,12 +2366,10 @@ public class QueueImpl implements Queue { if (bindingList.getBindings().isEmpty()) { ActiveMQServerLogger.LOGGER.errorExpiringReferencesNoBindings(expiryAddress); - } - else { + } else { move(expiryAddress, tx, ref, true, true); } - } - else { + } else { ActiveMQServerLogger.LOGGER.errorExpiringReferencesNoQueue(name); acknowledge(tx, ref); @@ -2425,7 +2381,8 @@ public class QueueImpl implements Queue { sendToDeadLetterAddress(tx, ref, addressSettingsRepository.getMatch(address.toString()).getDeadLetterAddress()); } - private void sendToDeadLetterAddress(final Transaction tx, final MessageReference ref, + private void sendToDeadLetterAddress(final Transaction tx, + final MessageReference ref, final SimpleString deadLetterAddress) throws Exception { if (deadLetterAddress != null) { Bindings bindingList = postOffice.getBindingsForAddress(deadLetterAddress); @@ -2433,13 +2390,11 @@ public class QueueImpl implements Queue { if (bindingList.getBindings().isEmpty()) { ActiveMQServerLogger.LOGGER.messageExceededMaxDelivery(ref, deadLetterAddress); ref.acknowledge(tx, AckReason.KILLED); - } - else { + } else { ActiveMQServerLogger.LOGGER.messageExceededMaxDeliverySendtoDLA(ref, deadLetterAddress, name); move(tx, deadLetterAddress, ref, false, AckReason.KILLED); } - } - else { + } else { ActiveMQServerLogger.LOGGER.messageExceededMaxDeliveryNoDLA(name); ref.acknowledge(tx, AckReason.KILLED); @@ -2455,8 +2410,7 @@ public class QueueImpl implements Queue { if (originalTX != null) { tx = originalTX; - } - else { + } else { // if no TX we create a new one to commit at the end tx = new TransactionImpl(storageManager); } @@ -2546,8 +2500,7 @@ public class QueueImpl implements Queue { try { consumer.proceedDeliver(reference); deliveriesInTransit.countDown(); - } - catch (Throwable t) { + } catch (Throwable t) { deliveriesInTransit.countDown(); ActiveMQServerLogger.LOGGER.removingBadConsumer(t, consumer, reference); @@ -2555,8 +2508,7 @@ public class QueueImpl implements Queue { // If the consumer throws an exception we remove the consumer try { removeConsumer(consumer); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingConsumer(e); } @@ -2576,18 +2528,15 @@ public class QueueImpl implements Queue { try { expire(reference); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorExpiringRef(e); } return true; - } - else { + } else { return false; } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return false; } @@ -2597,15 +2546,13 @@ public class QueueImpl implements Queue { HandleStatus status; try { status = consumer.handle(reference); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.removingBadConsumer(t, consumer, reference); // If the consumer throws an exception we remove the consumer try { removeConsumer(consumer); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingConsumer(e); } return HandleStatus.BUSY; @@ -2642,20 +2589,19 @@ public class QueueImpl implements Queue { try { message = ref.getMessage(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); message = null; } - if (message == null) return; + if (message == null) + return; boolean durableRef = message.isDurable() && queue.durable; try { message.decrementRefCount(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorDecrementingRefCount(e); } @@ -2679,8 +2625,7 @@ public class QueueImpl implements Queue { // There is a startup check to remove non referenced messages case these deletes fail try { storageManager.deleteMessage(message.getMessageID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingMessage(e, message.getMessageID()); } } @@ -2787,11 +2732,9 @@ public class QueueImpl implements Queue { synchronized (QueueImpl.this.deliverRunner) { deliver(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorDelivering(e); - } - finally { + } finally { scheduledRunners.decrementAndGet(); } } @@ -2809,8 +2752,7 @@ public class QueueImpl implements Queue { public void run() { try { depage(scheduleExpiry); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorDelivering(e); } } @@ -2966,12 +2908,10 @@ public class QueueImpl implements Queue { logger.debug("Cancelled slow-consumer-reaper thread for queue \"" + getName() + "\""); } } - } - else { + } else { if (slowConsumerReaperRunnable == null) { scheduleSlowConsumerReaper(settings); - } - else if (slowConsumerReaperRunnable.checkPeriod != settings.getSlowConsumerCheckPeriod() || + } else if (slowConsumerReaperRunnable.checkPeriod != settings.getSlowConsumerCheckPeriod() || slowConsumerReaperRunnable.threshold != settings.getSlowConsumerThreshold() || !slowConsumerReaperRunnable.policy.equals(settings.getSlowConsumerPolicy())) { slowConsumerReaperFuture.cancel(false); @@ -2987,9 +2927,9 @@ public class QueueImpl implements Queue { if (logger.isDebugEnabled()) { logger.debug("Scheduled slow-consumer-reaper thread for queue \"" + getName() + - "\"; slow-consumer-check-period=" + settings.getSlowConsumerCheckPeriod() + - ", slow-consumer-threshold=" + settings.getSlowConsumerThreshold() + - ", slow-consumer-policy=" + settings.getSlowConsumerPolicy()); + "\"; slow-consumer-check-period=" + settings.getSlowConsumerCheckPeriod() + + ", slow-consumer-threshold=" + settings.getSlowConsumerThreshold() + + ", slow-consumer-policy=" + settings.getSlowConsumerPolicy()); } } @@ -3029,8 +2969,7 @@ public class QueueImpl implements Queue { if (logger.isDebugEnabled()) { logger.debug("Insufficient messages received on queue \"" + getName() + "\" to satisfy slow-consumer-threshold. Skipping inspection of consumer."); } - } - else if (consumerRate < threshold) { + } else if (consumerRate < threshold) { RemotingConnection connection = null; ActiveMQServer server = ((PostOfficeImpl) postOffice).getServer(); RemotingService remotingService = server.getRemotingService(); @@ -3049,8 +2988,7 @@ public class QueueImpl implements Queue { connection.killMessage(server.getNodeID()); remotingService.removeConnection(connection.getID()); connection.fail(ActiveMQMessageBundle.BUNDLE.connectionsClosedByManagement(connection.getRemoteAddress())); - } - else if (policy.equals(SlowConsumerPolicy.NOTIFY)) { + } else if (policy.equals(SlowConsumerPolicy.NOTIFY)) { TypedProperties props = new TypedProperties(); props.putIntProperty(ManagementHelper.HDR_CONSUMER_COUNT, getConsumerCount()); @@ -3072,8 +3010,7 @@ public class QueueImpl implements Queue { ManagementService managementService = ((PostOfficeImpl) postOffice).getServer().getManagementService(); try { managementService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToSendSlowConsumerNotification(notification, e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java index b90a30efa5..8e3a94b979 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java @@ -101,8 +101,7 @@ public class RefsOperation extends TransactionOperationAbstract { toCancel.addFirst(ref); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorCheckingDLQ(e); } } @@ -140,8 +139,7 @@ public class RefsOperation extends TransactionOperationAbstract { message.incrementRefCount(); } ackedTX.commit(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -165,12 +163,10 @@ public class RefsOperation extends TransactionOperationAbstract { private void decrementRefCount(MessageReference refmsg) { try { refmsg.getMessage().decrementRefCount(); - } - catch (NonExistentPage e) { + } catch (NonExistentPage e) { // This could happen on after commit, since the page could be deleted on file earlier by another thread logger.debug(e); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java index 55c5adadaa..7c333a5a63 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java @@ -22,8 +22,8 @@ import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupReplicationStartFailedMessage; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.LiveNodeLocator; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java index 6bbeaf4c7a..6e0aa95699 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java @@ -56,8 +56,7 @@ public final class RoutingContextImpl implements RoutingContext { if (queue.isDurable()) { listing.getDurableQueues().add(queue); - } - else { + } else { listing.getNonDurableQueues().add(queue); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java index c6d3f70c44..3e6f005937 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java @@ -102,7 +102,10 @@ public class ScaleDownHandler { return num; } - public long scaleDownMessages(ClientSessionFactory sessionFactory, SimpleString nodeId, String user, String password) throws Exception { + public long scaleDownMessages(ClientSessionFactory sessionFactory, + SimpleString nodeId, + String user, + String password) throws Exception { long messageCount = 0; targetNodeId = nodeId != null ? nodeId.toString() : getTargetNodeId(sessionFactory); @@ -127,8 +130,7 @@ public class ScaleDownHandler { if (address.toString().startsWith("sf.")) { messageCount += scaleDownSNF(address, queues, producer); - } - else { + } else { messageCount += scaleDownRegularMessages(address, queues, session, producer); } @@ -176,8 +178,7 @@ public class ScaleDownHandler { if (controlEntry.getKey() == loopQueue) { // no need to lookup on itself, we just add it queuesFound.add(controlEntry.getValue()); - } - else if (controlEntry.getValue().lookup(messageReference)) { + } else if (controlEntry.getValue().lookup(messageReference)) { logger.debug("Message existed on queue " + controlEntry.getKey().getID() + " removeID=" + controlEntry.getValue().getQueueID()); queuesFound.add(controlEntry.getValue()); } @@ -196,8 +197,7 @@ public class ScaleDownHandler { if (logger.isDebugEnabled()) { if (messageReference.isPaged()) { logger.debug("*********************<<<<< Scaling down pdgmessage " + message); - } - else { + } else { logger.debug("*********************<<<<< Scaling down message " + message); } } @@ -223,8 +223,7 @@ public class ScaleDownHandler { } return messageCount; - } - finally { + } finally { pageStore.enableCleanup(); pageStore.getCursorProvider().scheduleCleanup(); } @@ -242,8 +241,7 @@ public class ScaleDownHandler { if (queueOnTarget) { propertyEnd = targetNodeId; - } - else { + } else { propertyEnd = address.toString().substring(address.toString().lastIndexOf(".")); } @@ -283,8 +281,7 @@ public class ScaleDownHandler { if (queueOnTarget) { message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, oldRouteToIDs); - } - else { + } else { message.putBytesProperty(MessageImpl.HDR_SCALEDOWN_TO_IDS, oldRouteToIDs); } @@ -337,8 +334,7 @@ public class ScaleDownHandler { if (queueIDs.containsKey(queueName)) { queueID = queueIDs.get(queueName); - } - else { + } else { queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddress()); queueIDs.put(queueName, queueID); // store it so we don't have to look it up every time } @@ -349,8 +345,7 @@ public class ScaleDownHandler { } queueIds.getA().add(queueID); } - } - else if (operation instanceof RefsOperation) { + } else if (operation instanceof RefsOperation) { RefsOperation refsOperation = (RefsOperation) operation; List refs = refsOperation.getReferencesToAcknowledge(); for (MessageReference ref : refs) { @@ -361,8 +356,7 @@ public class ScaleDownHandler { if (queueIDs.containsKey(queueName)) { queueID = queueIDs.get(queueName); - } - else { + } else { queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddress()); queueIDs.put(queueName, queueID); // store it so we don't have to look it up every time } @@ -409,7 +403,7 @@ public class ScaleDownHandler { try (ClientSession session = sessionFactory.createSession(user, password, true, false, false, false, 0); ClientProducer producer = session.createProducer(managementAddress)) { //todo - https://issues.jboss.org/browse/HORNETQ-1336 - for (Map.Entry>> entry : duplicateIDMap.entrySet()) { + for (Map.Entry>> entry : duplicateIDMap.entrySet()) { ClientMessage message = session.createMessage(false); List> list = entry.getValue(); String[] array = new String[list.size()]; @@ -545,8 +539,7 @@ public class ScaleDownHandler { if (subscription.contains((PagedReference) reference)) { return true; } - } - else { + } else { if (lastRef != null && lastRef.getMessage().equals(reference.getMessage())) { lastRef = null; @@ -579,8 +572,7 @@ public class ScaleDownHandler { if (initialRef == null) { initialRef = lastRef; - } - else { + } else { if (initialRef.equals(lastRef)) { if (!memoryIterator.hasNext()) { // if by coincidence we are at the end of the iterator, we just reset the iterator diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java index b70c1b13ec..6eaba4cafc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java @@ -143,8 +143,7 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { // if delay == 0 we will avoid races between adding the scheduler and finishing it ScheduledDeliveryRunnable runnable = new ScheduledDeliveryRunnable(deliveryTime); scheduledExecutor.schedule(runnable, 0, TimeUnit.MILLISECONDS); - } - else if (!runnables.containsKey(deliveryTime)) { + } else if (!runnables.containsKey(deliveryTime)) { ScheduledDeliveryRunnable runnable = new ScheduledDeliveryRunnable(deliveryTime); if (logger.isTraceEnabled()) { @@ -153,8 +152,7 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { runnables.put(deliveryTime, runnable); scheduledExecutor.schedule(runnable, delay, TimeUnit.MILLISECONDS); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("Couldn't make another scheduler as " + deliveryTime + " is already set, now is " + now); } @@ -186,8 +184,8 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { // this is basically a hack to work around an OS or JDK bug! if (logger.isTraceEnabled()) { logger.trace("Scheduler is working around OS imprecisions on " + - "timing and re-scheduling an executor. now=" + now + - " and deliveryTime=" + deliveryTime); + "timing and re-scheduling an executor. now=" + now + + " and deliveryTime=" + deliveryTime); } ScheduledDeliveryHandlerImpl.this.scheduleDelivery(deliveryTime); } @@ -281,19 +279,16 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { // Even if ref1 and ref2 have the same delivery time, we only want to return 0 if they are identical if (ref1 == ref2) { return 0; - } - else { + } else { if (ref1.isTail() && !ref2.isTail()) { return 1; - } - else if (!ref1.isTail() && ref2.isTail()) { + } else if (!ref1.isTail() && ref2.isTail()) { return -1; } if (!ref1.isTail() && !ref2.isTail()) { return -1; - } - else { + } else { return 1; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java index 7de9fc5021..24eacf53d7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java @@ -207,8 +207,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (browseOnly) { browserDeliverer = new BrowserDeliverer(messageQueue.totalIterator()); - } - else { + } else { messageQueue.addConsumer(this); } this.supportLargeMessage = supportLargeMessage; @@ -216,8 +215,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (credits != null) { if (credits == -1) { availableCredits = null; - } - else { + } else { availableCredits.set(credits); } } @@ -314,9 +312,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (callback != null && !callback.hasCredits(this) || availableCredits != null && availableCredits.get() <= 0) { if (logger.isDebugEnabled()) { logger.debug(this + " is busy for the lack of credits. Current credits = " + - availableCredits + - " Can't receive reference " + - ref); + availableCredits + + " Can't receive reference " + + ref); } return HandleStatus.BUSY; @@ -336,9 +334,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (largeMessageDeliverer != null) { if (logger.isDebugEnabled()) { logger.debug(this + " is busy delivering large message " + - largeMessageDeliverer + - ", can't deliver reference " + - ref); + largeMessageDeliverer + + ", can't deliver reference " + + ref); } return HandleStatus.BUSY; } @@ -412,12 +410,10 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // The deliverer was prepared during handle, as we can't have more than one pending large message // as it would return busy if there is anything pending largeMessageDeliverer.deliver(); - } - else { + } else { deliverStandardMessage(reference, message); } - } - finally { + } finally { lockDelivery.readLock().unlock(); callback.afterDelivery(); } @@ -495,8 +491,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { public void removeItself() throws Exception { if (browseOnly) { browserDeliverer.close(); - } - else { + } else { messageQueue.removeConsumer(this); } @@ -544,13 +539,11 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { forceDelivery(sequence, r); } }); - } - else { + } else { r.run(); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorSendingForcedDelivery(e); } } @@ -567,11 +560,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (largeMessageDeliverer != null) { largeMessageDeliverer.finish(); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorResttingLargeMessage(e, largeMessageDeliverer); - } - finally { + } finally { largeMessageDeliverer = null; } @@ -584,8 +575,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { ref.acknowledge(tx); performACK = false; - } - else { + } else { refs.add(ref); updateDeliveryCountForCanceledRef(ref, failed); } @@ -626,8 +616,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // you restart the server try { this.started = browseOnly || started; - } - finally { + } finally { if (locked) { lockDelivery.writeLock().unlock(); } @@ -650,8 +639,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { return false; } return true; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return false; } @@ -665,8 +653,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { boolean locked = lockDelivery(); try { this.transferring = transferring; - } - finally { + } finally { if (locked) { lockDelivery.writeLock().unlock(); } @@ -706,22 +693,20 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // There may be messages already in the queue promptDelivery(); - } - else if (credits == 0) { + } else if (credits == 0) { // reset, used on slow consumers logger.debug(this + ":: FlowControl::Received reset flow control message"); availableCredits.set(0); - } - else { + } else { int previous = availableCredits.getAndAdd(credits); if (logger.isDebugEnabled()) { logger.debug(this + "::FlowControl::Received " + - credits + - " credits, previous value = " + - previous + - " currentValue = " + - availableCredits.get()); + credits + + " credits, previous value = " + + previous + + " currentValue = " + + availableCredits.get()); } if (previous <= 0 && previous + credits > 0) { @@ -738,14 +723,17 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { return messageQueue; } - - /** Remove references based on the protocolData. - * there will be an interval defined between protocolDataStart and protocolDataEnd. - * This method will fetch the delivering references, remove them from the delivering list and return a list. + /** + * Remove references based on the protocolData. + * there will be an interval defined between protocolDataStart and protocolDataEnd. + * This method will fetch the delivering references, remove them from the delivering list and return a list. * - * This will be useful for other protocols that will need this such as openWire or MQTT. */ + * This will be useful for other protocols that will need this such as openWire or MQTT. + */ @Override - public List getDeliveringReferencesBasedOnProtocol(boolean remove, Object protocolDataStart, Object protocolDataEnd) { + public List getDeliveringReferencesBasedOnProtocol(boolean remove, + Object protocolDataStart, + Object protocolDataEnd) { LinkedList retReferences = new LinkedList<>(); boolean hit = false; synchronized (lock) { @@ -822,23 +810,19 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (startedTransaction) { tx.commit(); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (startedTransaction) { tx.rollback(); - } - else { + } else { tx.markAsRollbackOnly(e); } throw e; - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorAckingMessage((Exception) e); ActiveMQException activeMQIllegalStateException = new ActiveMQIllegalStateException(e.getMessage()); if (startedTransaction) { tx.rollback(); - } - else { + } else { tx.markAsRollbackOnly(activeMQIllegalStateException); } throw activeMQIllegalStateException; @@ -846,15 +830,13 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } @Override - public void individualAcknowledge(Transaction tx, - final long messageID) throws Exception { + public void individualAcknowledge(Transaction tx, final long messageID) throws Exception { if (browseOnly) { return; } boolean startedTransaction = false; - if (logger.isTraceEnabled()) { logger.trace("individualACK messageID=" + messageID); } @@ -887,23 +869,19 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (startedTransaction) { tx.commit(); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (startedTransaction) { tx.rollback(); - } - else { + } else { tx.markAsRollbackOnly(e); } throw e; - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorAckingMessage((Exception) e); ActiveMQIllegalStateException hqex = new ActiveMQIllegalStateException(e.getMessage()); if (startedTransaction) { tx.rollback(); - } - else { + } else { tx.markAsRollbackOnly(hqex); } throw hqex; @@ -930,7 +908,6 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { ref.getQueue().cancel(ref, System.currentTimeMillis()); } - @Override public void backToDelivering(MessageReference reference) { deliveringRefs.addFirst(reference); @@ -1016,8 +993,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // if we don't acquire a lock, we will have NPE eventually if (largeMessageDeliverer != null) { resumeLargeMessage(); - } - else { + } else { forceDelivery(); } } @@ -1025,8 +1001,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { private void forceDelivery() { if (browseOnly) { messageQueue.getExecutor().execute(browserDeliverer); - } - else { + } else { messageQueue.deliverAsync(); } } @@ -1047,9 +1022,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (logger.isTraceEnabled()) { logger.trace(this + "::FlowControl::delivery standard taking " + - packetSize + - " from credits, available now is " + - availableCredits); + packetSize + + " from credits, available now is " + + availableCredits); } } } @@ -1065,8 +1040,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (largeMessageDeliverer == null || largeMessageDeliverer.deliver()) { forceDelivery(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRunningLargeMessageDeliverer(e); } } @@ -1117,7 +1091,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (availableCredits != null && availableCredits.get() <= 0) { if (logger.isTraceEnabled()) { logger.trace(this + "::FlowControl::delivery largeMessage interrupting as there are no more credits, available=" + - availableCredits); + availableCredits); } return false; @@ -1139,10 +1113,10 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (logger.isTraceEnabled()) { logger.trace(this + "::FlowControl::" + - " deliver initialpackage with " + - packetSize + - " delivered, available now = " + - availableCredits); + " deliver initialpackage with " + + packetSize + + " delivered, available now = " + + availableCredits); } } @@ -1152,12 +1126,11 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { resumeLargeMessage(); return false; - } - else { + } else { if (availableCredits != null && availableCredits.get() <= 0) { if (logger.isTraceEnabled()) { logger.trace(this + "::FlowControl::deliverLargeMessage Leaving loop of send LargeMessage because of credits, available=" + - availableCredits); + availableCredits); } return false; @@ -1175,8 +1148,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (bodyBuffer.toByteBuffer().hasArray()) { body = bodyBuffer.toByteBuffer().array(); - } - else { + } else { body = new byte[0]; } @@ -1189,9 +1161,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (logger.isTraceEnabled()) { logger.trace(this + "::FlowControl::largeMessage deliver continuation, packetSize=" + - packetSize + - " available now=" + - availableCredits); + packetSize + + " available now=" + + availableCredits); } } @@ -1211,8 +1183,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { finish(); return true; - } - finally { + } finally { lockDelivery.readLock().unlock(); } } @@ -1275,8 +1246,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } current = null; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorBrowserHandlingMessage(e, current); return; } @@ -1301,15 +1271,13 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (status == HandleStatus.HANDLED) { proceedDeliver(ref); - } - else if (status == HandleStatus.BUSY) { + } else if (status == HandleStatus.BUSY) { // keep a reference on the current message reference // to handle it next time the browser deliverer is executed current = ref; break; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorBrowserHandlingMessage(e, ref); break; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerInfo.java index fce327e227..84ce87492c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerInfo.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerInfo.java @@ -68,8 +68,7 @@ public class ServerInfo { try { pageStore = pagingManager.getPageStore(storeName); info.append(String.format("\t%s: %s%n", storeName, SizeFormatterUtil.sizeof(pageStore.getPageSizeBytes() * pageStore.getNumberOfPages()))); - } - catch (Exception e) { + } catch (Exception e) { info.append(String.format("\t%s: %s%n", storeName, e.getMessage())); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java index 26cbde7534..984b682b4a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java @@ -50,8 +50,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { if (MemorySize.is64bitArch()) { memoryOffset = 352; - } - else { + } else { memoryOffset = 232; } } @@ -115,8 +114,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { if (pagingStore != null) { if (count == 1) { pagingStore.addSize(getMemoryEstimate() + MessageReferenceImpl.getMemoryEstimate()); - } - else { + } else { pagingStore.addSize(MessageReferenceImpl.getMemoryEstimate()); } } @@ -136,8 +134,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { // release the buffer now buffer.byteBuf().release(); } - } - else { + } else { pagingStore.addSize(-MessageReferenceImpl.getMemoryEstimate()); } } @@ -228,8 +225,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { if (originalQueue != null) { putStringProperty(Message.HDR_ORIGINAL_QUEUE, originalQueue); - } - else if (originalReference != null) { + } else if (originalReference != null) { putStringProperty(Message.HDR_ORIGINAL_QUEUE, originalReference.getQueue().getName()); } @@ -237,8 +233,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { putStringProperty(Message.HDR_ORIGINAL_ADDRESS, other.getSimpleStringProperty(Message.HDR_ORIGINAL_ADDRESS)); putLongProperty(Message.HDR_ORIG_MESSAGE_ID, other.getLongProperty(Message.HDR_ORIG_MESSAGE_ID)); - } - else { + } else { putStringProperty(Message.HDR_ORIGINAL_ADDRESS, other.getAddress()); putLongProperty(Message.HDR_ORIG_MESSAGE_ID, other.getMessageID()); @@ -280,8 +275,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { public boolean storeIsPaging() { if (pagingStore != null) { return pagingStore.isPaging(); - } - else { + } else { return false; } } @@ -292,8 +286,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { return "ServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBufferDuplicate().capacity() + ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this); - } - catch (Throwable e) { + } catch (Throwable e) { return "ServerMessage[messageID=" + messageID + "]"; } } @@ -301,8 +294,7 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { private static String toDate(long timestamp) { if (timestamp == 0) { return "0"; - } - else { + } else { return new java.util.Date(timestamp).toString(); } @@ -328,12 +320,10 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { if (duplicateID == null) { return null; - } - else { + } else { if (duplicateID instanceof SimpleString) { return ((SimpleString) duplicateID).getData(); - } - else { + } else { return (byte[]) duplicateID; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index 091c35cb17..37d99bb657 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -274,6 +274,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { public boolean isClosed() { return closed; } + /** * @return the sessionContext */ @@ -319,8 +320,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (currentTX != null) { if (e instanceof ActiveMQException) { currentTX.markAsRollbackOnly((ActiveMQException) e); - } - else { + } else { ActiveMQException exception = new ActiveMQException(e.getMessage()); exception.initCause(e); currentTX.markAsRollbackOnly(exception); @@ -344,8 +344,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { try { rollback(failed, false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -358,13 +357,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { for (ServerConsumer consumer : consumersClone) { try { consumer.close(failed); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); try { consumer.removeItself(); - } - catch (Throwable e2) { + } catch (Throwable e2) { ActiveMQServerLogger.LOGGER.warn(e2.getMessage(), e2); } } @@ -375,8 +372,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (currentLargeMessage != null) { try { currentLargeMessage.deleteFile(); - } - catch (Throwable error) { + } catch (Throwable error) { ActiveMQServerLogger.LOGGER.errorDeletingLargeMessageFile(error); } } @@ -429,23 +425,20 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (browseOnly) { try { securityCheck(binding.getAddress(), CheckType.BROWSE, this); - } - catch (Exception e) { + } catch (Exception e) { securityCheck(binding.getAddress().concat(".").concat(queueName), CheckType.BROWSE, this); } - } - else { + } else { try { securityCheck(binding.getAddress(), CheckType.CONSUME, this); - } - catch (Exception e) { + } catch (Exception e) { securityCheck(binding.getAddress().concat(".").concat(queueName), CheckType.CONSUME, this); } } Filter filter = FilterImpl.createFilter(filterString); - ServerConsumer consumer = new ServerConsumerImpl(consumerID, this, (QueueBinding)binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, supportLargeMessage, credits, server); + ServerConsumer consumer = new ServerConsumerImpl(consumerID, this, (QueueBinding) binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, supportLargeMessage, credits, server); consumers.put(consumer.getID(), consumer); if (!browseOnly) { @@ -478,9 +471,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (logger.isDebugEnabled()) { logger.debug("Session with user=" + username + - ", connection=" + this.remotingConnection + - " created a consumer on queue " + queueName + - ", filter = " + filterString); + ", connection=" + this.remotingConnection + + " created a consumer on queue " + queueName + + ", filter = " + filterString); } managementService.sendNotification(notification); @@ -489,9 +482,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { return consumer; } - /** Some protocols may chose to hold their transactions outside of the ServerSession. - * This can be used to replace the transaction. - * Notice that we set autoCommitACK and autoCommitSends to true if tx == null */ + /** + * Some protocols may chose to hold their transactions outside of the ServerSession. + * This can be used to replace the transaction. + * Notice that we set autoCommitACK and autoCommitSends to true if tx == null + */ @Override public void resetTX(Transaction transaction) { this.tx = transaction; @@ -508,8 +503,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (durable) { // make sure the user has privileges to create this queue securityCheck(address, CheckType.CREATE_DURABLE_QUEUE, this); - } - else { + } else { securityCheck(address, CheckType.CREATE_NON_DURABLE_QUEUE, this); } @@ -518,10 +512,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Queue queue; // any non-temporary JMS destination created via this method should be marked as auto-created - if (!temporary && ((address.toString().startsWith(ResourceNames.JMS_QUEUE) && address.equals(name)) || address.toString().startsWith(ResourceNames.JMS_TOPIC)) ) { + if (!temporary && ((address.toString().startsWith(ResourceNames.JMS_QUEUE) && address.equals(name)) || address.toString().startsWith(ResourceNames.JMS_TOPIC))) { queue = server.createQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary, true); - } - else { + } else { queue = server.createQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary); } @@ -542,8 +535,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (logger.isDebugEnabled()) { logger.debug("Queue " + name + " created on address " + address + - " with filter=" + filterString + " temporary = " + - temporary + " durable=" + durable + " on session user=" + this.username + ", connection=" + this.remotingConnection); + " with filter=" + filterString + " temporary = " + + temporary + " durable=" + durable + " on session user=" + this.username + ", connection=" + this.remotingConnection); } return queue; @@ -586,13 +579,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } try { server.destroyQueue(bindingName, null, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // that's fine.. it can happen due to queue already been deleted logger.debug(e.getMessage(), e); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingTempQueue(e, bindingName); } } @@ -669,16 +660,14 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Transaction newTX = newTransaction(); try { consumer.acknowledge(newTX, messageID); - } - catch (Exception e) { + } catch (Exception e) { // just ignored // will log it just in case logger.debug("Ignored exception while acking messageID " + messageID + - " on a rolledback TX", e); + " on a rolledback TX", e); } newTX.rollback(); - } - else { + } else { consumer.acknowledge(autoCommitAcks ? null : tx, messageID); } } @@ -715,8 +704,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Transaction newTX = newTransaction(); consumer.individualAcknowledge(tx, messageID); newTX.rollback(); - } - else { + } else { consumer.individualAcknowledge(autoCommitAcks ? null : tx, messageID); } @@ -750,12 +738,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (tx != null) { tx.commit(); } - } - finally { + } finally { if (xa) { tx = null; - } - else { + } else { tx = newTransaction(); } } @@ -783,8 +769,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (xa) { tx = null; - } - else { + } else { tx = newTransaction(); } } @@ -812,8 +797,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot commit, session is currently doing work in transaction " + tx.getXid(); throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { Transaction theTx = resourceManager.removeTransaction(xid); if (logger.isTraceEnabled()) { @@ -824,27 +808,23 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // checked heuristic committed transactions if (resourceManager.getHeuristicCommittedTransactions().contains(xid)) { throw new ActiveMQXAException(XAException.XA_HEURCOM, "transaction has been heuristically committed: " + xid); - } - // checked heuristic rolled back transactions - else if (resourceManager.getHeuristicRolledbackTransactions().contains(xid)) { + } else if (resourceManager.getHeuristicRolledbackTransactions().contains(xid)) { + // checked heuristic rolled back transactions throw new ActiveMQXAException(XAException.XA_HEURRB, "transaction has been heuristically rolled back: " + xid); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("XAcommit into " + theTx + ", xid=" + xid + " cannot find it"); } throw new ActiveMQXAException(XAException.XAER_NOTA, "Cannot find xid in resource manager: " + xid); } - } - else { + } else { if (theTx.getState() == Transaction.State.SUSPENDED) { // Put it back resourceManager.putTransaction(xid, theTx); throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot commit transaction, it is suspended " + xid); - } - else { + } else { theTx.commit(onePhase); } } @@ -858,8 +838,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot end, transaction is suspended"; throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else if (tx.getState() == Transaction.State.ROLLEDBACK) { + } else if (tx.getState() == Transaction.State.ROLLEDBACK) { final String msg = "Cannot end, transaction is rolled back"; final boolean timeout = tx.hasTimedOut(); @@ -867,16 +846,13 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (timeout) { throw new ActiveMQXAException(XAException.XA_RBTIMEOUT, msg); - } - else { + } else { throw new ActiveMQXAException(XAException.XAER_PROTO, msg); } - } - else { + } else { tx = null; } - } - else { + } else { // It's also legal for the TM to call end for a Xid in the suspended // state // See JTA 1.1 spec 3.4.4 - state diagram @@ -887,14 +863,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot find suspended transaction to end " + xid; throw new ActiveMQXAException(XAException.XAER_NOTA, msg); - } - else { + } else { if (theTx.getState() != Transaction.State.SUSPENDED) { final String msg = "Transaction is not suspended " + xid; throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { theTx.resume(); } } @@ -908,13 +882,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (id != -1) { try { storageManager.deleteHeuristicCompletion(id); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); throw new ActiveMQXAException(XAException.XAER_RMFAIL); } - } - else { + } else { throw new ActiveMQXAException(XAException.XAER_NOTA); } } @@ -927,12 +899,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot find xid in resource manager: " + xid; throw new ActiveMQXAException(XAException.XAER_NOTA, msg); - } - else { + } else { if (theTx.getState() == Transaction.State.SUSPENDED) { throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot join tx, it is suspended " + xid); - } - else { + } else { tx = theTx; } } @@ -944,20 +914,17 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot resume, session is currently doing work in a transaction " + tx.getXid(); throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { Transaction theTx = resourceManager.getTransaction(xid); if (theTx == null) { final String msg = "Cannot find xid in resource manager: " + xid; throw new ActiveMQXAException(XAException.XAER_NOTA, msg); - } - else { + } else { if (theTx.getState() != Transaction.State.SUSPENDED) { throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot resume transaction, it is not suspended " + xid); - } - else { + } else { tx = theTx; tx.resume(); @@ -972,8 +939,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot roll back, session is currently doing work in a transaction " + tx.getXid(); throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { Transaction theTx = resourceManager.removeTransaction(xid); if (logger.isTraceEnabled()) { logger.trace("xarollback into " + theTx); @@ -983,12 +949,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // checked heuristic committed transactions if (resourceManager.getHeuristicCommittedTransactions().contains(xid)) { throw new ActiveMQXAException(XAException.XA_HEURCOM, "transaction has ben heuristically committed: " + xid); - } - // checked heuristic rolled back transactions - else if (resourceManager.getHeuristicRolledbackTransactions().contains(xid)) { + } else if (resourceManager.getHeuristicRolledbackTransactions().contains(xid)) { + // checked heuristic rolled back transactions throw new ActiveMQXAException(XAException.XA_HEURRB, "transaction has ben heuristically rolled back: " + xid); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("xarollback into " + theTx + ", xid=" + xid + " forcing a rollback regular"); } @@ -998,15 +962,13 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // This could have happened because the TX timed out, // at this point we would be better on rolling back this session as a way to prevent consumers from holding their messages this.rollback(false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } throw new ActiveMQXAException(XAException.XAER_NOTA, "Cannot find xid in resource manager: " + xid); } - } - else { + } else { if (theTx.getState() == Transaction.State.SUSPENDED) { if (logger.isTraceEnabled()) { logger.trace("xarollback into " + theTx + " sending tx back as it was suspended"); @@ -1016,8 +978,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { resourceManager.putTransaction(xid, tx); throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot rollback transaction, it is suspended " + xid); - } - else { + } else { doRollback(false, false, theTx); } } @@ -1037,8 +998,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } tx.rollback(); } - } - catch (Exception e) { + } catch (Exception e) { logger.debug("An exception happened while we tried to debug the previous tx, we can ignore this exception", e); } } @@ -1070,8 +1030,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (theTX.isEffective()) { logger.debug("Client failed with Xid " + xid + " but the server already had it " + theTX.getState()); tx = null; - } - else { + } else { theTX.markAsRollbackOnly(new ActiveMQException("Can't commit as a Failover happened during the operation")); tx = theTX; } @@ -1092,14 +1051,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot suspend, session is not doing work in a transaction "; throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { if (tx.getState() == Transaction.State.SUSPENDED) { final String msg = "Cannot suspend, transaction is already suspended " + tx.getXid(); throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { tx.suspend(); tx = null; @@ -1113,8 +1070,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot commit, session is currently doing work in a transaction " + tx.getXid(); throw new ActiveMQXAException(XAException.XAER_PROTO, msg); - } - else { + } else { Transaction theTx = resourceManager.getTransaction(xid); if (logger.isTraceEnabled()) { @@ -1125,15 +1081,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final String msg = "Cannot find xid in resource manager: " + xid; throw new ActiveMQXAException(XAException.XAER_NOTA, msg); - } - else { + } else { if (theTx.getState() == Transaction.State.SUSPENDED) { throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot prepare transaction, it is suspended " + xid); - } - else if (theTx.getState() == Transaction.State.PREPARED) { + } else if (theTx.getState() == Transaction.State.PREPARED) { ActiveMQServerLogger.LOGGER.info("ignoring prepare on xid as already called :" + xid); - } - else { + } else { theTx.prepare(); } } @@ -1174,8 +1127,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (!context.waitCompletion(10000)) { ActiveMQServerLogger.LOGGER.errorCompletingContext(new Exception("warning")); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -1193,8 +1145,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { public void done() { try { doClose(failed); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSession(e); } } @@ -1207,8 +1158,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (consumer != null) { consumer.close(false); - } - else { + } else { ActiveMQServerLogger.LOGGER.cannotFindConsumer(consumerID); } } @@ -1255,12 +1205,17 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } @Override - public RoutingStatus send(final ServerMessage message, final boolean direct, boolean noAutoCreateQueue) throws Exception { + public RoutingStatus send(final ServerMessage message, + final boolean direct, + boolean noAutoCreateQueue) throws Exception { return send(getCurrentTransaction(), message, direct, noAutoCreateQueue); } @Override - public RoutingStatus send(Transaction tx, final ServerMessage message, final boolean direct, boolean noAutoCreateQueue) throws Exception { + public RoutingStatus send(Transaction tx, + final ServerMessage message, + final boolean direct, + boolean noAutoCreateQueue) throws Exception { // If the protocol doesn't support flow control, we have no choice other than fail the communication if (!this.getRemotingConnection().isSupportsFlowControl() && pagingManager.isDiskFull()) { @@ -1294,8 +1249,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // We need to force a re-encode when the message gets persisted or when it gets reloaded // it will have no address message.setAddress(defaultAddress); - } - else { + } else { // We don't want to force a re-encode when the message gets sent to the consumer message.setAddressTransient(defaultAddress); } @@ -1314,8 +1268,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // It's a management message handleManagementMessage(tx, message, direct); - } - else { + } else { result = doSend(tx, message, direct, noAutoCreateQueue); } return result; @@ -1385,8 +1338,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (sessionWithMetaData != null && sessionWithMetaData != this) { // There is a duplication of this property return false; - } - else { + } else { addMetaData(key, data); return true; } @@ -1425,8 +1377,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Pair value = targetAddressInfos.get(SimpleString.toSimpleString(address)); if (value != null) { return value.getA().toString(); - } - else { + } else { return null; } } @@ -1449,12 +1400,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (entry.getValue().getA() != null) { uuid = entry.getValue().getA().toString(); } - JsonObjectBuilder producerInfo = JsonLoader.createObjectBuilder() - .add("connectionID", this.getConnectionID().toString()) - .add("sessionID", this.getName()) - .add("destination", entry.getKey().toString()) - .add("lastUUIDSent", nullSafe(uuid)) - .add("msgSent", entry.getValue().getB().longValue()); + JsonObjectBuilder producerInfo = JsonLoader.createObjectBuilder().add("connectionID", this.getConnectionID().toString()).add("sessionID", this.getName()).add("destination", entry.getKey().toString()).add("lastUUIDSent", nullSafe(uuid)).add("msgSent", entry.getValue().getB().longValue()); array.add(producerInfo); } } @@ -1475,8 +1421,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Object tmpValue = value.getValue(); if (tmpValue == null || tmpValue.toString().isEmpty()) { buffer.append(value.getKey() + "=*N/A*"); - } - else { + } else { buffer.append(value.getKey() + "=" + tmpValue); } } @@ -1498,8 +1443,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { close(true); ActiveMQServerLogger.LOGGER.clientConnectionFailedClearingSession(name); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorClosingConnection(this); } } @@ -1531,11 +1475,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener { started = s; } - private RoutingStatus handleManagementMessage(final Transaction tx, final ServerMessage message, final boolean direct) throws Exception { + private RoutingStatus handleManagementMessage(final Transaction tx, + final ServerMessage message, + final boolean direct) throws Exception { try { securityCheck(message.getAddress(), CheckType.MANAGE, this); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (!autoCommitSends) { tx.markAsRollbackOnly(e); } @@ -1577,8 +1522,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (theTx.getState() == State.ROLLEDBACK) { Transaction newTX = newTransaction(); cancelAndRollback(clientFailed, newTX, wasStarted, toCancel); - } - else { + } else { cancelAndRollback(clientFailed, theTx, wasStarted, toCancel); } } @@ -1607,13 +1551,15 @@ public class ServerSessionImpl implements ServerSession, FailureListener { theTx.rollback(); } - public RoutingStatus doSend(final Transaction tx, final ServerMessage msg, final boolean direct, final boolean noAutoCreateQueue) throws Exception { + public RoutingStatus doSend(final Transaction tx, + final ServerMessage msg, + final boolean direct, + final boolean noAutoCreateQueue) throws Exception { RoutingStatus result = RoutingStatus.OK; // check the user has write access to this address. try { securityCheck(msg.getAddress(), CheckType.SEND, this); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (!autoCommitSends && tx != null) { tx.markAsRollbackOnly(e); } @@ -1621,16 +1567,14 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } if (tx == null || autoCommitSends) { - } - else { + } else { routingContext.setTransaction(tx); } try { if (noAutoCreateQueue) { result = postOffice.route(msg, null, routingContext, direct); - } - else { + } else { result = postOffice.route(msg, queueCreator, routingContext, direct); } @@ -1638,13 +1582,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (value == null) { targetAddressInfos.put(msg.getAddress(), new Pair<>(msg.getUserID(), new AtomicLong(1))); - } - else { + } else { value.setA(msg.getUserID()); value.getB().incrementAndGet(); } - } - finally { + } finally { routingContext.clear(); } return result; @@ -1657,12 +1599,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener { if (oper == null) { return Collections.emptyList(); - } - else { + } else { return oper.getListOnConsumer(consumerId); } - } - else { + } else { return Collections.emptyList(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServiceRegistryImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServiceRegistryImpl.java index 46dbd58c86..d2d66a4798 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServiceRegistryImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServiceRegistryImpl.java @@ -16,16 +16,6 @@ */ package org.apache.activemq.artemis.core.server.impl; -import org.apache.activemq.artemis.api.core.BaseInterceptor; -import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; -import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; -import org.apache.activemq.artemis.core.server.ConnectorServiceFactory; -import org.apache.activemq.artemis.core.server.ServiceRegistry; -import org.apache.activemq.artemis.core.server.cluster.Transformer; -import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory; -import org.apache.activemq.artemis.utils.ClassloadingUtil; - import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; @@ -37,6 +27,16 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; +import org.apache.activemq.artemis.api.core.BaseInterceptor; +import org.apache.activemq.artemis.api.core.Pair; +import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; +import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; +import org.apache.activemq.artemis.core.server.ConnectorServiceFactory; +import org.apache.activemq.artemis.core.server.ServiceRegistry; +import org.apache.activemq.artemis.core.server.cluster.Transformer; +import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory; +import org.apache.activemq.artemis.utils.ClassloadingUtil; + public class ServiceRegistryImpl implements ServiceRegistry { private ExecutorService executorService; @@ -213,8 +213,7 @@ public class ServiceRegistryImpl implements ServiceRegistry { return (Transformer) ClassloadingUtil.newInstanceFromClassLoader(className); } }); - } - catch (Exception e) { + } catch (Exception e) { throw ActiveMQMessageBundle.BUNDLE.errorCreatingTransformerClass(e, className); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java index d279864c79..8351c4dc12 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.util.Map; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException; import org.apache.activemq.artemis.api.core.Pair; @@ -45,19 +48,14 @@ import org.apache.activemq.artemis.core.server.management.ManagementService; import org.apache.activemq.artemis.utils.ReusableLatch; import org.jboss.logging.Logger; -import java.util.Map; -import java.util.concurrent.TimeUnit; - import static org.apache.activemq.artemis.core.server.cluster.qourum.SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAILURE_REPLICATING; import static org.apache.activemq.artemis.core.server.cluster.qourum.SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAIL_OVER; import static org.apache.activemq.artemis.core.server.cluster.qourum.SharedNothingBackupQuorum.BACKUP_ACTIVATION.STOP; public final class SharedNothingBackupActivation extends Activation { - private static final Logger logger = Logger.getLogger(SharedNothingBackupActivation.class); - //this is how we act when we start as a backup private ReplicaPolicy replicaPolicy; @@ -128,8 +126,7 @@ public final class SharedNothingBackupActivation extends Activation { if (activationParams.get(ActivationParams.REPLICATION_ENDPOINT) != null) { TopologyMember member = (TopologyMember) activationParams.get(ActivationParams.REPLICATION_ENDPOINT); nodeLocator = new NamedNodeIdNodeLocator(member.getNodeId(), new Pair<>(member.getLive(), member.getBackup())); - } - else { + } else { nodeLocator = replicaPolicy.getGroupName() == null ? new AnyLiveNodeLocatorForReplication(backupQuorum, activeMQServer) : new NamedLiveNodeLocatorForReplication(replicaPolicy.getGroupName(), backupQuorum); } ClusterController clusterController = activeMQServer.getClusterManager().getClusterController(); @@ -173,7 +170,6 @@ public final class SharedNothingBackupActivation extends Activation { SharedNothingBackupQuorum.BACKUP_ACTIVATION signal; do { - if (closed) { if (logger.isTraceEnabled()) { logger.trace("Activation is closed, so giving up"); @@ -211,14 +207,12 @@ public final class SharedNothingBackupActivation extends Activation { logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + possibleLive.getA() + ")"); } clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getA()); - } - catch (Exception e) { + } catch (Exception e) { logger.debug(e.getMessage(), e); if (possibleLive.getB() != null) { try { clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getB()); - } - catch (Exception e1) { + } catch (Exception e1) { clusterControl = null; } } @@ -258,16 +252,14 @@ public final class SharedNothingBackupActivation extends Activation { logger.trace("giving up on the activation:: activemqServer.isStarted=" + activeMQServer.isStarted() + " while signal = " + signal); } return; - } + } else if (signal == FAIL_OVER) { // time to fail over - else if (signal == FAIL_OVER) { if (logger.isTraceEnabled()) { logger.trace("signal == FAIL_OVER, breaking the loop"); } break; - } + } else if (signal == SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAILURE_REPLICATING) { // something has gone badly run restart from scratch - else if (signal == SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAILURE_REPLICATING) { if (logger.isTraceEnabled()) { logger.trace("Starting a new thread to stop the server!"); } @@ -280,8 +272,7 @@ public final class SharedNothingBackupActivation extends Activation { logger.trace("Calling activeMQServer.stop()"); } activeMQServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(e, activeMQServer); } } @@ -328,15 +319,13 @@ public final class SharedNothingBackupActivation extends Activation { activeMQServer.getBackupManager().activated(); if (scalingDown) { activeMQServer.initialisePart2(true); - } - else { + } else { activeMQServer.setActivation(new SharedNothingLiveActivation(activeMQServer, replicaPolicy.getReplicatedPolicy())); activeMQServer.initialisePart2(false); if (activeMQServer.getIdentity() != null) { ActiveMQServerLogger.LOGGER.serverIsLive(activeMQServer.getIdentity()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverIsLive(); } @@ -344,8 +333,7 @@ public final class SharedNothingBackupActivation extends Activation { activeMQServer.completeActivation(); } - } - catch (Exception e) { + } catch (Exception e) { if (logger.isTraceEnabled()) { logger.trace(e.getMessage() + ", serverStarted=" + activeMQServer.isStarted(), e); } @@ -396,8 +384,7 @@ public final class SharedNothingBackupActivation extends Activation { ActiveMQServer parentServer) throws ActiveMQException { if (replicaPolicy.getScaleDownPolicy() != null && replicaPolicy.getScaleDownPolicy().isEnabled()) { return new BackupRecoveryJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer, ScaleDownPolicy.getScaleDownConnector(replicaPolicy.getScaleDownPolicy(), activeMQServer), activeMQServer.getClusterManager().getClusterController()); - } - else { + } else { return super.createJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer); } } @@ -427,8 +414,7 @@ public final class SharedNothingBackupActivation extends Activation { public void failOver(final ReplicationLiveIsStoppingMessage.LiveStopping finalMessage) { if (finalMessage == null) { backupQuorum.causeExit(FAILURE_REPLICATING); - } - else { + } else { backupQuorum.failOver(finalMessage); } } @@ -470,8 +456,7 @@ public final class SharedNothingBackupActivation extends Activation { if (!backupUpToDate) { failOver(null); - } - else { + } else { failOver(finalMessage); } } @@ -489,8 +474,7 @@ public final class SharedNothingBackupActivation extends Activation { connectToReplicationEndpoint(clusterControl); replicationEndpoint.start(); clusterControl.announceReplicatingBackupToLive(attemptFailBack, replicaPolicy.getClusterName()); - } - catch (Exception e) { + } catch (Exception e) { //we shouldn't stop the server just mark the connector as tried and unavailable ActiveMQServerLogger.LOGGER.replicationStartProblem(e); backupQuorum.causeExit(FAILURE_REPLICATING); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java index 938f5dd3b7..c984ae2d6b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java @@ -79,8 +79,7 @@ public class SharedNothingLiveActivation extends LiveActivation { if (remotingService != null && localReplicationManager != null) { remotingService.freeze(null, localReplicationManager.getBackupTransportConnection()); - } - else if (remotingService != null) { + } else if (remotingService != null) { remotingService.freeze(null, null); } } @@ -108,12 +107,10 @@ public class SharedNothingLiveActivation extends LiveActivation { if (activeMQServer.getIdentity() != null) { ActiveMQServerLogger.LOGGER.serverIsLive(activeMQServer.getIdentity()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverIsLive(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.initializationError(e); activeMQServer.callActivationFailureListeners(e); } @@ -129,11 +126,9 @@ public class SharedNothingLiveActivation extends LiveActivation { ClusterConnection clusterConnection = acceptorUsed.getClusterConnection(); try { startReplication(channel.getConnection(), clusterConnection, getPair(msg.getConnector(), true), msg.isFailBackRequest()); - } - catch (ActiveMQAlreadyReplicatingException are) { + } catch (ActiveMQAlreadyReplicatingException are) { channel.send(new BackupReplicationStartFailedMessage(BackupReplicationStartFailedMessage.BackupRegistrationProblem.ALREADY_REPLICATING)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { logger.debug("Failed to process backup registration packet", e); channel.send(new BackupReplicationStartFailedMessage(BackupReplicationStartFailedMessage.BackupRegistrationProblem.EXCEPTION)); } @@ -182,16 +177,14 @@ public class SharedNothingLiveActivation extends LiveActivation { //if we have to many backups kept or are not configured to restart just stop, otherwise restart as a backup activeMQServer.stop(true); ActiveMQServerLogger.LOGGER.restartingReplicatedBackupAfterFailback(); -// activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize()); + // activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize()); activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy()); activeMQServer.start(); - } - else { + } else { ActiveMQServerLogger.LOGGER.failbackMissedBackupAnnouncement(); } } - } - catch (Exception e) { + } catch (Exception e) { if (activeMQServer.getState() == ActiveMQServerImpl.SERVER_STATE.STARTED) { /* * The reasoning here is that the exception was either caused by (1) the @@ -203,11 +196,9 @@ public class SharedNothingLiveActivation extends LiveActivation { } try { ActiveMQServerImpl.stopComponent(replicationManager); - } - catch (Exception amqe) { + } catch (Exception amqe) { ActiveMQServerLogger.LOGGER.errorStoppingReplication(amqe); - } - finally { + } finally { synchronized (replicationLock) { replicationManager = null; } @@ -272,8 +263,7 @@ public class SharedNothingLiveActivation extends LiveActivation { SimpleString nodeId0; try { nodeId0 = activeMQServer.getNodeManager().readNodeId(); - } - catch (ActiveMQIllegalStateException e) { + } catch (ActiveMQIllegalStateException e) { nodeId0 = null; } @@ -287,8 +277,7 @@ public class SharedNothingLiveActivation extends LiveActivation { try (ClientSessionFactoryInternal factory = locator.connectNoWarnings()) { // Just try connecting listener.latch.await(5, TimeUnit.SECONDS); - } - catch (Exception notConnected) { + } catch (Exception notConnected) { return false; } @@ -307,8 +296,7 @@ public class SharedNothingLiveActivation extends LiveActivation { //todo does this actually make any difference, we only set a different flag in the lock file which replication doesn't use if (permanently) { nodeManagerInUse.crashLiveServer(); - } - else { + } else { nodeManagerInUse.pauseLiveServer(); } } @@ -347,8 +335,7 @@ public class SharedNothingLiveActivation extends LiveActivation { throw ActiveMQMessageBundle.BUNDLE.noDiscoveryGroupFound(dg); } locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(dg); - } - else { + } else { TransportConfiguration[] tcConfigs = config.getStaticConnectors() != null ? connectorNameListToArray(config.getStaticConnectors()) : null; locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(tcConfigs); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java index d9963ee27b..097ecb8bcf 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java @@ -102,16 +102,14 @@ public final class SharedStoreBackupActivation extends Activation { if (sharedStoreSlavePolicy.isRestartBackup()) { activeMQServer.start(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.serverRestartWarning(); } } }); t.start(); return; - } - else { + } else { ActiveMQServerLogger.LOGGER.backupServerIsLive(); activeMQServer.getNodeManager().releaseBackup(); @@ -119,16 +117,13 @@ public final class SharedStoreBackupActivation extends Activation { if (sharedStoreSlavePolicy.isAllowAutoFailBack()) { startFailbackChecker(); } - } - catch (ClosedChannelException | InterruptedException e) { + } catch (ClosedChannelException | InterruptedException e) { // these are ok, we are being stopped - } - catch (Exception e) { + } catch (Exception e) { if (!(e.getCause() instanceof InterruptedException)) { ActiveMQServerLogger.LOGGER.initializationError(e); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.initializationError(e); } } @@ -151,8 +146,7 @@ public final class SharedStoreBackupActivation extends Activation { if (nodeManagerInUse != null) { nodeManagerInUse.stopBackup(); } - } - else { + } else { if (nodeManagerInUse != null) { // if we are now live, behave as live @@ -160,8 +154,7 @@ public final class SharedStoreBackupActivation extends Activation { // started before the live if (sharedStoreSlavePolicy.isFailoverOnServerShutdown() || permanently) { nodeManagerInUse.crashLiveServer(); - } - else { + } else { nodeManagerInUse.pauseLiveServer(); } } @@ -180,8 +173,7 @@ public final class SharedStoreBackupActivation extends Activation { ActiveMQServer parentServer) throws ActiveMQException { if (sharedStoreSlavePolicy.getScaleDownPolicy() != null && sharedStoreSlavePolicy.getScaleDownPolicy().isEnabled()) { return new BackupRecoveryJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer, ScaleDownPolicy.getScaleDownConnector(sharedStoreSlavePolicy.getScaleDownPolicy(), activeMQServer), activeMQServer.getClusterManager().getClusterController()); - } - else { + } else { return super.createJournalLoader(postOffice, pagingManager, storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration, parentServer); } } @@ -194,6 +186,7 @@ public final class SharedStoreBackupActivation extends Activation { } private class FailbackChecker implements Runnable { + BackupTopologyListener backupListener; FailbackChecker() { @@ -233,9 +226,8 @@ public final class SharedStoreBackupActivation extends Activation { logger.debug(activeMQServer + "::Starting backup node now after failback"); activeMQServer.start(); } - } - catch (Exception e) { - ActiveMQServerLogger.LOGGER.warn(e.getMessage(),e); + } catch (Exception e) { + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); ActiveMQServerLogger.LOGGER.serverRestartWarning(); } } @@ -243,8 +235,7 @@ public final class SharedStoreBackupActivation extends Activation { t.start(); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.serverRestartWarning(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java index ff688d16a3..485ae166f9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java @@ -72,8 +72,7 @@ public final class SharedStoreLiveActivation extends LiveActivation { activeMQServer.completeActivation(); ActiveMQServerLogger.LOGGER.serverIsLive(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.initializationError(e); activeMQServer.callActivationFailureListeners(e); } @@ -87,8 +86,7 @@ public final class SharedStoreLiveActivation extends LiveActivation { if (nodeManagerInUse != null) { if (sharedStoreMasterPolicy.isFailoverOnServerShutdown() || permanently) { nodeManagerInUse.crashLiveServer(); - } - else { + } else { nodeManagerInUse.pauseLiveServer(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java index 6a491a5d58..a8da6eb999 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java @@ -42,12 +42,10 @@ public class TransientQueueManagerImpl implements TransientQueueManager { try { server.destroyQueue(queueName, null, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.warn("Error on deleting queue " + queueName + ", " + e.getMessage(), e); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingTempQueue(e, queueName); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java index c98c22e81d..5f40c53ceb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.core.server.management; +import javax.management.ObjectName; import java.util.Set; import java.util.concurrent.ScheduledExecutorService; -import javax.management.ObjectName; - import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -37,9 +36,9 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.remoting.server.RemotingService; import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.security.SecurityStore; -import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.QueueFactory; import org.apache.activemq.artemis.core.server.ServerMessage; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java index 4fe6f9d4c1..73248f0c7f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java @@ -301,8 +301,7 @@ public class ManagementServiceImpl implements ManagementService { String name = acceptor.substring(ResourceNames.CORE_ACCEPTOR.length()); try { unregisterAcceptor(name); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -389,21 +388,18 @@ public class ManagementServiceImpl implements ManagementService { ManagementHelper.storeResult(reply, result); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.managementOperationError(e, operation, resourceName); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, false); String exceptionMessage; if (e instanceof InvocationTargetException) { exceptionMessage = ((InvocationTargetException) e).getTargetException().getMessage(); - } - else { + } else { exceptionMessage = e.getMessage(); } ManagementHelper.storeResult(reply, exceptionMessage); } - } - else { + } else { String attribute = message.getStringProperty(ManagementHelper.HDR_ATTRIBUTE); if (attribute != null) { @@ -413,15 +409,13 @@ public class ManagementServiceImpl implements ManagementService { ManagementHelper.storeResult(reply, result); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.managementAttributeError(e, attribute, resourceName); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, false); String exceptionMessage; if (e instanceof InvocationTargetException) { exceptionMessage = ((InvocationTargetException) e).getTargetException().getMessage(); - } - else { + } else { exceptionMessage = e.getMessage(); } ManagementHelper.storeResult(reply, exceptionMessage); @@ -551,8 +545,7 @@ public class ManagementServiceImpl implements ManagementService { for (ObjectName on : registeredNames) { try { mbeanServer.unregisterMBean(on); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } } @@ -604,8 +597,8 @@ public class ManagementServiceImpl implements ManagementService { public void sendNotification(final Notification notification) throws Exception { if (logger.isTraceEnabled()) { logger.trace("Sending Notification = " + notification + - ", notificationEnabled=" + notificationsEnabled + - " messagingServerControl=" + messagingServerControl); + ", notificationEnabled=" + notificationsEnabled + + " messagingServerControl=" + messagingServerControl); } // This needs to be synchronized since we need to ensure notifications are processed in strict sequence synchronized (this) { @@ -619,8 +612,7 @@ public class ManagementServiceImpl implements ManagementService { for (NotificationListener listener : listeners) { try { listener.onNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { // Exception thrown from one listener should not stop execution of others ActiveMQServerLogger.LOGGER.errorCallingNotifListener(e); } @@ -684,18 +676,15 @@ public class ManagementServiceImpl implements ManagementService { String upperCaseAttribute = attribute.substring(0, 1).toUpperCase() + attribute.substring(1); try { method = resource.getClass().getMethod("get" + upperCaseAttribute, new Class[0]); - } - catch (NoSuchMethodException nsme) { + } catch (NoSuchMethodException nsme) { try { method = resource.getClass().getMethod("is" + upperCaseAttribute, new Class[0]); - } - catch (NoSuchMethodException nsme2) { + } catch (NoSuchMethodException nsme2) { throw ActiveMQMessageBundle.BUNDLE.noGetterMethod(attribute); } } return method.invoke(resource, new Object[0]); - } - catch (Throwable t) { + } catch (Throwable t) { throw new IllegalStateException("Problem while retrieving attribute " + attribute, t); } } @@ -732,8 +721,7 @@ public class ManagementServiceImpl implements ManagementService { paramTypes[i] == Integer.TYPE && params[i].getClass() == Integer.class || paramTypes[i] == Boolean.TYPE && params[i].getClass() == Boolean.class) { // parameter match - } - else { + } else { match = false; break; // parameter check loop } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketServerHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketServerHandler.java index 671cb76b73..56ece3ea99 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketServerHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketServerHandler.java @@ -64,8 +64,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { handleHttpRequest(ctx, (FullHttpRequest) msg); - } - else if (msg instanceof WebSocketFrame) { + } else if (msg instanceof WebSocketFrame) { WebSocketFrame frame = (WebSocketFrame) msg; boolean handle = handleWebSocketFrame(ctx, frame); if (handle) { @@ -83,13 +82,12 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler // Handshake String supportedProtocolsCSV = StringUtil.joinStringList(supportedProtocols, ","); - WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(this.getWebSocketLocation(req), supportedProtocolsCSV,false); + WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(this.getWebSocketLocation(req), supportedProtocolsCSV, false); this.httpRequest = req; this.handshaker = wsFactory.newHandshaker(req); if (this.handshaker == null) { WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel()); - } - else { + } else { ChannelFuture handshake = this.handshaker.handshake(ctx.channel(), req); handshake.addListener(new ChannelFutureListener() { @@ -99,8 +97,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler // we need to insert an encoder that takes the underlying ChannelBuffer of a StompFrame.toActiveMQBuffer and // wrap it in a binary web socket frame before letting the wsencoder send it on the wire future.channel().pipeline().addAfter("wsencoder", "binary-websocket-encoder", BINARY_WEBSOCKET_ENCODER); - } - else { + } else { // Handshake failed, fire an exceptionCaught event future.channel().pipeline().fireExceptionCaught(future.cause()); } @@ -115,12 +112,10 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler if (frame instanceof CloseWebSocketFrame) { this.handshaker.close(ctx.channel(), ((CloseWebSocketFrame) frame).retain()); return false; - } - else if (frame instanceof PingWebSocketFrame) { + } else if (frame instanceof PingWebSocketFrame) { ctx.writeAndFlush(new PongWebSocketFrame(frame.content().retain())); return false; - } - else if (!(frame instanceof TextWebSocketFrame) && !(frame instanceof BinaryWebSocketFrame)) { + } else if (!(frame instanceof TextWebSocketFrame) && !(frame instanceof BinaryWebSocketFrame)) { throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass().getName())); } return true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadCallback.java index cc4f5df866..cd5bd043bf 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadCallback.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadCallback.java @@ -20,5 +20,6 @@ package org.apache.activemq.artemis.core.server.reload; import java.net.URL; public interface ReloadCallback { + void reload(URL uri) throws Exception; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManager.java index 0dfe6a76b6..497a584b0e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManager.java @@ -22,8 +22,11 @@ import java.net.URL; import org.apache.activemq.artemis.core.server.ActiveMQComponent; public interface ReloadManager extends ActiveMQComponent { + void addCallback(URL uri, ReloadCallback callback); - /** Callback for the next tick */ + /** + * Callback for the next tick + */ void setTick(Runnable callback); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java index fd4929ebc6..a8c8b69abc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java @@ -31,7 +31,8 @@ import org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.jboss.logging.Logger; -public class ReloadManagerImpl extends ActiveMQScheduledComponent implements ReloadManager { +public class ReloadManagerImpl extends ActiveMQScheduledComponent implements ReloadManager { + private static final Logger logger = Logger.getLogger(ReloadManagerImpl.class); private volatile Runnable tick; @@ -83,6 +84,7 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel } class ReloadRegistry { + private final File file; private final URL uri; private long lastModified; @@ -95,7 +97,7 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel this.uri = uri; } - public void check() { + public void check() { long fileModified = file.lastModified(); @@ -108,8 +110,7 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel for (ReloadCallback callback : callbacks) { try { callback.reload(uri); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.configurationReloadFailed(e); } } @@ -118,7 +119,6 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel this.lastModified = fileModified; } - public List getCallbacks() { return callbacks; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java index f5f00f77f7..0d14c7cd64 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java @@ -482,8 +482,7 @@ public class AddressSettings implements Mergeable, Serializable if (policyStr != null) { addressFullMessagePolicy = AddressFullMessagePolicy.valueOf(policyStr.toString()); - } - else { + } else { addressFullMessagePolicy = null; } @@ -525,8 +524,7 @@ public class AddressSettings implements Mergeable, Serializable if (policyStr != null) { slowConsumerPolicy = SlowConsumerPolicy.valueOf(policyStr.toString()); - } - else { + } else { slowConsumerPolicy = null; } @@ -677,161 +675,135 @@ public class AddressSettings implements Mergeable, Serializable if (addressFullMessagePolicy == null) { if (other.addressFullMessagePolicy != null) return false; - } - else if (!addressFullMessagePolicy.equals(other.addressFullMessagePolicy)) + } else if (!addressFullMessagePolicy.equals(other.addressFullMessagePolicy)) return false; if (deadLetterAddress == null) { if (other.deadLetterAddress != null) return false; - } - else if (!deadLetterAddress.equals(other.deadLetterAddress)) + } else if (!deadLetterAddress.equals(other.deadLetterAddress)) return false; if (dropMessagesWhenFull == null) { if (other.dropMessagesWhenFull != null) return false; - } - else if (!dropMessagesWhenFull.equals(other.dropMessagesWhenFull)) + } else if (!dropMessagesWhenFull.equals(other.dropMessagesWhenFull)) return false; if (expiryAddress == null) { if (other.expiryAddress != null) return false; - } - else if (!expiryAddress.equals(other.expiryAddress)) + } else if (!expiryAddress.equals(other.expiryAddress)) return false; if (expiryDelay == null) { if (other.expiryDelay != null) return false; - } - else if (!expiryDelay.equals(other.expiryDelay)) + } else if (!expiryDelay.equals(other.expiryDelay)) return false; if (lastValueQueue == null) { if (other.lastValueQueue != null) return false; - } - else if (!lastValueQueue.equals(other.lastValueQueue)) + } else if (!lastValueQueue.equals(other.lastValueQueue)) return false; if (maxDeliveryAttempts == null) { if (other.maxDeliveryAttempts != null) return false; - } - else if (!maxDeliveryAttempts.equals(other.maxDeliveryAttempts)) + } else if (!maxDeliveryAttempts.equals(other.maxDeliveryAttempts)) return false; if (maxSizeBytes == null) { if (other.maxSizeBytes != null) return false; - } - else if (!maxSizeBytes.equals(other.maxSizeBytes)) + } else if (!maxSizeBytes.equals(other.maxSizeBytes)) return false; if (messageCounterHistoryDayLimit == null) { if (other.messageCounterHistoryDayLimit != null) return false; - } - else if (!messageCounterHistoryDayLimit.equals(other.messageCounterHistoryDayLimit)) + } else if (!messageCounterHistoryDayLimit.equals(other.messageCounterHistoryDayLimit)) return false; if (pageSizeBytes == null) { if (other.pageSizeBytes != null) return false; - } - else if (!pageSizeBytes.equals(other.pageSizeBytes)) + } else if (!pageSizeBytes.equals(other.pageSizeBytes)) return false; if (pageMaxCache == null) { if (other.pageMaxCache != null) return false; - } - else if (!pageMaxCache.equals(other.pageMaxCache)) + } else if (!pageMaxCache.equals(other.pageMaxCache)) return false; if (redeliveryDelay == null) { if (other.redeliveryDelay != null) return false; - } - else if (!redeliveryDelay.equals(other.redeliveryDelay)) + } else if (!redeliveryDelay.equals(other.redeliveryDelay)) return false; if (redeliveryMultiplier == null) { if (other.redeliveryMultiplier != null) return false; - } - else if (!redeliveryMultiplier.equals(other.redeliveryMultiplier)) + } else if (!redeliveryMultiplier.equals(other.redeliveryMultiplier)) return false; if (maxRedeliveryDelay == null) { if (other.maxRedeliveryDelay != null) return false; - } - else if (!maxRedeliveryDelay.equals(other.maxRedeliveryDelay)) + } else if (!maxRedeliveryDelay.equals(other.maxRedeliveryDelay)) return false; if (redistributionDelay == null) { if (other.redistributionDelay != null) return false; - } - else if (!redistributionDelay.equals(other.redistributionDelay)) + } else if (!redistributionDelay.equals(other.redistributionDelay)) return false; if (sendToDLAOnNoRoute == null) { if (other.sendToDLAOnNoRoute != null) return false; - } - else if (!sendToDLAOnNoRoute.equals(other.sendToDLAOnNoRoute)) + } else if (!sendToDLAOnNoRoute.equals(other.sendToDLAOnNoRoute)) return false; if (slowConsumerThreshold == null) { if (other.slowConsumerThreshold != null) return false; - } - else if (!slowConsumerThreshold.equals(other.slowConsumerThreshold)) + } else if (!slowConsumerThreshold.equals(other.slowConsumerThreshold)) return false; if (slowConsumerCheckPeriod == null) { if (other.slowConsumerCheckPeriod != null) return false; - } - else if (!slowConsumerCheckPeriod.equals(other.slowConsumerCheckPeriod)) + } else if (!slowConsumerCheckPeriod.equals(other.slowConsumerCheckPeriod)) return false; if (slowConsumerPolicy == null) { if (other.slowConsumerPolicy != null) return false; - } - else if (!slowConsumerPolicy.equals(other.slowConsumerPolicy)) + } else if (!slowConsumerPolicy.equals(other.slowConsumerPolicy)) return false; if (autoCreateJmsQueues == null) { if (other.autoCreateJmsQueues != null) return false; - } - else if (!autoCreateJmsQueues.equals(other.autoCreateJmsQueues)) + } else if (!autoCreateJmsQueues.equals(other.autoCreateJmsQueues)) return false; if (autoDeleteJmsQueues == null) { if (other.autoDeleteJmsQueues != null) return false; - } - else if (!autoDeleteJmsQueues.equals(other.autoDeleteJmsQueues)) + } else if (!autoDeleteJmsQueues.equals(other.autoDeleteJmsQueues)) return false; if (autoCreateJmsTopics == null) { if (other.autoCreateJmsTopics != null) return false; - } - else if (!autoCreateJmsTopics.equals(other.autoCreateJmsTopics)) + } else if (!autoCreateJmsTopics.equals(other.autoCreateJmsTopics)) return false; if (autoDeleteJmsTopics == null) { if (other.autoDeleteJmsTopics != null) return false; - } - else if (!autoDeleteJmsTopics.equals(other.autoDeleteJmsTopics)) + } else if (!autoDeleteJmsTopics.equals(other.autoDeleteJmsTopics)) return false; if (managementBrowsePageSize == null) { if (other.managementBrowsePageSize != null) return false; - } - else if (!managementBrowsePageSize.equals(other.managementBrowsePageSize)) + } else if (!managementBrowsePageSize.equals(other.managementBrowsePageSize)) return false; if (queuePrefetch == null) { if (other.queuePrefetch != null) return false; - } - else if (!queuePrefetch.equals(other.queuePrefetch)) + } else if (!queuePrefetch.equals(other.queuePrefetch)) return false; if (maxSizeBytesRejectThreshold == null) { if (other.maxSizeBytesRejectThreshold != null) return false; - } - else if (!maxSizeBytesRejectThreshold.equals(other.maxSizeBytesRejectThreshold)) + } else if (!maxSizeBytesRejectThreshold.equals(other.maxSizeBytesRejectThreshold)) return false; return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java index 6e032d191c..1d648ed89f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java @@ -99,8 +99,7 @@ public class HierarchicalObjectRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository match1 = new Match<>(match); match1.setValue(value); matches.put(match, match1); - } - finally { + } finally { lock.writeLock().unlock(); } @@ -201,8 +197,7 @@ public class HierarchicalObjectRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository entry : entries) { addMatch(entry.getKey(), entry.getValue(), true, false); } - } - finally { + } finally { lock.writeLock().unlock(); } @@ -358,14 +346,12 @@ public class HierarchicalObjectRepository implements HierarchicalRepository implements HierarchicalRepository implements HierarchicalRepository { // replace any regex characters if (Match.WILDCARD.equals(match)) { actMatch = Match.WILDCARD_REPLACEMENT; - } - else { + } else { // this is to match with what's documented actMatch = actMatch.replace(DOT_WILDCARD, WILDCARD); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/ResourceLimitSettings.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/ResourceLimitSettings.java index 843e09006f..4e6c418749 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/ResourceLimitSettings.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/ResourceLimitSettings.java @@ -17,13 +17,13 @@ package org.apache.activemq.artemis.core.settings.impl; +import java.io.Serializable; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.utils.BufferHelper; -import java.io.Serializable; - public class ResourceLimitSettings implements Serializable, EncodingSupport { private static final long serialVersionUID = -110638321333856932L; @@ -158,4 +158,4 @@ public class ResourceLimitSettings implements Serializable, EncodingSupport { // queueNameRegex + "]"; } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/ResourceManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/ResourceManager.java index 5f4b240f86..20bdb5b3bd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/ResourceManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/ResourceManager.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.core.transaction; +import javax.transaction.xa.Xid; import java.util.List; import java.util.Map; -import javax.transaction.xa.Xid; - import org.apache.activemq.artemis.core.server.ActiveMQComponent; public interface ResourceManager extends ActiveMQComponent { @@ -47,5 +46,4 @@ public interface ResourceManager extends ActiveMQComponent { List getInDoubtTransactions(); - } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/Transaction.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/Transaction.java index 69ddae6f52..0ddc2cb564 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/Transaction.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/Transaction.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.core.transaction; -import java.util.List; - import javax.transaction.xa.Xid; +import java.util.List; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.server.Queue; @@ -35,8 +34,10 @@ public interface Transaction { Object getProtocolData(); - /** Protocol managers can use this field to store any object needed. - * An example would be the Session used by the transaction on openwire */ + /** + * Protocol managers can use this field to store any object needed. + * An example would be the Session used by the transaction on openwire + */ void setProtocolData(Object data); boolean isEffective(); @@ -67,17 +68,21 @@ public interface Transaction { void addOperation(TransactionOperation sync); - /** This is an operation that will be called right after the storage is completed. - * addOperation could only happen after paging and replication, while these operations will just be - * about the storage*/ + /** + * This is an operation that will be called right after the storage is completed. + * addOperation could only happen after paging and replication, while these operations will just be + * about the storage + */ void afterStore(TransactionOperation sync); List getAllOperations(); boolean hasTimedOut(long currentTime, int defaultTimeout); - /** To validate if the Transaction had previously timed out. - * This is to check the reason why a TX has been rolled back. */ + /** + * To validate if the Transaction had previously timed out. + * This is to check the reason why a TX has been rolled back. + */ boolean hasTimedOut(); void putProperty(int index, Object property); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java index 73b6bb317e..efe4cf9ea5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.core.transaction; -import java.text.DateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; - import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.transaction.xa.Xid; +import java.text.DateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.core.server.MessageReference; @@ -66,12 +65,7 @@ public abstract class TransactionDetail { public JsonObject toJSON() throws Exception { DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); - JsonObjectBuilder detailJson = JsonLoader.createObjectBuilder() - .add(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime))) - .add(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid)) - .add(KEY_XID_FORMAT_ID, this.xid.getFormatId()) - .add(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId())) - .add(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier())); + JsonObjectBuilder detailJson = JsonLoader.createObjectBuilder().add(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime))).add(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid)).add(KEY_XID_FORMAT_ID, this.xid.getFormatId()).add(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId())).add(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier())); JsonArrayBuilder msgsJson = JsonLoader.createArrayBuilder(); @@ -89,8 +83,7 @@ public abstract class TransactionDetail { String opType = null; if (opClassName.equals("org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl$AddOperation")) { opType = "(+) send"; - } - else if (opClassName.equals("org.apache.activemq.artemis.core.server.impl.QueueImpl$RefsOperation")) { + } else if (opClassName.equals("org.apache.activemq.artemis.core.server.impl.QueueImpl$RefsOperation")) { opType = "(-) receive"; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java index 6683882aca..47305961ad 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.core.transaction.impl; -import java.util.Map; - import javax.transaction.xa.Xid; +import java.util.Map; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.core.server.ServerMessage; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java index ff415159d5..3ff73d7af8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java @@ -213,8 +213,7 @@ public class ResourceManagerImpl implements ResourceManager { for (Transaction failedTransaction : timedoutTransactions) { try { failedTransaction.rollback(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorTimingOutTX(e, failedTransaction.getXid()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java index 44e626a7dd..cc2fa22571 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java @@ -165,8 +165,7 @@ public class TransactionImpl implements Transaction { boolean timedout; if (timeoutSeconds == -1) { timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + defaultTimeout * 1000; - } - else { + } else { timedout = getState() != Transaction.State.PREPARED && currentTime > createTime + timeoutSeconds * 1000; } @@ -204,13 +203,11 @@ public class TransactionImpl implements Transaction { if (exception != null) { throw exception; - } - else { + } else { // Do nothing return; } - } - else if (state != State.ACTIVE) { + } else if (state != State.ACTIVE) { throw new IllegalStateException("Transaction is in invalid state " + state); } @@ -239,8 +236,7 @@ public class TransactionImpl implements Transaction { } }); } - } - finally { + } finally { storageManager.readUnLock(); } } @@ -266,8 +262,7 @@ public class TransactionImpl implements Transaction { if (exception != null) { throw exception; - } - else { + } else { // Do nothing return; } @@ -277,8 +272,7 @@ public class TransactionImpl implements Transaction { if (onePhase && state != State.ACTIVE || !onePhase && state != State.PREPARED) { throw new ActiveMQIllegalStateException("Transaction is in invalid state " + state); } - } - else { + } else { if (state != State.ACTIVE) { throw new ActiveMQIllegalStateException("Transaction is in invalid state " + state); } @@ -361,8 +355,7 @@ public class TransactionImpl implements Transaction { if (state != State.PREPARED && state != State.ACTIVE && state != State.ROLLBACK_ONLY) { throw new ActiveMQIllegalStateException("Transaction is in invalid state " + state); } - } - else { + } else { if (state != State.ACTIVE && state != State.ROLLBACK_ONLY) { throw new ActiveMQIllegalStateException("Transaction is in invalid state " + state); } @@ -382,8 +375,7 @@ public class TransactionImpl implements Transaction { try { doRollback(); state = State.ROLLEDBACK; - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Something happened before and the TX didn't make to the Journal / Storage // We will like to execute afterRollback and clear anything pending ActiveMQServerLogger.LOGGER.warn(e); @@ -491,7 +483,6 @@ public class TransactionImpl implements Transaction { operations.add(operation); } - @Override public synchronized void afterStore(TransactionOperation sync) { if (storeOperations == null) { @@ -511,8 +502,7 @@ public class TransactionImpl implements Transaction { if (operations != null) { return new ArrayList<>(operations); - } - else { + } else { return new ArrayList<>(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManager.java index ddefe86644..6ce2518cf9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManager.java @@ -19,25 +19,21 @@ package org.apache.activemq.artemis.spi.core.protocol; +import java.util.List; + import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; -import java.util.List; +public abstract class AbstractProtocolManager, C extends RemotingConnection> implements ProtocolManager { -public abstract class AbstractProtocolManager, C extends RemotingConnection> - implements ProtocolManager { - - protected void invokeInterceptors(final List interceptors, - final P message, - final C connection) { + protected void invokeInterceptors(final List interceptors, final P message, final C connection) { if (interceptors != null && !interceptors.isEmpty()) { for (I interceptor : interceptors) { try { if (!interceptor.intercept(message, connection)) { break; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.error(e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java index fcca774cec..10fb249eef 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java @@ -37,8 +37,7 @@ public abstract class AbstractProtocolManagerFactory

protected List

internalFilterInterceptors(Class

type, List listIn) { if (listIn == null) { return Collections.emptyList(); - } - else { + } else { CopyOnWriteArrayList

listOut = new CopyOnWriteArrayList<>(); for (BaseInterceptor in : listIn) { if (type.isInstance(in)) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java index 3d5be393fc..a7e50d509b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java @@ -55,9 +55,11 @@ public interface ProtocolManager

{ */ MessageConverter getConverter(); - /** If this protocols accepts connectoins without an initial handshake. - * If true this protocol will be the failback case no other connections are made. - * New designed protocols should always require a handshake. This is only useful for legacy protocols. */ + /** + * If this protocols accepts connectoins without an initial handshake. + * If true this protocol will be the failback case no other connections are made. + * New designed protocols should always require a handshake. This is only useful for legacy protocols. + */ boolean acceptsNoHandshake(); void handshake(NettyServerConnection connection, ActiveMQBuffer buffer); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java index 9f23f802d0..891f1adad8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java @@ -29,13 +29,16 @@ public interface SessionCallback { */ boolean hasCredits(ServerConsumer consumerID); - /** This can be used to complete certain operations outside of the lock, - * like acks or other operations. */ + /** + * This can be used to complete certain operations outside of the lock, + * like acks or other operations. + */ void afterDelivery() throws Exception; /** * Use this to updates specifics on the message after a redelivery happened. * Return true if there was specific logic applied on the protocol, so the ServerConsumer won't make any adjustments. + * * @param consumer * @param ref * @param failed @@ -54,7 +57,11 @@ public interface SessionCallback { // Future developments may change this, but beware why I have chosen to keep the parameter separated here int sendMessage(MessageReference ref, ServerMessage message, ServerConsumer consumerID, int deliveryCount); - int sendLargeMessage(MessageReference reference, ServerMessage message, ServerConsumer consumerID, long bodySize, int deliveryCount); + int sendLargeMessage(MessageReference reference, + ServerMessage message, + ServerConsumer consumerID, + long bodySize, + int deliveryCount); int sendLargeMessageContinuation(ServerConsumer consumerID, byte[] body, @@ -67,6 +74,8 @@ public interface SessionCallback { boolean isWritable(ReadyListener callback); - /** Some protocols (Openwire) needs a special message with the browser is finished. */ + /** + * Some protocols (Openwire) needs a special message with the browser is finished. + */ void browserFinished(ServerConsumer consumer); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Acceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Acceptor.java index c0da381d46..2468c81c92 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Acceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Acceptor.java @@ -31,8 +31,10 @@ import org.apache.activemq.artemis.core.server.management.NotificationService; */ public interface Acceptor extends ActiveMQComponent { - /** The name of the acceptor used on the configuration. - * for logging and debug purposes. */ + /** + * The name of the acceptor used on the configuration. + * for logging and debug purposes. + */ String getName(); /** @@ -42,8 +44,8 @@ public interface Acceptor extends ActiveMQComponent { /** * This will update the list of interceptors for each ProtocolManager inside the acceptor. - * */ - void updateInterceptors(List incomingInterceptors, List outgoingInterceptors); + */ + void updateInterceptors(List incomingInterceptors, List outgoingInterceptors); /** * @return the cluster connection associated with this Acceptor diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java index 7e3c8fdb04..4668d0d552 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java @@ -19,4 +19,5 @@ package org.apache.activemq.artemis.spi.core.remoting; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager; public interface ServerConnectionLifeCycleListener extends BaseConnectionLifeCycleListener { + } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java index 943851ece0..26c88b27c2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java @@ -73,7 +73,10 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { this.configuration = configuration; } - public ActiveMQJAASSecurityManager(String configurationName, String certificateConfigurationName, SecurityConfiguration configuration, SecurityConfiguration certificateConfiguration) { + public ActiveMQJAASSecurityManager(String configurationName, + String certificateConfigurationName, + SecurityConfiguration configuration, + SecurityConfiguration certificateConfiguration) { this.configurationName = configurationName; this.configuration = configuration; this.certificateConfigurationName = certificateConfigurationName; @@ -89,8 +92,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { public String validateUser(final String user, final String password, X509Certificate[] certificates) { try { return getUserFromSubject(getAuthenticatedSubject(user, password, certificates)); - } - catch (LoginException e) { + } catch (LoginException e) { if (logger.isDebugEnabled()) { logger.debug("Couldn't validate user", e); } @@ -116,11 +118,11 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { @Override public String validateUserAndRole(final String user, - final String password, - final Set roles, - final CheckType checkType, - final String address, - final RemotingConnection connection) { + final String password, + final Set roles, + final CheckType checkType, + final String address, + final RemotingConnection connection) { X509Certificate[] certificates = null; if (connection != null && connection.getTransportConnection() instanceof NettyConnection) { certificates = CertificateUtil.getCertsFromChannel(((NettyConnection) connection.getTransportConnection()).getChannel()); @@ -128,8 +130,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { Subject localSubject; try { localSubject = getAuthenticatedSubject(user, password, certificates); - } - catch (LoginException e) { + } catch (LoginException e) { if (logger.isDebugEnabled()) { logger.debug("Couldn't validate user", e); } @@ -145,8 +146,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { Set rolesForSubject = new HashSet<>(); try { rolesForSubject.addAll(localSubject.getPrincipals(Class.forName(rolePrincipalClass).asSubclass(Principal.class))); - } - catch (Exception e) { + } catch (Exception e) { logger.info("Can't find roles for the subject", e); } if (rolesForSubject.size() > 0 && rolesWithPermission.size() > 0) { @@ -168,18 +168,18 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { if (authorized) { return getUserFromSubject(localSubject); - } - else { + } else { return null; } } - private Subject getAuthenticatedSubject(final String user, final String password, final X509Certificate[] certificates) throws LoginException { + private Subject getAuthenticatedSubject(final String user, + final String password, + final X509Certificate[] certificates) throws LoginException { LoginContext lc; if (certificateConfigurationName != null && certificateConfigurationName.length() > 0 && certificates != null) { lc = new LoginContext(certificateConfigurationName, null, new JaasCallbackHandler(user, password, certificates), certificateConfiguration); - } - else { + } else { lc = new LoginContext(configurationName, null, new JaasCallbackHandler(user, password, certificates), configuration); } lc.login(); @@ -192,8 +192,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { if (checkType.hasRole(role)) { try { principals.add(createGroupPrincipal(role.getName(), rolePrincipalClass)); - } - catch (Exception e) { + } catch (Exception e) { logger.info("Can't add role principal", e); } } @@ -276,8 +275,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { } if (i < constructors.length) { instance = constructors[i].newInstance(param); - } - else { + } else { instance = cls.newInstance(); Method[] methods = cls.getMethods(); i = 0; @@ -290,8 +288,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager3 { if (i < methods.length) { methods[i].invoke(instance, param); - } - else { + } else { throw new NoSuchMethodException(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager2.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager2.java index e44a785e18..fa340e00fa 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager2.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager2.java @@ -52,13 +52,18 @@ public interface ActiveMQSecurityManager2 extends ActiveMQSecurityManager { * This method is called instead of * {@link ActiveMQSecurityManager#validateUserAndRole(String, String, Set, CheckType)}. * - * @param user the user - * @param password the user's password - * @param roles the user's roles - * @param checkType which permission to validate - * @param address the address for which to perform authorization - * @param connection the user's connection + * @param user the user + * @param password the user's password + * @param roles the user's roles + * @param checkType which permission to validate + * @param address the address for which to perform authorization + * @param connection the user's connection * @return true if the user is valid and they have the correct roles for the given destination address */ - boolean validateUserAndRole(String user, String password, Set roles, CheckType checkType, String address, RemotingConnection connection); + boolean validateUserAndRole(String user, + String password, + Set roles, + CheckType checkType, + String address, + RemotingConnection connection); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager3.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager3.java index 192f5dd402..d565da48e4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager3.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManager3.java @@ -52,13 +52,18 @@ public interface ActiveMQSecurityManager3 extends ActiveMQSecurityManager { * This method is called instead of * {@link ActiveMQSecurityManager#validateUserAndRole(String, String, Set, CheckType)}. * - * @param user the user - * @param password the user's password - * @param roles the user's roles - * @param checkType which permission to validate - * @param address the address for which to perform authorization - * @param connection the user's connection + * @param user the user + * @param password the user's password + * @param roles the user's roles + * @param checkType which permission to validate + * @param address the address for which to perform authorization + * @param connection the user's connection * @return the name of the validated user or null if the user isn't validated */ - String validateUserAndRole(String user, String password, Set roles, CheckType checkType, String address, RemotingConnection connection); + String validateUserAndRole(String user, + String password, + Set roles, + CheckType checkType, + String address, + RemotingConnection connection); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java index def688f973..4aff8e2f3e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java @@ -51,11 +51,9 @@ public class ActiveMQSecurityManagerImpl implements ActiveMQSecurityManager { if (username != null) { User user = configuration.getUser(username); return user != null && user.isValid(username, password); - } - else if (password == null) { + } else if (password == null) { return configuration.getDefaultUser() != null; - } - else { // the only possible case here is user == null, password != null + } else { // the only possible case here is user == null, password != null logger.debug("Validating default user against a provided password. This happens when username=null, password!=null"); String defaultUsername = configuration.getDefaultUser(); User defaultUser = configuration.getUser(defaultUsername); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java index 0037e67363..9c100588a3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java @@ -52,7 +52,10 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements * Overriding to allow for proper initialization. Standard JAAS. */ @Override - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { this.subject = subject; this.callbackHandler = callbackHandler; @@ -69,11 +72,9 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements callbacks[0] = new CertificateCallback(); try { callbackHandler.handle(callbacks); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); - } - catch (UnsupportedCallbackException uce) { + } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " Unable to obtain client certificates."); } certificates = ((CertificateCallback) callbacks[0]).getCertificates(); @@ -168,8 +169,7 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements protected String getDistinguishedName(final X509Certificate[] certs) { if (certs != null && certs.length > 0 && certs[0] != null) { return certs[0].getSubjectDN().getName(); - } - else { + } else { return null; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java index 22fdb7efa3..5907b27675 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java @@ -36,7 +36,6 @@ import org.jboss.logging.Logger; * * Useful for unauthenticated communication channels being used in the * same broker as authenticated ones. - * */ public class GuestLoginModule implements LoginModule { @@ -55,7 +54,10 @@ public class GuestLoginModule implements LoginModule { private boolean loginSucceeded; @Override - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { this.subject = subject; this.callbackHandler = callbackHandler; debug = "true".equalsIgnoreCase((String) options.get("debug")); @@ -89,8 +91,7 @@ public class GuestLoginModule implements LoginModule { loginSucceeded = false; passwordCallback.clearPassword(); } - } - catch (IOException | UnsupportedCallbackException e) { + } catch (IOException | UnsupportedCallbackException e) { } } if (debug) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java index 9aa656c59f..f1347fb7b7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java @@ -49,7 +49,10 @@ public class InVMLoginModule implements LoginModule { private boolean loginSucceeded; @Override - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { this.subject = subject; this.callbackHandler = callbackHandler; this.configuration = (SecurityConfiguration) options.get(CONFIG_PROP_NAME); @@ -63,11 +66,9 @@ public class InVMLoginModule implements LoginModule { callbacks[1] = new PasswordCallback("Password: ", false); try { callbackHandler.handle(callbacks); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); - } - catch (UnsupportedCallbackException uce) { + } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " not available to obtain information from user"); } user = ((NameCallback) callbacks[0]).getName(); @@ -78,12 +79,10 @@ public class InVMLoginModule implements LoginModule { if (user == null) { if (configuration.getDefaultUser() == null) { throw new FailedLoginException("Both username and defaultUser are null"); - } - else { + } else { user = configuration.getDefaultUser(); } - } - else { + } else { String password = configuration.getUser(user) == null ? null : configuration.getUser(user).getPassword(); if (password == null) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java index 97beffab8c..ca4edbef99 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java @@ -46,26 +46,21 @@ public class JaasCallbackHandler implements CallbackHandler { PasswordCallback passwordCallback = (PasswordCallback) callback; if (password == null) { passwordCallback.setPassword(null); - } - else { + } else { passwordCallback.setPassword(password.toCharArray()); } - } - else if (callback instanceof NameCallback) { + } else if (callback instanceof NameCallback) { NameCallback nameCallback = (NameCallback) callback; if (username == null) { nameCallback.setName(null); - } - else { + } else { nameCallback.setName(username); } - } - else if (callback instanceof CertificateCallback) { + } else if (callback instanceof CertificateCallback) { CertificateCallback certCallback = (CertificateCallback) callback; certCallback.setCertificates(certificates); - } - else { + } else { throw new UnsupportedCallbackException(callback); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java index df5c7d516b..5c2343a3a2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java @@ -85,7 +85,10 @@ public class LDAPLoginModule implements LoginModule { private final Set groups = new HashSet<>(); @Override - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { this.subject = subject; this.handler = callbackHandler; @@ -101,8 +104,7 @@ public class LDAPLoginModule implements LoginModule { callbacks[1] = new PasswordCallback("Password", false); try { handler.handle(callbacks); - } - catch (IOException | UnsupportedCallbackException e) { + } catch (IOException | UnsupportedCallbackException e) { throw (LoginException) new LoginException().initCause(e); } @@ -150,8 +152,7 @@ public class LDAPLoginModule implements LoginModule { try { context.close(); context = null; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.error(e.toString()); } } @@ -167,8 +168,7 @@ public class LDAPLoginModule implements LoginModule { } try { openContext(); - } - catch (NamingException ne) { + } catch (NamingException ne) { FailedLoginException ex = new FailedLoginException("Error opening LDAP connection"); ex.initCause(ne); throw ex; @@ -186,8 +186,7 @@ public class LDAPLoginModule implements LoginModule { SearchControls constraints = new SearchControls(); if (userSearchSubtreeBool) { constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); - } - else { + } else { constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE); } @@ -231,8 +230,7 @@ public class LDAPLoginModule implements LoginModule { Name name = contextName.addAll(baseName); name = name.addAll(entryName); dn = name.toString(); - } - else { + } else { logger.debug("LDAP returned an absolute name: " + result.getName()); try { @@ -241,12 +239,10 @@ public class LDAPLoginModule implements LoginModule { if (path.startsWith("/")) { dn = path.substring(1); - } - else { + } else { dn = path; } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error parsing absolute name as URI."); ex.initCause(e); @@ -277,18 +273,15 @@ public class LDAPLoginModule implements LoginModule { for (String role : roles) { groups.add(new RolePrincipal(role)); } - } - else { + } else { throw new FailedLoginException("Password does not match for user: " + username); } - } - catch (CommunicationException e) { + } catch (CommunicationException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; - } - catch (NamingException e) { + } catch (NamingException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); @@ -321,8 +314,7 @@ public class LDAPLoginModule implements LoginModule { SearchControls constraints = new SearchControls(); if (roleSearchSubtreeBool) { constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); - } - else { + } else { constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE); } if (logger.isDebugEnabled()) { @@ -409,8 +401,7 @@ public class LDAPLoginModule implements LoginModule { if (logger.isDebugEnabled()) { logger.debug("User " + dn + " successfully bound."); } - } - catch (AuthenticationException e) { + } catch (AuthenticationException e) { isValid = false; if (logger.isDebugEnabled()) { logger.debug("Authentication failed for dn=" + dn); @@ -419,14 +410,12 @@ public class LDAPLoginModule implements LoginModule { if (isLoginPropertySet(CONNECTION_USERNAME)) { context.addToEnvironment(Context.SECURITY_PRINCIPAL, getLDAPPropertyValue(CONNECTION_USERNAME)); - } - else { + } else { context.removeFromEnvironment(Context.SECURITY_PRINCIPAL); } if (isLoginPropertySet(CONNECTION_PASSWORD)) { context.addToEnvironment(Context.SECURITY_CREDENTIALS, getLDAPPropertyValue(CONNECTION_PASSWORD)); - } - else { + } else { context.removeFromEnvironment(Context.SECURITY_CREDENTIALS); } @@ -462,15 +451,13 @@ public class LDAPLoginModule implements LoginModule { env.put(Context.INITIAL_CONTEXT_FACTORY, getLDAPPropertyValue(INITIAL_CONTEXT_FACTORY)); if (isLoginPropertySet(CONNECTION_USERNAME)) { env.put(Context.SECURITY_PRINCIPAL, getLDAPPropertyValue(CONNECTION_USERNAME)); - } - else { + } else { throw new NamingException("Empty username is not allowed"); } if (isLoginPropertySet(CONNECTION_PASSWORD)) { env.put(Context.SECURITY_CREDENTIALS, getLDAPPropertyValue(CONNECTION_PASSWORD)); - } - else { + } else { throw new NamingException("Empty password is not allowed"); } env.put(Context.SECURITY_PROTOCOL, getLDAPPropertyValue(CONNECTION_PROTOCOL)); @@ -478,8 +465,7 @@ public class LDAPLoginModule implements LoginModule { env.put(Context.SECURITY_AUTHENTICATION, getLDAPPropertyValue(AUTHENTICATION)); context = new InitialDirContext(env); - } - catch (NamingException e) { + } catch (NamingException e) { closeContext(); ActiveMQServerLogger.LOGGER.error(e.toString()); throw e; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java index 863b021e4a..0a07658c61 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java @@ -106,8 +106,7 @@ public class PropertiesLoader { File baseDir = null; if (options.get("baseDir") != null) { baseDir = new File((String) options.get("baseDir")); - } - else { + } else { if (System.getProperty("java.security.auth.login.config") != null) { baseDir = new File(System.getProperty("java.security.auth.login.config")).getParentFile(); } @@ -138,4 +137,4 @@ public class PropertiesLoader { public static void resetUsersAndGroupsCache() { staticCache.clear(); } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java index 709c510dfe..d120a98a28 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java @@ -45,7 +45,7 @@ public class PropertiesLoginModule extends PropertiesLoader implements LoginModu private CallbackHandler callbackHandler; private Properties users; - private Map> roles; + private Map> roles; private String user; private final Set principals = new HashSet<>(); private boolean loginSucceeded; @@ -72,11 +72,9 @@ public class PropertiesLoginModule extends PropertiesLoader implements LoginModu callbacks[1] = new PasswordCallback("Password: ", false); try { callbackHandler.handle(callbacks); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); - } - catch (UnsupportedCallbackException uce) { + } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " not available to obtain information from user"); } user = ((NameCallback) callbacks[0]).getName(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java index 77a99d9913..66ba1a5b13 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java @@ -56,8 +56,7 @@ public class ReloadableProperties { if (key.isDebug()) { logger.debug("Load of: " + key); } - } - catch (IOException e) { + } catch (IOException e) { ActiveMQServerLogger.LOGGER.error("Failed to load: " + key + ", reason:" + e.getLocalizedMessage()); if (key.isDebug()) { logger.debug("Load of: " + key + ", failure exception" + e); @@ -82,22 +81,21 @@ public class ReloadableProperties { if (invertedValueProps == null) { invertedValueProps = new HashMap<>(props.size()); for (Map.Entry val : props.entrySet()) { - String[] userList = ((String)val.getValue()).split(","); + String[] userList = ((String) val.getValue()).split(","); for (String user : userList) { Set set = invertedValueProps.get(user); if (set == null) { set = new HashSet<>(); invertedValueProps.put(user, set); } - set.add((String)val.getKey()); + set.add((String) val.getKey()); } } } return invertedValueProps; } - private void load(final File source, - Properties props) throws IOException { + private void load(final File source, Properties props) throws IOException { try (FileInputStream in = new FileInputStream(source)) { props.load(in); // if (key.isDecrypt()) { @@ -117,4 +115,4 @@ public class ReloadableProperties { return key.file.lastModified() > reloadTime; } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/TextFileCertificateLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/TextFileCertificateLoginModule.java index 45a121174b..478bbf748f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/TextFileCertificateLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/TextFileCertificateLoginModule.java @@ -47,7 +47,10 @@ public class TextFileCertificateLoginModule extends CertificateLoginModule { * Performs initialization of file paths. A standard JAAS override. */ @Override - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { super.initialize(subject, callbackHandler, sharedState, options); usersByDn = load(USER_FILE_PROP_NAME, "", options).invertedPropertiesMap(); rolesByUser = load(ROLE_FILE_PROP_NAME, "", options).invertedPropertiesValuesMap(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationParser.java index e6637dee3c..96128c09f0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationParser.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, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/acceptor/TCPAcceptorTransportConfigurationSchema.java b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/acceptor/TCPAcceptorTransportConfigurationSchema.java index ed92ac383f..683b3ae969 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/acceptor/TCPAcceptorTransportConfigurationSchema.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/acceptor/TCPAcceptorTransportConfigurationSchema.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.uri.schemas.acceptor; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; -import org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfigurationSchema; - import java.net.URI; import java.util.Set; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; +import org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfigurationSchema; + public class TCPAcceptorTransportConfigurationSchema extends TCPTransportConfigurationSchema { public TCPAcceptorTransportConfigurationSchema(Set allowableProperties) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java index b465be43a2..a27e7a646c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.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, @@ -37,8 +37,7 @@ public class ClusterConnectionMulticastSchema extends ClusterConnectionStaticSch if (URISupport.isCompositeURI(uri)) { super.populateObject(uri, bean); - } - else { + } else { bean.setDiscoveryGroupName(uri.getHost()); Map parameters = URISupport.parseParameters(uri); BeanSupport.setData(uri, bean, parameters); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java index 0f62d264a8..cb7ada5bb3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.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, @@ -37,7 +37,6 @@ public class ClusterConnectionStaticSchema extends URISchema query, String param) throws Exception { - ClusterConnectionConfiguration configuration = new ClusterConnectionConfiguration(); populateObject(uri, configuration); @@ -45,7 +44,6 @@ public class ClusterConnectionStaticSchema extends URISchema 0) { return XMLUtil.parseBoolean(nl.item(0)); - } - else { + } else { return def; } } @@ -112,8 +107,7 @@ public class XMLConfigurationUtil { NodeList nl = e.getElementsByTagName(name); if (nl.getLength() > 0) { return true; - } - else { + } else { return false; } } diff --git a/artemis-server/src/main/resources/schema/artemis-server.xsd b/artemis-server/src/main/resources/schema/artemis-server.xsd index 552ce5f0a0..1e2e816114 100644 --- a/artemis-server/src/main/resources/schema/artemis-server.xsd +++ b/artemis-server/src/main/resources/schema/artemis-server.xsd @@ -31,16 +31,16 @@ - - - - A profile declaration may include configuration - elements from other namespaces for the subsystems that make up the profile. - - - - - + + + + A profile declaration may include configuration + elements from other namespaces for the subsystems that make up the profile. + + + + + diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index 425f3262a0..3fd1aaaccc 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -497,12 +497,10 @@ public class ConfigurationImplTest extends ActiveMQTestBase { configuration.setJournalDirectory("./data-journal"); File journalLocation = configuration.getJournalLocation(); Assert.assertFalse("This path shouldn't resolve to a real folder", journalLocation.exists()); - } - finally { + } finally { if (oldProperty == null) { System.clearProperty("artemis.instance"); - } - else { + } else { System.setProperty("artemis.instance", oldProperty); } } @@ -531,12 +529,10 @@ public class ConfigurationImplTest extends ActiveMQTestBase { File journalLocation = configuration.getJournalLocation(); Assert.assertTrue(journalLocation.exists()); - } - finally { + } finally { if (oldProperty == null) { System.clearProperty("artemis.instance"); - } - else { + } else { System.setProperty("artemis.instance", oldProperty); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java index 44f1c61c3e..9653760cd6 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java @@ -53,8 +53,7 @@ public class FileConfigurationParserTest extends ActiveMQTestBase { try { deploymentManager.readConfiguration(); fail("parsing should have failed for " + filename); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Throwable cause = e.getCause(); assertTrue("must have been org.xml.sax.SAXParseException", cause instanceof org.xml.sax.SAXParseException); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java index 6045c8d8f8..a2afd976d7 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java @@ -134,8 +134,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals("456", ac.getParams().get("tcpNoDelay")); Assert.assertEquals("44", ac.getParams().get("connectionTtl")); Assert.assertEquals("92", ac.getParams().get(TransportConstants.CONNECTIONS_ALLOWED)); - } - else { + } else { Assert.assertEquals("org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory", ac.getFactoryClassName()); Assert.assertEquals("0", ac.getParams().get("serverId")); Assert.assertEquals("87", ac.getParams().get(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED)); @@ -152,8 +151,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals(11999, udpBc.getGroupPort()); Assert.assertEquals(12345, bc.getBroadcastPeriod()); Assert.assertEquals("connector1", bc.getConnectorInfos().get(0)); - } - else { + } else { Assert.assertEquals("bg2", bc.getName()); Assert.assertEquals(12999, udpBc.getLocalBindPort()); Assert.assertEquals("192.168.0.121", udpBc.getGroupAddress()); @@ -188,8 +186,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals("speed > 88", dic.getFilterString()); Assert.assertEquals("org.foo.Transformer", dic.getTransformerClassName()); Assert.assertEquals(true, dic.isExclusive()); - } - else { + } else { Assert.assertEquals("divert2", dic.getName()); Assert.assertEquals("routing-name2", dic.getRoutingName()); Assert.assertEquals("address2", dic.getAddress()); @@ -219,8 +216,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals("connector1", bc.getStaticConnectors().get(0)); Assert.assertEquals(null, bc.getDiscoveryGroupName()); Assert.assertEquals(444, bc.getProducerWindowSize()); - } - else { + } else { Assert.assertEquals("bridge2", bc.getName()); Assert.assertEquals("queue2", bc.getQueueName()); Assert.assertEquals("bridge-forwarding-address2", bc.getForwardingAddress()); @@ -262,8 +258,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals("connector2", ccc.getStaticConnectors().get(1)); Assert.assertEquals(null, ccc.getDiscoveryGroupName()); Assert.assertEquals(222, ccc.getProducerWindowSize()); - } - else { + } else { Assert.assertEquals("cluster-connection2", ccc.getName()); Assert.assertEquals("queues2", ccc.getAddress()); Assert.assertEquals(4, ccc.getRetryInterval()); @@ -425,8 +420,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { FileDeploymentManager deploymentManager = new FileDeploymentManager(customConfiguration.getName()); deploymentManager.addDeployable(fileConfiguration); deploymentManager.readConfiguration(); - } - catch (Exception e) { + } catch (Exception e) { holder.t = e; } } @@ -441,8 +435,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { fail("Exception caught while loading configuration with the context class loader: " + holder.t.getMessage()); } - } - finally { + } finally { customConfiguration.delete(); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java index 59019dda0b..7bae74e249 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.core.config.impl; +import java.util.List; + import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy; @@ -37,8 +39,6 @@ import org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; -import java.util.List; - public class HAPolicyConfigurationTest extends ActiveMQTestBase { @Test @@ -59,8 +59,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { List connectors = scaleDownPolicy.getConnectors(); assertNotNull(connectors); assertEquals(connectors.size(), 0); - } - finally { + } finally { server.stop(); } } @@ -86,8 +85,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertEquals(connectors.size(), 2); assertTrue(connectors.contains("sd-connector1")); assertTrue(connectors.contains("sd-connector2")); - } - finally { + } finally { server.stop(); } } @@ -122,8 +120,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertTrue(replicatedPolicy.isCheckForLiveServer()); assertEquals(replicatedPolicy.getClusterName(), "abcdefg"); assertEquals(replicatedPolicy.getInitialReplicationSyncTimeout(), 9876); - } - finally { + } finally { server.stop(); } } @@ -152,8 +149,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { List connectors = scaleDownPolicy.getConnectors(); assertNotNull(connectors); assertEquals(connectors.size(), 0); - } - finally { + } finally { server.stop(); } } @@ -182,8 +178,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertEquals(connectors.size(), 2); assertTrue(connectors.contains("sd-connector1")); assertTrue(connectors.contains("sd-connector2")); - } - finally { + } finally { server.stop(); } } @@ -205,8 +200,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertFalse(replicaPolicy.isRestartBackup()); ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy(); assertNull(scaleDownPolicy); - } - finally { + } finally { server.stop(); } } @@ -223,8 +217,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertTrue(haPolicy instanceof SharedStoreMasterPolicy); SharedStoreMasterPolicy masterPolicy = (SharedStoreMasterPolicy) haPolicy; assertFalse(masterPolicy.isFailoverOnServerShutdown()); - } - finally { + } finally { server.stop(); } } @@ -249,8 +242,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { List connectors = scaleDownPolicy.getConnectors(); assertNotNull(connectors); assertEquals(connectors.size(), 0); - } - finally { + } finally { server.stop(); } } @@ -277,8 +269,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertEquals(connectors.size(), 2); assertTrue(connectors.contains("sd-connector1")); assertTrue(connectors.contains("sd-connector2")); - } - finally { + } finally { server.stop(); } } @@ -298,8 +289,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertTrue(sharedStoreSlavePolicy.isRestartBackup()); ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy(); assertNull(scaleDownPolicy); - } - finally { + } finally { server.stop(); } } @@ -327,8 +317,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertEquals(backupPolicy.getMaxSavedReplicatedJournalsSize(), 22); assertEquals(backupPolicy.getClusterName(), "33rrrrr"); assertFalse(backupPolicy.isRestartBackup()); - } - finally { + } finally { server.stop(); } } @@ -352,8 +341,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertEquals(livePolicy.getClusterName(), "abcdefg"); ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy(); assertNotNull(backupPolicy); - } - finally { + } finally { server.stop(); } } @@ -377,8 +365,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertNotNull(backupPolicy); assertFalse(backupPolicy.isFailoverOnServerShutdown()); assertFalse(backupPolicy.isRestartBackup()); - } - finally { + } finally { server.stop(); } } @@ -400,8 +387,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { assertFalse(livePolicy.isFailoverOnServerShutdown()); SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy(); assertNotNull(backupPolicy); - } - finally { + } finally { server.stop(); } } @@ -418,8 +404,7 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase { LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy; ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy(); assertNull(scaleDownPolicy); - } - finally { + } finally { server.stop(); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ValidatorsTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ValidatorsTest.java index b830a68eea..5d4c1e8298 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ValidatorsTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ValidatorsTest.java @@ -16,12 +16,10 @@ */ package org.apache.activemq.artemis.core.config.impl; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class ValidatorsTest extends Assert { @@ -33,8 +31,7 @@ public class ValidatorsTest extends Assert { try { validator.validate(RandomUtil.randomString(), value); Assert.fail(validator + " must not validate " + value); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java index 9e8ffbcbb5..d3f76797d9 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.core.config.impl; +import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; + import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; @@ -23,9 +26,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import java.io.ByteArrayInputStream; -import java.nio.charset.StandardCharsets; - /** * When running this test from an IDE add this to the test command line so that the AssertionLoggerHandler works properly: * -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration=file:/tests/config/logging.properties diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java index 18935dd78d..d73accd1ea 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java @@ -134,8 +134,7 @@ public class FilterTest extends SilentTestCase { if (i == 3) { Assert.assertTrue(filter.match(message)); - } - else { + } else { Assert.assertFalse(filter.match(message)); } } @@ -705,11 +704,9 @@ public class FilterTest extends SilentTestCase { try { filter = FilterImpl.createFilter(filterString); Assert.fail("Should throw exception"); - } - catch (ActiveMQInvalidFilterExpressionException ife) { + } catch (ActiveMQInvalidFilterExpressionException ife) { //pass - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid exception type:" + e.getType()); } } @@ -718,11 +715,9 @@ public class FilterTest extends SilentTestCase { try { filter = FilterImpl.createFilter(filterString); Assert.fail("Should throw exception"); - } - catch (ActiveMQInvalidFilterExpressionException ife) { + } catch (ActiveMQInvalidFilterExpressionException ife) { //pass - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid exception type:" + e.getType()); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/CertificateLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/CertificateLoginModuleTest.java index 102a364a5c..14c0d6ff30 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/CertificateLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/CertificateLoginModuleTest.java @@ -76,18 +76,15 @@ public class CertificateLoginModuleTest extends Assert { if (currentPrincipal.getName().equals(USER_NAME)) { if (!nameFound) { nameFound = true; - } - else { + } else { fail("UserPrincipal found twice."); } - } - else { + } else { fail("Unknown UserPrincipal found."); } - } - else if (currentPrincipal instanceof RolePrincipal) { + } else if (currentPrincipal instanceof RolePrincipal) { int principalIdx = ROLE_NAMES.indexOf(((RolePrincipal) currentPrincipal).getName()); if (principalIdx < 0) { @@ -96,12 +93,10 @@ public class CertificateLoginModuleTest extends Assert { if (!rolesFound[principalIdx]) { rolesFound[principalIdx] = true; - } - else { + } else { fail("RolePrincipal found twice."); } - } - else { + } else { fail("Unknown Principal type found."); } } @@ -111,8 +106,7 @@ public class CertificateLoginModuleTest extends Assert { public void testLoginSuccess() throws IOException { try { loginWithCredentials(USER_NAME, new HashSet<>(ROLE_NAMES)); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to login: " + e.getMessage()); } @@ -125,8 +119,7 @@ public class CertificateLoginModuleTest extends Assert { try { loginWithCredentials(null, new HashSet()); - } - catch (LoginException e) { + } catch (LoginException e) { loginFailed = true; } @@ -139,8 +132,7 @@ public class CertificateLoginModuleTest extends Assert { public void testLogOut() throws IOException { try { loginWithCredentials(USER_NAME, new HashSet<>(ROLE_NAMES)); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to login: " + e.getMessage()); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPLoginModuleTest.java index 17eae10cfb..e3ace3ae78 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPLoginModuleTest.java @@ -106,11 +106,9 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { ((NameCallback) callbacks[i]).setName("first"); - } - else if (callbacks[i] instanceof PasswordCallback) { + } else if (callbacks[i] instanceof PasswordCallback) { ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray()); - } - else { + } else { throw new UnsupportedCallbackException(callbacks[i]); } } @@ -128,11 +126,9 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { ((NameCallback) callbacks[i]).setName("first"); - } - else if (callbacks[i] instanceof PasswordCallback) { + } else if (callbacks[i] instanceof PasswordCallback) { ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray()); - } - else { + } else { throw new UnsupportedCallbackException(callbacks[i]); } } @@ -140,8 +136,7 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit { }); try { context.login(); - } - catch (LoginException le) { + } catch (LoginException le) { assertEquals(le.getCause().getMessage(), "Empty password is not allowed"); return; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPModuleRoleExpansionTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPModuleRoleExpansionTest.java index afd723c0cb..cc16ad6cea 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPModuleRoleExpansionTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/LDAPModuleRoleExpansionTest.java @@ -106,11 +106,9 @@ public class LDAPModuleRoleExpansionTest extends AbstractLdapTestUnit { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { ((NameCallback) callbacks[i]).setName("first"); - } - else if (callbacks[i] instanceof PasswordCallback) { + } else if (callbacks[i] instanceof PasswordCallback) { ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray()); - } - else { + } else { throw new UnsupportedCallbackException(callbacks[i]); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java index 4fa9c71b9e..03e60ff8fe 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java @@ -97,11 +97,9 @@ public class PropertiesLoginModuleRaceConditionTest { module.initialize(subject, callback, new HashMap(), options); module.login(); module.commit(); - } - catch (Exception e) { + } catch (Exception e) { errors.offer(e); - } - finally { + } finally { finished.countDown(); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleTest.java index 777ba504ff..9d35aea50c 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleTest.java @@ -117,8 +117,7 @@ public class PropertiesLoginModuleTest extends Assert { try { context.login(); fail("Should have thrown a FailedLoginException"); - } - catch (FailedLoginException doNothing) { + } catch (FailedLoginException doNothing) { } } @@ -130,8 +129,7 @@ public class PropertiesLoginModuleTest extends Assert { try { context.login(); fail("Should have thrown a FailedLoginException"); - } - catch (FailedLoginException doNothing) { + } catch (FailedLoginException doNothing) { } } @@ -151,11 +149,9 @@ public class PropertiesLoginModuleTest extends Assert { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { ((NameCallback) callbacks[i]).setName(user); - } - else if (callbacks[i] instanceof PasswordCallback) { + } else if (callbacks[i] instanceof PasswordCallback) { ((PasswordCallback) callbacks[i]).setPassword(pass.toCharArray()); - } - else { + } else { throw new UnsupportedCallbackException(callbacks[i]); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/RolePrincipalTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/RolePrincipalTest.java index e23fe6aa0e..9349e0d9b4 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/RolePrincipalTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/RolePrincipalTest.java @@ -31,8 +31,7 @@ public class RolePrincipalTest extends Assert { try { new RolePrincipal(null); fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException ingore) { + } catch (IllegalArgumentException ingore) { } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java index 3dbe9eff4d..46a8756dd4 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java @@ -113,11 +113,12 @@ public class TextFileCertificateLoginModuleTest { return new JaasCallbackHandler(null, null, new X509Certificate[]{cert}); } - private Subject doAuthenticate(HashMap options, JaasCallbackHandler callbackHandler) throws LoginException { + private Subject doAuthenticate(HashMap options, + JaasCallbackHandler callbackHandler) throws LoginException { Subject mySubject = new Subject(); loginModule.initialize(mySubject, callbackHandler, null, options); loginModule.login(); loginModule.commit(); return mySubject; } -} \ No newline at end of file +} diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/UserPrincipalTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/UserPrincipalTest.java index 9a081414a4..bd6ecaf7ed 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/UserPrincipalTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/UserPrincipalTest.java @@ -31,8 +31,7 @@ public class UserPrincipalTest extends Assert { try { new UserPrincipal(null); fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException ingore) { + } catch (IllegalArgumentException ingore) { } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImplTest.java index 222a11b9c6..a373f4abc6 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImplTest.java @@ -25,10 +25,13 @@ import org.apache.activemq.artemis.core.server.impl.InVMNodeManager; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; -/** Test the {@link BroadcastGroupImpl}.
*/ +/** + * Test the {@link BroadcastGroupImpl}.
+ */ public class BroadcastGroupImplTest extends ActiveMQTestBase { static class BroadcastEndpointFactoryImpl implements BroadcastEndpointFactory { + private static final long serialVersionUID = 1L; int sent = 0; @@ -40,6 +43,7 @@ public class BroadcastGroupImplTest extends ActiveMQTestBase { } static class BroadcastEndpointImpl implements BroadcastEndpoint { + private BroadcastEndpointFactoryImpl factory; BroadcastEndpointImpl(BroadcastEndpointFactoryImpl factory) { @@ -47,13 +51,16 @@ public class BroadcastGroupImplTest extends ActiveMQTestBase { } @Override - public void openClient() { } + public void openClient() { + } @Override - public void openBroadcaster() { } + public void openBroadcaster() { + } @Override - public void close(boolean isBroadcast) { } + public void close(boolean isBroadcast) { + } @Override public void broadcast(byte[] data) throws Exception { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java index b00efcab49..d53cdd9151 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java @@ -58,7 +58,6 @@ public class FileMoveManagerTest { private File dataLocation; private FileMoveManager manager; - @Before public void setUp() { dataLocation = new File(temporaryFolder.getRoot(), "data"); @@ -66,7 +65,6 @@ public class FileMoveManagerTest { manager = new FileMoveManager(dataLocation, 10); } - public FileMoveManagerTest() { File parent = new File("./target/tmp"); parent.mkdirs(); @@ -88,7 +86,6 @@ public class FileMoveManagerTest { Assert.assertEquals(12, manager.getFolders().length); Assert.assertEquals(12, manager.getNumberOfFolders()); - assertIDs(originalFiles, manager.getIDlist()); } @@ -153,7 +150,6 @@ public class FileMoveManagerTest { testMinMax(); } - @Test public void testNoFolders() { Assert.assertEquals(0, manager.getFolders().length); @@ -165,7 +161,6 @@ public class FileMoveManagerTest { Assert.assertEquals(0, manager.getNumberOfFolders()); } - @Test public void testNoFiles() throws Exception { // nothing to be moved, so why to do a backup @@ -207,12 +202,10 @@ public class FileMoveManagerTest { manager.setMaxFolders(1).checkOldFolders(); Assert.assertEquals(1, manager.getNumberOfFolders()); - Assert.assertEquals(10, manager.getMaxID()); Assert.assertEquals(10, manager.getMinID()); } - @Test public void testMoveFolders() throws Exception { manager.setMaxFolders(3); @@ -262,7 +255,6 @@ public class FileMoveManagerTest { manager.setMaxFolders(1).checkOldFolders(); Assert.assertEquals(1, manager.getNumberOfFolders()); - Assert.assertEquals(10, manager.getMaxID()); Assert.assertEquals(10, manager.getMinID()); } @@ -310,9 +302,7 @@ public class FileMoveManagerTest { final StorageManager storageManager = new NullStorageManager(); - PagingStoreFactoryNIO storeFactory = - new PagingStoreFactoryNIO(storageManager, dataLocation, 100, null, - new OrderedExecutorFactory(threadPool), true, null); + PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, dataLocation, 100, null, new OrderedExecutorFactory(threadPool), true, null); PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings, -1); @@ -332,16 +322,13 @@ public class FileMoveManagerTest { } Assert.assertFalse("The loggers are complaining about address.txt", AssertionLoggerHandler.findText("address.txt")); - } - finally { + } finally { AssertionLoggerHandler.stopCapture(); threadPool.shutdown(); } - } - private void assertIDs(int[] originalFiles, int[] ids) { Assert.assertEquals(originalFiles.length, ids.length); for (int i = 0; i < ids.length; i++) { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java index 7b5629fd68..bc4017c92f 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java @@ -101,8 +101,7 @@ public class FileStoreMonitorTest extends ActiveMQTestBase { protected double calculateUsage(FileStore store) throws IOException { if (fakeReturn.get()) { return 1f; - } - else { + } else { return super.calculateUsage(store); } } @@ -151,7 +150,6 @@ public class FileStoreMonitorTest extends ActiveMQTestBase { }); storeMonitor.start(); - Assert.assertTrue(latch.await(1, TimeUnit.SECONDS)); storeMonitor.stop(); @@ -160,7 +158,7 @@ public class FileStoreMonitorTest extends ActiveMQTestBase { Assert.assertFalse(latch.await(100, TimeUnit.MILLISECONDS)); -// FileStoreMonitor monitor = new FileStoreMonitor() + // FileStoreMonitor monitor = new FileStoreMonitor() } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java index 47b45faa0c..1211deed1d 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.core.server.group.impl; +import javax.management.ObjectName; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -54,12 +60,6 @@ import org.apache.activemq.artemis.utils.ReusableLatch; import org.junit.Assert; import org.junit.Test; -import javax.management.ObjectName; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - /** * this is testing the case for resending notifications from RemotingGroupHandler * There is a small window where you could receive notifications wrongly @@ -126,8 +126,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase { throw sni.ex; } } - } - finally { + } finally { for (Sender sni : sn) { sni.interrupt(); @@ -157,12 +156,10 @@ public class ClusteredResetMockTest extends ActiveMQTestBase { Response response = handler.propose(proposal); if (response == null) { ex = new NullPointerException("expected value on " + getName()); - } - else if (!response.getGroupId().equals(code)) { + } else if (!response.getGroupId().equals(code)) { ex = new IllegalStateException("expected code=" + code + " but it was " + response.getGroupId()); } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); this.ex = ex; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java index 0f2e0f065a..4b882cf3bb 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; @@ -27,10 +31,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - public class EmbeddedServerTest { private static final String SERVER_LOCK_NAME = "server.lock"; @@ -46,8 +46,7 @@ public class EmbeddedServerTest { server = ActiveMQServers.newActiveMQServer(configuration); try { server.start(); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail(); } } @@ -56,8 +55,7 @@ public class EmbeddedServerTest { public void teardown() { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { // Do Nothing } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java index 4e05b3a1ab..91e5e7af43 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java @@ -178,8 +178,7 @@ public class ScheduledDeliveryHandlerTest extends Assert { // it's better to run the test a few times instead of run millions of messages here internalSchedule(executor, scheduler); } - } - finally { + } finally { scheduler.shutdownNow(); executor.shutdownNow(); } @@ -205,12 +204,10 @@ public class ScheduledDeliveryHandlerTest extends Assert { for (int i = 0; i < NUMBER_OF_MESSAGES; i++) { checkAndSchedule(handler, i, now, false, fakeQueue); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); error.incrementAndGet(); - } - finally { + } finally { latchDone.countDown(); } @@ -257,7 +254,9 @@ public class ScheduledDeliveryHandlerTest extends Assert { handler.checkAndSchedule(refImpl, tail); } - private void debugList(boolean fail, ScheduledDeliveryHandlerImpl handler, long numberOfExpectedMessages) throws Exception { + private void debugList(boolean fail, + ScheduledDeliveryHandlerImpl handler, + long numberOfExpectedMessages) throws Exception { List refs = handler.getScheduledReferences(); HashSet messages = new HashSet<>(); @@ -270,8 +269,7 @@ public class ScheduledDeliveryHandlerTest extends Assert { if (fail) { assertTrue(ref.getScheduledDeliveryTime() >= lastTime); - } - else { + } else { if (ref.getScheduledDeliveryTime() < lastTime) { System.out.println("^^^fail at " + ref.getScheduledDeliveryTime()); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java index ca01857c48..2f59240171 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.core.settings; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; @@ -23,10 +27,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.concurrent.atomic.AtomicInteger; - public class RepositoryTest extends ActiveMQTestBase { HierarchicalRepository> securityRepository; @@ -217,15 +217,13 @@ public class RepositoryTest extends ActiveMQTestBase { try { repository.addMatch("hjhjhjhjh.#.hhh", "test"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // pass } try { repository.addMatch(null, "test"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // pass } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java index 2a6837f75c..0c2fec550e 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java @@ -120,8 +120,7 @@ public class TransactionImplTest extends ActiveMQTestBase { try { tx.commit(); Assert.fail("Exception expected!"); - } - catch (ActiveMQException expected) { + } catch (ActiveMQException expected) { } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/version/impl/VersionImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/version/impl/VersionImplTest.java index f6ea5d05e5..caa8bba664 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/version/impl/VersionImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/version/impl/VersionImplTest.java @@ -16,14 +16,13 @@ */ package org.apache.activemq.artemis.core.version.impl; -import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.junit.Assert; +import org.junit.Test; public class VersionImplTest extends Assert { // Constants ----------------------------------------------------- diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java index 9d727a7ffb..69ed8b643b 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java @@ -223,12 +223,10 @@ public abstract class ActiveMQTestBase extends Assert { public void shutdownDerby() { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } - static { Random random = new Random(); DEFAULT_UDP_PORT = 6000 + random.nextInt(1000); @@ -261,8 +259,7 @@ public abstract class ActiveMQTestBase extends Assert { assertAllClientConsumersAreClosed(); assertAllClientProducersAreClosed(); assertAllClientSessionsAreClosed(); - } - finally { + } finally { synchronized (servers) { for (ActiveMQServer server : servers) { if (server == null) { @@ -275,8 +272,7 @@ public abstract class ActiveMQTestBase extends Assert { stopComponent(cc); } } - } - catch (Exception e) { + } catch (Exception e) { // no-op } stopComponentOutputExceptions(server); @@ -289,8 +285,7 @@ public abstract class ActiveMQTestBase extends Assert { ArrayList exceptions; try { exceptions = checkCsfStopped(); - } - finally { + } finally { cleanupPools(); } @@ -300,7 +295,6 @@ public abstract class ActiveMQTestBase extends Assert { InVMConnector.resetThreadPool(); assertAllExecutorsFinished(); - //clean up pools before failing if (!exceptions.isEmpty()) { for (Exception exception : exceptions) { @@ -323,8 +317,7 @@ public abstract class ActiveMQTestBase extends Assert { this.getName() + " on this following dump")); fail("test '" + getName() + "' left serverlocator running, this could effect other tests"); - } - else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread)) { + } else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread)) { alreadyFailedThread.add(thread); System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " + thread.getName() + @@ -424,7 +417,6 @@ public abstract class ActiveMQTestBase extends Assert { return configuration; } - protected Configuration createDefaultConfig(final int serverID, final boolean netty) throws Exception { ConfigurationImpl configuration = createBasicConfig(serverID).setJMXManagementEnabled(false).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, generateInVMParams(serverID))); @@ -487,16 +479,13 @@ public abstract class ActiveMQTestBase extends Assert { statement.execute("DROP TABLE " + sqlProvider.getTableName()); } connection.commit(); - } - catch (SQLException e) { + } catch (SQLException e) { connection.rollback(); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); - } - finally { + } finally { connection.close(); } } @@ -555,8 +544,7 @@ public abstract class ActiveMQTestBase extends Assert { public static JournalType getDefaultJournalType() { if (LibaioContext.isLoaded()) { return JournalType.ASYNCIO; - } - else { + } else { return JournalType.NIO; } } @@ -565,7 +553,6 @@ public abstract class ActiveMQTestBase extends Assert { ThreadLeakCheckRule.forceGC(); } - /** * Verifies whether weak references are released after a few GCs. * @@ -734,8 +721,7 @@ public abstract class ActiveMQTestBase extends Assert { try { context.lookup(binding); Assert.fail("there must be no resource to look up for " + binding); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -770,16 +756,13 @@ public abstract class ActiveMQTestBase extends Assert { ServerSocket ssocket = null; try { ssocket = new ServerSocket(port); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException("port " + port + " is bound", e); - } - finally { + } finally { if (ssocket != null) { try { ssocket.close(); - } - catch (IOException e) { + } catch (IOException e) { } } } @@ -798,7 +781,7 @@ public abstract class ActiveMQTestBase extends Assert { } protected final String getJDBCClassName() { - return System.getProperty("jdbc.driver.class","org.apache.derby.jdbc.EmbeddedDriver"); + return System.getProperty("jdbc.driver.class", "org.apache.derby.jdbc.EmbeddedDriver"); } protected final File getTestDirfile() { @@ -969,8 +952,7 @@ public abstract class ActiveMQTestBase extends Assert { try { action.run(); Assert.fail(message); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e instanceof ActiveMQException); Assert.assertEquals(errorCode, ((ActiveMQException) e).getType()); } @@ -984,8 +966,7 @@ public abstract class ActiveMQTestBase extends Assert { try { action.run(); Assert.fail("must throw a XAException with the expected errorCode: " + errorCode); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e instanceof XAException); Assert.assertEquals(errorCode, ((XAException) e).errorCode); } @@ -1015,8 +996,7 @@ public abstract class ActiveMQTestBase extends Assert { } if (count++ < size) { return getSamplebyte(count - 1); - } - else { + } else { return -1; } } @@ -1044,28 +1024,22 @@ public abstract class ActiveMQTestBase extends Assert { if (prop.getPropertyType() == String.class) { value = RandomUtil.randomString(); - } - else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE) { + } else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE) { value = RandomUtil.randomInt(); - } - else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE) { + } else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE) { value = RandomUtil.randomLong(); - } - else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE) { + } else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE) { value = RandomUtil.randomBoolean(); - } - else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE) { + } else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE) { value = RandomUtil.randomDouble(); - } - else { + } else { System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName()); value = null; } if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() == null) { System.out.println("WriteOnly property " + prop.getName() + " on " + pojo.getClass()); - } - else if (value != null && prop.getWriteMethod() != null && + } else if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() != null && !ignoreSet.contains(prop.getName())) { System.out.println("Validating " + prop.getName() + " type = " + prop.getPropertyType()); @@ -1202,8 +1176,7 @@ public abstract class ActiveMQTestBase extends Assert { if (netty) { params.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + node); - } - else { + } else { params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, node); } @@ -1240,16 +1213,13 @@ public abstract class ActiveMQTestBase extends Assert { if (netty) { if (acceptor) { className = NETTY_ACCEPTOR_FACTORY; - } - else { + } else { className = NETTY_CONNECTOR_FACTORY; } - } - else { + } else { if (acceptor) { className = INVM_ACCEPTOR_FACTORY; - } - else { + } else { className = INVM_CONNECTOR_FACTORY; } } @@ -1276,7 +1246,6 @@ public abstract class ActiveMQTestBase extends Assert { fail("server didn't start: " + server); } - if (activation) { if (!server.getHAPolicy().isBackup()) { if (!server.waitForActivation(wait, TimeUnit.MILLISECONDS)) @@ -1329,15 +1298,13 @@ public abstract class ActiveMQTestBase extends Assert { if (isReplicated) { if (activation instanceof SharedNothingBackupActivation) { isRemoteUpToDate = backup.isReplicaSync(); - } - else { + } else { //we may have already failed over and changed the Activation if (actualServer.isStarted()) { //let it fail a few time to have time to start stopping in the case of waiting to failback isRemoteUpToDate = loop++ > 10; - } - //we could be waiting to failback or restart if the server is stopping - else { + } else { + //we could be waiting to failback or restart if the server is stopping isRemoteUpToDate = false; } } @@ -1355,8 +1322,7 @@ public abstract class ActiveMQTestBase extends Assert { } try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { fail(e.getMessage()); } } @@ -1375,24 +1341,24 @@ public abstract class ActiveMQTestBase extends Assert { } try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { fail(e.getMessage()); } } } + protected final ActiveMQServer createServer(final boolean realFiles, final Configuration configuration, final long pageSize, final long maxAddressSize) { - return createServer(realFiles, configuration, pageSize, maxAddressSize, (Map)null); + return createServer(realFiles, configuration, pageSize, maxAddressSize, (Map) null); } protected ActiveMQServer createServer(final boolean realFiles, - final Configuration configuration, - final long pageSize, - final long maxAddressSize, - final Map settings) { + final Configuration configuration, + final long pageSize, + final long maxAddressSize, + final Map settings) { ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, realFiles)); if (settings != null) { @@ -1436,7 +1402,9 @@ public abstract class ActiveMQTestBase extends Assert { return createServer(configuration.isPersistenceEnabled(), configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES); } - protected ActiveMQServer createServer(final boolean realFiles, boolean isNetty, StoreConfiguration.StoreType storeType) throws Exception { + protected ActiveMQServer createServer(final boolean realFiles, + boolean isNetty, + StoreConfiguration.StoreType storeType) throws Exception { Configuration configuration = storeType == StoreConfiguration.StoreType.DATABASE ? createDefaultJDBCConfig(isNetty) : createDefaultConfig(isNetty); return createServer(realFiles, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES); } @@ -1474,8 +1442,7 @@ public abstract class ActiveMQTestBase extends Assert { server.getAddressSettingsRepository().addMatch("#", defaultSetting); return server; - } - finally { + } finally { addServer(server); } } @@ -1515,8 +1482,7 @@ public abstract class ActiveMQTestBase extends Assert { server.getAddressSettingsRepository().addMatch("#", defaultSetting); return server; - } - finally { + } finally { addServer(server); } } @@ -1541,8 +1507,7 @@ public abstract class ActiveMQTestBase extends Assert { protected ServerLocator createFactory(final boolean isNetty) throws Exception { if (isNetty) { return createNettyNonHALocator(); - } - else { + } else { return createInVMNonHALocator(); } } @@ -1553,8 +1518,7 @@ public abstract class ActiveMQTestBase extends Assert { ClientSession session = sf.createSession(); try { session.createQueue(address, queue); - } - finally { + } finally { session.close(); closeSessionFactory(sf); closeServerLocator(locator); @@ -1681,14 +1645,12 @@ public abstract class ActiveMQTestBase extends Assert { messagesJournal.load(committedRecords, preparedTransactions, null, false); return new Pair<>(committedRecords, preparedTransactions); - } - finally { + } finally { try { if (messagesJournal != null) { messagesJournal.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1744,8 +1706,7 @@ public abstract class ActiveMQTestBase extends Assert { if (messageJournal) { ff = new NIOSequentialFileFactory(config.getJournalLocation(), null, 1); journal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(), config.getJournalPoolFiles(), 0, 0, ff, "activemq-data", "amq", 1); - } - else { + } else { ff = new NIOSequentialFileFactory(config.getBindingsLocation(), null, 1); journal = new JournalImpl(1024 * 1024, 2, config.getJournalCompactMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactPercentage(), ff, "activemq-bindings", "bindings", 1); } @@ -1960,8 +1921,7 @@ public abstract class ActiveMQTestBase extends Assert { while (!ClientSessionFactoryImpl.CLOSE_RUNNABLES.isEmpty() && time < waitUntil) { try { Thread.sleep(50); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } time = System.currentTimeMillis(); @@ -2008,8 +1968,7 @@ public abstract class ActiveMQTestBase extends Assert { while (LibaioContext.getTotalMaxIO() != 0 && System.currentTimeMillis() > timeout) { try { Thread.sleep(100); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -2033,16 +1992,14 @@ public abstract class ActiveMQTestBase extends Assert { // We shutdown the global pools to give a better isolation between tests try { ServerLocatorImpl.clearThreadPools(); - } - catch (Throwable e) { + } catch (Throwable e) { log.info(threadDump(e.getMessage())); System.err.println(threadDump(e.getMessage())); } try { NettyConnector.clearThreadPools(); - } - catch (Exception e) { + } catch (Exception e) { log.info(threadDump(e.getMessage())); System.err.println(threadDump(e.getMessage())); } @@ -2069,8 +2026,7 @@ public abstract class ActiveMQTestBase extends Assert { for (String sub : subs) { copyRecursive(new File(from, sub), new File(to, sub)); } - } - else { + } else { try (InputStream in = new BufferedInputStream(new FileInputStream(from)); OutputStream out = new BufferedOutputStream(new FileOutputStream(to))) { int b; @@ -2210,8 +2166,7 @@ public abstract class ActiveMQTestBase extends Assert { return; try { component.stop(); - } - catch (Exception e) { + } catch (Exception e) { // no-op } } @@ -2221,8 +2176,7 @@ public abstract class ActiveMQTestBase extends Assert { return; try { component.stop(); - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Exception closing " + component); e.printStackTrace(); } @@ -2344,8 +2298,7 @@ public abstract class ActiveMQTestBase extends Assert { return; try { locator.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -2355,8 +2308,7 @@ public abstract class ActiveMQTestBase extends Assert { return; try { sf.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -2387,13 +2339,11 @@ public abstract class ActiveMQTestBase extends Assert { ClientSession session = sf.createSession(); try { crashAndWaitForFailure(server, session); - } - finally { + } finally { try { session.close(); sf.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -2420,8 +2370,7 @@ public abstract class ActiveMQTestBase extends Assert { public void run() { try { runner.run(); - } - catch (Throwable t) { + } catch (Throwable t) { this.t = t; } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java index 806e0f26d5..6130dcf0a9 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ColocatedActiveMQServer.java @@ -70,16 +70,13 @@ public class ColocatedActiveMQServer extends ActiveMQServerImpl { if (replicatingBackup) { if (getConfiguration().getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { return new AIOFileLockNodeManager(directory, replicatingBackup, getConfiguration().getJournalLockAcquisitionTimeout()); - } - else { + } else { return new FileLockNodeManager(directory, replicatingBackup, getConfiguration().getJournalLockAcquisitionTimeout()); } - } - else { + } else { if (backup) { return nodeManagerBackup; - } - else { + } else { return nodeManagerLive; } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/InVMNodeManagerServer.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/InVMNodeManagerServer.java index a14cb5293f..10502508b1 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/InVMNodeManagerServer.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/InVMNodeManagerServer.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.tests.util; import javax.management.MBeanServer; - import java.io.File; import org.apache.activemq.artemis.core.config.Configuration; diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java index 7c220da7c5..b367015d02 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java @@ -16,15 +16,13 @@ */ package org.apache.activemq.artemis.tests.util; -import org.junit.Test; - import java.util.concurrent.CountDownLatch; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.utils.DataConstants; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class SimpleStringTest extends Assert { @@ -122,32 +120,28 @@ public class SimpleStringTest extends Assert { try { s1.charAt(-1); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.charAt(-2); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.charAt(s.length()); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.charAt(s.length() + 1); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } @@ -169,40 +163,35 @@ public class SimpleStringTest extends Assert { try { s1.subSequence(-1, 2); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.subSequence(-4, -2); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.subSequence(0, s1.length() + 1); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.subSequence(0, s1.length() + 2); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } try { s1.subSequence(5, 1); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } } @@ -379,8 +368,7 @@ public class SimpleStringTest extends Assert { if (newhash != initialhash) { failed = true; } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed = true; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationTest.java index 3df2ecfd74..e6b97ebf23 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/ClusterConnectionConfigurationTest.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, diff --git a/artemis-server/src/test/resources/ConfigurationTest-defaults.xml b/artemis-server/src/test/resources/ConfigurationTest-defaults.xml index cb97112521..b18bc6454d 100644 --- a/artemis-server/src/test/resources/ConfigurationTest-defaults.xml +++ b/artemis-server/src/test/resources/ConfigurationTest-defaults.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/schemas/artemis-server.xsd "> diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml index cc11029c73..89844056a3 100644 --- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml +++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer false diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest0.xml b/artemis-server/src/test/resources/InvalidConfigurationTest0.xml index db2c2d3888..9eabc9e5f7 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest0.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest0.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest1.xml b/artemis-server/src/test/resources/InvalidConfigurationTest1.xml index 907ff3408c..7080f3746a 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest1.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest1.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest2.xml b/artemis-server/src/test/resources/InvalidConfigurationTest2.xml index b95c10e8a4..3d3ae9891c 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest2.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest2.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest3.xml b/artemis-server/src/test/resources/InvalidConfigurationTest3.xml index 000211ad0a..7b3eb9bb9d 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest3.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest3.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest4.xml b/artemis-server/src/test/resources/InvalidConfigurationTest4.xml index b50ebb20bd..e6feceda9e 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest4.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest4.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest5.xml b/artemis-server/src/test/resources/InvalidConfigurationTest5.xml index 88590b1c34..1b4dc9cb91 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest5.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest5.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> SomeNameForUseOnTheApplicationServer 12345 diff --git a/artemis-server/src/test/resources/InvalidConfigurationTest6.xml b/artemis-server/src/test/resources/InvalidConfigurationTest6.xml index db3799a797..154a746029 100644 --- a/artemis-server/src/test/resources/InvalidConfigurationTest6.xml +++ b/artemis-server/src/test/resources/InvalidConfigurationTest6.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../src/config/common/schema/artemis-server.xsd"> @@ -26,7 +26,8 @@ - + diff --git a/artemis-server/src/test/resources/colocated-hapolicy-config-null-backup.xml b/artemis-server/src/test/resources/colocated-hapolicy-config-null-backup.xml index 5b6b6d59ed..6d779e9098 100644 --- a/artemis-server/src/test/resources/colocated-hapolicy-config-null-backup.xml +++ b/artemis-server/src/test/resources/colocated-hapolicy-config-null-backup.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/colocated-hapolicy-config.xml b/artemis-server/src/test/resources/colocated-hapolicy-config.xml index f7872d4e21..c27a81f9ac 100644 --- a/artemis-server/src/test/resources/colocated-hapolicy-config.xml +++ b/artemis-server/src/test/resources/colocated-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/colocated-hapolicy-config2-null-backup.xml b/artemis-server/src/test/resources/colocated-hapolicy-config2-null-backup.xml index e4200338c6..87e1ff3417 100644 --- a/artemis-server/src/test/resources/colocated-hapolicy-config2-null-backup.xml +++ b/artemis-server/src/test/resources/colocated-hapolicy-config2-null-backup.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/colocated-hapolicy-config2.xml b/artemis-server/src/test/resources/colocated-hapolicy-config2.xml index ca13b65c01..9b0032150c 100644 --- a/artemis-server/src/test/resources/colocated-hapolicy-config2.xml +++ b/artemis-server/src/test/resources/colocated-hapolicy-config2.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/database-store-config.xml b/artemis-server/src/test/resources/database-store-config.xml index c3be405ac9..1fa3bd6534 100644 --- a/artemis-server/src/test/resources/database-store-config.xml +++ b/artemis-server/src/test/resources/database-store-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/divertRoutingNameNotRequired.xml b/artemis-server/src/test/resources/divertRoutingNameNotRequired.xml index d9b7063ac5..b34ecd1f97 100644 --- a/artemis-server/src/test/resources/divertRoutingNameNotRequired.xml +++ b/artemis-server/src/test/resources/divertRoutingNameNotRequired.xml @@ -15,8 +15,8 @@ limitations under the License. --> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> @@ -53,7 +53,7 @@ before the JMS queue is deployed, so the first time, it otherwise won't find the queue --> -

jms.queue.priceForwarding
+
jms.queue.priceForwarding
@@ -68,7 +68,8 @@
jms.topic.priceUpdates
jms.queue.priceForwarding - org.apache.activemq.artemis.jms.example.AddForwardingTimeTransformer + org.apache.activemq.artemis.jms.example.AddForwardingTimeTransformer + true diff --git a/artemis-server/src/test/resources/live-only-hapolicy-config.xml b/artemis-server/src/test/resources/live-only-hapolicy-config.xml index 356b4860f8..ab9bb20f65 100644 --- a/artemis-server/src/test/resources/live-only-hapolicy-config.xml +++ b/artemis-server/src/test/resources/live-only-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/live-only-hapolicy-config2.xml b/artemis-server/src/test/resources/live-only-hapolicy-config2.xml index b1de311a36..b713eb4f2b 100644 --- a/artemis-server/src/test/resources/live-only-hapolicy-config2.xml +++ b/artemis-server/src/test/resources/live-only-hapolicy-config2.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/live-only-hapolicy-config3.xml b/artemis-server/src/test/resources/live-only-hapolicy-config3.xml index 6cd2554422..eaafb88e47 100644 --- a/artemis-server/src/test/resources/live-only-hapolicy-config3.xml +++ b/artemis-server/src/test/resources/live-only-hapolicy-config3.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/live-only-hapolicy-config4.xml b/artemis-server/src/test/resources/live-only-hapolicy-config4.xml index 19def04acb..0267571a88 100644 --- a/artemis-server/src/test/resources/live-only-hapolicy-config4.xml +++ b/artemis-server/src/test/resources/live-only-hapolicy-config4.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/live-only-hapolicy-config5.xml b/artemis-server/src/test/resources/live-only-hapolicy-config5.xml index 6fa80ff3e9..a4463a60a0 100644 --- a/artemis-server/src/test/resources/live-only-hapolicy-config5.xml +++ b/artemis-server/src/test/resources/live-only-hapolicy-config5.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/replica-hapolicy-config.xml b/artemis-server/src/test/resources/replica-hapolicy-config.xml index 03983fc8d5..3b2c3baa69 100644 --- a/artemis-server/src/test/resources/replica-hapolicy-config.xml +++ b/artemis-server/src/test/resources/replica-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/replica-hapolicy-config2.xml b/artemis-server/src/test/resources/replica-hapolicy-config2.xml index 95df78bbd7..22d5c4567b 100644 --- a/artemis-server/src/test/resources/replica-hapolicy-config2.xml +++ b/artemis-server/src/test/resources/replica-hapolicy-config2.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/replica-hapolicy-config3.xml b/artemis-server/src/test/resources/replica-hapolicy-config3.xml index 369eca6603..b0e9f00ac1 100644 --- a/artemis-server/src/test/resources/replica-hapolicy-config3.xml +++ b/artemis-server/src/test/resources/replica-hapolicy-config3.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/replicated-hapolicy-config.xml b/artemis-server/src/test/resources/replicated-hapolicy-config.xml index 8195e45379..fb2a60243c 100644 --- a/artemis-server/src/test/resources/replicated-hapolicy-config.xml +++ b/artemis-server/src/test/resources/replicated-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/securitySettingPlugin.xml b/artemis-server/src/test/resources/securitySettingPlugin.xml index 25207d50f4..81eeb9c4b7 100644 --- a/artemis-server/src/test/resources/securitySettingPlugin.xml +++ b/artemis-server/src/test/resources/securitySettingPlugin.xml @@ -15,12 +15,13 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> - + diff --git a/artemis-server/src/test/resources/shared-store-master-hapolicy-config.xml b/artemis-server/src/test/resources/shared-store-master-hapolicy-config.xml index 132cd00c92..1fe7c59ed3 100644 --- a/artemis-server/src/test/resources/shared-store-master-hapolicy-config.xml +++ b/artemis-server/src/test/resources/shared-store-master-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config.xml b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config.xml index 28c6051f89..6029640800 100644 --- a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config.xml +++ b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config2.xml b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config2.xml index 57acd13f3d..38661a6cc2 100644 --- a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config2.xml +++ b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config2.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config3.xml b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config3.xml index 991ea55057..eb8e67970a 100644 --- a/artemis-server/src/test/resources/shared-store-slave-hapolicy-config3.xml +++ b/artemis-server/src/test/resources/shared-store-slave-hapolicy-config3.xml @@ -15,9 +15,9 @@ limitations under the License. --> + xmlns="urn:activemq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:activemq ../../../../activemq-server/src/main/resources/schema/artemis-server.xsd"> diff --git a/artemis-service-extensions/pom.xml b/artemis-service-extensions/pom.xml index 175012d4eb..f32a28c9e6 100644 --- a/artemis-service-extensions/pom.xml +++ b/artemis-service-extensions/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/ServiceUtils.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/ServiceUtils.java index 99a372b5b4..6faa5f87fe 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/ServiceUtils.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/ServiceUtils.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.service.extensions; +import javax.transaction.TransactionManager; +import javax.transaction.xa.XAResource; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Iterator; import java.util.Map; import java.util.ServiceLoader; -import javax.transaction.TransactionManager; -import javax.transaction.xa.XAResource; - import org.apache.activemq.artemis.service.extensions.transactions.TransactionManagerLocator; import org.apache.activemq.artemis.service.extensions.xa.ActiveMQXAResourceWrapper; import org.apache.activemq.artemis.service.extensions.xa.ActiveMQXAResourceWrapperFactory; @@ -54,8 +53,7 @@ public class ServiceUtils { transactionManager = findTransactionManager(); if (transactionManager != null) { transactionManagerLoaded = true; - } - else { + } else { ActiveMQServiceExtensionLogger.LOGGER.transactionManagerNotFound(); } } @@ -67,9 +65,8 @@ public class ServiceUtils { transactionManagerLoaded = (transactionManager != null); } - /** - * Find the first transaction manager loaded from the {@code TransactionManagerLocator} service or {@code null} if none is loaded. + * Find the first transaction manager loaded from the {@code TransactionManagerLocator} service or {@code null} if none is loaded. */ private static TransactionManager findTransactionManager() { return AccessController.doPrivileged(new PrivilegedAction() { @@ -85,8 +82,8 @@ public class ServiceUtils { } /** - * Find the first wrapper factory loaded from the {@code ActiveMQXAResourceWrapperFactory} service or - * use the default {@code ActiveMQXAResourceWrapperFactoryImpl} if none is loaded. + * Find the first wrapper factory loaded from the {@code ActiveMQXAResourceWrapperFactory} service or + * use the default {@code ActiveMQXAResourceWrapperFactoryImpl} if none is loaded. */ private static ActiveMQXAResourceWrapperFactory findActiveMQXAResourceWrapperFactory() { return AccessController.doPrivileged(new PrivilegedAction() { @@ -95,8 +92,7 @@ public class ServiceUtils { Iterator iterator = ServiceLoader.load(ActiveMQXAResourceWrapperFactory.class, ServiceUtils.class.getClassLoader()).iterator(); if (iterator.hasNext()) { return iterator.next(); - } - else { + } else { return new ActiveMQXAResourceWrapperFactoryImpl(); } } diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/ActiveMQXAResourceWrapperImpl.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/ActiveMQXAResourceWrapperImpl.java index 8f353e07fa..e1c182abfa 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/ActiveMQXAResourceWrapperImpl.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/ActiveMQXAResourceWrapperImpl.java @@ -49,7 +49,7 @@ public class ActiveMQXAResourceWrapperImpl implements ActiveMQXAResourceWrapper //this.productVersion = VersionLoader.getVersion().getFullVersion(); this.productVersion = (String) properties.get(ACTIVEMQ_PRODUCT_VERSION); - String jndiName = (String) properties.get(ACTIVEMQ_JNDI_NAME); + String jndiName = (String) properties.get(ACTIVEMQ_JNDI_NAME); String nodeId = "NodeId:" + properties.get(ACTIVEMQ_NODE_ID); this.jndiNameNodeId = jndiName == null ? nodeId : jndiName + " " + nodeId; diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java index e00b49e4d1..ceeec59d86 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java @@ -16,18 +16,17 @@ */ package org.apache.activemq.artemis.service.extensions.xa.recovery; -import java.util.Arrays; - import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; +import java.util.Arrays; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.SessionFailureListener; @@ -81,8 +80,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } return xids; - } - catch (XAException e) { + } catch (XAException e) { ActiveMQXARecoveryLogger.LOGGER.xaRecoverError(e); throw check(e); } @@ -96,8 +94,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { xaResource.commit(xid, onePhase); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -110,8 +107,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { xaResource.rollback(xid); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -125,8 +121,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList try { xaResource.forget(xid); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -140,8 +135,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList XAResource xaResource = getDelegate(false); try { return xaResource.isSameRM(xaRes); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -154,8 +148,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { return xaResource.prepare(xid); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -168,8 +161,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { xaResource.start(xid, flags); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -182,8 +174,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { xaResource.end(xid, flags); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -196,8 +187,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { return xaResource.getTransactionTimeout(); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -210,8 +200,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } try { return xaResource.setTransactionTimeout(seconds); - } - catch (XAException e) { + } catch (XAException e) { throw check(e); } } @@ -222,8 +211,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { ActiveMQXARecoveryLogger.LOGGER.debug("being disconnected for server shutdown", me); } - } - else { + } else { ActiveMQXARecoveryLogger.LOGGER.xaRecoverConnectionError(me, csf); } close(); @@ -249,8 +237,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList Exception error = null; try { result = connect(); - } - catch (Exception e) { + } catch (Exception e) { error = e; } @@ -267,8 +254,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList ActiveMQXARecoveryLogger.LOGGER.debug("Cannot get connectionFactory XAResource", xae); } throw xae; - } - else { + } else { XAException xae = new XAException("Error trying to connect to any providers for xa recovery"); xae.errorCode = XAException.XAER_RMFAIL; if (error != null) { @@ -317,8 +303,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList // Manual configuration may still use discovery, so we will keep this if (xaRecoveryConfig.getDiscoveryConfiguration() != null) { serverLocator = ActiveMQClient.createServerLocator(false, xaRecoveryConfig.getDiscoveryConfiguration()); - } - else { + } else { serverLocator = ActiveMQClient.createServerLocator(false, xaRecoveryConfig.getTransportConfig()); } serverLocator.disableFinalizeCheck(); @@ -326,12 +311,10 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList csf = serverLocator.createSessionFactory(); if (xaRecoveryConfig.getUsername() == null) { cs = csf.createSession(true, false, false); - } - else { + } else { cs = csf.createSession(xaRecoveryConfig.getUsername(), xaRecoveryConfig.getPassword(), true, false, false, false, 1); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQXARecoveryLogger.LOGGER.xaRecoverAutoConnectionError(e, xaRecoveryConfig); if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { ActiveMQXARecoveryLogger.LOGGER.debug(e.getMessage(), e); @@ -342,8 +325,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList cs.close(); if (serverLocator != null) serverLocator.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { ActiveMQXARecoveryLogger.LOGGER.trace(e.getMessage(), ignored); } @@ -399,8 +381,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (oldDelegate != null) { try { oldDelegate.close(); - } - catch (Throwable ignorable) { + } catch (Throwable ignorable) { ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } @@ -408,8 +389,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (oldCSF != null) { try { oldCSF.close(); - } - catch (Throwable ignorable) { + } catch (Throwable ignorable) { ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } @@ -417,8 +397,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (oldServerLocator != null) { try { oldServerLocator.close(); - } - catch (Throwable ignorable) { + } catch (Throwable ignorable) { ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java index a75bdac9f8..f2f78645d3 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/XARecoveryConfig.java @@ -45,11 +45,13 @@ public class XARecoveryConfig { private final Map properties; private final ClientProtocolManagerFactory clientProtocolManager; - public static XARecoveryConfig newConfig(ActiveMQConnectionFactory factory, String userName, String password, Map properties) { + public static XARecoveryConfig newConfig(ActiveMQConnectionFactory factory, + String userName, + String password, + Map properties) { if (factory.getServerLocator().getDiscoveryGroupConfiguration() != null) { return new XARecoveryConfig(factory.getServerLocator().isHA(), factory.getServerLocator().getDiscoveryGroupConfiguration(), userName, password, properties, factory.getServerLocator().getProtocolManagerFactory()); - } - else { + } else { return new XARecoveryConfig(factory.getServerLocator().isHA(), factory.getServerLocator().getStaticTransportConfigurations(), userName, password, properties, factory.getServerLocator().getProtocolManagerFactory()); } @@ -75,7 +77,6 @@ public class XARecoveryConfig { this.clientProtocolManager = clientProtocolManager; } - public XARecoveryConfig(final boolean ha, final TransportConfiguration[] transportConfiguration, final String username, @@ -143,8 +144,7 @@ public class XARecoveryConfig { public ServerLocator createServerLocator() { if (getDiscoveryConfiguration() != null) { return ActiveMQClient.createServerLocator(isHA(), getDiscoveryConfiguration()).setProtocolManagerFactory(clientProtocolManager); - } - else { + } else { return ActiveMQClient.createServerLocator(isHA(), getTransportConfig()).setProtocolManagerFactory(clientProtocolManager); } @@ -175,8 +175,7 @@ public class XARecoveryConfig { if (discoveryConfiguration == null) { if (other.discoveryConfiguration != null) return false; - } - else if (!discoveryConfiguration.equals(other.discoveryConfiguration)) + } else if (!discoveryConfiguration.equals(other.discoveryConfiguration)) return false; if (!Arrays.equals(transportConfiguration, other.transportConfiguration)) return false; diff --git a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/recovery/XARecoveryConfigTest.java b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/recovery/XARecoveryConfigTest.java index b5f1021aa0..d856220f4c 100644 --- a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/recovery/XARecoveryConfigTest.java +++ b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/recovery/XARecoveryConfigTest.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, @@ -22,7 +22,6 @@ import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConf import org.junit.Assert; import org.junit.Test; - public class XARecoveryConfigTest { @Test @@ -30,12 +29,10 @@ public class XARecoveryConfigTest { String factClass = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory"; TransportConfiguration transportConfig = new TransportConfiguration(factClass, null); - XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig}, - null, null, null); + XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig}, null, null, null); TransportConfiguration transportConfig2 = new TransportConfiguration(factClass, null); - XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig2}, - null, null, null); + XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig2}, null, null, null); // They are using Different names Assert.assertNotEquals(transportConfig, transportConfig2); @@ -50,12 +47,10 @@ public class XARecoveryConfigTest { String factClass = "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory"; TransportConfiguration transportConfig = new TransportConfiguration(factClass, null); - XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig}, - null, null, null); + XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig}, null, null, null); TransportConfiguration transportConfig2 = new TransportConfiguration(factClass + "2", null); - XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig2}, - null, null, null); + XARecoveryConfig config2 = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig2}, null, null, null); // They are using Different names Assert.assertNotEquals(transportConfig, transportConfig2); diff --git a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/transactions/DummyTransactionManagerLocator.java b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/transactions/DummyTransactionManagerLocator.java index 3ed77fcde6..2fd09da8f8 100644 --- a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/transactions/DummyTransactionManagerLocator.java +++ b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/transactions/DummyTransactionManagerLocator.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.service.extensions.tests.transactions; -import org.apache.activemq.artemis.service.extensions.transactions.TransactionManagerLocator; - import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction.InvalidTransactionException; @@ -27,6 +25,8 @@ import javax.transaction.SystemException; import javax.transaction.Transaction; import javax.transaction.TransactionManager; +import org.apache.activemq.artemis.service.extensions.transactions.TransactionManagerLocator; + public class DummyTransactionManagerLocator implements TransactionManagerLocator, TransactionManager { @Override diff --git a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ActiveMQXAResourceWrapperImplTest.java b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ActiveMQXAResourceWrapperImplTest.java index 3d7f37ec61..7ecb0f7818 100644 --- a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ActiveMQXAResourceWrapperImplTest.java +++ b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ActiveMQXAResourceWrapperImplTest.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.service.extensions.tests.xa; import javax.transaction.xa.XAResource; - import java.util.HashMap; import java.util.Map; diff --git a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ServiceUtilsTest.java b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ServiceUtilsTest.java index 5e9db0047c..2fd139523a 100644 --- a/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ServiceUtilsTest.java +++ b/artemis-service-extensions/src/test/java/org/apache/activemq/artemis/service/extensions/tests/xa/ServiceUtilsTest.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.service.extensions.tests.xa; -import static org.jgroups.util.Util.assertTrue; - import java.lang.reflect.Method; import org.apache.activemq.artemis.service.extensions.ServiceUtils; import org.junit.Test; +import static org.jgroups.util.Util.assertTrue; + public class ServiceUtilsTest { @Test diff --git a/artemis-web/pom.xml b/artemis-web/pom.xml index 89a54ad1a1..88101927eb 100644 --- a/artemis-web/pom.xml +++ b/artemis-web/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -28,7 +29,7 @@ ActiveMQ Artemis Web - ${project.basedir}/.. + ${project.basedir}/.. @@ -75,10 +76,10 @@ - - org.jboss.logging - jboss-logging - + + org.jboss.logging + jboss-logging + diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java index 739edc0890..699dce36c7 100644 --- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java +++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.component; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; + import org.apache.activemq.artemis.ActiveMQWebLogger; import org.apache.activemq.artemis.components.ExternalComponent; import org.apache.activemq.artemis.dto.AppDTO; @@ -34,11 +39,6 @@ import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; - public class WebServerComponent implements ExternalComponent { private Server server; @@ -75,8 +75,7 @@ public class WebServerComponent implements ExternalComponent { connector = new ServerConnector(server, sslConnectionFactory, httpFactory); - } - else { + } else { connector = new ServerConnector(server); } connector.setPort(uri.getPort()); @@ -86,8 +85,7 @@ public class WebServerComponent implements ExternalComponent { handlers = new HandlerList(); - Path warDir = Paths.get(artemisHome != null ? artemisHome : ".") - .resolve( webServerConfig.path ).toAbsolutePath(); + Path warDir = Paths.get(artemisHome != null ? artemisHome : ".").resolve(webServerConfig.path).toAbsolutePath(); if (webServerConfig.apps != null) { for (AppDTO app : webServerConfig.apps) { @@ -134,8 +132,7 @@ public class WebServerComponent implements ExternalComponent { WebAppContext webapp = new WebAppContext(); if (url.startsWith("/")) { webapp.setContextPath(url); - } - else { + } else { webapp.setContextPath("/" + url); } diff --git a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java index 587c76f39a..1e0aff787f 100644 --- a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java +++ b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.cli.test; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; import java.net.URI; import java.net.URISyntaxException; import java.util.concurrent.CountDownLatch; @@ -46,9 +48,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - public class WebServerComponentTest extends Assert { static final String URL = System.getProperty("url", "http://localhost:8161/WebServerComponentTest.txt"); @@ -115,12 +114,7 @@ public class WebServerComponentTest extends Assert { // Make the connection attempt. String keyStoreProvider = "JKS"; - SSLContext context = SSLSupport.createContext(keyStoreProvider, - webServerDTO.keyStorePath, - webServerDTO.keyStorePassword, - keyStoreProvider, - webServerDTO.keyStorePath, - webServerDTO.keyStorePassword); + SSLContext context = SSLSupport.createContext(keyStoreProvider, webServerDTO.keyStorePath, webServerDTO.keyStorePassword, keyStoreProvider, webServerDTO.keyStorePath, webServerDTO.keyStorePassword); SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(true); @@ -173,12 +167,7 @@ public class WebServerComponentTest extends Assert { // Make the connection attempt. String keyStoreProvider = "JKS"; - SSLContext context = SSLSupport.createContext(keyStoreProvider, - webServerDTO.keyStorePath, - webServerDTO.keyStorePassword, - keyStoreProvider, - webServerDTO.trustStorePath, - webServerDTO.trustStorePassword); + SSLContext context = SSLSupport.createContext(keyStoreProvider, webServerDTO.keyStorePath, webServerDTO.keyStorePassword, keyStoreProvider, webServerDTO.trustStorePath, webServerDTO.trustStorePassword); SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(true); diff --git a/artemis-website/package.json b/artemis-website/package.json index 9bf826fa67..1f7a8bca26 100644 --- a/artemis-website/package.json +++ b/artemis-website/package.json @@ -8,6 +8,6 @@ "url": "https://github.com/apache/activemq-artemis" }, "devDependencies": { - "gitbook-cli": "~0.3.6" + "gitbook-cli": "~0.3.6" } } diff --git a/artemis-website/pom.xml b/artemis-website/pom.xml index 11cf3c0357..9b2eba6700 100644 --- a/artemis-website/pom.xml +++ b/artemis-website/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -61,17 +62,17 @@ - org.jboss.logging - jboss-logging-processor - provided - true + org.jboss.logging + jboss-logging-processor + provided + true - xalan - xalan - 2.7.2 - true - provided + xalan + xalan + 2.7.2 + true + provided @@ -119,7 +120,8 @@ false true - org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils + @@ -168,25 +170,26 @@ generate-sources - - + + - + executing ${gitbook.cmd} - - - - + + + + - + executing ${gitbook.cmd} - - - - + + + + diff --git a/artemis-website/src/main/resources/examples/index.html b/artemis-website/src/main/resources/examples/index.html index 9c325e3c49..e6ddb7490a 100644 --- a/artemis-website/src/main/resources/examples/index.html +++ b/artemis-website/src/main/resources/examples/index.html @@ -31,7 +31,8 @@
@@ -41,20 +42,27 @@
-

Apache ActiveMQ Artemis Examples

+

Apache ActiveMQ Artemis Examples

-

Apache ActiveMQ Artemis comes with over 90 runnable examples. These can be found in the examples directory in the root of the - distribution folder. There are examples covering JMS as well as all the protocols and functionality that Apache ActiveMQ Artemis - supports.

+

Apache ActiveMQ Artemis comes with over 90 runnable examples. These can be found in the examples + directory in the root of the + distribution folder. There are examples covering JMS as well as all the protocols and functionality that + Apache ActiveMQ Artemis + supports.

-

Each example has its own instructions as to how they can be run, but for most of them it is as simple as running - mvn verify from the example directory. This will start a broker with the correct configuration, run the - example and then stop the broker. You'll need to ensure there is not a broker already running as this may conflict - with the broker that is configured and used in the example.

+

Each example has its own instructions as to how they can be run, but for most of them it is as simple as + running + mvn verify from the example directory. This will start a broker with the correct + configuration, run the + example and then stop the broker. You'll need to ensure there is not a broker already running as this + may conflict + with the broker that is configured and used in the example.

-

You may also run the example without starting the server by specifying -PnoServer (mvn -PnoServer verify). You can then use your own server for the example.

+

You may also run the example without starting the server by specifying -PnoServer (mvn -PnoServer + verify). You can then use your own server for the example.

-

Notice that some examples will require special cases and multiple servers, for example in some Failover tests. Always refer to the README on each example.

+

Notice that some examples will require special cases and multiple servers, for example in some Failover + tests. Always refer to the README on each example.

diff --git a/artemis-website/src/main/resources/hacking-guide/index.html b/artemis-website/src/main/resources/hacking-guide/index.html index 8f71b63691..4975dcbfec 100644 --- a/artemis-website/src/main/resources/hacking-guide/index.html +++ b/artemis-website/src/main/resources/hacking-guide/index.html @@ -17,14 +17,17 @@ specific language governing permissions and limitations under the License. --> - - - + + +

User Manual

-

If you are seeing this message, it is because the Hacking Guide was not built during the Apache ActiveMQ Artemis build. To -build Apache ActiveMQ Artemis with the Hacking Guide you must use the maven release profile: -mvn clean install -Prelease.

-

You can view the current documentation directly on github.

+

If you are seeing this message, it is because the Hacking Guide was not built during the Apache ActiveMQ Artemis + build. To + build Apache ActiveMQ Artemis with the Hacking Guide you must use the maven release profile: + mvn clean install -Prelease.

+

You can view the current documentation directly on github.

diff --git a/artemis-website/src/main/resources/index.html b/artemis-website/src/main/resources/index.html index 3e8ab5cc7f..58890ec3c0 100644 --- a/artemis-website/src/main/resources/index.html +++ b/artemis-website/src/main/resources/index.html @@ -31,7 +31,8 @@
diff --git a/artemis-website/src/main/resources/user-manual/index.html b/artemis-website/src/main/resources/user-manual/index.html index 0727109ced..7fc5fdab0d 100644 --- a/artemis-website/src/main/resources/user-manual/index.html +++ b/artemis-website/src/main/resources/user-manual/index.html @@ -18,15 +18,18 @@ under the License. --> - - - + + +

User Manual

-

If you are seeing this message, it is because the User Manual was not built during the Apache ActiveMQ Artemis build. To -build Apache ActiveMQ Artemis with the User Manual you must use the maven release profile: -mvn clean install -Prelease.

-

You can view the current documentation directly on github.

+

If you are seeing this message, it is because the User Manual was not built during the Apache ActiveMQ Artemis build. + To + build Apache ActiveMQ Artemis with the User Manual you must use the maven release profile: + mvn clean install -Prelease.

+

You can view the current documentation directly on github.

diff --git a/docs/hacking-guide/en/formatting.md b/docs/hacking-guide/en/formatting.md index e6c4979fcd..976d853e72 100644 --- a/docs/hacking-guide/en/formatting.md +++ b/docs/hacking-guide/en/formatting.md @@ -8,4 +8,8 @@ copy them _after importing all your projects_: done Do not use the [maven-eclipse-plugin](https://maven.apache.org/plugins/maven-eclipse-plugin/) to copy the files as it -conflicts with [m2e](http://eclipse.org/m2e/). \ No newline at end of file +conflicts with [m2e](http://eclipse.org/m2e/). + +# Idea + +If you completed the step described on [idea instructions](ide.md#style-templates-and-inspection-settings-for-idea), and selected the code style accordingly you should be ready to go. diff --git a/docs/hacking-guide/en/ide.md b/docs/hacking-guide/en/ide.md index 88435a5949..85a832e7d9 100644 --- a/docs/hacking-guide/en/ide.md +++ b/docs/hacking-guide/en/ide.md @@ -45,7 +45,9 @@ We have shared the style templates that are good for this project. If you want t * Select both Code Style Templates and File templates (it's the default option) * Select OK and restart Idea -Similarly, to import inspection settings: +Alternatively you can copy artemis-codestyle.xml under your home settings at ``IntelliJIdea15/codestyles``. + +#### To import inspection settings: * File->Settings->Editor->Inspections->Manage->Import * Select the file ./artemis-cloned-folder/etc/ide-settings/IDEA-artemis-inspections.xml diff --git a/etc/checkstyle.xml b/etc/checkstyle.xml index bb266c5544..f695bef59a 100644 --- a/etc/checkstyle.xml +++ b/etc/checkstyle.xml @@ -65,11 +65,13 @@ under the License. - + - + + + diff --git a/etc/ide-settings/IDEA-style.jar b/etc/ide-settings/IDEA-style.jar deleted file mode 100644 index 83893f3fa5..0000000000 Binary files a/etc/ide-settings/IDEA-style.jar and /dev/null differ diff --git a/etc/ide-settings/idea/IDEA-style.jar b/etc/ide-settings/idea/IDEA-style.jar new file mode 100644 index 0000000000..8e400805ae Binary files /dev/null and b/etc/ide-settings/idea/IDEA-style.jar differ diff --git a/etc/ide-settings/idea/artemis-codestyle.xml b/etc/ide-settings/idea/artemis-codestyle.xml new file mode 100644 index 0000000000..e336530c05 --- /dev/null +++ b/etc/ide-settings/idea/artemis-codestyle.xml @@ -0,0 +1,52 @@ + + + + diff --git a/etc/ide-settings/IDEA-artemis-inspections.xml b/etc/ide-settings/idea/artemis-inspections.xml similarity index 100% rename from etc/ide-settings/IDEA-artemis-inspections.xml rename to etc/ide-settings/idea/artemis-inspections.xml diff --git a/examples/features/clustered/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java b/examples/features/clustered/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java index af98901a63..ba96e56a4b 100644 --- a/examples/features/clustered/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java +++ b/examples/features/clustered/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; + /** * This example demonstrates how sessions created from a single connection can be load * balanced across the different nodes of the cluster. @@ -70,8 +70,8 @@ public class ClientSideLoadBalancingExample { Session sessionC = connectionC.createSession(false, Session.AUTO_ACKNOWLEDGE); System.out.println("Session A - " + ((ClientSessionInternal) ((org.apache.activemq.artemis.jms.client.ActiveMQSession) sessionA).getCoreSession()).getConnection().getRemoteAddress()); - System.out.println("Session B - " + ((ClientSessionInternal)((org.apache.activemq.artemis.jms.client.ActiveMQSession) sessionB).getCoreSession()).getConnection().getRemoteAddress()); - System.out.println("Session C - " + ((ClientSessionInternal)((org.apache.activemq.artemis.jms.client.ActiveMQSession) sessionC).getCoreSession()).getConnection().getRemoteAddress()); + System.out.println("Session B - " + ((ClientSessionInternal) ((org.apache.activemq.artemis.jms.client.ActiveMQSession) sessionB).getCoreSession()).getConnection().getRemoteAddress()); + System.out.println("Session C - " + ((ClientSessionInternal) ((org.apache.activemq.artemis.jms.client.ActiveMQSession) sessionC).getCoreSession()).getConnection().getRemoteAddress()); // Step 6. We create JMS MessageProducer objects on the sessions MessageProducer producerA = sessionA.createProducer(queue); @@ -107,8 +107,7 @@ public class ClientSideLoadBalancingExample { consume(sessionA, queue, numMessages, "A"); consume(sessionB, queue, numMessages, "B"); consume(sessionC, queue, numMessages, "C"); - } - finally { + } finally { // Step 10. Be sure to close our resources! if (connectionA != null) { diff --git a/examples/features/clustered/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java b/examples/features/clustered/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java index 6af9577329..7935ce50e4 100644 --- a/examples/features/clustered/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java +++ b/examples/features/clustered/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java @@ -115,8 +115,7 @@ public class ClusteredDurableSubscriptionExample { System.out.println("Got message: " + message1.getText() + " from node 1"); } - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (connection0 != null) { connection0.close(); diff --git a/examples/features/clustered/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java b/examples/features/clustered/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java index dfadef55f5..5d01f0843f 100644 --- a/examples/features/clustered/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java +++ b/examples/features/clustered/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java @@ -133,8 +133,7 @@ public class ClusteredGroupingExample { System.out.println("Got message: " + message0.getText() + " from node 0"); } - } - finally { + } finally { // Step 17. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/clustered/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java b/examples/features/clustered/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java index 5f956b5b32..1c0cbbbb7f 100644 --- a/examples/features/clustered/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java +++ b/examples/features/clustered/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java @@ -116,8 +116,7 @@ public class ClusteredJgroupsExample { System.out.println("Got message: " + message1.getText() + " from node 1"); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/clustered/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java b/examples/features/clustered/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java index f92514b3f8..7fe989ba2c 100644 --- a/examples/features/clustered/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java +++ b/examples/features/clustered/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java @@ -101,8 +101,7 @@ public class ClusteredQueueExample { System.out.println("Got message: " + message1.getText() + " from node 1"); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/clustered/clustered-static-discovery-uri/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java b/examples/features/clustered/clustered-static-discovery-uri/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java index 453fafc6a6..6e649ceede 100644 --- a/examples/features/clustered/clustered-static-discovery-uri/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java +++ b/examples/features/clustered/clustered-static-discovery-uri/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java @@ -145,8 +145,7 @@ public class StaticClusteredQueueExample { System.out.println("Got message: " + message3.getText() + " from node " + con3Node); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (initialConnection != null) { diff --git a/examples/features/clustered/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java b/examples/features/clustered/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java index 170d1d3c9d..7e732ddfba 100644 --- a/examples/features/clustered/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java +++ b/examples/features/clustered/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java @@ -145,8 +145,7 @@ public class StaticClusteredQueueExample { System.out.println("Got message: " + message3.getText() + " from node " + con3Node); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (initialConnection != null) { diff --git a/examples/features/clustered/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java b/examples/features/clustered/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java index 03979074b8..b8eddaabd4 100644 --- a/examples/features/clustered/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java +++ b/examples/features/clustered/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java @@ -135,8 +135,7 @@ public class ClusterStaticOnewayExample { System.out.println("Got message: " + message2.getText() + " from node " + con2Node); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (initialConnection != null) { diff --git a/examples/features/clustered/clustered-topic-uri/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java b/examples/features/clustered/clustered-topic-uri/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java index 10592c9652..cca45b8122 100644 --- a/examples/features/clustered/clustered-topic-uri/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java +++ b/examples/features/clustered/clustered-topic-uri/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java @@ -101,8 +101,7 @@ public class ClusteredTopicExample { System.out.println("Got message: " + message1.getText() + " from node 1"); } - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (connection0 != null) { connection0.close(); diff --git a/examples/features/clustered/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java b/examples/features/clustered/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java index 10592c9652..cca45b8122 100644 --- a/examples/features/clustered/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java +++ b/examples/features/clustered/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java @@ -101,8 +101,7 @@ public class ClusteredTopicExample { System.out.println("Got message: " + message1.getText() + " from node 1"); } - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (connection0 != null) { connection0.close(); diff --git a/examples/features/clustered/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java b/examples/features/clustered/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java index b3c056b825..bc0ec2ad00 100644 --- a/examples/features/clustered/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java +++ b/examples/features/clustered/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java @@ -129,8 +129,7 @@ public class QueueMessageRedistributionExample { // Step 18. We ack the messages. message0.acknowledge(); - } - finally { + } finally { // Step 18. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/clustered/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java b/examples/features/clustered/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java index 1163ec872d..1e3ea2b872 100644 --- a/examples/features/clustered/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java +++ b/examples/features/clustered/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java @@ -207,8 +207,7 @@ public class SymmetricClusterExample { throw new IllegalStateException("Message is null!"); } } - } - finally { + } finally { // Step 15. Be sure to close our resources! connection0.close(); diff --git a/examples/features/ha/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java b/examples/features/ha/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java index d4ab658002..1d8d3a755d 100644 --- a/examples/features/ha/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java +++ b/examples/features/ha/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java @@ -119,11 +119,9 @@ public class ApplicationLayerFailoverExample { System.out.println("Got message: " + message0.getText()); } - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); - } - finally { + } finally { // Step 14. Be sure to close our resources! closeResources(); ServerUtil.killServer(server0); @@ -158,8 +156,7 @@ public class ApplicationLayerFailoverExample { if (initialContext != null) { try { initialContext.close(); - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } @@ -167,8 +164,7 @@ public class ApplicationLayerFailoverExample { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -180,8 +176,7 @@ public class ApplicationLayerFailoverExample { public void onException(final JMSException exception) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { //ignore } for (int i = 0; i < 10; i++) { @@ -205,13 +200,11 @@ public class ApplicationLayerFailoverExample { failoverLatch.countDown(); return; - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Failed to handle failover, trying again."); try { Thread.sleep(500); - } - catch (InterruptedException e1) { + } catch (InterruptedException e1) { //ignored } } diff --git a/examples/features/ha/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java b/examples/features/ha/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java index 335da0d445..6f430c103f 100644 --- a/examples/features/ha/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java +++ b/examples/features/ha/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.api.core.client.FailoverEventListener; -import org.apache.activemq.artemis.api.core.client.FailoverEventType; -import org.apache.activemq.artemis.jms.client.ActiveMQConnection; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -30,6 +25,11 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.api.core.client.FailoverEventListener; +import org.apache.activemq.artemis.api.core.client.FailoverEventType; +import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.util.ServerUtil; + /** * This example demonstrates how you can listen on failover event on the client side *

@@ -88,8 +88,7 @@ public class ClientSideFailoverListerExample { // Step 9. We consume messages from the session A, one at a time. // We reached message no 5 the first server will crash consume(sessionA, queue, numMessages, "A"); - } - finally { + } finally { // Step 10. Be sure to close our resources! if (connectionA != null) { diff --git a/examples/features/ha/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java b/examples/features/ha/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java index ee592f9aff..43521a5849 100644 --- a/examples/features/ha/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java +++ b/examples/features/ha/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java @@ -116,8 +116,7 @@ public class ColocatedFailoverScaleDownExample { System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - } - finally { + } finally { // Step 11. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java b/examples/features/ha/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java index 5bf32f5dc2..e2b24c051c 100644 --- a/examples/features/ha/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java +++ b/examples/features/ha/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java @@ -123,8 +123,7 @@ public class ColocatedFailoverExample { System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - } - finally { + } finally { // Step 11. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java b/examples/features/ha/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java index d2b8d95802..dcbbbda575 100644 --- a/examples/features/ha/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java +++ b/examples/features/ha/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java @@ -116,8 +116,7 @@ public class HAPolicyAutoBackupExample { System.out.println("Got message: " + message0.getText() + " from node 1"); } - } - finally { + } finally { // Step 17. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/ha/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java b/examples/features/ha/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java index ab0baecedc..848243e15d 100644 --- a/examples/features/ha/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java +++ b/examples/features/ha/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + public class MultipleFailoverFailbackExample { public static void main(final String[] args) throws Exception { @@ -93,8 +93,7 @@ public class MultipleFailoverFailbackExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -111,8 +110,7 @@ public class MultipleFailoverFailbackExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -122,8 +120,7 @@ public class MultipleFailoverFailbackExample { System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java b/examples/features/ha/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java index 41d9e52c33..071930e5af 100644 --- a/examples/features/ha/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java +++ b/examples/features/ha/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + public class MultipleFailoverExample { public static void main(final String[] args) throws Exception { @@ -93,8 +93,7 @@ public class MultipleFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -111,8 +110,7 @@ public class MultipleFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { throw new IllegalStateException("Got exception while acknowledging message: " + e.getMessage()); } @@ -122,8 +120,7 @@ public class MultipleFailoverExample { System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java b/examples/features/ha/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java index 9352ac5ca0..3957316a41 100644 --- a/examples/features/ha/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java +++ b/examples/features/ha/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS non-transacted session. @@ -97,8 +97,7 @@ public class NonTransactionFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -108,8 +107,7 @@ public class NonTransactionFailoverExample { System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java b/examples/features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java index d2f74ba28d..b3bd4666cf 100644 --- a/examples/features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java +++ b/examples/features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + /** * Example of live and replicating backup pair. *

@@ -101,8 +101,7 @@ public class ReplicatedFailbackStaticExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("Got (the expected) exception while acknowledging message: " + e.getMessage()); } @@ -119,8 +118,7 @@ public class ReplicatedFailbackStaticExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -130,8 +128,7 @@ public class ReplicatedFailbackStaticExample { System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java b/examples/features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java index 29ae3816b1..cae5da1445 100644 --- a/examples/features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java +++ b/examples/features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + /** * Example of live and replicating backup pair. *

@@ -101,8 +101,7 @@ public class ReplicatedFailbackExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("Got (the expected) exception while acknowledging message: " + e.getMessage()); } @@ -119,8 +118,7 @@ public class ReplicatedFailbackExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -130,8 +128,7 @@ public class ReplicatedFailbackExample { System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java b/examples/features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java index 491d792a96..c6b122b26d 100644 --- a/examples/features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java +++ b/examples/features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import org.apache.activemq.artemis.util.ServerUtil; + public class ReplicatedMultipleFailoverExample { private static Process server0; @@ -100,8 +100,7 @@ public class ReplicatedMultipleFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -118,8 +117,7 @@ public class ReplicatedMultipleFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -129,8 +127,7 @@ public class ReplicatedMultipleFailoverExample { System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java b/examples/features/ha/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java index e6887c7ddf..cf387dba4e 100644 --- a/examples/features/ha/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java +++ b/examples/features/ha/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -29,6 +26,9 @@ import javax.jms.TextMessage; import javax.jms.TransactionRolledBackException; import javax.naming.InitialContext; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.util.ServerUtil; + /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS transacted session and replication. @@ -84,8 +84,7 @@ public class ReplicatedTransactionFailoverExample { // Step 9. As failover occurred during transaction, the session has been marked for rollback only try { session.commit(); - } - catch (TransactionRolledBackException e) { + } catch (TransactionRolledBackException e) { System.err.println("transaction has been rolled back: " + e.getMessage()); } @@ -111,8 +110,7 @@ public class ReplicatedTransactionFailoverExample { session.commit(); System.out.println("Other message on the server? " + consumer.receive(5000)); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java b/examples/features/ha/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java index 4383b287fd..6d17dc91a3 100644 --- a/examples/features/ha/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java +++ b/examples/features/ha/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -28,6 +26,8 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; +import org.apache.activemq.artemis.util.ServerUtil; + /** * A simple example that demonstrates a colocated server */ @@ -106,8 +106,7 @@ public class ScaleDownExample { System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - } - finally { + } finally { // Step 11. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java b/examples/features/ha/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java index 38f06c07b6..90c9564083 100644 --- a/examples/features/ha/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java +++ b/examples/features/ha/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java @@ -90,8 +90,7 @@ public class StopServerFailoverExample { // backup server has occurred try { message0.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Got exception while acknowledging message: " + e.getMessage()); } @@ -101,8 +100,7 @@ public class StopServerFailoverExample { System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/ha/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java b/examples/features/ha/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java index 58c514a5ea..8f69b94edf 100644 --- a/examples/features/ha/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java +++ b/examples/features/ha/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -29,6 +26,9 @@ import javax.jms.TextMessage; import javax.jms.TransactionRolledBackException; import javax.naming.InitialContext; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.util.ServerUtil; + /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS transacted session. @@ -84,8 +84,7 @@ public class TransactionFailoverExample { // Step 9. As failover occurred during transaction, the session has been marked for rollback only try { session.commit(); - } - catch (TransactionRolledBackException e) { + } catch (TransactionRolledBackException e) { System.err.println("transaction has been rolled back: " + e.getMessage()); } @@ -111,8 +110,7 @@ public class TransactionFailoverExample { session.commit(); System.out.println("Other message on the server? " + consumer.receive(5000)); - } - finally { + } finally { // Step 13. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java index ad92b08c02..ade1c5bc6c 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java @@ -62,8 +62,7 @@ public abstract class PerfBase { if (args != null && args.length > 0) { fileName = args[0]; - } - else { + } else { fileName = PerfBase.DEFAULT_PERF_PROPERTIES_FILE_NAME; } @@ -151,16 +150,14 @@ public abstract class PerfBase { destination = new org.apache.activemq.command.ActiveMQQueue(perfParams.getDestinationName()); connection = factory.createConnection(); - } - else if (perfParams.isCore()) { - factory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(perfParams.getUri()); + } else if (perfParams.isCore()) { + factory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(perfParams.getUri()); destination = new org.apache.activemq.artemis.jms.client.ActiveMQQueue(perfParams.getDestinationName()); connection = factory.createConnection(); - } - else if (perfParams.isAMQP()) { + } else if (perfParams.isAMQP()) { factory = new JmsConnectionFactory(perfParams.getUri()); destination = new org.apache.activemq.artemis.jms.client.ActiveMQQueue(perfParams.getDestinationName()); @@ -199,24 +196,20 @@ public abstract class PerfBase { sendMessages(perfParams.getNoOfMessagesToSend(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), true, perfParams.getThrottleRate(), perfParams.getMessageSize()); long end = System.currentTimeMillis(); displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -243,24 +236,20 @@ public abstract class PerfBase { long end = System.currentTimeMillis(); // start was set on the first received message displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -327,8 +316,7 @@ public abstract class PerfBase { if (i % txBatchSize == 0) { session.commit(); committed = true; - } - else { + } else { committed = false; } } @@ -402,8 +390,7 @@ public abstract class PerfBase { double duration = (1.0 * System.currentTimeMillis() - start) / 1000; PerfBase.log.info(String.format("received %6d messages in %2.2fs", currentCount, duration)); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java index 3f2c4785dc..6d447c9289 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java @@ -29,8 +29,7 @@ public class PerfListener extends PerfBase { PerfParams params = PerfBase.getParams(fileName); new PerfListener(params).run(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java index 3e192c044c..60e07e328e 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java @@ -181,7 +181,6 @@ public class PerfParams implements Serializable { this.libraryType = libraryType; } - public void setLibraryType(String libraryType) { this.libraryType = ClientLibraryType.valueOf(libraryType); } diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java index 6649bfa674..b8cca50fe6 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java @@ -29,8 +29,7 @@ public class PerfSender extends PerfBase { PerfParams params = PerfBase.getParams(fileName); new PerfSender(params).run(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java index fe0905fe63..8002f1f988 100644 --- a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java +++ b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java @@ -57,8 +57,7 @@ public class SoakReceiver { }); receiver.run(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -98,8 +97,7 @@ public class SoakReceiver { return; } - } - catch (JMSException e1) { + } catch (JMSException e1) { e1.printStackTrace(); } if (count.incrementAndGet() % modulo == 0) { @@ -135,8 +133,7 @@ public class SoakReceiver { connection.close(); connection = null; } - } - else { + } else { while (true) { Thread.sleep(500); } @@ -148,11 +145,9 @@ public class SoakReceiver { try { connection.setExceptionListener(null); connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); - } - finally { + } finally { connection = null; } } @@ -176,15 +171,12 @@ public class SoakReceiver { messageConsumer.setMessageListener(listener); connection.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { try { ic.close(); - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } diff --git a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java index d5868ea867..839acba14f 100644 --- a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java +++ b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java @@ -52,8 +52,7 @@ public class SoakSender { }); sender.run(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -128,8 +127,7 @@ public class SoakSender { if (!runInfinitely && totalDuration > perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS) { break; } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -148,11 +146,9 @@ public class SoakSender { try { connection.setExceptionListener(null); connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); - } - finally { + } finally { connection = null; } } @@ -180,15 +176,12 @@ public class SoakSender { producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp()); connection.setExceptionListener(exceptionListener); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { try { ic.close(); - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } diff --git a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java index 4c0e3b97e3..8c5d327973 100644 --- a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java +++ b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java @@ -147,12 +147,10 @@ public class BridgeExample { if (receivedMessage == null) { System.out.println("Didn't receive that message from mincing-machine on node 1"); - } - else { + } else { throw new IllegalStateException(); } - } - finally { + } finally { // Step 15. Be sure to close our resources! if (connection0 != null) { diff --git a/examples/features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java b/examples/features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java index 1c9db3b469..c307cbf175 100644 --- a/examples/features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java +++ b/examples/features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java @@ -89,8 +89,7 @@ public class QueueBrowserExample { System.out.println("Received message: " + messageReceived.getText()); messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java b/examples/features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java index bf70e96d28..c8753ee7d5 100644 --- a/examples/features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java +++ b/examples/features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java @@ -92,8 +92,7 @@ public class ClientKickoffExample { System.err.println("----------------------------------"); exception.get().printStackTrace(); System.err.println("----------------------------------"); - } - finally { + } finally { // Step 10. Be sure to close the resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java b/examples/features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java index fb98c7639c..bc2bbcce5b 100644 --- a/examples/features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java +++ b/examples/features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java @@ -100,8 +100,7 @@ public class ConsumerRateLimitExample { System.out.println("We consumed " + i + " messages in " + (end - start) + " milliseconds"); System.out.println("Actual consume rate was " + rate + " messages per second"); - } - finally { + } finally { // Step 9. Be sure to close our resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java b/examples/features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java index db28568c2d..536d78904b 100644 --- a/examples/features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java +++ b/examples/features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java @@ -122,8 +122,7 @@ public class DeadLetterExample { // Step 23. This time, we commit the session, the delivery from the dead letter queue is successful! session.commit(); - } - finally { + } finally { // Step 24. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java b/examples/features/standard/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java index cc122935c8..e70fd6cfcf 100644 --- a/examples/features/standard/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java +++ b/examples/features/standard/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java @@ -112,8 +112,7 @@ public class DelayedRedeliveryExample { " after " + (end - start) + " milliseconds."); - } - finally { + } finally { // Step 17. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java index e0146938ea..98740fef32 100644 --- a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java +++ b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java @@ -199,8 +199,7 @@ public class DivertExample { System.out.println("Received forwarded price update on server 2: " + priceUpdate2.getText()); System.out.println("Time of forward: " + priceUpdate2.getLongProperty("time_of_forward")); - } - finally { + } finally { if (connectionLondon != null) { connectionLondon.close(); } diff --git a/examples/features/standard/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java b/examples/features/standard/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java index 46cd94cf7b..179f230c98 100644 --- a/examples/features/standard/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java +++ b/examples/features/standard/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java @@ -101,8 +101,7 @@ public class DurableSubscriptionExample { // Step 18. Delete the durable subscription session.unsubscribe("subscriber-1"); - } - finally { + } finally { if (connection != null) { // Step 19. Be sure to close our JMS resources! connection.close(); diff --git a/examples/features/standard/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/features/standard/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java index 31fc14a6a1..7e7dd60cfc 100644 --- a/examples/features/standard/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java +++ b/examples/features/standard/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java @@ -72,8 +72,7 @@ public class EmbeddedExample { connection.start(); TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000); System.out.println("Received message:" + messageReceived.getText()); - } - finally { + } finally { // Step 11. Stop the JMS server jmsServer.stop(); System.out.println("Stopped the JMS Server"); diff --git a/examples/features/standard/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/features/standard/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java index 6118ea9957..61f5a015df 100644 --- a/examples/features/standard/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java +++ b/examples/features/standard/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java @@ -23,8 +23,8 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; -import java.util.Date; import java.util.Arrays; +import java.util.Date; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; @@ -46,35 +46,21 @@ public final class EmbeddedExample { public static void main(final String[] args) throws Exception { // Step 1. Create ActiveMQ Artemis core configuration, and set the properties accordingly - Configuration configuration = new ConfigurationImpl() - .setPersistenceEnabled(false) - .setJournalDirectory("target/data/journal") - .setSecurityEnabled(false) - .addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName())) - .addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName())); + Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setJournalDirectory("target/data/journal").setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName())).addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName())); // Step 2. Create the JMS configuration JMSConfiguration jmsConfig = new JMSConfigurationImpl(); // Step 3. Configure the JMS ConnectionFactory - ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl() - .setName("cf") - .setConnectorNames(Arrays.asList("connector")) - .setBindings("cf"); + ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("connector")).setBindings("cf"); jmsConfig.getConnectionFactoryConfigurations().add(cfConfig); // Step 4. Configure the JMS Queue - JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl() - .setName("queue1") - .setDurable(false) - .setBindings("queue/queue1"); + JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1"); jmsConfig.getQueueConfigurations().add(queueConfig); // Step 5. Start the JMS Server using the ActiveMQ Artemis core server and the JMS configuration - EmbeddedJMS jmsServer = new EmbeddedJMS() - .setConfiguration(configuration) - .setJmsConfiguration(jmsConfig) - .start(); + EmbeddedJMS jmsServer = new EmbeddedJMS().setConfiguration(configuration).setJmsConfiguration(jmsConfig).start(); System.out.println("Started Embedded JMS Server"); // Step 6. Lookup JMS resources defined in the configuration @@ -94,8 +80,7 @@ public final class EmbeddedExample { connection.start(); TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000); System.out.println("Received message:" + messageReceived.getText()); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/examples/features/standard/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java b/examples/features/standard/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java index 996da7438a..94ac96c992 100644 --- a/examples/features/standard/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java +++ b/examples/features/standard/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java @@ -106,8 +106,7 @@ public class ExpiryExample { System.out.println("*Origin destination* of the expired message: " + messageReceived.getStringProperty("_AMQ_ORIG_ADDRESS")); // Step 21. the actual expiration time is stored in the _AMQ_ACTUAL_EXPIRY property System.out.println("*Actual expiration time* of the expired message: " + messageReceived.getLongProperty("_AMQ_ACTUAL_EXPIRY")); - } - finally { + } finally { // Step 22. Be sure to close the resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java b/examples/features/standard/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java index 265f0c6607..0dded7aa1f 100644 --- a/examples/features/standard/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java +++ b/examples/features/standard/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java @@ -71,8 +71,7 @@ public class HttpTransportExample { System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/examples/features/standard/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java b/examples/features/standard/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java index 47bc66c9ea..5895ecc7f3 100644 --- a/examples/features/standard/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java +++ b/examples/features/standard/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java @@ -71,8 +71,7 @@ public class InstantiateConnectionFactoryExample { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/examples/features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java b/examples/features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java index b78875f662..251f2a22ab 100644 --- a/examples/features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java +++ b/examples/features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java @@ -74,8 +74,7 @@ public class InterceptorExample { System.out.println("Received message [" + messageReceived.getText() + "] with String property: " + messageReceived.getStringProperty("newproperty")); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java index 23946b0bd0..82e881904c 100644 --- a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java +++ b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java @@ -99,8 +99,7 @@ public class JMSBridgeExample { // Step 11. Display the received message's ID and this "bridged" message ID System.out.format("Message ID : %s%n", messageReceived.getJMSMessageID()); System.out.format("Bridged Message ID : %s%n", messageReceived.getStringProperty("AMQ_BRIDGE_MSG_ID_LIST")); - } - finally { + } finally { // Step 12. Be sure to close the resources! jmsBridge.stop(); if (sourceContext != null) { diff --git a/examples/features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java b/examples/features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java index 4688ba33dc..ffe0b0d795 100644 --- a/examples/features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java +++ b/examples/features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java @@ -22,7 +22,6 @@ import javax.jms.JMSContext; import javax.jms.JMSProducer; import javax.jms.Message; import javax.jms.Queue; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -72,8 +71,7 @@ public class JMSCompletionListenerExample { if (!latch.await(5, TimeUnit.SECONDS)) { throw new IllegalStateException("Completion listener not called as expected."); } - } - finally { + } finally { if (jmsContext != null) { jmsContext.close(); } diff --git a/examples/features/standard/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java b/examples/features/standard/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java index da43eb0805..d226dbf5d8 100644 --- a/examples/features/standard/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java +++ b/examples/features/standard/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java @@ -70,8 +70,7 @@ public class JMSSharedConsumerExample { body = jmsConsumer2.receiveBody(String.class, 5000); System.out.println("body = " + body); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java b/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java index 108897f89f..44be2f9856 100644 --- a/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java +++ b/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.HashMap; - import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; @@ -33,6 +31,7 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.naming.InitialContext; +import java.util.HashMap; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; @@ -107,8 +106,7 @@ public class JMXExample { // The call will timeout after 5000ms and messageReceived will be null TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived); - } - finally { + } finally { // Step 20. Be sure to close the resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java index b400d41e27..702fe41cbd 100644 --- a/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java +++ b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.util.ServerUtil; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -33,6 +31,8 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.activemq.artemis.util.ServerUtil; + /** * This example demonstrates the ability of ActiveMQ Artemis to send and consume a very large message, much * bigger than can fit in RAM. @@ -166,8 +166,7 @@ public class LargeMessageExample { } System.out.println("File streamed to disk. Size of received file on disk is " + outputFile.length()); - } - finally { + } finally { // Step 12. Be sure to close our resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java b/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java index 317835b0e9..d164e13a62 100644 --- a/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java +++ b/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java @@ -93,8 +93,7 @@ public class LastValueQueueExample { System.out.format("Received message: %s%n", messageReceived); cf.close(); - } - finally { + } finally { // Step 13. Be sure to close our JMS resources! if (connection != null) { connection.close(); diff --git a/examples/features/standard/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java b/examples/features/standard/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java index fed21b0705..94f6418a9e 100644 --- a/examples/features/standard/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java +++ b/examples/features/standard/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.Enumeration; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -29,6 +27,7 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.Topic; import javax.naming.InitialContext; +import java.util.Enumeration; /** * An example that shows how to receive management notifications using JMS messages. @@ -70,8 +69,7 @@ public class ManagementNotificationExample { String propertyName = (String) propertyNames.nextElement(); System.out.format(" %s: %s%n", propertyName, notif.getObjectProperty(propertyName)); } - } - catch (JMSException e) { + } catch (JMSException e) { } System.out.println("------------------------"); } @@ -89,15 +87,13 @@ public class ManagementNotificationExample { // Step 10. Try to create a connection with unknown user try { cf.createConnection("not.a.valid.user", "not.a.valid.password"); - } - catch (JMSException e) { + } catch (JMSException e) { } // sleep a little bit to be sure to receive the notification for the security // authentication violation before leaving the example Thread.sleep(2000); - } - finally { + } finally { // Step 11. Be sure to close the resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java b/examples/features/standard/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java index 73375d62b3..79a4898bf5 100644 --- a/examples/features/standard/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java +++ b/examples/features/standard/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java @@ -119,8 +119,7 @@ public class ManagementExample { // there is none to consume. The call will timeout after 5000ms and messageReceived will be null TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived); - } - finally { + } finally { // Step 23. Be sure to close the resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java b/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java index 8e6cc26aea..5fc824565d 100644 --- a/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java +++ b/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.HashMap; - import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; @@ -33,6 +31,7 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.naming.InitialContext; +import java.util.HashMap; import org.apache.activemq.artemis.api.core.management.MessageCounterInfo; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; @@ -112,8 +111,7 @@ public class MessageCounterExample { counters = queueControl.listMessageCounter(); messageCounter = MessageCounterInfo.fromJSON(counters); displayMessageCounter(messageCounter); - } - finally { + } finally { // Step 17. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java b/examples/features/standard/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java index f8ee48ab42..e04b790ba5 100644 --- a/examples/features/standard/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java +++ b/examples/features/standard/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java @@ -89,8 +89,7 @@ public class MessageGroupExample { } cf.close(); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (connection != null) { connection.close(); @@ -115,9 +114,8 @@ class SimpleMessageListener implements MessageListener { TextMessage msg = (TextMessage) message; System.out.format("Message: [%s] received by %s%n", msg.getText(), name); messageReceiverMap.put(msg.getText(), name); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java b/examples/features/standard/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java index 4b24928578..740d83b53d 100644 --- a/examples/features/standard/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java +++ b/examples/features/standard/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java @@ -96,8 +96,7 @@ public class MessageGroup2Example { throw new IllegalStateException("Group message [producer2 message " + i + "] went to wrong receiver: " + receiver); } } - } - finally { + } finally { //Step 11. Be sure to close our JMS resources! if (connection != null) { connection.close(); @@ -122,9 +121,8 @@ class SimpleMessageListener implements MessageListener { TextMessage msg = (TextMessage) message; System.out.format("Message: [%s] received by %s%n", msg.getText(), name); messageReceiverMap.put(msg.getText(), name); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java b/examples/features/standard/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java index 113f9fe587..2208445c38 100644 --- a/examples/features/standard/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java +++ b/examples/features/standard/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -30,6 +27,8 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -79,11 +78,9 @@ public class MessagePriorityExample { "with priority: " + sentMessages[2].getJMSPriority()); - MessageConsumer redConsumer = session.createConsumer(queue); redConsumer.setMessageListener(new SimpleMessageListener(msgReceived, result)); - // Step 10. Start the connection now. connection.start(); @@ -100,8 +97,7 @@ public class MessagePriorityExample { if (!result.get()) throw new IllegalStateException(); - } - finally { + } finally { // Step 13. Be sure to close our JMS resources! if (connection != null) { connection.close(); @@ -125,8 +121,7 @@ class SimpleMessageListener implements MessageListener { TextMessage textMessage = (TextMessage) msg; try { System.out.println("Received message : [" + textMessage.getText() + "]"); - } - catch (JMSException e) { + } catch (JMSException e) { result.set(false); } msgReceived.add(textMessage); diff --git a/examples/features/standard/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java b/examples/features/standard/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java index 6f321b08d4..6bb1904eb7 100644 --- a/examples/features/standard/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java +++ b/examples/features/standard/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java @@ -98,8 +98,7 @@ public class NoConsumerBufferingExample { System.out.println("Consumed message from consumer1: " + message.getText()); } - } - finally { + } finally { // Step 9. Be sure to close our resources! if (connection != null) { diff --git a/examples/features/standard/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java b/examples/features/standard/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java index 19d8a178ab..165fae2739 100644 --- a/examples/features/standard/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java +++ b/examples/features/standard/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java @@ -118,8 +118,7 @@ public class PagingExample { message.acknowledge(); } - } - finally { + } finally { // And finally, always remember to close your JMS connections after use, in a finally block. Closing a JMS // connection will automatically close all of its sessions, consumers, producer and browser objects diff --git a/examples/features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java b/examples/features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java index 5c809f8de2..4962535010 100644 --- a/examples/features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java +++ b/examples/features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java @@ -92,8 +92,7 @@ public class PreacknowledgeExample { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { // Step 9. Be sure to close our resources! if (connection != null) { connection.close(); diff --git a/examples/features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java b/examples/features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java index a7623bbbec..e3afaa37de 100644 --- a/examples/features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java +++ b/examples/features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java @@ -95,8 +95,7 @@ public class ProducerRateLimitExample { } System.out.println("Received " + i + " messages"); - } - finally { + } finally { // Step 9. Be sure to close our resources! if (connection != null) { connection.close(); diff --git a/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java b/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java index 607d82fc38..3fec19a591 100644 --- a/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java +++ b/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java @@ -75,14 +75,12 @@ public class QueueRequestorExample { // Step 13. close the text reverser service reverserService.close(); - } - finally { + } finally { if (connection != null) { try { // Step 14. Be sure to close the JMS resources! connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java b/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java index 12c5272acd..8e72f0f167 100644 --- a/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java +++ b/examples/features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java @@ -82,8 +82,7 @@ public class TextReverserService implements MessageListener { // send the reply producer.send(reply); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -95,8 +94,7 @@ public class TextReverserService implements MessageListener { try { // be sure to close the JMS resources connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/examples/features/standard/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java b/examples/features/standard/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java index b915dd0248..68d8e704a3 100644 --- a/examples/features/standard/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java +++ b/examples/features/standard/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java @@ -99,8 +99,7 @@ public class QueueSelectorExample { if (!result.get()) throw new IllegalStateException(); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); @@ -135,8 +134,7 @@ class SimpleMessageListener implements MessageListener { if (!colorProp.equals(name) && !name.equals("any")) { result.set(false); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); result.set(false); } diff --git a/examples/features/standard/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/features/standard/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java index b6ce381510..6a80dc262b 100644 --- a/examples/features/standard/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java +++ b/examples/features/standard/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -70,8 +70,7 @@ public class QueueExample { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java b/examples/features/standard/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java index 459c33b357..b76afb430f 100644 --- a/examples/features/standard/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java +++ b/examples/features/standard/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java @@ -93,8 +93,7 @@ public class ReattachExample { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { // Step 14. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); @@ -139,8 +138,7 @@ public class ReattachExample { JMSManagementHelper.putOperationInvocation(m, "core.acceptor.netty-acceptor", oper); producer.send(m); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/examples/features/standard/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java b/examples/features/standard/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java index edab71c91f..6ba2618074 100644 --- a/examples/features/standard/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java +++ b/examples/features/standard/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.HashMap; -import java.util.Map; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -32,6 +29,8 @@ import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.util.HashMap; +import java.util.Map; /** * A simple JMS example that shows how to use Request/Replay style messaging. @@ -118,8 +117,7 @@ public class RequestReplyExample { // Step 19. Shutdown the request server server.shutdown(); - } - finally { + } finally { // Step 20. Be sure to close our JMS resources! if (connection != null) { connection.close(); @@ -191,8 +189,7 @@ class SimpleRequestServer implements MessageListener { replyProducer.send(replyDestination, replyMessage); System.out.println("Reply sent"); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/examples/features/standard/rest/dup-send/src/main/java/ReceiveOrder.java b/examples/features/standard/rest/dup-send/src/main/java/ReceiveOrder.java index d6dcb818ab..e16d4eee64 100644 --- a/examples/features/standard/rest/dup-send/src/main/java/ReceiveOrder.java +++ b/examples/features/standard/rest/dup-send/src/main/java/ReceiveOrder.java @@ -36,16 +36,14 @@ public class ReceiveOrder { if (res.getStatus() == 503) { System.out.println("Timeout..."); consumeNext = res.getHeaderAsLink("msg-consume-next"); - } - else if (res.getStatus() == 200) { + } else if (res.getStatus() == 200) { Order order = (Order) res.getEntity(Order.class); System.out.println(order); consumeNext = res.getHeaderAsLink("msg-consume-next"); - } - else { + } else { throw new RuntimeException("Failure! " + res.getStatus()); } res.releaseConnection(); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/rest/javascript-chat/src/test/java/org/jboss/resteasy/messaging/test/AutoAckTopicTest.java b/examples/features/standard/rest/javascript-chat/src/test/java/org/jboss/resteasy/messaging/test/AutoAckTopicTest.java index 0a0d5aeeca..10fb311a72 100644 --- a/examples/features/standard/rest/javascript-chat/src/test/java/org/jboss/resteasy/messaging/test/AutoAckTopicTest.java +++ b/examples/features/standard/rest/javascript-chat/src/test/java/org/jboss/resteasy/messaging/test/AutoAckTopicTest.java @@ -16,10 +16,10 @@ */ package org.jboss.resteasy.messaging.test; +import org.apache.activemq.artemis.rest.util.LinkStrategy; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; -import org.apache.activemq.artemis.rest.util.LinkStrategy; import org.junit.Assert; public class AutoAckTopicTest { @@ -85,4 +85,4 @@ public class AutoAckTopicTest { */ } -} \ No newline at end of file +} diff --git a/examples/features/standard/rest/jms-to-rest/src/main/java/JmsReceive.java b/examples/features/standard/rest/jms-to-rest/src/main/java/JmsReceive.java index 455540c56b..54ca51f0a7 100644 --- a/examples/features/standard/rest/jms-to-rest/src/main/java/JmsReceive.java +++ b/examples/features/standard/rest/jms-to-rest/src/main/java/JmsReceive.java @@ -15,10 +15,6 @@ * limitations under the License. */ -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; -import org.apache.activemq.artemis.rest.Jms; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -27,6 +23,10 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.rest.Jms; + public class JmsReceive { public static void main(String[] args) throws Exception { @@ -38,15 +38,15 @@ public class JmsReceive { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(destination); consumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(Message message) { - System.out.println("Received Message: "); - Order order = Jms.getEntity(message, Order.class); - System.out.println(order); - } - }); + @Override + public void onMessage(Message message) { + System.out.println("Received Message: "); + Order order = Jms.getEntity(message, Order.class); + System.out.println(order); + } + }); conn.start(); Thread.sleep(1000000); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/rest/jms-to-rest/src/main/java/JmsSend.java b/examples/features/standard/rest/jms-to-rest/src/main/java/JmsSend.java index 0cde207f51..7d5734f3b0 100644 --- a/examples/features/standard/rest/jms-to-rest/src/main/java/JmsSend.java +++ b/examples/features/standard/rest/jms-to-rest/src/main/java/JmsSend.java @@ -15,9 +15,6 @@ * limitations under the License. */ -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -25,6 +22,9 @@ import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; + public class JmsSend { public static void main(String[] args) throws Exception { diff --git a/examples/features/standard/rest/jms-to-rest/src/main/java/RestReceive.java b/examples/features/standard/rest/jms-to-rest/src/main/java/RestReceive.java index a4754d0bac..34b915407d 100644 --- a/examples/features/standard/rest/jms-to-rest/src/main/java/RestReceive.java +++ b/examples/features/standard/rest/jms-to-rest/src/main/java/RestReceive.java @@ -35,15 +35,13 @@ public class RestReceive { if (res.getStatus() == 503) { System.out.println("Timeout..."); ackNext = res.getHeaderAsLink("msg-acknowledge-next"); - } - else if (res.getStatus() == 200) { + } else if (res.getStatus() == 200) { Order order = (Order) res.getEntity(Order.class); System.out.println(order); Link ack = res.getHeaderAsLink("msg-acknowledgement"); res = ack.request().formParameter("acknowledge", "true").post(); ackNext = res.getHeaderAsLink("msg-acknowledge-next"); - } - else { + } else { throw new RuntimeException("Failure! " + res.getStatus()); } res.releaseConnection(); diff --git a/examples/features/standard/rest/push/src/main/java/PostOrder.java b/examples/features/standard/rest/push/src/main/java/PostOrder.java index b37adf712a..5ceaecd86d 100644 --- a/examples/features/standard/rest/push/src/main/java/PostOrder.java +++ b/examples/features/standard/rest/push/src/main/java/PostOrder.java @@ -15,9 +15,6 @@ * limitations under the License. */ -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -25,6 +22,9 @@ import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; + public class PostOrder { public static void main(String[] args) throws Exception { diff --git a/examples/features/standard/rest/push/src/main/java/ReceiveShipping.java b/examples/features/standard/rest/push/src/main/java/ReceiveShipping.java index b82bbe89e5..b422c03da2 100644 --- a/examples/features/standard/rest/push/src/main/java/ReceiveShipping.java +++ b/examples/features/standard/rest/push/src/main/java/ReceiveShipping.java @@ -15,10 +15,6 @@ * limitations under the License. */ -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; -import org.apache.activemq.artemis.rest.Jms; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -27,6 +23,10 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.rest.Jms; + public class ReceiveShipping { public static void main(String[] args) throws Exception { @@ -37,15 +37,15 @@ public class ReceiveShipping { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(destination); consumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(Message message) { - System.out.println("Received Message: "); - Order order = Jms.getEntity(message, Order.class); - System.out.println(order); - } - }); + @Override + public void onMessage(Message message) { + System.out.println("Received Message: "); + Order order = Jms.getEntity(message, Order.class); + System.out.println(order); + } + }); conn.start(); Thread.sleep(1000000); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java b/examples/features/standard/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java index ba869496b6..98e477684e 100644 --- a/examples/features/standard/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java +++ b/examples/features/standard/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.text.SimpleDateFormat; -import java.util.Date; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -27,6 +24,8 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.text.SimpleDateFormat; +import java.util.Date; import org.apache.activemq.artemis.api.core.Message; @@ -80,8 +79,7 @@ public class ScheduledMessageExample { System.out.println("Received message: " + messageReceived.getText()); System.out.println("Time of receive: " + formatter.format(new Date())); - } - finally { + } finally { // Step 13. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java index abf5fac48d..2861182ded 100644 --- a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java @@ -58,8 +58,7 @@ public class SecurityExample { try { failConnection = cf.createConnection(); result = false; - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { System.out.println("Default user cannot get a connection. Details: " + e.getMessage()); } @@ -67,8 +66,7 @@ public class SecurityExample { try { billConnection = createConnection("bill", "activemq1", cf); result = false; - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User bill failed to connect. Details: " + e.getMessage()); } @@ -125,8 +123,7 @@ public class SecurityExample { // Step 18. Check permissions on news.us.usTopic for sam: can't send but can receive checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection); System.out.println("-------------------------------------------------------------------------------------"); - } - finally { + } finally { // Step 19. Be sure to close our JMS resources! if (failConnection != null) { failConnection.close(); @@ -170,8 +167,7 @@ public class SecurityExample { msg.getText() + "] to topic " + topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); } @@ -184,8 +180,7 @@ public class SecurityExample { if (receivedMsg != null) { System.out.println("User " + user + " can receive message [" + receivedMsg.getText() + "] from topic " + topic); - } - else { + } else { throw new IllegalStateException("Security setting is broken! User " + user + " cannot receive message from topic " + topic); } @@ -202,8 +197,7 @@ public class SecurityExample { MessageProducer producer = session.createProducer(topic); try { session.createConsumer(topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot receive any message from topic " + topic); } @@ -216,8 +210,7 @@ public class SecurityExample { TextMessage receivedMsg = (TextMessage) goodConsumer.receive(2000); if (receivedMsg != null) { System.out.println("User " + user + " can send message [" + receivedMsg.getText() + "] to topic " + topic); - } - else { + } else { throw new IllegalStateException("Security setting is broken! User " + user + " cannot send message [" + msg.getText() + @@ -238,8 +231,7 @@ public class SecurityExample { try { session.createConsumer(topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot create consumer on topic " + topic); } @@ -251,8 +243,7 @@ public class SecurityExample { msg.getText() + "] to topic " + topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); } @@ -272,8 +263,7 @@ public class SecurityExample { if (receivedMsg != null) { System.out.println("User " + user + " can send message: [" + msg.getText() + "] to topic: " + topic); System.out.println("User " + user + " can receive message: [" + msg.getText() + "] from topic: " + topic); - } - else { + } else { throw new IllegalStateException("Error! User " + user + " cannot receive the message! "); } session.close(); diff --git a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemoryDirectoryServiceFactory.java b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemoryDirectoryServiceFactory.java index d7ebde4b84..f6aaf44b13 100644 --- a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemoryDirectoryServiceFactory.java +++ b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemoryDirectoryServiceFactory.java @@ -23,7 +23,6 @@ import java.util.List; import net.sf.ehcache.CacheManager; import net.sf.ehcache.config.CacheConfiguration; import net.sf.ehcache.config.Configuration; - import org.apache.commons.io.FileUtils; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.schema.LdapComparator; @@ -65,8 +64,7 @@ public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory public InMemoryDirectoryServiceFactory() { try { directoryService = new DefaultDirectoryService(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } directoryService.setShutdownHookEnabled(false); @@ -100,8 +98,7 @@ public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); - } - catch (IOException e) { + } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } @@ -109,11 +106,7 @@ public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); - CacheConfiguration defaultCache = new CacheConfiguration("default", 1) - .eternal(false) - .timeToIdleSeconds(30) - .timeToLiveSeconds(30) - .overflowToDisk(false); + CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30).timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig)); directoryService.setCacheService(cacheService); @@ -141,10 +134,7 @@ public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory } // Init system partition - Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService - .getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService - .getInstanceLayout() - .getPartitionsDirectory(), "system")); + Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); diff --git a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemorySchemaPartition.java b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemorySchemaPartition.java index f7ec24d5dc..28f39e8900 100644 --- a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemorySchemaPartition.java +++ b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/InMemorySchemaPartition.java @@ -16,14 +16,13 @@ */ package org.apache.activemq.artemis.jms.example.ldap; +import javax.naming.InvalidNameException; import java.net.URL; import java.util.Map; import java.util.TreeSet; import java.util.UUID; import java.util.regex.Pattern; -import javax.naming.InvalidNameException; - import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; diff --git a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/LdapServer.java b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/LdapServer.java index 1161922b72..c9a4b3cf4b 100644 --- a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/LdapServer.java +++ b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/ldap/LdapServer.java @@ -39,7 +39,6 @@ public class LdapServer { * Create a single LDAP server. * * @param ldifFile - * * @throws Exception */ public LdapServer(String ldifFile) throws Exception { @@ -68,18 +67,18 @@ public class LdapServer { directoryService.shutdown(); } - private void importLdif(DirectoryService directoryService, final SchemaManager schemaManager, LdifReader ldifReader) throws Exception { + private void importLdif(DirectoryService directoryService, + final SchemaManager schemaManager, + LdifReader ldifReader) throws Exception { try { for (LdifEntry ldifEntry : ldifReader) { checkPartition(ldifEntry); directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry())); } - } - finally { + } finally { try { ldifReader.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { // ignore } } @@ -90,8 +89,7 @@ public class LdapServer { Dn parent = dn.getParent(); try { directoryService.getAdminSession().exists(parent); - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Creating new partition for DN=" + dn + "\n"); AvlPartition partition = new AvlPartition(directoryService.getSchemaManager()); partition.setId(dn.getName()); @@ -99,4 +97,4 @@ public class LdapServer { directoryService.addPartition(partition); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java index 90cf72ca54..04d8c500b9 100644 --- a/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ b/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java @@ -54,8 +54,7 @@ public class SecurityExample { try { failConnection = cf.createConnection(); result = false; - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { System.out.println("Default user cannot get a connection. Details: " + e.getMessage()); } @@ -63,8 +62,7 @@ public class SecurityExample { try { billConnection = createConnection("bill", "activemq1", cf); result = false; - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User bill failed to connect. Details: " + e.getMessage()); } @@ -121,8 +119,7 @@ public class SecurityExample { // Step 18. Check permissions on news.us.usTopic for sam: can't send but can receive checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection); System.out.println("-------------------------------------------------------------------------------------"); - } - finally { + } finally { // Step 19. Be sure to close our JMS resources! if (failConnection != null) { failConnection.close(); @@ -164,8 +161,7 @@ public class SecurityExample { msg.getText() + "] to topic " + topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); } @@ -178,8 +174,7 @@ public class SecurityExample { if (receivedMsg != null) { System.out.println("User " + user + " can receive message [" + receivedMsg.getText() + "] from topic " + topic); - } - else { + } else { throw new IllegalStateException("Security setting is broken! User " + user + " cannot receive message from topic " + topic); } @@ -196,8 +191,7 @@ public class SecurityExample { MessageProducer producer = session.createProducer(topic); try { session.createConsumer(topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot receive any message from topic " + topic); } @@ -210,8 +204,7 @@ public class SecurityExample { TextMessage receivedMsg = (TextMessage) goodConsumer.receive(2000); if (receivedMsg != null) { System.out.println("User " + user + " can send message [" + receivedMsg.getText() + "] to topic " + topic); - } - else { + } else { throw new IllegalStateException("Security setting is broken! User " + user + " cannot send message [" + msg.getText() + @@ -232,8 +225,7 @@ public class SecurityExample { try { session.createConsumer(topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot create consumer on topic " + topic); } @@ -245,8 +237,7 @@ public class SecurityExample { msg.getText() + "] to topic " + topic); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); } @@ -266,8 +257,7 @@ public class SecurityExample { if (receivedMsg != null) { System.out.println("User " + user + " can send message: [" + msg.getText() + "] to topic: " + topic); System.out.println("User " + user + " can receive message: [" + msg.getText() + "] from topic: " + topic); - } - else { + } else { throw new IllegalStateException("Error! User " + user + " cannot receive the message! "); } session.close(); diff --git a/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java index f49d83487e..a3097d2fa8 100644 --- a/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java +++ b/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java @@ -90,8 +90,7 @@ public class SendAcknowledgementsExample { System.out.println("Sent message " + i); } - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java b/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java index 174f092372..25b006831b 100644 --- a/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java +++ b/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java @@ -29,8 +29,7 @@ public class ExampleListener implements MessageListener { public void onMessage(Message message) { try { lastMessage = ((TextMessage) message).getText(); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } System.out.println("MESSAGE RECEIVED: " + lastMessage); diff --git a/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java b/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java index 594c69b335..0d75bedb4e 100644 --- a/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java +++ b/examples/features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java @@ -53,16 +53,13 @@ public class MessageSender { MessageProducer producer = session.createProducer(destination); TextMessage message = session.createTextMessage(msg); producer.send(message); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); - } - finally { + } finally { if (conn != null) { try { conn.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/examples/features/standard/ssl-enabled-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/SSLDualAuthenticationExample.java b/examples/features/standard/ssl-enabled-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/SSLDualAuthenticationExample.java index a3c928e586..29c186e944 100644 --- a/examples/features/standard/ssl-enabled-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/SSLDualAuthenticationExample.java +++ b/examples/features/standard/ssl-enabled-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/SSLDualAuthenticationExample.java @@ -82,8 +82,7 @@ public class SSLDualAuthenticationExample { System.out.println("Received message: " + messageReceived.getText()); initialContext.close(); - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java b/examples/features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java index 27bf7390e4..cceedfcf0a 100644 --- a/examples/features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java +++ b/examples/features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java @@ -72,8 +72,7 @@ public class SSLExample { System.out.println("Received message: " + messageReceived.getText()); initialContext.close(); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java b/examples/features/standard/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java index 627ef7da7e..d930890d41 100644 --- a/examples/features/standard/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java +++ b/examples/features/standard/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java @@ -93,8 +93,7 @@ public class StaticSelectorExample { if (!result.get()) throw new IllegalStateException(); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); @@ -129,8 +128,7 @@ class SimpleMessageListener implements MessageListener { if (colorProp != null && !colorProp.equals(name)) { result.set(false); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); result.set(false); } diff --git a/examples/features/standard/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java b/examples/features/standard/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java index 5747faeceb..7f3fab77df 100644 --- a/examples/features/standard/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java +++ b/examples/features/standard/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java @@ -99,12 +99,10 @@ public class TemporaryQueueExample { try { messageConsumer = session.createConsumer(tempQueue2); throw new Exception("Temporary queue cannot be accessed outside its lifecycle!"); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("Exception got when trying to access a temp queue outside its scope: " + e); } - } - finally { + } finally { if (connection != null) { // Step 20. Be sure to close our JMS resources! connection.close(); diff --git a/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java b/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java index 5b9a0847b3..41bda55746 100644 --- a/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java +++ b/examples/features/standard/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java @@ -102,8 +102,7 @@ public class TopicHierarchyExample { } System.out.println("Didn't received any more message: " + message); - } - finally { + } finally { // Step 12. Be sure to close our resources! if (connection != null) { connection.close(); diff --git a/examples/features/standard/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java b/examples/features/standard/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java index 53aee126cd..8fe570f04b 100644 --- a/examples/features/standard/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java +++ b/examples/features/standard/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java @@ -131,8 +131,7 @@ public class TopicSelectorExample1 { messageConsumer1.close(); messageConsumer2.close(); messageConsumer3.close(); - } - finally { + } finally { // Step 15. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java b/examples/features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java index 037e5fb087..56202517c2 100644 --- a/examples/features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java +++ b/examples/features/standard/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java @@ -99,8 +99,7 @@ public class TopicSelectorExample2 { if (!result.get()) throw new IllegalStateException(); - } - finally { + } finally { // Step 14. Be sure to close our JMS resources! if (connection != null) { connection.close(); @@ -137,10 +136,9 @@ class SimpleMessageListener implements MessageListener { if (!colorProp.equals(name) && !name.equals("all")) { result.set(false); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); result.set(false); } } -} \ No newline at end of file +} diff --git a/examples/features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java b/examples/features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java index 1c8695b813..2265dfd578 100644 --- a/examples/features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java +++ b/examples/features/standard/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java @@ -78,8 +78,7 @@ public class TopicExample { messageReceived = (TextMessage) messageConsumer2.receive(); System.out.println("Consumer 2 Received message: " + messageReceived.getText()); - } - finally { + } finally { // Step 14. Be sure to close our JMS resources! if (connection != null) { connection.close(); diff --git a/examples/features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java b/examples/features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java index 09c2a3d052..d7be85ee2a 100644 --- a/examples/features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java +++ b/examples/features/standard/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java @@ -111,8 +111,7 @@ public class TransactionalExample { System.out.println("Message received after receive commit: " + receivedMessage); - } - finally { + } finally { if (connection != null) { // Step 18. Be sure to close our JMS resources! connection.close(); diff --git a/examples/features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java b/examples/features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java index 6025b322f6..2d5a2acfe1 100644 --- a/examples/features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java +++ b/examples/features/standard/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java @@ -166,8 +166,7 @@ public class XAHeuristicExample { // Step 32. Close the JMX Connector connector.close(); - } - finally { + } finally { // Step 32. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); @@ -212,8 +211,7 @@ class SimpleMessageListener implements MessageListener { try { System.out.println("Message received: " + ((TextMessage) message).getText()); receiveHolder.add(((TextMessage) message).getText()); - } - catch (JMSException e) { + } catch (JMSException e) { result = false; e.printStackTrace(); } diff --git a/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java index 6427bd4fdc..a570770748 100644 --- a/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java +++ b/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.utils.Base64; - import javax.transaction.xa.Xid; +import org.apache.activemq.artemis.utils.Base64; + public class DummyXid implements Xid { private static final long serialVersionUID = 407053232840068514L; diff --git a/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java b/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java index 4c4448dd5b..4e21c0faf3 100644 --- a/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java +++ b/examples/features/standard/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java @@ -127,12 +127,10 @@ public class XAReceiveExample { TextMessage rm3 = (TextMessage) xaConsumer.receive(2000); if (rm3 == null) { System.out.println("No message received after commit."); - } - else { + } else { throw new IllegalStateException(); } - } - finally { + } finally { // Step 27. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java index 6427bd4fdc..a570770748 100644 --- a/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java +++ b/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.utils.Base64; - import javax.transaction.xa.Xid; +import org.apache.activemq.artemis.utils.Base64; + public class DummyXid implements Xid { private static final long serialVersionUID = 407053232840068514L; diff --git a/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java b/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java index 769727b490..5c65f119a1 100644 --- a/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java +++ b/examples/features/standard/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java @@ -141,8 +141,7 @@ public class XASendExample { if (!result.get()) throw new IllegalStateException(); - } - finally { + } finally { // Step 29. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); @@ -183,8 +182,7 @@ class SimpleMessageListener implements MessageListener { try { System.out.println("Message received: " + message); receiveHolder.add(((TextMessage) message).getText()); - } - catch (JMSException e) { + } catch (JMSException e) { result.set(false); e.printStackTrace(); } diff --git a/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java b/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java index b412d8773a..7d1a662533 100644 --- a/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java +++ b/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java @@ -63,8 +63,7 @@ public class AerogearExample { System.out.println("now check your mobile app and press enter"); System.in.read(); - } - finally { + } finally { // Step 12. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java index ac6ccdc945..3f248afc89 100644 --- a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java +++ b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java @@ -47,8 +47,7 @@ public class ExampleVerticle extends Verticle { try { latch0.await(5000, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } diff --git a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java index e7f6d6292b..b8e6d98d40 100644 --- a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java +++ b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java @@ -75,8 +75,7 @@ public class VertxConnectorExample { // Step 4 Waiting for the Verticle to process the message latch.await(10000, TimeUnit.MILLISECONDS); - } - finally { + } finally { if (platformManager != null) { platformManager.undeployAll(null); platformManager.stop(); @@ -92,8 +91,7 @@ public class VertxConnectorExample { System.err.println("### FAILURE! ###"); System.err.println("#####################"); System.exit(1); - } - else { + } else { System.out.println(); System.out.println("#####################"); System.out.println("### SUCCESS! ###"); diff --git a/examples/protocols/amqp/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java b/examples/protocols/amqp/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java index be9c2f3a38..c8fd1ff8bf 100644 --- a/examples/protocols/amqp/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java +++ b/examples/protocols/amqp/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java @@ -77,15 +77,13 @@ public class ProtonCPPExample { // We are not going to issue this as an error because // we also use this example as part of our tests on artemis // this is not considered an error, just that no messages arrived (i.e. hello wasn't called) - } - else { + } else { System.out.println("message received: " + messageReceived); // Sending message back to client producerAnswer.send(session.createTextMessage("HELLO from Apache ActiveMQ Artemis")); } - } - finally { + } finally { // Step 9. Be sure to close our resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/protocols/amqp/queue/src/main/java/org/apache/activemq/artemis/jms/example/AMQPQueueExample.java b/examples/protocols/amqp/queue/src/main/java/org/apache/activemq/artemis/jms/example/AMQPQueueExample.java index ea3f006c7a..8386fc4fb0 100644 --- a/examples/protocols/amqp/queue/src/main/java/org/apache/activemq/artemis/jms/example/AMQPQueueExample.java +++ b/examples/protocols/amqp/queue/src/main/java/org/apache/activemq/artemis/jms/example/AMQPQueueExample.java @@ -56,8 +56,7 @@ public class AMQPQueueExample { TextMessage m = (TextMessage) consumer.receive(5000); System.out.println("message = " + m.getText()); - } - finally { + } finally { if (connection != null) { // Step 9. close the connection connection.close(); diff --git a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java index 0195894a9f..73e44ff21b 100644 --- a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java +++ b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java @@ -41,8 +41,7 @@ public class Chat implements javax.jms.MessageListener { connect = factory.createConnection(username, password); pubSession = connect.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); subSession = connect.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - } - catch (javax.jms.JMSException jmse) { + } catch (javax.jms.JMSException jmse) { System.err.println("error: Cannot connect to Broker - " + broker); jmse.printStackTrace(); System.exit(1); @@ -56,8 +55,7 @@ public class Chat implements javax.jms.MessageListener { publisher = pubSession.createProducer(topic); // Now that setup is complete, start the Connection connect.start(); - } - catch (javax.jms.JMSException jmse) { + } catch (javax.jms.JMSException jmse) { jmse.printStackTrace(); } @@ -76,11 +74,9 @@ public class Chat implements javax.jms.MessageListener { publisher.send(msg); } } - } - catch (java.io.IOException ioe) { + } catch (java.io.IOException ioe) { ioe.printStackTrace(); - } - catch (javax.jms.JMSException jmse) { + } catch (javax.jms.JMSException jmse) { jmse.printStackTrace(); } } @@ -100,12 +96,10 @@ public class Chat implements javax.jms.MessageListener { try { String string = textMessage.getText(); System.out.println(string); - } - catch (javax.jms.JMSException jmse) { + } catch (javax.jms.JMSException jmse) { jmse.printStackTrace(); } - } - catch (java.lang.RuntimeException rte) { + } catch (java.lang.RuntimeException rte) { rte.printStackTrace(); } } @@ -116,8 +110,7 @@ public class Chat implements javax.jms.MessageListener { private void exit() { try { connect.close(); - } - catch (javax.jms.JMSException jmse) { + } catch (javax.jms.JMSException jmse) { jmse.printStackTrace(); } diff --git a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Server.java b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Server.java index a3d021c122..c3e838eee6 100644 --- a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Server.java +++ b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Server.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, @@ -22,6 +22,7 @@ import java.util.Scanner; import org.apache.activemq.artemis.util.ServerUtil; public class Server { + private static Process server0; private static Scanner scanner; @@ -30,15 +31,13 @@ public class Server { try { server0 = ServerUtil.startServer(args[0], Server.class.getSimpleName(), 0, 5000); - Scanner scanner = new Scanner(System.in); System.out.println("Alternatively you could start the server under ./target/server0"); System.out.println("Press enter to stop the server:"); scanner.nextLine(); - } - finally { + } finally { ServerUtil.killServer(server0); } diff --git a/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java index 59f18091c3..cfb0acab79 100644 --- a/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java +++ b/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -25,7 +25,6 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -72,9 +71,7 @@ public class QueueExample { System.out.println("Finished ok!"); - - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -93,9 +90,8 @@ public class QueueExample { public void onMessage(Message message) { latch.countDown(); try { - System.out.println("Received " + ((TextMessage)message).getText()); - } - catch (Exception e) { + System.out.println("Received " + ((TextMessage) message).getText()); + } catch (Exception e) { e.printStackTrace(); } } diff --git a/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java index 0ce9c9495e..4ecbb50933 100644 --- a/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java +++ b/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -25,7 +25,6 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -81,14 +80,12 @@ public class QueueExample { connection.start(); - if (!latch.await(5, TimeUnit.SECONDS)) { throw new RuntimeException("listener didn't receive all the messages"); } System.out.println("Finished ok!"); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -109,9 +106,8 @@ public class QueueExample { public void onMessage(Message message) { latch.countDown(); try { - System.out.println("Received " + ((TextMessage)message).getText()); - } - catch (Exception e) { + System.out.println("Received " + ((TextMessage) message).getText()); + } catch (Exception e) { e.printStackTrace(); } } diff --git a/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java index ca3f510665..5aebd13662 100644 --- a/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java +++ b/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -58,8 +58,7 @@ public class QueueExample { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/examples/protocols/stomp/stomp-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/StompDualAuthenticationExample.java b/examples/protocols/stomp/stomp-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/StompDualAuthenticationExample.java index 1694cf11a4..6aa5c81efe 100644 --- a/examples/protocols/stomp/stomp-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/StompDualAuthenticationExample.java +++ b/examples/protocols/stomp/stomp-dual-authentication/src/main/java/org/apache/activemq/artemis/jms/example/StompDualAuthenticationExample.java @@ -106,8 +106,7 @@ public class StompDualAuthenticationExample { // Step 10. Receive the message TextMessage messageReceived = (TextMessage) consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/MyStompInterceptor.java b/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/MyStompInterceptor.java index c11cc038c7..3e9f211d31 100644 --- a/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/MyStompInterceptor.java +++ b/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/MyStompInterceptor.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, @@ -26,8 +26,7 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; public class MyStompInterceptor implements StompFrameInterceptor { @Override - public boolean intercept(StompFrame frame, RemotingConnection remotingConnection) - throws ActiveMQException { + public boolean intercept(StompFrame frame, RemotingConnection remotingConnection) throws ActiveMQException { StompConnection connection = (StompConnection) remotingConnection; diff --git a/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/RegularInterceptor.java b/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/RegularInterceptor.java index 8457d68cb8..bb3c6eb731 100644 --- a/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/RegularInterceptor.java +++ b/examples/protocols/stomp/stomp-embedded-interceptor/src/main/java/org/apache/activemq/artemis/jms/example/RegularInterceptor.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, @@ -29,7 +29,7 @@ public class RegularInterceptor implements Interceptor { public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { System.out.println("Regular Intercept on " + packet); if (packet instanceof MessagePacket) { - MessagePacket messagePacket = (MessagePacket)packet; + MessagePacket messagePacket = (MessagePacket) packet; messagePacket.getMessage().putStringProperty("regularIntercepted", "HelloAgain"); } return true; diff --git a/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index 5c7b330f26..d466ab6f46 100644 --- a/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -45,7 +45,6 @@ public class StompExample { connection.start(); - System.out.println("Waiting 20 seconds"); Thread.sleep(10000); // increase this and it will fail System.out.println("waited"); diff --git a/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java b/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java index 87af3abf30..0f766795d1 100644 --- a/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java +++ b/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java @@ -46,8 +46,7 @@ public class StompWebSocketExample { System.in.read(); TextMessage message = session.createTextMessage("Server stopping!"); producer.send(message); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -57,4 +56,4 @@ public class StompWebSocketExample { } } } -} \ No newline at end of file +} diff --git a/examples/protocols/stomp/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/protocols/stomp/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index 78fed5e51c..98cae66fa3 100644 --- a/examples/protocols/stomp/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/protocols/stomp/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.nio.charset.StandardCharsets; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -28,6 +23,10 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.charset.StandardCharsets; /** * An example where a client will send a Stomp message on a TCP socket @@ -96,8 +95,7 @@ public class StompExample { // Step 10. Receive the message TextMessage messageReceived = (TextMessage) consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/protocols/stomp/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/protocols/stomp/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index 4e22435af3..02937bf503 100644 --- a/examples/protocols/stomp/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/protocols/stomp/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.nio.charset.StandardCharsets; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -28,6 +23,10 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.charset.StandardCharsets; /** * An example where a Stomp 1.1 client sends a message on a TCP socket @@ -99,8 +98,7 @@ public class StompExample { // Step 10. Receive the message TextMessage messageReceived = (TextMessage) consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/examples/protocols/stomp/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/protocols/stomp/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index 318de16f8d..05bf1febd9 100644 --- a/examples/protocols/stomp/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/protocols/stomp/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.nio.charset.StandardCharsets; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -28,6 +23,10 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.charset.StandardCharsets; /** * An example where a Stomp 1.2 client sends a message on a TCP socket @@ -99,8 +98,7 @@ public class StompExample { // Step 10. Receive the message TextMessage messageReceived = (TextMessage) consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - } - finally { + } finally { // Step 11. Be sure to close our JMS resources! if (initialContext != null) { initialContext.close(); diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java index e389def98b..5855abefff 100644 --- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java +++ b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java @@ -17,9 +17,9 @@ package org.apache.activemq.artemis.integration.aerogear; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; +import org.jboss.logging.Messages; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; -import org.jboss.logging.Messages; /** * Logger Code 23 diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java index 6da582c7b3..5191524fd7 100644 --- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java +++ b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java @@ -272,10 +272,9 @@ public class AeroGearConnectorService implements ConnectorService, Consumer, Mes if (handled) { reference.acknowledge(); return HandleStatus.HANDLED; - } - //if we have been stopped we must return no match as we have been removed as a consumer, - // anything else will cause an exception - else if (!started) { + } else if (!started) { + //if we have been stopped we must return no match as we have been removed as a consumer, + // anything else will cause an exception return HandleStatus.NO_MATCH; } //we must be reconnecting @@ -288,18 +287,15 @@ public class AeroGearConnectorService implements ConnectorService, Consumer, Mes handled = false; if (statusCode == 401) { ActiveMQAeroGearLogger.LOGGER.reply401(); - } - else if (statusCode == 404) { + } else if (statusCode == 404) { ActiveMQAeroGearLogger.LOGGER.reply404(); - } - else { + } else { ActiveMQAeroGearLogger.LOGGER.replyUnknown(statusCode); } queue.removeConsumer(this); started = false; - } - else { + } else { handled = true; } } @@ -328,13 +324,11 @@ public class AeroGearConnectorService implements ConnectorService, Consumer, Mes reconnecting = false; ActiveMQAeroGearLogger.LOGGER.connected(endpoint); queue.deliverAsync(); - } - catch (Exception e) { + } catch (Exception e) { retryAttempt++; if (retryAttempts == -1 || retryAttempt < retryAttempts) { scheduledThreadPool.schedule(this, retryInterval, TimeUnit.SECONDS); - } - else { + } else { ActiveMQAeroGearLogger.LOGGER.unableToReconnect(retryAttempt); started = false; } diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java index 585fa1b877..749c87a044 100644 --- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java +++ b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java @@ -16,15 +16,15 @@ */ package org.apache.activemq.artemis.integration.aerogear; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; + import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.server.ConnectorService; import org.apache.activemq.artemis.core.server.ConnectorServiceFactory; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - public class AeroGearConnectorServiceFactory implements ConnectorServiceFactory { @Override diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java index 4e921283dc..07eda7735e 100644 --- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java +++ b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.integration.aerogear; -import org.apache.activemq.artemis.api.core.SimpleString; - import java.util.HashSet; import java.util.Set; +import org.apache.activemq.artemis.api.core.SimpleString; + public class AeroGearConstants { public static final Set ALLOWABLE_PROPERTIES = new HashSet<>(); diff --git a/integration/activemq-spring-integration/src/main/java/org/apache/activemq/artemis/integration/spring/SpringBindingRegistry.java b/integration/activemq-spring-integration/src/main/java/org/apache/activemq/artemis/integration/spring/SpringBindingRegistry.java index 1451366c25..cda3f8a085 100644 --- a/integration/activemq-spring-integration/src/main/java/org/apache/activemq/artemis/integration/spring/SpringBindingRegistry.java +++ b/integration/activemq-spring-integration/src/main/java/org/apache/activemq/artemis/integration/spring/SpringBindingRegistry.java @@ -33,8 +33,7 @@ public class SpringBindingRegistry implements BindingRegistry { Object obj = null; try { obj = factory.getBean(name); - } - catch (NoSuchBeanDefinitionException e) { + } catch (NoSuchBeanDefinitionException e) { //ignore } return obj; diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java index 49be35c129..a5a5015055 100644 --- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java +++ b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java @@ -92,8 +92,7 @@ class IncomingVertxEventHandler implements ConnectorService { System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName()); if (quorumSize != -1) { platformManager = PlatformLocator.factory.createPlatformManager(port, host, quorumSize, haGroup); - } - else { + } else { platformManager = PlatformLocator.factory.createPlatformManager(port, host); } @@ -156,8 +155,7 @@ class IncomingVertxEventHandler implements ConnectorService { try { postOffice.route(msg, null, false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQVertxLogger.LOGGER.error("failed to route msg " + msg, e); } } @@ -226,47 +224,33 @@ class IncomingVertxEventHandler implements ConnectorService { if (message instanceof PingMessage) { return VertxConstants.TYPE_PING; - } - else if (body instanceof Buffer) { + } else if (body instanceof Buffer) { return VertxConstants.TYPE_BUFFER; - } - else if (body instanceof Boolean) { + } else if (body instanceof Boolean) { return VertxConstants.TYPE_BOOLEAN; - } - else if (body instanceof byte[]) { + } else if (body instanceof byte[]) { return VertxConstants.TYPE_BYTEARRAY; - } - else if (body instanceof Byte) { + } else if (body instanceof Byte) { return VertxConstants.TYPE_BYTE; - } - else if (body instanceof Character) { + } else if (body instanceof Character) { return VertxConstants.TYPE_CHARACTER; - } - else if (body instanceof Double) { + } else if (body instanceof Double) { return VertxConstants.TYPE_DOUBLE; - } - else if (body instanceof Float) { + } else if (body instanceof Float) { return VertxConstants.TYPE_FLOAT; - } - else if (body instanceof Integer) { + } else if (body instanceof Integer) { return VertxConstants.TYPE_INT; - } - else if (body instanceof Long) { + } else if (body instanceof Long) { return VertxConstants.TYPE_LONG; - } - else if (body instanceof Short) { + } else if (body instanceof Short) { return VertxConstants.TYPE_SHORT; - } - else if (body instanceof String) { + } else if (body instanceof String) { return VertxConstants.TYPE_STRING; - } - else if (body instanceof JsonArray) { + } else if (body instanceof JsonArray) { return VertxConstants.TYPE_JSON_ARRAY; - } - else if (body instanceof JsonObject) { + } else if (body instanceof JsonObject) { return VertxConstants.TYPE_JSON_OBJECT; - } - else if (body instanceof ReplyException) { + } else if (body instanceof ReplyException) { return VertxConstants.TYPE_REPLY_FAILURE; } throw new IllegalArgumentException("Type not supported: " + message); diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java index 6c50b260ef..8820c39b75 100644 --- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java +++ b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java @@ -92,8 +92,7 @@ class OutgoingVertxEventHandler implements Consumer, ConnectorService { System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName()); if (quorumSize != -1) { platformManager = PlatformLocator.factory.createPlatformManager(port, host, quorumSize, haGroup); - } - else { + } else { platformManager = PlatformLocator.factory.createPlatformManager(port, host); } @@ -178,8 +177,7 @@ class OutgoingVertxEventHandler implements Consumer, ConnectorService { // send to bus if (!publish) { eventBus.send(vertxAddress, vertxMsgBody); - } - else { + } else { eventBus.publish(vertxAddress, vertxMsgBody); } diff --git a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisClientConfigBean.java b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisClientConfigBean.java index ef91f4dfea..54f5a7f09e 100644 --- a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisClientConfigBean.java +++ b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisClientConfigBean.java @@ -19,9 +19,6 @@ package org.apache.artemis.client.cdi.extension; -import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; -import org.apache.artemis.client.cdi.configuration.DefaultArtemisClientConfigurationImpl; - import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.Bean; @@ -31,6 +28,9 @@ import java.lang.reflect.Type; import java.util.HashSet; import java.util.Set; +import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; +import org.apache.artemis.client.cdi.configuration.DefaultArtemisClientConfigurationImpl; + import static java.util.Collections.emptySet; class ArtemisClientConfigBean implements Bean { diff --git a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisEmbeddedServerConfigBean.java b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisEmbeddedServerConfigBean.java index 07ae6cdca0..5f38240a6b 100644 --- a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisEmbeddedServerConfigBean.java +++ b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisEmbeddedServerConfigBean.java @@ -19,11 +19,6 @@ package org.apache.artemis.client.cdi.extension; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; - import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.Bean; @@ -35,6 +30,11 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; + import static java.util.Collections.emptySet; public class ArtemisEmbeddedServerConfigBean implements Bean { diff --git a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java index 1b644f9311..d9a0d54e89 100644 --- a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java +++ b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java @@ -19,15 +19,15 @@ package org.apache.artemis.client.cdi.extension; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; -import org.apache.artemis.client.cdi.logger.ActiveMQCDILogger; - import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterBeanDiscovery; import javax.enterprise.inject.spi.Extension; import javax.enterprise.inject.spi.ProcessAnnotatedType; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; +import org.apache.artemis.client.cdi.logger.ActiveMQCDILogger; + public class ArtemisExtension implements Extension { private boolean foundEmbeddedConfig = false; @@ -46,14 +46,12 @@ public class ArtemisExtension implements Extension { void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery) { if (!foundConfiguration) { afterBeanDiscovery.addBean(new ArtemisClientConfigBean()); - } - else { + } else { ActiveMQCDILogger.LOGGER.notUsingDefaultConfiguration(); } if (!foundEmbeddedConfig) { afterBeanDiscovery.addBean(new ArtemisEmbeddedServerConfigBean()); - } - else { + } else { ActiveMQCDILogger.LOGGER.notUsingDefaultClientConfiguration(); } diff --git a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/factory/ConnectionFactoryProvider.java b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/factory/ConnectionFactoryProvider.java index 9a6fe9da5b..b57b771339 100644 --- a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/factory/ConnectionFactoryProvider.java +++ b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/factory/ConnectionFactoryProvider.java @@ -19,6 +19,14 @@ package org.apache.artemis.client.cdi.factory; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.jms.JMSContext; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -30,14 +38,6 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.inject.Inject; -import javax.jms.JMSContext; -import java.util.HashMap; -import java.util.Map; - @ApplicationScoped public class ConnectionFactoryProvider { @@ -58,16 +58,14 @@ public class ConnectionFactoryProvider { ActiveMQServer activeMQServer = ActiveMQServers.newActiveMQServer(embeddedConfiguration, false); JMSServerManagerImpl jmsServerManager = new JMSServerManagerImpl(activeMQServer); jmsServerManager.start(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Unable to start embedded JMS", e); } } try { this.activeMQConnectionFactory = createConnectionFactory(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Unable to connect to remote server", e); } } @@ -84,16 +82,14 @@ public class ConnectionFactoryProvider { final ActiveMQConnectionFactory activeMQConnectionFactory; if (configuration.getUrl() != null) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactory(configuration.getUrl(), null); - } - else { + } else { if (configuration.getHost() != null) { params.put(TransportConstants.HOST_PROP_NAME, configuration.getHost()); params.put(TransportConstants.PORT_PROP_NAME, configuration.getPort()); } if (configuration.isHa()) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); - } - else { + } else { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); } } diff --git a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java index ef8952f8b7..fd2f7e7efa 100644 --- a/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java +++ b/integration/artemis-cdi-integration/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java @@ -19,14 +19,14 @@ package org.apache.artemis.client.cdi.logger; +import javax.enterprise.inject.spi.ProcessAnnotatedType; + import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; -import javax.enterprise.inject.spi.ProcessAnnotatedType; - /** * Logger code 57 * @@ -44,8 +44,7 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; @MessageLogger(projectCode = "AMQ") public interface ActiveMQCDILogger extends BasicLogger { - ActiveMQCDILogger LOGGER = Logger.getMessageLogger(ActiveMQCDILogger.class, - ActiveMQCDILogger.class.getPackage().getName()); + ActiveMQCDILogger LOGGER = Logger.getMessageLogger(ActiveMQCDILogger.class, ActiveMQCDILogger.class.getPackage().getName()); @LogMessage @Message(id = 571000, value = "Discovered configuration class {0}", format = Message.Format.MESSAGE_FORMAT) diff --git a/integration/artemis-cdi-integration/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapTest.java b/integration/artemis-cdi-integration/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapTest.java index 6762dd6bc7..84afda742d 100644 --- a/integration/artemis-cdi-integration/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapTest.java +++ b/integration/artemis-cdi-integration/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapTest.java @@ -19,6 +19,12 @@ package org.apache.activemq.artemis.cdi.bootstrap; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.spi.Extension; +import javax.inject.Inject; +import javax.jms.JMSContext; +import javax.jms.Queue; + import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration; import org.apache.artemis.client.cdi.configuration.DefaultArtemisClientConfigurationImpl; import org.apache.artemis.client.cdi.extension.ArtemisExtension; @@ -33,12 +39,6 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.spi.Extension; -import javax.inject.Inject; -import javax.jms.JMSContext; -import javax.jms.Queue; - import static org.junit.Assert.assertEquals; @RunWith(Arquillian.class) @@ -46,10 +46,7 @@ public class CDIBootstrapTest { @Deployment public static Archive createArchive() { - return ShrinkWrap.create(JavaArchive.class) - .addAsServiceProviderAndClasses(Extension.class, ArtemisExtension.class) - .addClasses(NativeConfig.class, ConnectionFactoryProvider.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + return ShrinkWrap.create(JavaArchive.class).addAsServiceProviderAndClasses(Extension.class, ArtemisExtension.class).addClasses(NativeConfig.class, ConnectionFactoryProvider.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Inject diff --git a/pom.xml b/pom.xml index b5617260e2..e39d82c9a5 100644 --- a/pom.xml +++ b/pom.xml @@ -1256,7 +1256,7 @@ **/*.txt **/*.md - etc/ide-settings/* + etc/ide-settings/** docs/**/*.json docs/**/_book/ **/target/ diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java index 14244ffdca..c86ffb94da 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.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, @@ -16,16 +16,6 @@ */ package org.apache.activemq; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.RejectedExecutionHandler; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.ExceptionListener; @@ -35,6 +25,15 @@ import javax.jms.QueueConnectionFactory; import javax.jms.TopicConnection; import javax.jms.TopicConnectionFactory; import javax.naming.Context; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.RejectedExecutionHandler; import org.apache.activemq.blob.BlobTransferPolicy; import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap; @@ -81,8 +80,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne return result; } }); - } - catch (Throwable e) { + } catch (Throwable e) { LOG.debug("Failed to look up System properties for host and port", e); } host = (host == null || host.isEmpty()) ? "localhost" : host; @@ -106,16 +104,14 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne return result; } }); - } - catch (Throwable e) { + } catch (Throwable e) { LOG.debug("Failed to look up System properties for host and port", e); } bindURL = (bindURL == null || bindURL.isEmpty()) ? defaultURL : bindURL; DEFAULT_BROKER_BIND_URL = bindURL; try { defaultTcpUri = new URI(defaultURL); - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { LOG.debug("Failed to build default tcp url", e); } @@ -210,8 +206,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne this.vmBrokerUri = URISupport.createRemainingURI(uri, params); } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { } } @@ -235,8 +230,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne public ActiveMQConnectionFactory copy() { try { return (ActiveMQConnectionFactory) super.clone(); - } - catch (CloneNotSupportedException e) { + } catch (CloneNotSupportedException e) { throw new RuntimeException("This should never happen: " + e, e); } } @@ -256,8 +250,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne return defaultTcpUri; } return uri; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { throw (IllegalArgumentException) new IllegalArgumentException("Invalid broker URI: " + brokerURL).initCause(e); } } @@ -313,8 +306,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne Transport t = TransportFactory.connect(brokerURL); System.out.println("xxxxxxxxxxxx created transport" + t); return t; - } - catch (Exception e) { + } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } } @@ -340,22 +332,18 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne } return connection; - } - catch (JMSException e) { + } catch (JMSException e) { // Clean up! try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } throw e; - } - catch (Exception e) { + } catch (Exception e) { // Clean up! try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } throw JMSExceptionSupport.create("Could not connect to broker URL: " + brokerURL + ". Reason: " + e, e); } @@ -437,8 +425,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne if ("vm".equals(scheme)) { this.vmBrokerUri = uri; } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { } this.brokerURL = createURI(brokerURL); @@ -460,12 +447,10 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne this.brokerURL = URISupport.createRemainingURI(this.brokerURL, map); } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { } - } - else { + } else { // It might be a composite URI. try { @@ -479,8 +464,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne this.brokerURL = data.toURI(); } - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { } } } @@ -815,8 +799,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne if (clientIdGenerator == null) { if (clientIDPrefix != null) { clientIdGenerator = new IdGenerator(clientIDPrefix); - } - else { + } else { clientIdGenerator = new IdGenerator(); } } @@ -835,8 +818,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne if (connectionIdGenerator == null) { if (connectionIDPrefix != null) { connectionIdGenerator = new IdGenerator(connectionIDPrefix); - } - else { + } else { connectionIdGenerator = new IdGenerator(); } } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java index fce53ee669..5cb3d40415 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.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, @@ -27,6 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ArtemisBrokerHelper { + private static final Logger LOG = LoggerFactory.getLogger(ArtemisBrokerHelper.class); private static volatile Object service = null; @@ -35,8 +36,7 @@ public class ArtemisBrokerHelper { static { try { serviceClass = Class.forName("org.apache.activemq.broker.BrokerService"); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { e.printStackTrace(); } @@ -54,23 +54,17 @@ public class ArtemisBrokerHelper { Method startMethod = serviceClass.getMethod("start"); startMethod.invoke(service, (Object[]) null); LOG.info("started a service instance: " + service); - } - catch (InstantiationException e) { + } catch (InstantiationException e) { throw new IOException("Inst exception", e); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new IOException("IllegalAccess exception ", e); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { throw new IOException("Nosuchmethod", e); - } - catch (SecurityException e) { + } catch (SecurityException e) { throw new IOException("Security exception", e); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new IOException("IllegalArgumentException exception", e); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { throw new IOException("InvocationTargetException exception", e); } } @@ -91,11 +85,9 @@ public class ArtemisBrokerHelper { startMethod.invoke(service, (Object[]) null); System.out.println("stopped the service instance: " + service); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { service = null; } } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java index eff9ab37fa..97e3482e45 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java @@ -17,12 +17,13 @@ package org.apache.activemq.broker; -import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper; - import java.util.ArrayList; import java.util.List; +import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper; + public class ArtemisBrokerWrapperFactory { + List brokers = new ArrayList<>(); public static Broker createBroker(BrokerService brokerService) { diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java index 69724c7ef2..58885d6d6f 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -117,8 +117,7 @@ public class BrokerService implements Service { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); try { version = reader.readLine(); - } - catch (Exception e) { + } catch (Exception e) { } } BROKER_VERSION = version; @@ -156,14 +155,12 @@ public class BrokerService implements Service { public void run() { try { doStartBroker(); - } - catch (Throwable t) { + } catch (Throwable t) { startException = t; } } }.start(); - } - else { + } else { doStartBroker(); } } @@ -180,11 +177,9 @@ public class BrokerService implements Service { try { broker.start(); - } - catch (Exception e) { + } catch (Exception e) { throw e; - } - catch (Throwable t) { + } catch (Throwable t) { throw new Exception(t); } @@ -360,8 +355,7 @@ public class BrokerService implements Service { try { URI substituteUri = new URI("tcp://localhost:61616"); return substituteUri; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { e.printStackTrace(); } return null; @@ -490,9 +484,8 @@ public class BrokerService implements Service { this.transportConnectors = transportConnectors; for (TransportConnector connector : transportConnectors) { if (sslContext instanceof SpringSslContext) { - this.extraConnectors.add(new ConnectorInfo(connector.getUri(), (SpringSslContext)sslContext)); - } - else { + this.extraConnectors.add(new ConnectorInfo(connector.getUri(), (SpringSslContext) sslContext)); + } else { this.extraConnectors.add(new ConnectorInfo(connector.getUri())); } } @@ -509,7 +502,7 @@ public class BrokerService implements Service { @Override public boolean connectTo(URI location) { List transportConnectors = getTransportConnectors(); - for (Iterator iter = transportConnectors.iterator(); iter.hasNext();) { + for (Iterator iter = transportConnectors.iterator(); iter.hasNext(); ) { try { TransportConnector tc = iter.next(); if (location.equals(tc.getConnectUri())) { @@ -556,15 +549,13 @@ public class BrokerService implements Service { } - bindAddress = new URI(bindAddress.getScheme(), bindAddress.getUserInfo(), - host, port, bindAddress.getPath(), bindAddress.getQuery(), bindAddress.getFragment()); + bindAddress = new URI(bindAddress.getScheme(), bindAddress.getUserInfo(), host, port, bindAddress.getPath(), bindAddress.getQuery(), bindAddress.getFragment()); connector = new FakeTransportConnector(bindAddress); this.transportConnectors.add(connector); if (sslContext instanceof SpringSslContext) { this.extraConnectors.add(new ConnectorInfo(bindAddress, (SpringSslContext) sslContext)); - } - else { + } else { this.extraConnectors.add(new ConnectorInfo(bindAddress)); } @@ -584,8 +575,7 @@ public class BrokerService implements Service { } try { TimeUnit.SECONDS.sleep(5); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } return currentRandomPort; @@ -595,17 +585,14 @@ public class BrokerService implements Service { ServerSocket ssocket = null; try { ssocket = new ServerSocket(port); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("port " + port + " is being used."); return false; - } - finally { + } finally { if (ssocket != null) { try { ssocket.close(); - } - catch (IOException e) { + } catch (IOException e) { } } } @@ -740,8 +727,7 @@ public class BrokerService implements Service { if (!b.isStopped()) { try { b.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } brokerExceptionEntry.getValue().printStackTrace(); @@ -807,20 +793,11 @@ public class BrokerService implements Service { String query = bindAddress.getQuery(); if (!ssl || query != null && query.contains(TransportConstants.SSL_ENABLED_PROP_NAME)) { //it means the uri is already configured ssl - uri = new URI("tcp", bindAddress.getUserInfo(), - host, port, bindAddress.getPath(), bindAddress.getQuery(), bindAddress.getFragment()); - } - else { - String baseUri = "tcp://" + host + ":" + port + "?" - + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" - + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + (context == null ? defaultKeyStore : context.getKeyStore()) + "&" - + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + (context == null ? defaultKeyStorePassword : context.getKeyStorePassword()) + "&" - + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + (context == null ? defaultKeyStoreType : context.getKeyStoreType()); + uri = new URI("tcp", bindAddress.getUserInfo(), host, port, bindAddress.getPath(), bindAddress.getQuery(), bindAddress.getFragment()); + } else { + String baseUri = "tcp://" + host + ":" + port + "?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + (context == null ? defaultKeyStore : context.getKeyStore()) + "&" + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + (context == null ? defaultKeyStorePassword : context.getKeyStorePassword()) + "&" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + (context == null ? defaultKeyStoreType : context.getKeyStoreType()); if (clientAuth) { - baseUri = baseUri + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true" + "&" - + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + (context == null ? defaultTrustStore : context.getTrustStore()) + "&" - + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + (context == null ? defaultTrustStorePassword : context.getTrustStorePassword()) + "&" - + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + (context == null ? defaultTrustStoreType : context.getTrustStoreType()); + baseUri = baseUri + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true" + "&" + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + (context == null ? defaultTrustStore : context.getTrustStore()) + "&" + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + (context == null ? defaultTrustStorePassword : context.getTrustStorePassword()) + "&" + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + (context == null ? defaultTrustStoreType : context.getTrustStoreType()); } uri = new URI(baseUri); } @@ -835,7 +812,7 @@ public class BrokerService implements Service { @Override public boolean equals(Object obj) { if (obj instanceof ConnectorInfo) { - return uri.getPort() == ((ConnectorInfo)obj).uri.getPort(); + return uri.getPort() == ((ConnectorInfo) obj).uri.getPort(); } return false; } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/FakeTransportConnector.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/FakeTransportConnector.java index 9fb8233c03..899907857d 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/FakeTransportConnector.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/FakeTransportConnector.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, diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/SslBrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/SslBrokerService.java index 2f36cf62d1..ef96a6f99b 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/SslBrokerService.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/SslBrokerService.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, @@ -17,7 +17,6 @@ package org.apache.activemq.broker; -import org.apache.activemq.transport.TransportServer; import javax.net.ssl.KeyManager; import javax.net.ssl.TrustManager; import java.io.IOException; @@ -25,6 +24,8 @@ import java.net.URI; import java.security.KeyManagementException; import java.security.SecureRandom; +import org.apache.activemq.transport.TransportServer; + /** * A BrokerService that allows access to the key and trust managers used by SSL * connections. There is no reason to use this class unless SSL is being used diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java index fb3c242f2e..c4fe1c0c81 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.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, @@ -465,8 +465,7 @@ public abstract class ArtemisBrokerBase implements Broker { protected Configuration createDefaultConfig(final boolean netty) throws Exception { if (netty) { return createDefaultConfig(new HashMap(), NETTY_ACCEPTOR_FACTORY); - } - else { + } else { return createDefaultConfig(new HashMap(), INVM_ACCEPTOR_FACTORY); } } @@ -530,8 +529,7 @@ public abstract class ArtemisBrokerBase implements Broker { protected static JournalType getDefaultJournalType() { if (LibaioContext.isLoaded()) { return JournalType.ASYNCIO; - } - else { + } else { return JournalType.NIO; } } @@ -593,8 +591,7 @@ public abstract class ArtemisBrokerBase implements Broker { while (files == null && (attempts < num)) { try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } files = directory.list(); attempts++; @@ -611,8 +608,7 @@ public abstract class ArtemisBrokerBase implements Broker { return directory.delete(); } - public ActiveMQServer getServer() - { + public ActiveMQServer getServer() { return server; } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java index c8602212da..b16383a322 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.broker.artemiswrapper; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; import java.io.File; import java.util.HashMap; import java.util.HashSet; @@ -45,10 +47,8 @@ import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.broker.region.virtual.VirtualDestination; import org.apache.activemq.command.ActiveMQDestination; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; - public class ArtemisBrokerWrapper extends ArtemisBrokerBase { + protected final Map testQueues = new HashMap<>(); protected JMSServerManagerImpl jmsServer; protected MBeanServer mbeanServer; @@ -224,8 +224,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { String pattern = physicalName.replace(">", "#"); if (dest.isTopic()) { pattern = "jms.topic." + pattern; - } - else { + } else { pattern = "jms.queue." + pattern; } @@ -238,11 +237,9 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { server.stop(); testQueues.clear(); stopped = true; - } - catch (Throwable t) { + } catch (Throwable t) { //ignore - } - finally { + } finally { server = null; } } @@ -255,8 +252,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { try { this.server.createQueue(coreQ, coreQ, null, false, false); testQueues.put(qname, coreQ); - } - catch (ActiveMQQueueExistsException e) { + } catch (ActiveMQQueueExistsException e) { //ignore } } @@ -271,8 +267,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { String qname = null; if (amq5Dest.isTemporary()) { qname = "jms.tempqueue." + amq5Dest.getPhysicalName(); - } - else { + } else { qname = "jms.queue." + amq5Dest.getPhysicalName(); } Binding binding = server.getPostOffice().getBinding(new SimpleString(qname)); diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java index 2ddac3bc60..2c5a3e6b4d 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java @@ -36,15 +36,13 @@ public class CleanupThreadRule extends ExternalResource { // We shutdown the global pools to give a better isolation between tests try { ServerLocatorImpl.clearThreadPools(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } try { NettyConnector.clearThreadPools(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNameParser.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNameParser.java index 6ab5340fa5..facbe24d61 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNameParser.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNameParser.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.broker.artemiswrapper; -import java.io.Serializable; -import java.util.Properties; - import javax.naming.CompoundName; import javax.naming.Name; import javax.naming.NameParser; import javax.naming.NamingException; +import java.io.Serializable; +import java.util.Properties; /** * @author Ovidiu Feodorov diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNamingContext.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNamingContext.java index 27b9f7209c..e1c40b64d5 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNamingContext.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/InVMNamingContext.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.broker.artemiswrapper; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import javax.naming.Binding; import javax.naming.Context; import javax.naming.Name; @@ -36,6 +27,14 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class InVMNamingContext implements Context, Serializable { // Constants ----------------------------------------------------- @@ -89,8 +88,7 @@ public class InVMNamingContext implements Context, Serializable { // we only deal with references create by NonSerializableFactory String key = (String) refAddr.getContent(); return NonSerializableFactory.lookup(key); - } - else { + } else { return value; } } @@ -127,8 +125,7 @@ public class InVMNamingContext implements Context, Serializable { boolean terminal = i == -1; if (terminal) { map.remove(name); - } - else { + } else { String tok = name.substring(0, i); InVMNamingContext c = (InVMNamingContext) map.get(tok); if (c == null) { @@ -169,8 +166,7 @@ public class InVMNamingContext implements Context, Serializable { if (!"".equals(contextName) && !".".equals(contextName)) { try { return ((InVMNamingContext) lookup(contextName)).listBindings(""); - } - catch (Throwable t) { + } catch (Throwable t) { throw new NamingException(t.getMessage()); } } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/NonSerializableFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/NonSerializableFactory.java index 91b365e51e..6c0415db7e 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/NonSerializableFactory.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/NonSerializableFactory.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, @@ -22,14 +22,13 @@ import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; - -//import org.jboss.util.naming.Util; - import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; +//import org.jboss.util.naming.Util; + /** * used by the default context when running in embedded local configuration * diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java index c364916b55..2cb755af5d 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.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, @@ -17,6 +17,9 @@ package org.apache.activemq.broker.artemiswrapper; +import javax.management.MBeanServer; +import javax.management.MBeanServerInvocationHandler; +import javax.management.ObjectName; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -41,11 +44,8 @@ import org.junit.Rule; import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; -import javax.management.MBeanServer; -import javax.management.MBeanServerInvocationHandler; -import javax.management.ObjectName; - public class OpenwireArtemisBaseTest { + @Rule public CleanupThreadRule cleanupRules = new CleanupThreadRule(); @@ -69,7 +69,6 @@ public class OpenwireArtemisBaseTest { BrokerService.disableWrapper = true; } - public String getTmp() { return getTmpFile().getAbsolutePath(); } @@ -123,16 +122,18 @@ public class OpenwireArtemisBaseTest { return createConfig(hostAddress, serverID, Collections.EMPTY_MAP); } - protected Configuration createConfig(final String hostAddress, final int serverID, Map params) throws Exception { + protected Configuration createConfig(final String hostAddress, + final int serverID, + Map params) throws Exception { ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false). - setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO). - setJournalDirectory(getJournalDir(serverID, false)). - setBindingsDirectory(getBindingsDir(serverID, false)). - setPagingDirectory(getPageDir(serverID, false)). - setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). - setJournalCompactMinFiles(0). - setJournalCompactPercentage(0). - setClusterPassword(CLUSTER_PASSWORD); + setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO). + setJournalDirectory(getJournalDir(serverID, false)). + setBindingsDirectory(getBindingsDir(serverID, false)). + setPagingDirectory(getPageDir(serverID, false)). + setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). + setJournalCompactMinFiles(0). + setJournalCompactPercentage(0). + setClusterPassword(CLUSTER_PASSWORD); configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true)); @@ -145,14 +146,14 @@ public class OpenwireArtemisBaseTest { //extraAcceptor takes form: "?name=value&name1=value ..." protected Configuration createConfig(final int serverID, String extraAcceptorParams) throws Exception { ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false). - setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO). - setJournalDirectory(getJournalDir(serverID, false)). - setBindingsDirectory(getBindingsDir(serverID, false)). - setPagingDirectory(getPageDir(serverID, false)). - setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). - setJournalCompactMinFiles(0). - setJournalCompactPercentage(0). - setClusterPassword(CLUSTER_PASSWORD); + setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO). + setJournalDirectory(getJournalDir(serverID, false)). + setBindingsDirectory(getBindingsDir(serverID, false)). + setPagingDirectory(getPageDir(serverID, false)). + setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). + setJournalCompactMinFiles(0). + setJournalCompactPercentage(0). + setClusterPassword(CLUSTER_PASSWORD); configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true)); @@ -163,7 +164,7 @@ public class OpenwireArtemisBaseTest { return configuration; } - public void deployClusterConfiguration(Configuration config, Integer ... targetIDs) throws Exception { + public void deployClusterConfiguration(Configuration config, Integer... targetIDs) throws Exception { StringBuffer stringBuffer = new StringBuffer(); String separator = ""; for (int x : targetIDs) { @@ -188,7 +189,9 @@ public class OpenwireArtemisBaseTest { return newURIwithPort(localhostAddress, port, Collections.EMPTY_MAP); } - protected static String newURIwithPort(String localhostAddress, int port, Map params) throws Exception { + protected static String newURIwithPort(String localhostAddress, + int port, + Map params) throws Exception { return "tcp://" + localhostAddress + ":" + port + "?" + URISupport.createQueryString(params); } @@ -211,8 +214,7 @@ public class OpenwireArtemisBaseTest { for (int i = 0; i < servers.length; i++) { try { servers[i].stop(); - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); } } @@ -262,8 +264,7 @@ public class OpenwireArtemisBaseTest { } } - private Integer[] getTargets(int total, int self) - { + private Integer[] getTargets(int total, int self) { int lenTargets = total - self; List targets = new ArrayList<>(); for (int i = 0; i < lenTargets; i++) { diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java index 1d102805a6..b6ee4508ee 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ServerSocketFactory; +import javax.net.SocketFactory; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -24,15 +26,16 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.net.ServerSocketFactory; -import javax.net.SocketFactory; - import org.apache.activemq.TransportLoggerSupport; import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper; import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.openwire.OpenWireFormat; -import org.apache.activemq.transport.*; +import org.apache.activemq.transport.InactivityMonitor; +import org.apache.activemq.transport.Transport; +import org.apache.activemq.transport.TransportFactory; +import org.apache.activemq.transport.TransportServer; +import org.apache.activemq.transport.WireFormatNegotiator; import org.apache.activemq.util.IOExceptionSupport; import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.util.URISupport; @@ -53,8 +56,7 @@ public class TcpTransportFactory extends TransportFactory { String brokerId = params.remove("invmBrokerId"); boolean autoCreate = true; String create = params.remove("create"); - if (create != null) - { + if (create != null) { autoCreate = "true".equals(create); } @@ -96,8 +98,7 @@ public class TcpTransportFactory extends TransportFactory { server.bind(); return server; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } } @@ -119,8 +120,7 @@ public class TcpTransportFactory extends TransportFactory { if (tcpTransport.isTrace()) { try { transport = TransportLoggerSupport.createTransportLogger(transport, tcpTransport.getLogWriterName(), tcpTransport.isDynamicManagement(), tcpTransport.isStartLogging(), tcpTransport.getJmxPort()); - } - catch (Throwable e) { + } catch (Throwable e) { LOG.error("Could not create TransportLogger object for: " + tcpTransport.getLogWriterName() + ", reason: " + e, e); } } @@ -154,8 +154,7 @@ public class TcpTransportFactory extends TransportFactory { Integer.parseInt(path.substring(localPortIndex + 1, path.length())); String localString = location.getScheme() + ":/" + path; localLocation = new URI(localString); - } - catch (Exception e) { + } catch (Exception e) { LOG.warn("path isn't a valid local location for TcpTransport to use", e.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug("Failure detail", e); @@ -191,11 +190,9 @@ public class TcpTransportFactory extends TransportFactory { if (brokerService != null) { try { ArtemisBrokerHelper.stopArtemisBroker(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { brokerService = null; } } @@ -203,6 +200,7 @@ public class TcpTransportFactory extends TransportFactory { //added createTime for debugging private static class InternalServiceInfo { + private String internalService; private long createTime; diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/usage/SystemUsage.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/usage/SystemUsage.java index f6b4cdee05..97ae702f0d 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/usage/SystemUsage.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/usage/SystemUsage.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, @@ -147,8 +147,7 @@ public class SystemUsage implements Service { public boolean isSendFailIfNoSpace() { if (sendFailIfNoSpaceExplicitySet || parent == null) { return sendFailIfNoSpace; - } - else { + } else { return parent.isSendFailIfNoSpace(); } } @@ -180,8 +179,7 @@ public class SystemUsage implements Service { public long getSendFailIfNoSpaceAfterTimeout() { if (sendFailIfNoSpaceAfterTimeoutExplicitySet || parent == null) { return sendFailIfNoSpaceAfterTimeout; - } - else { + } else { return parent.getSendFailIfNoSpaceAfterTimeout(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java index 8769324f59..ad590fe2fc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.Session; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -23,10 +26,6 @@ import java.io.ObjectOutputStream; import java.net.URI; import java.net.URISyntaxException; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Session; - import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper; import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.BrokerService; @@ -60,19 +59,16 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport { // Try our best to close any previously opend connection. try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } // Try our best to stop any previously started broker. try { broker.stop(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } try { ArtemisBrokerHelper.stopArtemisBroker(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } TcpTransportFactory.clearService(); } @@ -171,8 +167,7 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport { try { factory.createConnection(); fail("Expected connection failure."); - } - catch (JMSException e) { + } catch (JMSException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java index d63d3c4998..07d4c6d33f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java index df71ec500e..f2c3b67f3b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.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, @@ -16,6 +16,10 @@ */ package org.apache.activemq; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; @@ -23,11 +27,6 @@ import java.io.IOException; import java.security.KeyStore; import java.security.SecureRandom; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; - import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.SslBrokerService; import org.apache.commons.logging.Log; @@ -50,14 +49,12 @@ public class ActiveMQSslConnectionFactoryTest extends CombinationTestSupport { // Try our best to close any previously opend connection. try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } // Try our best to stop any previously started broker. try { broker.stop(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } @@ -152,8 +149,7 @@ public class ActiveMQSslConnectionFactoryTest extends CombinationTestSupport { cf.setTrustStorePassword("wrongPassword"); try { connection = (ActiveMQConnection) cf.createConnection(); - } - catch (javax.jms.JMSException ignore) { + } catch (javax.jms.JMSException ignore) { // Expected exception LOG.info("Expected java.io.Exception [" + ignore + "]"); } @@ -174,8 +170,7 @@ public class ActiveMQSslConnectionFactoryTest extends CombinationTestSupport { cf.setTrustStorePassword("password"); try { connection = (ActiveMQConnection) cf.createConnection(); - } - catch (javax.jms.JMSException ignore) { + } catch (javax.jms.JMSException ignore) { // Expected exception LOG.info("Expected SSLHandshakeException [" + ignore + "]"); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java index c96f370b1c..c4203c7b2c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.concurrent.CopyOnWriteArrayList; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -36,6 +29,12 @@ import javax.jms.XATopicConnection; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.CopyOnWriteArrayList; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerRegistry; @@ -65,14 +64,12 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { // Try our best to close any previously opend connection. try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } // Try our best to stop any previously started broker. try { broker.stop(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } super.tearDown(); } @@ -170,21 +167,18 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { assertTrue(resource1.isSameRM(resource2)); session1.close(); session2.close(); - } - finally { + } finally { if (connection1 != null) { try { connection1.close(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } if (connection2 != null) { try { connection2.close(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -213,21 +207,18 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { assertTrue(resource1.isSameRM(session1a.getXAResource())); session1.close(); session2.close(); - } - finally { + } finally { if (connection1 != null) { try { connection1.close(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } if (connection2 != null) { try { connection2.close(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -268,13 +259,11 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { resource.commit(tid, true); session.close(); - } - finally { + } finally { if (connection1 != null) { try { connection1.close(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -449,22 +438,19 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { try { session.commit(); fail("expect exception after close"); - } - catch (javax.jms.IllegalStateException expected) { + } catch (javax.jms.IllegalStateException expected) { } try { session.rollback(); fail("expect exception after close"); - } - catch (javax.jms.IllegalStateException expected) { + } catch (javax.jms.IllegalStateException expected) { } try { session.getTransacted(); fail("expect exception after close"); - } - catch (javax.jms.IllegalStateException expected) { + } catch (javax.jms.IllegalStateException expected) { } } @@ -483,8 +469,7 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { try { resource.rollback(tid); fail("Expected xa exception on no tx"); - } - catch (XAException expected) { + } catch (XAException expected) { LOG.info("got expected xa", expected); assertEquals("no tx", XAException.XAER_NOTA, expected.errorCode); } @@ -516,8 +501,7 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { try { connection.processPrepareTransaction(new TransactionInfo(connectionId, new XATransactionId(tid), TransactionInfo.PREPARE)); fail("did not get expected excepton on missing transaction, it must be still there in error!"); - } - catch (IllegalStateException expectedOnNoTransaction) { + } catch (IllegalStateException expectedOnNoTransaction) { } } } @@ -529,8 +513,7 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport { try { transactionBroker.getTransaction(null, new XATransactionId(tid), false); fail("expected exception on tx not found"); - } - catch (XAException expectedOnNotFound) { + } catch (XAException expectedOnNotFound) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java index 4a2ccc9ece..fe58442e38 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.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, @@ -33,130 +33,130 @@ import org.slf4j.LoggerFactory; */ public abstract class AutoFailTestSupport extends TestCase { - public static final int EXIT_SUCCESS = 0; - public static final int EXIT_ERROR = 1; - private static final Logger LOG = LoggerFactory.getLogger(AutoFailTestSupport.class); - private long maxTestTime = 5 * 60 * 1000; // 5 mins by default - private Thread autoFailThread; + public static final int EXIT_SUCCESS = 0; + public static final int EXIT_ERROR = 1; + private static final Logger LOG = LoggerFactory.getLogger(AutoFailTestSupport.class); - private boolean verbose = true; - private boolean useAutoFail; // Disable auto fail by default - private AtomicBoolean isTestSuccess; + private long maxTestTime = 5 * 60 * 1000; // 5 mins by default + private Thread autoFailThread; - @Override - protected void setUp() throws Exception { - // Runs the auto fail thread before performing any setup - if (isAutoFail()) { - startAutoFailThread(); - } - super.setUp(); - } + private boolean verbose = true; + private boolean useAutoFail; // Disable auto fail by default + private AtomicBoolean isTestSuccess; - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @Override + protected void setUp() throws Exception { + // Runs the auto fail thread before performing any setup + if (isAutoFail()) { + startAutoFailThread(); + } + super.setUp(); + } - // Stops the auto fail thread only after performing any clean up - stopAutoFailThread(); - } + @Override + protected void tearDown() throws Exception { + super.tearDown(); - /** - * Manually start the auto fail thread. To start it automatically, just set - * the auto fail to true before calling any setup methods. As a rule, this - * method is used only when you are not sure, if the setUp and tearDown - * method is propagated correctly. - */ - public void startAutoFailThread() { - setAutoFail(true); - isTestSuccess = new AtomicBoolean(false); - autoFailThread = new Thread(new Runnable() { - @Override - public void run() { - try { - // Wait for test to finish successfully - Thread.sleep(getMaxTestTime()); - } catch (InterruptedException e) { - // This usually means the test was successful - } finally { - // Check if the test was able to tear down successfully, - // which usually means, it has finished its run. - if (!isTestSuccess.get()) { - LOG.error("Test case has exceeded the maximum allotted time to run of: " + getMaxTestTime() + " ms."); - dumpAllThreads(getName()); - if (System.getProperty("org.apache.activemq.AutoFailTestSupport.disableSystemExit") == null) { - System.exit(EXIT_ERROR); - } else { - LOG.error("No system.exit as it kills surefire - forkedProcessTimeoutInSeconds (surefire.timeout) will kick in eventually see pom.xml surefire plugin config"); - } - } - } + // Stops the auto fail thread only after performing any clean up + stopAutoFailThread(); + } + + /** + * Manually start the auto fail thread. To start it automatically, just set + * the auto fail to true before calling any setup methods. As a rule, this + * method is used only when you are not sure, if the setUp and tearDown + * method is propagated correctly. + */ + public void startAutoFailThread() { + setAutoFail(true); + isTestSuccess = new AtomicBoolean(false); + autoFailThread = new Thread(new Runnable() { + @Override + public void run() { + try { + // Wait for test to finish successfully + Thread.sleep(getMaxTestTime()); + } catch (InterruptedException e) { + // This usually means the test was successful + } finally { + // Check if the test was able to tear down successfully, + // which usually means, it has finished its run. + if (!isTestSuccess.get()) { + LOG.error("Test case has exceeded the maximum allotted time to run of: " + getMaxTestTime() + " ms."); + dumpAllThreads(getName()); + if (System.getProperty("org.apache.activemq.AutoFailTestSupport.disableSystemExit") == null) { + System.exit(EXIT_ERROR); + } else { + LOG.error("No system.exit as it kills surefire - forkedProcessTimeoutInSeconds (surefire.timeout) will kick in eventually see pom.xml surefire plugin config"); + } + } } - }, "AutoFailThread"); + } + }, "AutoFailThread"); - if (verbose) { - LOG.info("Starting auto fail thread..."); - } + if (verbose) { + LOG.info("Starting auto fail thread..."); + } - LOG.info("Starting auto fail thread..."); - autoFailThread.start(); - } + LOG.info("Starting auto fail thread..."); + autoFailThread.start(); + } - /** - * Manually stops the auto fail thread. As a rule, this method is used only - * when you are not sure, if the setUp and tearDown method is propagated - * correctly. - */ - public void stopAutoFailThread() { - if (isAutoFail() && autoFailThread != null && autoFailThread.isAlive()) { - isTestSuccess.set(true); - - if (verbose) { - LOG.info("Stopping auto fail thread..."); - } + /** + * Manually stops the auto fail thread. As a rule, this method is used only + * when you are not sure, if the setUp and tearDown method is propagated + * correctly. + */ + public void stopAutoFailThread() { + if (isAutoFail() && autoFailThread != null && autoFailThread.isAlive()) { + isTestSuccess.set(true); + if (verbose) { LOG.info("Stopping auto fail thread..."); - autoFailThread.interrupt(); - } - } + } - /** - * Sets the auto fail value. As a rule, this should be used only before any - * setup methods is called to automatically enable the auto fail thread in - * the setup method of the test case. - * - * @param val - */ - public void setAutoFail(boolean val) { - this.useAutoFail = val; - } + LOG.info("Stopping auto fail thread..."); + autoFailThread.interrupt(); + } + } - public boolean isAutoFail() { - return this.useAutoFail; - } + /** + * Sets the auto fail value. As a rule, this should be used only before any + * setup methods is called to automatically enable the auto fail thread in + * the setup method of the test case. + * + * @param val + */ + public void setAutoFail(boolean val) { + this.useAutoFail = val; + } - /** - * The assigned value will only be reflected when the auto fail thread has - * started its run. Value is in milliseconds. - * - * @param val - */ - public void setMaxTestTime(long val) { - this.maxTestTime = val; - } + public boolean isAutoFail() { + return this.useAutoFail; + } - public long getMaxTestTime() { - return this.maxTestTime; - } + /** + * The assigned value will only be reflected when the auto fail thread has + * started its run. Value is in milliseconds. + * + * @param val + */ + public void setMaxTestTime(long val) { + this.maxTestTime = val; + } + public long getMaxTestTime() { + return this.maxTestTime; + } - public static void dumpAllThreads(String prefix) { - Map stacks = Thread.getAllStackTraces(); - for (Entry stackEntry : stacks.entrySet()) { - System.err.println(prefix + " " + stackEntry.getKey()); - for(StackTraceElement element : stackEntry.getValue()) { - System.err.println(" " + element); - } - } - } + public static void dumpAllThreads(String prefix) { + Map stacks = Thread.getAllStackTraces(); + for (Entry stackEntry : stacks.entrySet()) { + System.err.println(prefix + " " + stackEntry.getKey()); + for (StackTraceElement element : stackEntry.getValue()) { + System.err.println(" " + element); + } + } + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ClientTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ClientTestSupport.java index afa6846476..1249b4f4c0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ClientTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ClientTestSupport.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, @@ -16,6 +16,7 @@ */ package org.apache.activemq; +import javax.jms.JMSException; import java.io.File; import java.io.IOException; import java.net.URI; @@ -23,8 +24,6 @@ import java.net.URISyntaxException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.jms.JMSException; - import junit.framework.TestCase; import org.apache.activemq.broker.Broker; @@ -72,11 +71,9 @@ public class ClientTestSupport extends TestCase { broker.addConnector(connector); broker.start(); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("Error creating broker " + e); - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { throw new JMSException("Error creating broker " + e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java index dc8f1384cb..23ca5a78c7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.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, @@ -76,8 +76,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { try { ProtectionDomain protectionDomain = clazz.getProtectionDomain(); return new File(new File(protectionDomain.getCodeSource().getLocation().getPath()), "../..").getCanonicalFile(); - } - catch (IOException e) { + } catch (IOException e) { return new File("."); } } @@ -101,8 +100,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { ComboOption co = this.comboOptions.get(attribute); if (co == null) { this.comboOptions.put(attribute, new ComboOption(attribute, Arrays.asList(options))); - } - else { + } else { co.values.addAll(Arrays.asList(options)); } } @@ -123,16 +121,13 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { ServerSocket socket = null; try { socket = new ServerSocket(61616); - } - catch (IOException e) { + } catch (IOException e) { fail("61616 port not released"); - } - finally { + } finally { if (socket != null) try { socket.close(); - } - catch (IOException e) { + } catch (IOException e) { } } } @@ -141,8 +136,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { public void runBare() throws Throwable { if (combosEvaluated) { super.runBare(); - } - else { + } else { CombinationTestSupport[] combinations = getCombinations(); for (int i = 0; i < combinations.length; i++) { CombinationTestSupport test = combinations[i]; @@ -161,8 +155,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { try { Field field = getClass().getField(attribute); field.set(this, value); - } - catch (Throwable e) { + } catch (Throwable e) { try { boolean found = false; String setterName = "set" + attribute.substring(0, 1).toUpperCase() + @@ -179,8 +172,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { throw new NoSuchMethodError("No setter found for field: " + attribute); } - } - catch (Throwable ex) { + } catch (Throwable ex) { LOG.info("Could not set field '" + attribute + "' to value '" + value + "', make sure the field exists and is public or has a setter."); } @@ -192,8 +184,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { try { Method method = getClass().getMethod("initCombos", (Class[]) null); method.invoke(this, (Object[]) null); - } - catch (Throwable e) { + } catch (Throwable e) { } String name = getName().split(" ")[0]; @@ -201,8 +192,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { try { Method method = getClass().getMethod(comboSetupMethodName, (Class[]) null); method.invoke(this, (Object[]) null); - } - catch (Throwable e) { + } catch (Throwable e) { } try { @@ -212,8 +202,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { if (expandedOptions.isEmpty()) { combosEvaluated = true; return new CombinationTestSupport[]{this}; - } - else { + } else { ArrayList result = new ArrayList<>(); // Run the test case for each possible combination @@ -228,8 +217,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { result.toArray(rc); return rc; } - } - catch (Throwable e) { + } catch (Throwable e) { combosEvaluated = true; return new CombinationTestSupport[]{this}; } @@ -242,8 +230,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { if (comboOptions.size() == optionsLeft.size()) { map = new HashMap<>(); expandedCombos.add(map); - } - else { + } else { map = expandedCombos.get(expandedCombos.size() - 1); } @@ -252,8 +239,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { int i = 0; if (comboOption.values.isEmpty() && !l.isEmpty()) { expandCombinations(l, expandedCombos); - } - else { + } else { for (Iterator iter = comboOption.values.iterator(); iter.hasNext(); ) { Object value = iter.next(); if (i != 0) { @@ -285,8 +271,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport { for (int j = 0; j < combinations.length; j++) { suite.addTest(combinations[j]); } - } - else { + } else { suite.addTest(test); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java index b8397e2598..c26831f1b5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.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, @@ -53,8 +53,7 @@ public class ConnectionCleanupTest extends TestCase { try { connection.setClientID("test"); fail("Should have received JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { } connection.doCleanup(true); @@ -65,8 +64,7 @@ public class ConnectionCleanupTest extends TestCase { try { connection.setClientID("test"); fail("Should have received JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesConcurrentTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesConcurrentTest.java index c4e5086d5e..9c44b6d329 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesConcurrentTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesConcurrentTest.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq; +import javax.jms.JMSException; +import javax.jms.Session; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import javax.jms.JMSException; -import javax.jms.Session; import junit.framework.TestCase; @@ -78,8 +78,7 @@ public class ConnectionCloseMultipleTimesConcurrentTest extends TestCase { assertTrue(connection.isClosed()); latch.countDown(); - } - catch (JMSException e) { + } catch (JMSException e) { // ignore } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesTest.java index dbd31f25e8..e6d56ce949 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCloseMultipleTimesTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConsumerReceiveWithTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConsumerReceiveWithTimeoutTest.java index 03ed8df2b4..8a6df60284 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConsumerReceiveWithTimeoutTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConsumerReceiveWithTimeoutTest.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, @@ -71,8 +71,7 @@ public class ConsumerReceiveWithTimeoutTest extends TestSupport { Thread.sleep(10000); MessageProducer producer = session.createProducer(queue); producer.send(session.createTextMessage("Hello")); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CreateConsumerButDontStartConnectionWarningTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CreateConsumerButDontStartConnectionWarningTest.java index 185fc48c9e..18998e6aad 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CreateConsumerButDontStartConnectionWarningTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CreateConsumerButDontStartConnectionWarningTest.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, @@ -37,8 +37,7 @@ public class CreateConsumerButDontStartConnectionWarningTest extends JmsQueueSen protected void assertMessagesAreReceived() throws JMSException { try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.warn("Caught: " + e, e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java index 1a3dab7d0a..5c45e40d1b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java index 9096c06dd2..02d6fd652f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import java.io.File; + import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.JournalType; @@ -29,11 +34,6 @@ import org.apache.activemq.command.ActiveMQTopic; import org.junit.rules.TemporaryFolder; import org.springframework.jms.core.JmsTemplate; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import java.io.File; - /** * A useful base class which creates and closes an embedded broker */ @@ -81,8 +81,7 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport { try { artemisBroker.stop(); artemisBroker = null; - } - catch (Exception e) { + } catch (Exception e) { } } temporaryFolder.delete(); @@ -141,8 +140,7 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport { protected ActiveMQDestination createDestination(String subject) { if (useTopic) { return new ActiveMQTopic(subject); - } - else { + } else { return new ActiveMQQueue(subject); } } @@ -163,7 +161,6 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport { return new ActiveMQConnectionFactory(bindAddress); } - public EmbeddedJMS createArtemisBroker() throws Exception { Configuration config0 = createConfig("localhost", 0); EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl()); @@ -172,14 +169,14 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport { protected Configuration createConfig(final String hostAddress, final int serverID) throws Exception { ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false). - setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO). - setJournalDirectory(getJournalDir(serverID, false)). - setBindingsDirectory(getBindingsDir(serverID, false)). - setPagingDirectory(getPageDir(serverID, false)). - setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). - setJournalCompactMinFiles(0). - setJournalCompactPercentage(0). - setClusterPassword(CLUSTER_PASSWORD); + setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO). + setJournalDirectory(getJournalDir(serverID, false)). + setBindingsDirectory(getBindingsDir(serverID, false)). + setPagingDirectory(getPageDir(serverID, false)). + setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)). + setJournalCompactMinFiles(0). + setJournalCompactPercentage(0). + setClusterPassword(CLUSTER_PASSWORD); configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true)); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java index 1e0555c548..db8eb5ff5d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.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, @@ -90,8 +90,7 @@ public class ExclusiveConsumerStartupDestinationTest extends EmbeddedBrokerTestS // Verify exclusive consumer receives the message. assertNotNull(exclusiveConsumer.receive(100)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -146,8 +145,7 @@ public class ExclusiveConsumerStartupDestinationTest extends EmbeddedBrokerTestS assertNotNull("Should have received a message", exclusiveConsumer2.receive(100)); assertNull("Should not have received a message", fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -196,8 +194,7 @@ public class ExclusiveConsumerStartupDestinationTest extends EmbeddedBrokerTestS assertNotNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java index 4142f93a02..409451b681 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.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, @@ -90,8 +90,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(exclusiveConsumer.receive(100)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -130,8 +129,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(exclusiveConsumer.receive(100)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -186,8 +184,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(exclusiveConsumer2.receive(100)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -243,8 +240,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(exclusiveConsumer2.receive(1000)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -293,8 +289,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); @@ -352,8 +347,7 @@ public class ExclusiveConsumerTest extends TestCase { assertNotNull(exclusiveConsumer.receive(100)); assertNull(fallbackConsumer.receive(100)); - } - finally { + } finally { fallbackSession.close(); senderSession.close(); conn.close(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExpiryHogTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExpiryHogTest.java index c3aac48991..cc67e80dae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExpiryHogTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExpiryHogTest.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, @@ -16,10 +16,10 @@ */ package org.apache.activemq; -import java.util.concurrent.TimeUnit; import javax.jms.ConnectionFactory; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.TimeUnit; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.PolicyEntry; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java index 6274890973..f62052c660 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.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, @@ -16,16 +16,6 @@ */ package org.apache.activemq; -import java.lang.Thread.UncaughtExceptionHandler; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.BytesMessage; import javax.jms.DeliveryMode; import javax.jms.Message; @@ -38,6 +28,15 @@ import javax.jms.Topic; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; @@ -168,8 +167,7 @@ public class JMSConsumerTest extends JmsTestSupport { // ack every 200 message.acknowledge(); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Exception on close or ack:", e); exceptions.put(Thread.currentThread(), e); } @@ -403,8 +401,7 @@ public class JMSConsumerTest extends JmsTestSupport { got2Done.countDown(); } tm.acknowledge(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -440,8 +437,7 @@ public class JMSConsumerTest extends JmsTestSupport { if (counter.get() == 4) { done2.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { LOG.error("unexpected ex onMessage: ", e); } } @@ -493,8 +489,7 @@ public class JMSConsumerTest extends JmsTestSupport { connection.close(); got2Done.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -528,8 +523,7 @@ public class JMSConsumerTest extends JmsTestSupport { if (counter.get() == 4) { done2.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { LOG.error("unexpected ex onMessage: ", e); } } @@ -928,8 +922,7 @@ public class JMSConsumerTest extends JmsTestSupport { String destName = destination.getPhysicalName(); if (destination.isQueue()) { return createJMSQueueControl(destName); - } - else { + } else { return createJMSTopicControl(destName); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSDurableTopicRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSDurableTopicRedeliverTest.java index 5baee6c558..0b5dc1c851 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSDurableTopicRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSDurableTopicRedeliverTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSExclusiveConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSExclusiveConsumerTest.java index 38dabfd1cd..88345b559e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSExclusiveConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSExclusiveConsumerTest.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, @@ -113,8 +113,7 @@ public class JMSExclusiveConsumerTest extends JmsTestSupport { m = consumer2.receive(1000); assertNotNull(m); } - } - else { + } else { // Consumer 1 should get all the messages. for (int i = 0; i < 3; i++) { m = consumer1.receive(1000); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSIndividualAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSIndividualAckTest.java index 34162510dd..8c12f526ef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSIndividualAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSIndividualAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSMessageTest.java index e38f92fb5f..83fe513cfe 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSMessageTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq; -import java.net.URISyntaxException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Vector; - import javax.jms.BytesMessage; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -34,6 +29,10 @@ import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TextMessage; +import java.net.URISyntaxException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Vector; import junit.framework.Test; @@ -180,8 +179,7 @@ public class JMSMessageTest extends JmsTestSupport { try { message.readByte(); fail("Expected exception not thrown."); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } } @@ -214,8 +212,7 @@ public class JMSMessageTest extends JmsTestSupport { try { message.readByte(); fail("Should have received NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } assertEquals("This is a test to see how it works.", message.readString()); @@ -225,8 +222,7 @@ public class JMSMessageTest extends JmsTestSupport { try { message.readByte(); fail("Should have received MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } } assertNull(consumer.receiveNoWait()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSQueueRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSQueueRedeliverTest.java index f924621aa4..ed42f215e8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSQueueRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSQueueRedeliverTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSUsecaseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSUsecaseTest.java index 534e190afe..a1a20dbc45 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSUsecaseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSUsecaseTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq; -import java.util.Enumeration; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -26,6 +24,7 @@ import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Enumeration; import junit.framework.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSXAConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSXAConsumerTest.java index fa6877db4e..a7c2cd6d67 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSXAConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSXAConsumerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckListenerTest.java index 0b5ea63f20..42e2c9f44a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckListenerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckTest.java index c2b00e94f6..4537ddebeb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsAutoAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsBenchmark.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsBenchmark.java index be59cd1074..9d90b8b7bf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsBenchmark.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsBenchmark.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -35,6 +26,14 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; @@ -153,8 +152,7 @@ public class JmsBenchmark extends JmsTestSupport { public void run() { try { producer.call(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); workerError[0] = e; } @@ -168,8 +166,7 @@ public class JmsBenchmark extends JmsTestSupport { public void run() { try { consumer.call(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); workerError[0] = e; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckListenerTest.java index a707a9636d..b0f42f64e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckListenerTest.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, @@ -123,8 +123,7 @@ public class JmsClientAckListenerTest extends TestSupport implements MessageList if (!dontAck) { try { message.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckTest.java index 4a86d9cb0e..79a5abccea 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsClientAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConnectionStartStopTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConnectionStartStopTest.java index e5990714af..5c3c3266e6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConnectionStartStopTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConnectionStartStopTest.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, @@ -16,12 +16,6 @@ */ package org.apache.activemq; -import java.util.Random; -import java.util.Vector; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -30,6 +24,11 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** * @@ -123,8 +122,7 @@ public class JmsConnectionStartStopTest extends TestSupport { try { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); } } @@ -137,8 +135,7 @@ public class JmsConnectionStartStopTest extends TestSupport { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.start(); stoppedConnection.stop(); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConsumerResetActiveListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConsumerResetActiveListenerTest.java index 1361b791e7..194b09f606 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConsumerResetActiveListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsConsumerResetActiveListenerTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq; -import java.util.Vector; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -31,6 +26,10 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Vector; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.TestCase; @@ -74,12 +73,10 @@ public class JmsConsumerResetActiveListenerTest extends TestCase { try { consumer.setMessageListener(this); results.add(message); - } - catch (JMSException e) { + } catch (JMSException e) { results.add(e); } - } - else { + } else { results.add(message); } latch.countDown(); @@ -126,12 +123,10 @@ public class JmsConsumerResetActiveListenerTest extends TestCase { MessageConsumer anotherConsumer = session.createConsumer(dest); anotherConsumer.setMessageListener(this); results.add(message); - } - catch (JMSException e) { + } catch (JMSException e) { results.add(e); } - } - else { + } else { results.add(message); } latch.countDown(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsCreateConsumerInOnMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsCreateConsumerInOnMessageTest.java index f48793780e..707063d68d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsCreateConsumerInOnMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsCreateConsumerInOnMessageTest.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, @@ -94,8 +94,7 @@ public class JmsCreateConsumerInOnMessageTest extends TestSupport implements Mes synchronized (lock) { lock.notify(); } - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); assertTrue(false); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java index 309fec95b8..7fd4a949db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSelectorTest.java index 7db52ae328..871fd0249c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSelectorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSendReceiveTest.java index 978f31c700..f54e1f5f2a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicTransactionTest.java index d8277787ac..065e9deaf5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicWildcardSendReceiveTest.java index b913726cde..89c64e1856 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicWildcardSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableTopicWildcardSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMessageConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMessageConsumerTest.java index e74c13aa73..6e2c814a73 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMessageConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMessageConsumerTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Message; @@ -31,6 +23,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.broker.BrokerService; import org.junit.After; @@ -39,6 +33,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + public class JmsMessageConsumerTest { private BrokerService brokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java index a826b0ad23..665782f2b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.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, @@ -16,20 +16,6 @@ */ package org.apache.activemq; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -42,6 +28,19 @@ import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.advisory.ConsumerEvent; import org.apache.activemq.advisory.ConsumerEventSource; @@ -133,8 +132,7 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport { localBroker.addNetworkConnector(connector); maxSetupTime = 2000; return connector; - } - else { + } else { throw new Exception("Remote broker has no registered connectors."); } @@ -433,8 +431,7 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport { latch.await(timeout, TimeUnit.MILLISECONDS); assertTrue("Expected at least " + count + " consumers to connect, but only " + actualConnected.get() + " connectect within " + timeout + " ms", actualConnected.get() >= count); - } - finally { + } finally { ces.stop(); conn.close(); brokerItem.connections.remove(conn); @@ -489,8 +486,7 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport { msg.setText(initText + str); // Do not pad message text - } - else { + } else { msg.setText(initText); } @@ -503,8 +499,7 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport { dest = new ActiveMQTopic(name); destinations.put(name, dest); return (ActiveMQDestination) dest; - } - else { + } else { dest = new ActiveMQQueue(name); destinations.put(name, dest); return (ActiveMQDestination) dest; @@ -654,10 +649,8 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport { Connection c = connections.remove(0); try { c.close(); - } - catch (ConnectionClosedException e) { - } - catch (JMSException e) { + } catch (ConnectionClosedException e) { + } catch (JMSException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleClientsTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleClientsTestSupport.java index 5ee575e2f1..288514dd23 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleClientsTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsMultipleClientsTestSupport.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, @@ -16,16 +16,6 @@ */ package org.apache.activemq; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -36,6 +26,15 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.TopicSubscriber; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; @@ -50,7 +49,7 @@ import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Test case support used to test multiple message comsumers and message @@ -98,8 +97,7 @@ public class JmsMultipleClientsTestSupport { public void run() { try { sendMessages(factory.createConnection(), dest, msgCount); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -121,8 +119,7 @@ public class JmsMultipleClientsTestSupport { } // Use serialized send - } - else { + } else { for (int i = 0; i < producerCount; i++) { sendMessages(factory.createConnection(), dest, msgCount); } @@ -158,8 +155,7 @@ public class JmsMultipleClientsTestSupport { msg.setText(initText + str); // Do not pad message text - } - else { + } else { msg.setText(initText); } @@ -175,8 +171,7 @@ public class JmsMultipleClientsTestSupport { for (int i = 0; i < consumerCount; i++) { if (durable && topic) { consumer = createDurableSubscriber(factory.createConnection(), dest, "consumer" + (i + 1)); - } - else { + } else { consumer = createMessageConsumer(factory.createConnection(), dest); } MessageIdList list = new MessageIdList(); @@ -219,8 +214,7 @@ public class JmsMultipleClientsTestSupport { if (topic) { destination = new ActiveMQTopic("Topic" + name); return (ActiveMQDestination) destination; - } - else { + } else { destination = new ActiveMQQueue("Queue" + name); return (ActiveMQDestination) destination; } @@ -246,8 +240,7 @@ public class JmsMultipleClientsTestSupport { Connection conn = iter.next(); try { conn.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } if (broker != null) { // FIXME remove diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java index 6a3cd1916e..4d5d921184 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; - import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -29,6 +25,9 @@ import javax.jms.TextMessage; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; import javax.management.openmbean.TabularData; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; import junit.framework.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java index 19103217c5..03f9675115 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.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, @@ -86,8 +86,7 @@ public class JmsQueueCompositeSendReceiveTest extends JmsTopicSendReceiveTest { if (durable) { LOG.info("Creating durable consumer"); consumer = consumeSession.createDurableSubscriber((Topic) consumerDestination, getName()); - } - else { + } else { consumer = consumeSession.createConsumer(consumerDestination); } consumer.setMessageListener(this); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueRequestReplyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueRequestReplyTest.java index 839a9b4937..f37942671e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueRequestReplyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueRequestReplyTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSelectorTest.java index ff2d521144..2a4c0b4b69 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSelectorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTest.java index f007190008..d88df8a9bc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java index b60c091513..c15dd1fb2d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.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, @@ -39,8 +39,7 @@ public class JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest extends JmsQ LOG.info("Lets wait: " + delayBeforeStartingBroker + " millis before creating the broker"); try { Thread.sleep(delayBeforeStartingBroker); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } @@ -50,8 +49,7 @@ public class JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest extends JmsQ broker.setPersistent(false); broker.addConnector("tcp://localhost:61616"); broker.start(); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Caught: " + e); errors.add(e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsTest.java index 01eda1dffd..4f020a0c59 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveTwoConnectionsTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveUsingTwoSessionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveUsingTwoSessionsTest.java index e5f0738f62..272536b1d4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveUsingTwoSessionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueSendReceiveUsingTwoSessionsTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTopicCompositeSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTopicCompositeSendReceiveTest.java index 28173b8f9c..6343792d3c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTopicCompositeSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTopicCompositeSendReceiveTest.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, @@ -47,8 +47,7 @@ public class JmsQueueTopicCompositeSendReceiveTest extends JmsTopicSendReceiveTe if (durable) { LOG.info("Creating durable consumer"); consumer2 = consumeSession.createDurableSubscriber((Topic) consumerDestination2, getName()); - } - else { + } else { consumer2 = consumeSession.createConsumer(consumerDestination2); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java index e464b7c3e1..f91c67a9eb 100755 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.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, @@ -35,201 +35,202 @@ import org.slf4j.LoggerFactory; * */ public class JmsQueueTransactionTest extends JmsTransactionTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(JmsQueueTransactionTest.class); - /** - * @see org.apache.activemq.JmsTransactionTestSupport#getJmsResourceProvider() - */ - @Override - protected JmsResourceProvider getJmsResourceProvider() { - JmsResourceProvider p = new JmsResourceProvider(); - p.setTopic(false); - return p; - } + private static final Logger LOG = LoggerFactory.getLogger(JmsQueueTransactionTest.class); - /** - * Tests if the the connection gets reset, the messages will still be - * received. - * - * @throws Exception - */ - public void testReceiveTwoThenCloseConnection() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + /** + * @see org.apache.activemq.JmsTransactionTestSupport#getJmsResourceProvider() + */ + @Override + protected JmsResourceProvider getJmsResourceProvider() { + JmsResourceProvider p = new JmsResourceProvider(); + p.setTopic(false); + return p; + } - // lets consume any outstanding messages from previous test runs - beginTx(); - while (consumer.receive(1000) != null) { - } - commitTx(); + /** + * Tests if the the connection gets reset, the messages will still be + * received. + * + * @throws Exception + */ + public void testReceiveTwoThenCloseConnection() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - beginTx(); - producer.send(outbound[0]); - producer.send(outbound[1]); - commitTx(); + // lets consume any outstanding messages from previous test runs + beginTx(); + while (consumer.receive(1000) != null) { + } + commitTx(); - LOG.info("Sent 0: " + outbound[0]); - LOG.info("Sent 1: " + outbound[1]); + beginTx(); + producer.send(outbound[0]); + producer.send(outbound[1]); + commitTx(); - ArrayList messages = new ArrayList<>(); - beginTx(); - Message message = consumer.receive(2000); - assertEquals(outbound[0], message); + LOG.info("Sent 0: " + outbound[0]); + LOG.info("Sent 1: " + outbound[1]); - message = consumer.receive(2000); - assertNotNull(message); - assertEquals(outbound[1], message); + ArrayList messages = new ArrayList<>(); + beginTx(); + Message message = consumer.receive(2000); + assertEquals(outbound[0], message); - // Close and reopen connection. - reconnect(); + message = consumer.receive(2000); + assertNotNull(message); + assertEquals(outbound[1], message); - // Consume again.. the previous message should - // get redelivered. - beginTx(); - message = consumer.receive(2000); - assertNotNull("Should have re-received the first message again!", message); - messages.add(message); - assertEquals(outbound[0], message); + // Close and reopen connection. + reconnect(); - message = consumer.receive(5000); - assertNotNull("Should have re-received the second message again!", message); - messages.add(message); - assertEquals(outbound[1], message); - commitTx(); + // Consume again.. the previous message should + // get redelivered. + beginTx(); + message = consumer.receive(2000); + assertNotNull("Should have re-received the first message again!", message); + messages.add(message); + assertEquals(outbound[0], message); - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); + message = consumer.receive(5000); + assertNotNull("Should have re-received the second message again!", message); + messages.add(message); + assertEquals(outbound[1], message); + commitTx(); - assertTextMessagesEqual("Rollback did not work", outbound, inbound); - } + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); - /** - * Tests sending and receiving messages with two sessions(one for producing - * and another for consuming). - * - * @throws Exception - */ - public void testSendReceiveInSeperateSessionTest() throws Exception { - session.close(); - int batchCount = 10; + assertTextMessagesEqual("Rollback did not work", outbound, inbound); + } - for (int i = 0; i < batchCount; i++) { - // Session that sends messages - { - Session session = resourceProvider.createSession(connection); - this.session = session; - MessageProducer producer = resourceProvider.createProducer(session, destination); - // consumer = resourceProvider.createConsumer(session, - // destination); - beginTx(); - producer.send(session.createTextMessage("Test Message: " + i)); - commitTx(); - session.close(); - } + /** + * Tests sending and receiving messages with two sessions(one for producing + * and another for consuming). + * + * @throws Exception + */ + public void testSendReceiveInSeperateSessionTest() throws Exception { + session.close(); + int batchCount = 10; - // Session that consumes messages - { - Session session = resourceProvider.createSession(connection); - this.session = session; - MessageConsumer consumer = resourceProvider.createConsumer(session, destination); + for (int i = 0; i < batchCount; i++) { + // Session that sends messages + { + Session session = resourceProvider.createSession(connection); + this.session = session; + MessageProducer producer = resourceProvider.createProducer(session, destination); + // consumer = resourceProvider.createConsumer(session, + // destination); + beginTx(); + producer.send(session.createTextMessage("Test Message: " + i)); + commitTx(); + session.close(); + } - beginTx(); - TextMessage message = (TextMessage)consumer.receive(1000 * 5); - assertNotNull("Received only " + i + " messages in batch ", message); - assertEquals("Test Message: " + i, message.getText()); + // Session that consumes messages + { + Session session = resourceProvider.createSession(connection); + this.session = session; + MessageConsumer consumer = resourceProvider.createConsumer(session, destination); - commitTx(); - session.close(); - } - } - } + beginTx(); + TextMessage message = (TextMessage) consumer.receive(1000 * 5); + assertNotNull("Received only " + i + " messages in batch ", message); + assertEquals("Test Message: " + i, message.getText()); - /** - * Tests the queue browser. Browses the messages then the consumer tries to - * receive them. The messages should still be in the queue even when it was - * browsed. - * - * @throws Exception - */ - public void testReceiveBrowseReceive() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message")}; + commitTx(); + session.close(); + } + } + } - // lets consume any outstanding messages from previous test runs - beginTx(); - while (consumer.receive(1000) != null) { - } - commitTx(); + /** + * Tests the queue browser. Browses the messages then the consumer tries to + * receive them. The messages should still be in the queue even when it was + * browsed. + * + * @throws Exception + */ + public void testReceiveBrowseReceive() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message")}; - beginTx(); - producer.send(outbound[0]); - producer.send(outbound[1]); - producer.send(outbound[2]); - commitTx(); + // lets consume any outstanding messages from previous test runs + beginTx(); + while (consumer.receive(1000) != null) { + } + commitTx(); - // Get the first. - beginTx(); - assertEquals(outbound[0], consumer.receive(1000)); - consumer.close(); - commitTx(); + beginTx(); + producer.send(outbound[0]); + producer.send(outbound[1]); + producer.send(outbound[2]); + commitTx(); - beginTx(); - QueueBrowser browser = session.createBrowser((Queue)destination); - Enumeration enumeration = browser.getEnumeration(); + // Get the first. + beginTx(); + assertEquals(outbound[0], consumer.receive(1000)); + consumer.close(); + commitTx(); - // browse the second - assertTrue("should have received the second message", enumeration.hasMoreElements()); - assertEquals(outbound[1], (Message)enumeration.nextElement()); + beginTx(); + QueueBrowser browser = session.createBrowser((Queue) destination); + Enumeration enumeration = browser.getEnumeration(); - // browse the third. - assertTrue("Should have received the third message", enumeration.hasMoreElements()); - assertEquals(outbound[2], (Message)enumeration.nextElement()); + // browse the second + assertTrue("should have received the second message", enumeration.hasMoreElements()); + assertEquals(outbound[1], (Message) enumeration.nextElement()); - LOG.info("Check for more..."); - // There should be no more. - boolean tooMany = false; - while (enumeration.hasMoreElements()) { - LOG.info("Got extra message: " + ((TextMessage)enumeration.nextElement()).getText()); - tooMany = true; - } - assertFalse(tooMany); - LOG.info("close browser..."); - browser.close(); + // browse the third. + assertTrue("Should have received the third message", enumeration.hasMoreElements()); + assertEquals(outbound[2], (Message) enumeration.nextElement()); - LOG.info("reopen and consume..."); - // Re-open the consumer. - consumer = resourceProvider.createConsumer(session, destination); - // Receive the second. - assertEquals(outbound[1], consumer.receive(1000)); - // Receive the third. - assertEquals(outbound[2], consumer.receive(1000)); - consumer.close(); + LOG.info("Check for more..."); + // There should be no more. + boolean tooMany = false; + while (enumeration.hasMoreElements()) { + LOG.info("Got extra message: " + ((TextMessage) enumeration.nextElement()).getText()); + tooMany = true; + } + assertFalse(tooMany); + LOG.info("close browser..."); + browser.close(); - commitTx(); - } + LOG.info("reopen and consume..."); + // Re-open the consumer. + consumer = resourceProvider.createConsumer(session, destination); + // Receive the second. + assertEquals(outbound[1], consumer.receive(1000)); + // Receive the third. + assertEquals(outbound[2], consumer.receive(1000)); + consumer.close(); - public void testCloseConsumer() throws Exception { - Destination dest = session.createQueue(getSubject() + "?consumer.prefetchSize=0"); - producer = session.createProducer(dest); - beginTx(); - producer.send(session.createTextMessage("message 1")); - producer.send(session.createTextMessage("message 2")); - commitTx(); + commitTx(); + } - beginTx(); - consumer = session.createConsumer(dest); - Message message1 = consumer.receive(1000); - String text1 = ((TextMessage)message1).getText(); - assertNotNull(message1); - assertEquals("message 1", text1); + public void testCloseConsumer() throws Exception { + Destination dest = session.createQueue(getSubject() + "?consumer.prefetchSize=0"); + producer = session.createProducer(dest); + beginTx(); + producer.send(session.createTextMessage("message 1")); + producer.send(session.createTextMessage("message 2")); + commitTx(); - consumer.close(); + beginTx(); + consumer = session.createConsumer(dest); + Message message1 = consumer.receive(1000); + String text1 = ((TextMessage) message1).getText(); + assertNotNull(message1); + assertEquals("message 1", text1); - consumer = session.createConsumer(dest); + consumer.close(); - Message message2 = consumer.receive(1000); - String text2 = ((TextMessage)message2).getText(); - assertNotNull(message2); - assertEquals("message 2", text2); - commitTx(); - } + consumer = session.createConsumer(dest); + + Message message2 = consumer.receive(1000); + String text2 = ((TextMessage) message2).getText(); + assertNotNull(message2); + assertEquals("message 2", text2); + commitTx(); + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java index 9a6dcb1e26..e98602308e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRedeliveredTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRedeliveredTest.java index 03a7614a0c..abd5e61d66 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRedeliveredTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRedeliveredTest.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, @@ -16,7 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -28,6 +27,7 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.util.concurrent.TimeUnit; import junit.framework.Test; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java index c57845da71..23e7781e59 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.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, @@ -17,10 +17,6 @@ package org.apache.activemq; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -29,17 +25,23 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.broker.BrokerService; import org.junit.After; import org.junit.Before; -import org.junit.Test; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class JmsRollbackRedeliveryTest { @@ -103,8 +105,7 @@ public class JmsRollbackRedeliveryTest { if (interleaveProducer) { populateDestinationWithInterleavedProducer(nbMessages, destinationName, connection); - } - else { + } else { populateDestination(nbMessages, destinationName, connection); } @@ -123,8 +124,7 @@ public class JmsRollbackRedeliveryTest { assertTrue(msg.getJMSRedelivered()); assertEquals(2, msg.getLongProperty("JMSXDeliveryCount")); session.commit(); - } - else { + } else { LOG.info("Rollback message " + msg.getText() + " id: " + msg.getJMSMessageID()); assertFalse("should not have redelivery flag set, id: " + msg.getJMSMessageID(), msg.getJMSRedelivered()); session.rollback(); @@ -159,8 +159,7 @@ public class JmsRollbackRedeliveryTest { LOG.info("Received message " + msg.getText() + " (" + received.getAndIncrement() + ")" + msg.getJMSMessageID()); assertTrue(msg.getJMSRedelivered()); session.commit(); - } - else { + } else { LOG.info("Rollback message " + msg.getText() + " id: " + msg.getJMSMessageID()); session.rollback(); } @@ -194,8 +193,7 @@ public class JmsRollbackRedeliveryTest { LOG.info("Received message " + msg.getText() + " (" + received.getAndIncrement() + ")" + msg.getJMSMessageID()); assertTrue(msg.getJMSRedelivered()); session.commit(); - } - else { + } else { LOG.info("Rollback message " + msg.getText() + " id: " + msg.getJMSMessageID()); session.rollback(); } @@ -340,8 +338,7 @@ public class JmsRollbackRedeliveryTest { for (int i = 1; i <= nbMessages; i++) { if (i % 2 == 0) { producer1.send(session1.createTextMessage("")); - } - else { + } else { producer2.send(session2.createTextMessage("")); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveTestSupport.java index 6fd36cc89b..04cbe1cf32 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveTestSupport.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; @@ -32,6 +25,12 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -181,8 +180,7 @@ public class JmsSendReceiveTestSupport extends TestSupport implements MessageLis while (messages.size() < data.length && waitTime >= 0) { try { lock.wait(200); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveWithMessageExpirationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveWithMessageExpirationTest.java index 6e4e214dbc..dffd722961 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveWithMessageExpirationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendReceiveWithMessageExpirationTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq; -import java.util.Date; -import java.util.Vector; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -29,6 +25,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; +import java.util.Date; +import java.util.Vector; +import java.util.concurrent.TimeUnit; import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.region.DestinationStatistics; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendWithAsyncCallbackTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendWithAsyncCallbackTest.java index f2717d283e..d88fd283ed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendWithAsyncCallbackTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSendWithAsyncCallbackTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.CountDownLatch; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -26,6 +24,7 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Queue; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSessionRecoverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSessionRecoverTest.java index e08333229b..04bcc37341 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSessionRecoverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsSessionRecoverTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -29,6 +26,8 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import junit.framework.TestCase; @@ -202,8 +201,7 @@ public class JmsSessionRecoverTest extends TestCase { errorMessage[0] = "Got too many messages: " + counter; doneCountDownLatch.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errorMessage[0] = "Got exception: " + e; doneCountDownLatch.countDown(); @@ -216,8 +214,7 @@ public class JmsSessionRecoverTest extends TestCase { if (errorMessage[0] != null) { fail(errorMessage[0]); } - } - else { + } else { fail("Timeout waiting for async message delivery to complete."); } @@ -273,8 +270,7 @@ public class JmsSessionRecoverTest extends TestCase { errorMessage[0] = "Got too many messages: " + counter; doneCountDownLatch.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errorMessage[0] = "Got exception: " + e; doneCountDownLatch.countDown(); @@ -287,8 +283,7 @@ public class JmsSessionRecoverTest extends TestCase { if (errorMessage[0] != null) { fail(errorMessage[0]); } - } - else { + } else { fail("Timeout waiting for async message delivery to complete."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTempDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTempDestinationTest.java index 866ab63ae5..060853c3e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTempDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTempDestinationTest.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, @@ -16,12 +16,6 @@ */ package org.apache.activemq; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -34,6 +28,11 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.TextMessage; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; import org.apache.activemq.util.Wait; import org.junit.After; @@ -70,8 +69,7 @@ public class JmsTempDestinationTest { Connection conn = iter.next(); try { conn.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } iter.remove(); } @@ -107,8 +105,7 @@ public class JmsTempDestinationTest { try { consumer = otherSession.createConsumer(queue); Assert.fail("Send should fail since temp destination should be used from another connection"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { Assert.assertTrue("failed to throw an exception", true); } @@ -249,8 +246,7 @@ public class JmsTempDestinationTest { message = session.createTextMessage("Hello"); producer.send(message); Assert.fail("Send should fail since temp destination should not exist anymore."); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -302,8 +298,7 @@ public class JmsTempDestinationTest { message = session.createTextMessage("Hello"); producer.send(message); Assert.fail("Send should fail since temp destination should not exist anymore."); - } - catch (JMSException e) { + } catch (JMSException e) { Assert.assertTrue("failed to throw an exception", true); } } @@ -329,8 +324,7 @@ public class JmsTempDestinationTest { try { queue.delete(); Assert.fail("Should fail as Subscribers are active"); - } - catch (JMSException e) { + } catch (JMSException e) { Assert.assertTrue("failed to throw an exception", true); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java index 03bf32c263..0fca303979 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.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, @@ -16,6 +16,13 @@ */ package org.apache.activemq; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.io.File; import java.io.IOException; import java.net.URI; @@ -25,14 +32,6 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQDestination; @@ -134,8 +133,7 @@ public class JmsTestSupport extends CombinationTestSupport { Connection conn = iter.next(); try { conn.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } iter.remove(); } @@ -146,32 +144,28 @@ public class JmsTestSupport extends CombinationTestSupport { protected void safeClose(Connection c) { try { c.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } protected void safeClose(Session s) { try { s.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } protected void safeClose(MessageConsumer c) { try { c.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } protected void safeClose(MessageProducer p) { try { p.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicCompositeSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicCompositeSendReceiveTest.java index eb9a06d8c6..8b5bc51c64 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicCompositeSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicCompositeSendReceiveTest.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, @@ -47,8 +47,7 @@ public class JmsTopicCompositeSendReceiveTest extends JmsTopicSendReceiveTest { if (durable) { LOG.info("Creating durable consumer"); consumer2 = consumeSession.createDurableSubscriber((Topic) consumerDestination2, getName()); - } - else { + } else { consumer2 = consumeSession.createConsumer(consumerDestination2); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRedeliverTest.java index 3bb2df9ead..d862a4a546 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRedeliverTest.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, @@ -75,8 +75,7 @@ public class JmsTopicRedeliverTest extends TestSupport { if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRequestReplyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRequestReplyTest.java index ad94f098f3..72913cfd11 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRequestReplyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicRequestReplyTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq; -import java.util.List; -import java.util.Vector; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -30,6 +27,8 @@ import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.TemporaryTopic; import javax.jms.TextMessage; +import java.util.List; +import java.util.Vector; import org.apache.activemq.test.TestSupport; import org.slf4j.Logger; @@ -91,8 +90,7 @@ public class JmsTopicRequestReplyTest extends TestSupport implements MessageList LOG.info("Received reply."); LOG.info(replyMessage.toString()); assertEquals("Wrong message content", "Hello: Olivier", replyMessage.getText()); - } - else { + } else { fail("Should have received a reply by now"); } replyConsumer.close(); @@ -133,15 +131,13 @@ public class JmsTopicRequestReplyTest extends TestSupport implements MessageList if (dynamicallyCreateProducer) { replyProducer = serverSession.createProducer(replyDestination); replyProducer.send(replyMessage); - } - else { + } else { replyProducer.send(replyDestination, replyMessage); } LOG.info("Sent reply."); LOG.info(replyMessage.toString()); - } - catch (JMSException e) { + } catch (JMSException e) { onException(e); } } @@ -154,12 +150,10 @@ public class JmsTopicRequestReplyTest extends TestSupport implements MessageList Message message = requestConsumer.receive(5000); if (message != null) { onMessage(message); - } - else { + } else { LOG.error("No message received"); } - } - catch (JMSException e) { + } catch (JMSException e) { onException(e); } } @@ -180,8 +174,7 @@ public class JmsTopicRequestReplyTest extends TestSupport implements MessageList final MessageConsumer requestConsumer = serverSession.createConsumer(requestDestination); if (useAsyncConsume) { requestConsumer.setMessageListener(this); - } - else { + } else { Thread thread = new Thread(new Runnable() { @Override public void run() { @@ -225,8 +218,7 @@ public class JmsTopicRequestReplyTest extends TestSupport implements MessageList protected void deleteTemporaryDestination(Destination dest) throws JMSException { if (topic) { ((TemporaryTopic) dest).delete(); - } - else { + } else { ((TemporaryQueue) dest).delete(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSelectorTest.java index 8968d31a53..97dd1fc168 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSelectorTest.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, @@ -67,8 +67,7 @@ public class JmsTopicSelectorTest extends TestSupport { if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveSubscriberTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveSubscriberTest.java index 3f120a6536..c96baa87c0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveSubscriberTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveSubscriberTest.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, @@ -30,8 +30,7 @@ public class JmsTopicSendReceiveSubscriberTest extends JmsTopicSendReceiveTest { protected MessageConsumer createConsumer() throws JMSException { if (durable) { return super.createConsumer(); - } - else { + } else { TopicSession topicSession = (TopicSession) session; return topicSession.createSubscriber((Topic) consumerDestination, null, false); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveTest.java index 71ddcd53c6..c34b492f07 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveTest.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, @@ -58,8 +58,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java index 216ed10caf..7bcd85056d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq; -import org.apache.activemq.transport.tcp.TcpTransportFactory; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -25,6 +23,8 @@ import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Session; +import org.apache.activemq.transport.tcp.TcpTransportFactory; + /** * @version */ @@ -65,8 +65,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java index 5acaece435..f622086ccd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendSameMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendSameMessageTest.java index 7b84a15f8f..99297746d6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendSameMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendSameMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicTransactionTest.java index b9ec483cd7..0fe34d18d8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java index 8fd1c00021..9a647b4d83 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicWildcardSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java index 0171bfa9e9..16a85eb627 100755 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.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, @@ -44,678 +44,677 @@ import org.slf4j.LoggerFactory; */ public abstract class JmsTransactionTestSupport extends TestSupport implements MessageListener { - private static final Logger LOG = LoggerFactory.getLogger(JmsTransactionTestSupport.class); - private static final int MESSAGE_COUNT = 5; - private static final String MESSAGE_TEXT = "message"; + private static final Logger LOG = LoggerFactory.getLogger(JmsTransactionTestSupport.class); + private static final int MESSAGE_COUNT = 5; + private static final String MESSAGE_TEXT = "message"; - protected ConnectionFactory connectionFactory; - protected Connection connection; - protected Session session; - protected MessageConsumer consumer; - protected MessageProducer producer; - protected JmsResourceProvider resourceProvider; - protected Destination destination; - protected int batchCount = 10; - protected int batchSize = 20; - protected BrokerService broker; + protected ConnectionFactory connectionFactory; + protected Connection connection; + protected Session session; + protected MessageConsumer consumer; + protected MessageProducer producer; + protected JmsResourceProvider resourceProvider; + protected Destination destination; + protected int batchCount = 10; + protected int batchSize = 20; + protected BrokerService broker; - // for message listener test - private final List unackMessages = new ArrayList<>(MESSAGE_COUNT); - private final List ackMessages = new ArrayList<>(MESSAGE_COUNT); - private boolean resendPhase; + // for message listener test + private final List unackMessages = new ArrayList<>(MESSAGE_COUNT); + private final List ackMessages = new ArrayList<>(MESSAGE_COUNT); + private boolean resendPhase; - public JmsTransactionTestSupport() { - super(); - } + public JmsTransactionTestSupport() { + super(); + } - public JmsTransactionTestSupport(String name) { - super(name); - } + public JmsTransactionTestSupport(String name) { + super(name); + } - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - broker = createBroker(); - broker.start(); - broker.waitUntilStarted(); + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + broker = createBroker(); + broker.start(); + broker.waitUntilStarted(); - resourceProvider = getJmsResourceProvider(); - topic = resourceProvider.isTopic(); - // We will be using transacted sessions. - setSessionTransacted(); - connectionFactory = newConnectionFactory(); - reconnect(); - } + resourceProvider = getJmsResourceProvider(); + topic = resourceProvider.isTopic(); + // We will be using transacted sessions. + setSessionTransacted(); + connectionFactory = newConnectionFactory(); + reconnect(); + } - protected void setSessionTransacted() { - resourceProvider.setTransacted(true); - } + protected void setSessionTransacted() { + resourceProvider.setTransacted(true); + } - protected ConnectionFactory newConnectionFactory() throws Exception { - return resourceProvider.createConnectionFactory(); - } + protected ConnectionFactory newConnectionFactory() throws Exception { + return resourceProvider.createConnectionFactory(); + } - protected void beginTx() throws Exception { - //no-op for local tx - } + protected void beginTx() throws Exception { + //no-op for local tx + } - protected void commitTx() throws Exception { - session.commit(); - } + protected void commitTx() throws Exception { + session.commit(); + } - protected void rollbackTx() throws Exception { - session.rollback(); - } + protected void rollbackTx() throws Exception { + session.rollback(); + } - /** - */ - protected BrokerService createBroker() throws Exception, URISyntaxException { - return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false")); - } + /** + */ + protected BrokerService createBroker() throws Exception, URISyntaxException { + return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false")); + } - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception { - LOG.info("Closing down connection"); + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception { + LOG.info("Closing down connection"); - try { - session.close(); - session = null; - connection.close(); - connection = null; - } catch (Exception e) { - LOG.info("Caught exception while closing resources."); - } + try { + session.close(); + session = null; + connection.close(); + connection = null; + } catch (Exception e) { + LOG.info("Caught exception while closing resources."); + } - try { - broker.stop(); - broker.waitUntilStopped(); - broker = null; - } catch (Exception e) { - LOG.info("Caught exception while shutting down the Broker", e); - } + try { + broker.stop(); + broker.waitUntilStopped(); + broker = null; + } catch (Exception e) { + LOG.info("Caught exception while shutting down the Broker", e); + } - LOG.info("Connection closed."); - } + LOG.info("Connection closed."); + } - protected abstract JmsResourceProvider getJmsResourceProvider(); + protected abstract JmsResourceProvider getJmsResourceProvider(); - /** - * Sends a batch of messages and validates that the messages are received. - * - * @throws Exception - */ - public void testSendReceiveTransactedBatches() throws Exception { + /** + * Sends a batch of messages and validates that the messages are received. + * + * @throws Exception + */ + public void testSendReceiveTransactedBatches() throws Exception { - TextMessage message = session.createTextMessage("Batch Message"); - for (int j = 0; j < batchCount; j++) { - LOG.info("Producing bacth " + j + " of " + batchSize + " messages"); + TextMessage message = session.createTextMessage("Batch Message"); + for (int j = 0; j < batchCount; j++) { + LOG.info("Producing bacth " + j + " of " + batchSize + " messages"); - beginTx(); - for (int i = 0; i < batchSize; i++) { - producer.send(message); + beginTx(); + for (int i = 0; i < batchSize; i++) { + producer.send(message); + } + messageSent(); + commitTx(); + LOG.info("Consuming bacth " + j + " of " + batchSize + " messages"); + + beginTx(); + for (int i = 0; i < batchSize; i++) { + message = (TextMessage) consumer.receive(1000 * 5); + assertNotNull("Received only " + i + " messages in batch " + j, message); + assertEquals("Batch Message", message.getText()); + } + + commitTx(); + } + } + + protected void messageSent() throws Exception { + } + + /** + * Sends a batch of messages and validates that the rollbacked message was + * not consumed. + * + * @throws Exception + */ + public void testSendRollback() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // sends a message + beginTx(); + producer.send(outbound[0]); + commitTx(); + + // sends a message that gets rollbacked + beginTx(); + producer.send(session.createTextMessage("I'm going to get rolled back.")); + rollbackTx(); + + // sends a message + beginTx(); + producer.send(outbound[1]); + commitTx(); + + // receives the first message + beginTx(); + ArrayList messages = new ArrayList<>(); + LOG.info("About to consume message 1"); + Message message = consumer.receive(1000); + messages.add(message); + LOG.info("Received: " + message); + + // receives the second message + LOG.info("About to consume message 2"); + message = consumer.receive(4000); + messages.add(message); + LOG.info("Received: " + message); + + // validates that the rollbacked was not consumed + commitTx(); + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Rollback did not work.", outbound, inbound); + } + + /** + * spec section 3.6 acking a message with automation acks has no effect. + * @throws Exception + */ + public void testAckMessageInTx() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message")}; + + // sends a message + beginTx(); + producer.send(outbound[0]); + outbound[0].acknowledge(); + commitTx(); + outbound[0].acknowledge(); + + // receives the first message + beginTx(); + ArrayList messages = new ArrayList<>(); + LOG.info("About to consume message 1"); + Message message = consumer.receive(1000); + messages.add(message); + LOG.info("Received: " + message); + + // validates that the rollbacked was not consumed + commitTx(); + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Message not delivered.", outbound, inbound); + } + + /** + * Sends a batch of messages and validates that the message sent before + * session close is not consumed. + * + * This test only works with local transactions, not xa. + * @throws Exception + */ + public void testSendSessionClose() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // sends a message + beginTx(); + producer.send(outbound[0]); + commitTx(); + + // sends a message that gets rollbacked + beginTx(); + producer.send(session.createTextMessage("I'm going to get rolled back.")); + consumer.close(); + + reconnectSession(); + + // sends a message + producer.send(outbound[1]); + commitTx(); + + // receives the first message + ArrayList messages = new ArrayList<>(); + LOG.info("About to consume message 1"); + beginTx(); + Message message = consumer.receive(1000); + messages.add(message); + LOG.info("Received: " + message); + + // receives the second message + LOG.info("About to consume message 2"); + message = consumer.receive(4000); + messages.add(message); + LOG.info("Received: " + message); + + // validates that the rollbacked was not consumed + commitTx(); + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Rollback did not work.", outbound, inbound); + } + + /** + * Sends a batch of messages and validates that the message sent before + * session close is not consumed. + * + * @throws Exception + */ + public void testSendSessionAndConnectionClose() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // sends a message + beginTx(); + producer.send(outbound[0]); + commitTx(); + + // sends a message that gets rollbacked + beginTx(); + producer.send(session.createTextMessage("I'm going to get rolled back.")); + consumer.close(); + session.close(); + + reconnect(); + + // sends a message + beginTx(); + producer.send(outbound[1]); + commitTx(); + + // receives the first message + ArrayList messages = new ArrayList<>(); + LOG.info("About to consume message 1"); + beginTx(); + Message message = consumer.receive(1000); + messages.add(message); + LOG.info("Received: " + message); + + // receives the second message + LOG.info("About to consume message 2"); + message = consumer.receive(4000); + messages.add(message); + LOG.info("Received: " + message); + + // validates that the rollbacked was not consumed + commitTx(); + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Rollback did not work.", outbound, inbound); + } + + /** + * Sends a batch of messages and validates that the rollbacked message was + * redelivered. + * + * @throws Exception + */ + public void testReceiveRollback() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // lets consume any outstanding messages from prev test runs + beginTx(); + while (consumer.receive(1000) != null) { + } + commitTx(); + + // sent both messages + beginTx(); + producer.send(outbound[0]); + producer.send(outbound[1]); + commitTx(); + + LOG.info("Sent 0: " + outbound[0]); + LOG.info("Sent 1: " + outbound[1]); + + ArrayList messages = new ArrayList<>(); + beginTx(); + Message message = consumer.receive(1000); + messages.add(message); + assertEquals(outbound[0], message); + commitTx(); + + // rollback so we can get that last message again. + beginTx(); + message = consumer.receive(1000); + assertNotNull(message); + assertEquals(outbound[1], message); + rollbackTx(); + + // Consume again.. the prev message should + // get redelivered. + beginTx(); + message = consumer.receive(5000); + assertNotNull("Should have re-received the message again!", message); + messages.add(message); + commitTx(); + + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Rollback did not work", outbound, inbound); + } + + /** + * Sends a batch of messages and validates that the rollbacked message was + * redelivered. + * + * @throws Exception + */ + public void testReceiveTwoThenRollback() throws Exception { + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // lets consume any outstanding messages from prev test runs + beginTx(); + while (consumer.receive(1000) != null) { + } + commitTx(); + + // + beginTx(); + producer.send(outbound[0]); + producer.send(outbound[1]); + commitTx(); + + LOG.info("Sent 0: " + outbound[0]); + LOG.info("Sent 1: " + outbound[1]); + + ArrayList messages = new ArrayList<>(); + beginTx(); + Message message = consumer.receive(1000); + assertEquals(outbound[0], message); + + message = consumer.receive(1000); + assertNotNull(message); + assertEquals(outbound[1], message); + rollbackTx(); + + // Consume again.. the prev message should + // get redelivered. + beginTx(); + message = consumer.receive(5000); + assertNotNull("Should have re-received the first message again!", message); + messages.add(message); + assertEquals(outbound[0], message); + message = consumer.receive(5000); + assertNotNull("Should have re-received the second message again!", message); + messages.add(message); + assertEquals(outbound[1], message); + + assertNull(consumer.receiveNoWait()); + commitTx(); + + Message inbound[] = new Message[messages.size()]; + messages.toArray(inbound); + assertTextMessagesEqual("Rollback did not work", outbound, inbound); + } + + /** + * Sends a batch of messages and validates that the rollbacked message was + * not consumed. + * + * @throws Exception + */ + public void testSendReceiveWithPrefetchOne() throws Exception { + setPrefetchToOne(); + Message[] outbound = new Message[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message"), session.createTextMessage("Fourth Message")}; + + beginTx(); + for (int i = 0; i < outbound.length; i++) { + // sends a message + producer.send(outbound[i]); + } + commitTx(); + + // receives the first message + beginTx(); + for (int i = 0; i < outbound.length; i++) { + LOG.info("About to consume message 1"); + Message message = consumer.receive(1000); + assertNotNull(message); + LOG.info("Received: " + message); + } + + // validates that the rollbacked was not consumed + commitTx(); + } + + /** + * Perform the test that validates if the rollbacked message was redelivered + * multiple times. + * + * @throws Exception + */ + public void testReceiveTwoThenRollbackManyTimes() throws Exception { + for (int i = 0; i < 5; i++) { + testReceiveTwoThenRollback(); + } + } + + /** + * Sends a batch of messages and validates that the rollbacked message was + * not consumed. This test differs by setting the message prefetch to one. + * + * @throws Exception + */ + public void testSendRollbackWithPrefetchOfOne() throws Exception { + setPrefetchToOne(); + testSendRollback(); + } + + /** + * Sends a batch of messages and and validates that the rollbacked message + * was redelivered. This test differs by setting the message prefetch to + * one. + * + * @throws Exception + */ + public void testReceiveRollbackWithPrefetchOfOne() throws Exception { + setPrefetchToOne(); + testReceiveRollback(); + } + + /** + * Tests if the messages can still be received if the consumer is closed + * (session is not closed). + * + * @throws Exception see http://jira.codehaus.org/browse/AMQ-143 + */ + public void testCloseConsumerBeforeCommit() throws Exception { + TextMessage[] outbound = new TextMessage[]{session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; + + // lets consume any outstanding messages from prev test runs + beginTx(); + while (consumer.receiveNoWait() != null) { + } + + commitTx(); + + // sends the messages + beginTx(); + producer.send(outbound[0]); + producer.send(outbound[1]); + commitTx(); + LOG.info("Sent 0: " + outbound[0]); + LOG.info("Sent 1: " + outbound[1]); + + beginTx(); + TextMessage message = (TextMessage) consumer.receive(1000); + assertEquals(outbound[0].getText(), message.getText()); + // Close the consumer before the commit. This should not cause the + // received message + // to rollback. + consumer.close(); + commitTx(); + + // Create a new consumer + consumer = resourceProvider.createConsumer(session, destination); + LOG.info("Created consumer: " + consumer); + + beginTx(); + message = (TextMessage) consumer.receive(1000); + assertEquals(outbound[1].getText(), message.getText()); + commitTx(); + } + + public void testChangeMutableObjectInObjectMessageThenRollback() throws Exception { + ArrayList list = new ArrayList<>(); + list.add("First"); + Message outbound = session.createObjectMessage(list); + outbound.setStringProperty("foo", "abc"); + + beginTx(); + producer.send(outbound); + commitTx(); + + LOG.info("About to consume message 1"); + beginTx(); + Message message = consumer.receive(5000); + + List body = assertReceivedObjectMessageWithListBody(message); + + // now lets try mutate it + try { + message.setStringProperty("foo", "def"); + fail("Cannot change properties of the object!"); + } catch (JMSException e) { + LOG.info("Caught expected exception: " + e, e); + } + body.clear(); + body.add("This should never be seen!"); + rollbackTx(); + + beginTx(); + message = consumer.receive(5000); + List secondBody = assertReceivedObjectMessageWithListBody(message); + assertNotSame("Second call should return a different body", secondBody, body); + commitTx(); + } + + @SuppressWarnings("unchecked") + protected List assertReceivedObjectMessageWithListBody(Message message) throws JMSException { + assertNotNull("Should have received a message!", message); + assertEquals("foo header", "abc", message.getStringProperty("foo")); + + assertTrue("Should be an object message but was: " + message, message instanceof ObjectMessage); + ObjectMessage objectMessage = (ObjectMessage) message; + List body = (List) objectMessage.getObject(); + LOG.info("Received body: " + body); + + assertEquals("Size of list should be 1", 1, body.size()); + assertEquals("element 0 of list", "First", body.get(0)); + return body; + } + + /** + * Recreates the connection. + * + * @throws javax.jms.JMSException + */ + protected void reconnect() throws Exception { + + if (connection != null) { + // Close the prev connection. + connection.close(); + } + session = null; + connection = resourceProvider.createConnection(connectionFactory); + reconnectSession(); + connection.start(); + } + + /** + * Recreates the connection. + * + * @throws javax.jms.JMSException + */ + protected void reconnectSession() throws JMSException { + if (session != null) { + session.close(); + } + + session = resourceProvider.createSession(connection); + destination = resourceProvider.createDestination(session, getSubject()); + producer = resourceProvider.createProducer(session, destination); + consumer = resourceProvider.createConsumer(session, destination); + } + + /** + * Sets the prefeftch policy to one. + */ + protected void setPrefetchToOne() { + ActiveMQPrefetchPolicy prefetchPolicy = getPrefetchPolicy(); + prefetchPolicy.setQueuePrefetch(1); + prefetchPolicy.setTopicPrefetch(1); + prefetchPolicy.setDurableTopicPrefetch(1); + prefetchPolicy.setOptimizeDurableTopicPrefetch(1); + } + + protected ActiveMQPrefetchPolicy getPrefetchPolicy() { + return ((ActiveMQConnection) connection).getPrefetchPolicy(); + } + + //This test won't work with xa tx so no beginTx() has been added. + public void testMessageListener() throws Exception { + // send messages + for (int i = 0; i < MESSAGE_COUNT; i++) { + producer.send(session.createTextMessage(MESSAGE_TEXT + i)); + } + commitTx(); + consumer.setMessageListener(this); + // wait receive + waitReceiveUnack(); + assertEquals(unackMessages.size(), MESSAGE_COUNT); + // resend phase + waitReceiveAck(); + assertEquals(ackMessages.size(), MESSAGE_COUNT); + // should no longer re-receive + consumer.setMessageListener(null); + assertNull(consumer.receive(500)); + reconnect(); + } + + @Override + public void onMessage(Message message) { + if (!resendPhase) { + unackMessages.add(message); + if (unackMessages.size() == MESSAGE_COUNT) { + try { + rollbackTx(); + resendPhase = true; + } catch (Exception e) { + e.printStackTrace(); } - messageSent(); - commitTx(); - LOG.info("Consuming bacth " + j + " of " + batchSize + " messages"); - - beginTx(); - for (int i = 0; i < batchSize; i++) { - message = (TextMessage)consumer.receive(1000 * 5); - assertNotNull("Received only " + i + " messages in batch " + j, message); - assertEquals("Batch Message", message.getText()); + } + } else { + ackMessages.add(message); + if (ackMessages.size() == MESSAGE_COUNT) { + try { + commitTx(); + } catch (Exception e) { + e.printStackTrace(); } - - commitTx(); - } - } - - protected void messageSent() throws Exception { - } - - /** - * Sends a batch of messages and validates that the rollbacked message was - * not consumed. - * - * @throws Exception - */ - public void testSendRollback() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // sends a message - beginTx(); - producer.send(outbound[0]); - commitTx(); - - // sends a message that gets rollbacked - beginTx(); - producer.send(session.createTextMessage("I'm going to get rolled back.")); - rollbackTx(); - - // sends a message - beginTx(); - producer.send(outbound[1]); - commitTx(); - - // receives the first message - beginTx(); - ArrayList messages = new ArrayList<>(); - LOG.info("About to consume message 1"); - Message message = consumer.receive(1000); - messages.add(message); - LOG.info("Received: " + message); - - // receives the second message - LOG.info("About to consume message 2"); - message = consumer.receive(4000); - messages.add(message); - LOG.info("Received: " + message); - - // validates that the rollbacked was not consumed - commitTx(); - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Rollback did not work.", outbound, inbound); - } - - /** - * spec section 3.6 acking a message with automation acks has no effect. - * @throws Exception - */ - public void testAckMessageInTx() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message")}; - - // sends a message - beginTx(); - producer.send(outbound[0]); - outbound[0].acknowledge(); - commitTx(); - outbound[0].acknowledge(); - - // receives the first message - beginTx(); - ArrayList messages = new ArrayList<>(); - LOG.info("About to consume message 1"); - Message message = consumer.receive(1000); - messages.add(message); - LOG.info("Received: " + message); - - // validates that the rollbacked was not consumed - commitTx(); - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Message not delivered.", outbound, inbound); - } - - /** - * Sends a batch of messages and validates that the message sent before - * session close is not consumed. - * - * This test only works with local transactions, not xa. - * @throws Exception - */ - public void testSendSessionClose() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // sends a message - beginTx(); - producer.send(outbound[0]); - commitTx(); - - // sends a message that gets rollbacked - beginTx(); - producer.send(session.createTextMessage("I'm going to get rolled back.")); - consumer.close(); - - reconnectSession(); - - // sends a message - producer.send(outbound[1]); - commitTx(); - - // receives the first message - ArrayList messages = new ArrayList<>(); - LOG.info("About to consume message 1"); - beginTx(); - Message message = consumer.receive(1000); - messages.add(message); - LOG.info("Received: " + message); - - // receives the second message - LOG.info("About to consume message 2"); - message = consumer.receive(4000); - messages.add(message); - LOG.info("Received: " + message); - - // validates that the rollbacked was not consumed - commitTx(); - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Rollback did not work.", outbound, inbound); - } - - /** - * Sends a batch of messages and validates that the message sent before - * session close is not consumed. - * - * @throws Exception - */ - public void testSendSessionAndConnectionClose() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // sends a message - beginTx(); - producer.send(outbound[0]); - commitTx(); - - // sends a message that gets rollbacked - beginTx(); - producer.send(session.createTextMessage("I'm going to get rolled back.")); - consumer.close(); - session.close(); - - reconnect(); - - // sends a message - beginTx(); - producer.send(outbound[1]); - commitTx(); - - // receives the first message - ArrayList messages = new ArrayList<>(); - LOG.info("About to consume message 1"); - beginTx(); - Message message = consumer.receive(1000); - messages.add(message); - LOG.info("Received: " + message); - - // receives the second message - LOG.info("About to consume message 2"); - message = consumer.receive(4000); - messages.add(message); - LOG.info("Received: " + message); - - // validates that the rollbacked was not consumed - commitTx(); - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Rollback did not work.", outbound, inbound); - } - - /** - * Sends a batch of messages and validates that the rollbacked message was - * redelivered. - * - * @throws Exception - */ - public void testReceiveRollback() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // lets consume any outstanding messages from prev test runs - beginTx(); - while (consumer.receive(1000) != null) { - } - commitTx(); - - // sent both messages - beginTx(); - producer.send(outbound[0]); - producer.send(outbound[1]); - commitTx(); - - LOG.info("Sent 0: " + outbound[0]); - LOG.info("Sent 1: " + outbound[1]); - - ArrayList messages = new ArrayList<>(); - beginTx(); - Message message = consumer.receive(1000); - messages.add(message); - assertEquals(outbound[0], message); - commitTx(); - - // rollback so we can get that last message again. - beginTx(); - message = consumer.receive(1000); - assertNotNull(message); - assertEquals(outbound[1], message); - rollbackTx(); - - // Consume again.. the prev message should - // get redelivered. - beginTx(); - message = consumer.receive(5000); - assertNotNull("Should have re-received the message again!", message); - messages.add(message); - commitTx(); - - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Rollback did not work", outbound, inbound); - } - - /** - * Sends a batch of messages and validates that the rollbacked message was - * redelivered. - * - * @throws Exception - */ - public void testReceiveTwoThenRollback() throws Exception { - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // lets consume any outstanding messages from prev test runs - beginTx(); - while (consumer.receive(1000) != null) { - } - commitTx(); - - // - beginTx(); - producer.send(outbound[0]); - producer.send(outbound[1]); - commitTx(); - - LOG.info("Sent 0: " + outbound[0]); - LOG.info("Sent 1: " + outbound[1]); - - ArrayList messages = new ArrayList<>(); - beginTx(); - Message message = consumer.receive(1000); - assertEquals(outbound[0], message); - - message = consumer.receive(1000); - assertNotNull(message); - assertEquals(outbound[1], message); - rollbackTx(); - - // Consume again.. the prev message should - // get redelivered. - beginTx(); - message = consumer.receive(5000); - assertNotNull("Should have re-received the first message again!", message); - messages.add(message); - assertEquals(outbound[0], message); - message = consumer.receive(5000); - assertNotNull("Should have re-received the second message again!", message); - messages.add(message); - assertEquals(outbound[1], message); - - assertNull(consumer.receiveNoWait()); - commitTx(); - - Message inbound[] = new Message[messages.size()]; - messages.toArray(inbound); - assertTextMessagesEqual("Rollback did not work", outbound, inbound); - } - - /** - * Sends a batch of messages and validates that the rollbacked message was - * not consumed. - * - * @throws Exception - */ - public void testSendReceiveWithPrefetchOne() throws Exception { - setPrefetchToOne(); - Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message"), - session.createTextMessage("Fourth Message")}; - - beginTx(); - for (int i = 0; i < outbound.length; i++) { - // sends a message - producer.send(outbound[i]); - } - commitTx(); - - // receives the first message - beginTx(); - for (int i = 0; i < outbound.length; i++) { - LOG.info("About to consume message 1"); - Message message = consumer.receive(1000); - assertNotNull(message); - LOG.info("Received: " + message); - } - - // validates that the rollbacked was not consumed - commitTx(); - } - - /** - * Perform the test that validates if the rollbacked message was redelivered - * multiple times. - * - * @throws Exception - */ - public void testReceiveTwoThenRollbackManyTimes() throws Exception { - for (int i = 0; i < 5; i++) { - testReceiveTwoThenRollback(); - } - } - - /** - * Sends a batch of messages and validates that the rollbacked message was - * not consumed. This test differs by setting the message prefetch to one. - * - * @throws Exception - */ - public void testSendRollbackWithPrefetchOfOne() throws Exception { - setPrefetchToOne(); - testSendRollback(); - } - - /** - * Sends a batch of messages and and validates that the rollbacked message - * was redelivered. This test differs by setting the message prefetch to - * one. - * - * @throws Exception - */ - public void testReceiveRollbackWithPrefetchOfOne() throws Exception { - setPrefetchToOne(); - testReceiveRollback(); - } - - /** - * Tests if the messages can still be received if the consumer is closed - * (session is not closed). - * - * @throws Exception see http://jira.codehaus.org/browse/AMQ-143 - */ - public void testCloseConsumerBeforeCommit() throws Exception { - TextMessage[] outbound = new TextMessage[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")}; - - // lets consume any outstanding messages from prev test runs - beginTx(); - while (consumer.receiveNoWait() != null) { - } - - commitTx(); - - // sends the messages - beginTx(); - producer.send(outbound[0]); - producer.send(outbound[1]); - commitTx(); - LOG.info("Sent 0: " + outbound[0]); - LOG.info("Sent 1: " + outbound[1]); - - beginTx(); - TextMessage message = (TextMessage)consumer.receive(1000); - assertEquals(outbound[0].getText(), message.getText()); - // Close the consumer before the commit. This should not cause the - // received message - // to rollback. - consumer.close(); - commitTx(); - - // Create a new consumer - consumer = resourceProvider.createConsumer(session, destination); - LOG.info("Created consumer: " + consumer); - - beginTx(); - message = (TextMessage)consumer.receive(1000); - assertEquals(outbound[1].getText(), message.getText()); - commitTx(); - } - - public void testChangeMutableObjectInObjectMessageThenRollback() throws Exception { - ArrayList list = new ArrayList<>(); - list.add("First"); - Message outbound = session.createObjectMessage(list); - outbound.setStringProperty("foo", "abc"); - - beginTx(); - producer.send(outbound); - commitTx(); - - LOG.info("About to consume message 1"); - beginTx(); - Message message = consumer.receive(5000); - - List body = assertReceivedObjectMessageWithListBody(message); - - // now lets try mutate it - try { - message.setStringProperty("foo", "def"); - fail("Cannot change properties of the object!"); - } catch (JMSException e) { - LOG.info("Caught expected exception: " + e, e); - } - body.clear(); - body.add("This should never be seen!"); - rollbackTx(); - - beginTx(); - message = consumer.receive(5000); - List secondBody = assertReceivedObjectMessageWithListBody(message); - assertNotSame("Second call should return a different body", secondBody, body); - commitTx(); - } - - @SuppressWarnings("unchecked") - protected List assertReceivedObjectMessageWithListBody(Message message) throws JMSException { - assertNotNull("Should have received a message!", message); - assertEquals("foo header", "abc", message.getStringProperty("foo")); - - assertTrue("Should be an object message but was: " + message, message instanceof ObjectMessage); - ObjectMessage objectMessage = (ObjectMessage)message; - List body = (List)objectMessage.getObject(); - LOG.info("Received body: " + body); - - assertEquals("Size of list should be 1", 1, body.size()); - assertEquals("element 0 of list", "First", body.get(0)); - return body; - } - - /** - * Recreates the connection. - * - * @throws javax.jms.JMSException - */ - protected void reconnect() throws Exception { - - if (connection != null) { - // Close the prev connection. - connection.close(); - } - session = null; - connection = resourceProvider.createConnection(connectionFactory); - reconnectSession(); - connection.start(); - } - - /** - * Recreates the connection. - * - * @throws javax.jms.JMSException - */ - protected void reconnectSession() throws JMSException { - if (session != null) { - session.close(); - } - - session = resourceProvider.createSession(connection); - destination = resourceProvider.createDestination(session, getSubject()); - producer = resourceProvider.createProducer(session, destination); - consumer = resourceProvider.createConsumer(session, destination); - } - - /** - * Sets the prefeftch policy to one. - */ - protected void setPrefetchToOne() { - ActiveMQPrefetchPolicy prefetchPolicy = getPrefetchPolicy(); - prefetchPolicy.setQueuePrefetch(1); - prefetchPolicy.setTopicPrefetch(1); - prefetchPolicy.setDurableTopicPrefetch(1); - prefetchPolicy.setOptimizeDurableTopicPrefetch(1); - } - - protected ActiveMQPrefetchPolicy getPrefetchPolicy() { - return ((ActiveMQConnection)connection).getPrefetchPolicy(); - } - - //This test won't work with xa tx so no beginTx() has been added. - public void testMessageListener() throws Exception { - // send messages - for (int i = 0; i < MESSAGE_COUNT; i++) { - producer.send(session.createTextMessage(MESSAGE_TEXT + i)); - } - commitTx(); - consumer.setMessageListener(this); - // wait receive - waitReceiveUnack(); - assertEquals(unackMessages.size(), MESSAGE_COUNT); - // resend phase - waitReceiveAck(); - assertEquals(ackMessages.size(), MESSAGE_COUNT); - // should no longer re-receive - consumer.setMessageListener(null); - assertNull(consumer.receive(500)); - reconnect(); - } - - @Override - public void onMessage(Message message) { - if (!resendPhase) { - unackMessages.add(message); - if (unackMessages.size() == MESSAGE_COUNT) { - try { - rollbackTx(); - resendPhase = true; - } catch (Exception e) { - e.printStackTrace(); - } - } - } else { - ackMessages.add(message); - if (ackMessages.size() == MESSAGE_COUNT) { - try { - commitTx(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - private void waitReceiveUnack() throws Exception { - for (int i = 0; i < 100 && !resendPhase; i++) { - Thread.sleep(100); - } - assertTrue(resendPhase); - } - - private void waitReceiveAck() throws Exception { - for (int i = 0; i < 100 && ackMessages.size() < MESSAGE_COUNT; i++) { - Thread.sleep(100); - } - assertFalse(ackMessages.size() < MESSAGE_COUNT); - } + } + } + } + + private void waitReceiveUnack() throws Exception { + for (int i = 0; i < 100 && !resendPhase; i++) { + Thread.sleep(100); + } + assertTrue(resendPhase); + } + + private void waitReceiveAck() throws Exception { + for (int i = 0; i < 100 && ackMessages.size() < MESSAGE_COUNT; i++) { + Thread.sleep(100); + } + assertFalse(ackMessages.size() < MESSAGE_COUNT); + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeMessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeMessageTestSupport.java index 889ec768ee..b20b6d527a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeMessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeMessageTestSupport.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, @@ -17,8 +17,6 @@ package org.apache.activemq; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -30,6 +28,7 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; @@ -69,8 +68,7 @@ public class LargeMessageTestSupport extends ClientTestSupport implements Messag String subject = getClass().getName(); if (isTopic) { return new ActiveMQTopic(subject); - } - else { + } else { return new ActiveMQQueue(subject); } } @@ -78,8 +76,7 @@ public class LargeMessageTestSupport extends ClientTestSupport implements Messag protected MessageConsumer createConsumer() throws JMSException { if (isTopic && isDurable) { return consumerSession.createDurableSubscriber((Topic) destination, idGen.generateId()); - } - else { + } else { return consumerSession.createConsumer(destination); } } @@ -96,8 +93,7 @@ public class LargeMessageTestSupport extends ClientTestSupport implements Messag for (int i = 0; i < LARGE_MESSAGE_SIZE; i++) { if (i % 2 == 0) { largeMessageData[i] = 'a'; - } - else { + } else { largeMessageData[i] = 'z'; } } @@ -105,8 +101,7 @@ public class LargeMessageTestSupport extends ClientTestSupport implements Messag try { // allow the broker to start Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new JMSException(e.getMessage()); } @@ -176,8 +171,7 @@ public class LargeMessageTestSupport extends ClientTestSupport implements Messag if (messageCount.get() % 50 == 0) { LOG.info("count = " + messageCount); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LoadTestBurnIn.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LoadTestBurnIn.java index bedfd478ec..3a4acfdbf0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LoadTestBurnIn.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LoadTestBurnIn.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, @@ -16,12 +16,6 @@ */ package org.apache.activemq; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -32,6 +26,11 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -71,11 +70,9 @@ public class LoadTestBurnIn extends JmsTestSupport { protected void tearDown() throws Exception { try { super.tearDown(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(System.out); - } - finally { + } finally { LOG.info("End: " + getName()); } } @@ -119,8 +116,7 @@ public class LoadTestBurnIn extends JmsTestSupport { MessageConsumer consumer; if (durableConsumer) { consumer = session.createDurableSubscriber((Topic) destination, "sub1:" + System.currentTimeMillis()); - } - else { + } else { consumer = session.createConsumer(destination); } profilerPause("Ready: "); @@ -143,11 +139,9 @@ public class LoadTestBurnIn extends JmsTestSupport { producer.send(m); } producer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); - } - finally { + } finally { safeClose(connection2); producerDoneLatch.countDown(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageEvictionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageEvictionTest.java index d95350eeba..e50c588581 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageEvictionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageEvictionTest.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, @@ -16,19 +16,6 @@ */ package org.apache.activemq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -38,6 +25,13 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.broker.BrokerService; @@ -57,6 +51,11 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class MessageEvictionTest { static final Logger LOG = LoggerFactory.getLogger(MessageEvictionTest.class); @@ -131,12 +130,10 @@ public class MessageEvictionTest { assertEquals(++advisoriesReceived, activeMQMessage.getIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT)); message.acknowledge(); advisoryIsGood.countDown(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); fail(e.toString()); - } - finally { + } finally { gotAdvisory.countDown(); } } @@ -145,8 +142,7 @@ public class MessageEvictionTest { gotAdvisory.await(120, TimeUnit.SECONDS); consumer.close(); advisorySession.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } @@ -178,12 +174,10 @@ public class MessageEvictionTest { LOG.info("acking: " + message.getJMSMessageID()); message.acknowledge(); ackDone.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.toString()); - } - finally { + } finally { consumerRegistered.countDown(); ackDone.countDown(); } @@ -192,8 +186,7 @@ public class MessageEvictionTest { consumerRegistered.countDown(); ackDone.await(60, TimeUnit.SECONDS); consumer.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } @@ -217,8 +210,7 @@ public class MessageEvictionTest { } producer.close(); sendDone.countDown(); - } - catch (Exception e) { + } catch (Exception e) { sendDone.countDown(); e.printStackTrace(); fail(e.toString()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java index 80744bd4db..363c8e07f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -32,6 +27,10 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; @@ -96,14 +95,12 @@ public class MessageListenerRedeliveryTest extends TestCase { if (counter <= 4) { LOG.info("Message Rollback."); session.rollback(); - } - else { + } else { LOG.info("Message Commit."); message.acknowledge(); session.commit(); } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("Error when rolling back transaction"); } } @@ -129,8 +126,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // first try.. should get 2 since there is no delay on the @@ -139,16 +135,14 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // 2nd redeliver (redelivery after 1 sec) assertEquals(3, listener.counter); try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // 3rd redeliver (redelivery after 2 seconds) - it should give up after // that @@ -160,16 +154,14 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // it should be committed, so no redelivery assertEquals(5, listener.counter); try { Thread.sleep(1500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // no redelivery, counter should still be 4 assertEquals(5, listener.counter); @@ -197,8 +189,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // first try @@ -206,8 +197,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // second try (redelivery after 1 sec) @@ -215,8 +205,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // third try (redelivery after 2 seconds) - it should give up after that @@ -228,8 +217,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // ignore } // it should be committed, so no redelivery @@ -237,8 +225,7 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(1500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // ignore } // no redelivery, counter should still be 4 @@ -270,8 +257,7 @@ public class MessageListenerRedeliveryTest extends TestCase { LOG.info("Message Received: " + message); try { received.add(((TextMessage) message).getText()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); fail(e.toString()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageTransformationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageTransformationTest.java index 683e3148af..22b310c9de 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageTransformationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/MessageTransformationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OnePrefetchAsyncConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OnePrefetchAsyncConsumerTest.java index 0246253d4d..5b2f7a3c13 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OnePrefetchAsyncConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OnePrefetchAsyncConsumerTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.ConnectionConsumer; import javax.jms.ConnectionFactory; @@ -31,6 +28,8 @@ import javax.jms.ServerSession; import javax.jms.ServerSessionPool; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.PolicyEntry; @@ -189,8 +188,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport { LOG.debug("About to call session.commit"); session.commit(); LOG.debug("Commit completed"); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("In start", e); } pool.serverSessionInUse = false; @@ -213,17 +211,14 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport { // computation logic in PrefetchSubscription to get here success.set(true); completed.set(true); - } - else if (text.equals("Msg2")) { + } else if (text.equals("Msg2")) { // simulate long message processing so that Msg3 comes when Msg2 is still being // processed and thus the single ServerSession is in use TimeUnit.SECONDS.sleep(4); } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("in onMessage", e); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.error("in onMessage", e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java index fb44c71626..0697e12edb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/OptimizedAckTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq; -import java.util.concurrent.TimeUnit; - import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.postoffice.Binding; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/PerDestinationStoreLimitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/PerDestinationStoreLimitTest.java index 0f70d8ffa0..02c6241a79 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/PerDestinationStoreLimitTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/PerDestinationStoreLimitTest.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, @@ -16,12 +16,6 @@ */ package org.apache.activemq; -import java.io.IOException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; - import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.MessageConsumer; @@ -29,6 +23,11 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; @@ -106,8 +105,7 @@ public class PerDestinationStoreLimitTest extends JmsTestSupport { LOG.info("committed/sent: " + sent.get()); } LOG.info("sent: " + i); - } - catch (JMSException e) { + } catch (JMSException e) { } } } @@ -135,8 +133,7 @@ public class PerDestinationStoreLimitTest extends JmsTestSupport { // force the use of the DLQ which will use some more store LOG.info("rollback on : " + received); consumerSession.rollback(); - } - else { + } else { LOG.info("commit on : " + received); consumerSession.commit(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlSendFailTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlSendFailTest.java index 4a4a07c137..06aeeee0af 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlSendFailTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlSendFailTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.ConnectionFactory; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -27,6 +24,8 @@ import javax.jms.MessageProducer; import javax.jms.ResourceAllocationException; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.PolicyEntry; @@ -94,8 +93,7 @@ public class ProducerFlowControlSendFailTest extends ProducerFlowControlTest { // will be limited by the network buffers Thread.sleep(200); } - } - catch (Exception e) { + } catch (Exception e) { // with async send, there will be no exceptions e.printStackTrace(); } @@ -137,8 +135,7 @@ public class ProducerFlowControlSendFailTest extends ProducerFlowControlTest { while (keepGoing.get()) { try { producer.send(session.createTextMessage("Test message")); - } - catch (JMSException arg0) { + } catch (JMSException arg0) { if (arg0 instanceof ResourceAllocationException) { gotResourceException.set(true); exceptionCount.incrementAndGet(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlTest.java index 0c6433e34a..721da2ce21 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ProducerFlowControlTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq; -import java.io.IOException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -28,6 +23,10 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; @@ -103,8 +102,7 @@ public class ProducerFlowControlTest extends JmsTestSupport { try { producer.send(session.createTextMessage("Test message " + ++i)); LOG.info("sent: " + i); - } - catch (JMSException e) { + } catch (JMSException e) { } } } @@ -151,8 +149,7 @@ public class ProducerFlowControlTest extends JmsTestSupport { try { producer.send(session.createTextMessage("Test message " + ++i)); LOG.info("sent: " + i); - } - catch (JMSException e) { + } catch (JMSException e) { } } } @@ -270,10 +267,8 @@ public class ProducerFlowControlTest extends JmsTestSupport { done.set(false); producer.send(session.createTextMessage("Hello World")); } - } - catch (JMSException e) { - } - finally { + } catch (JMSException e) { + } finally { safeClose(session); } } @@ -306,10 +301,8 @@ public class ProducerFlowControlTest extends JmsTestSupport { producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); producer.send(session.createTextMessage(message)); done.countDown(); - } - catch (JMSException e) { - } - finally { + } catch (JMSException e) { + } finally { safeClose(session); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java index 8d7da366d5..75fa6cabb0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.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, @@ -89,8 +89,7 @@ public class QueueConsumerPriorityTest extends TestCase { } assertNull(lowConsumer.receive(2000)); - } - finally { + } finally { conn.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java index d737f2c63e..0a2d52bfd4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq; -import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.InvalidClientIDException; import javax.jms.JMSException; import javax.jms.Session; +import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.Test; @@ -73,11 +73,9 @@ public class ReconnectWithSameClientIDTest extends EmbeddedBrokerTestSupport { try { useConnection(connection2); fail("Should have thrown InvalidClientIDException on attempt" + i); - } - catch (InvalidClientIDException e) { + } catch (InvalidClientIDException e) { LOG.info("Caught expected: " + e); - } - finally { + } finally { connection2.close(); } } @@ -87,8 +85,7 @@ public class ReconnectWithSameClientIDTest extends EmbeddedBrokerTestSupport { connection.close(); connection = connectionFactory.createConnection(); useConnection(connection); - } - finally { + } finally { log4jLogger.removeAppender(appender); } assertFalse("failed on unexpected log event", failed.get()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java index ea042bf279..4c9e0acf8a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -29,6 +25,9 @@ import javax.jms.ServerSession; import javax.jms.ServerSessionPool; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; @@ -415,8 +414,7 @@ public class RedeliveryPolicyTest extends JmsTestSupport { if (i <= maxRedeliveries) { assertEquals("1st", m.getText()); assertEquals(i, m.getRedeliveryCounter()); - } - else { + } else { assertNull("null on exceeding redelivery count", m); } connection.close(); @@ -473,8 +471,7 @@ public class RedeliveryPolicyTest extends JmsTestSupport { assertEquals(receivedCount.get(), m.getRedeliveryCounter()); receivedCount.incrementAndGet(); done.countDown(); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } @@ -482,8 +479,7 @@ public class RedeliveryPolicyTest extends JmsTestSupport { if (i <= maxRedeliveries) { assertTrue("listener done", done.await(5, TimeUnit.SECONDS)); - } - else { + } else { // final redlivery gets poisoned before dispatch assertFalse("listener done", done.await(1, TimeUnit.SECONDS)); } @@ -540,28 +536,27 @@ public class RedeliveryPolicyTest extends JmsTestSupport { assertEquals(receivedCount.get(), m.getRedeliveryCounter()); receivedCount.incrementAndGet(); done.countDown(); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } }); connection.createConnectionConsumer(destination, null, new ServerSessionPool() { - @Override - public ServerSession getServerSession() throws JMSException { - return new ServerSession() { - @Override - public Session getSession() throws JMSException { - return session; - } + @Override + public ServerSession getServerSession() throws JMSException { + return new ServerSession() { + @Override + public Session getSession() throws JMSException { + return session; + } - @Override - public void start() throws JMSException { - } - }; - } - }, 100, false); + @Override + public void start() throws JMSException { + } + }; + } + }, 100, false); Wait.waitFor(new Wait.Condition() { @Override @@ -573,8 +568,7 @@ public class RedeliveryPolicyTest extends JmsTestSupport { if (i <= maxRedeliveries) { assertTrue("listener done @" + i, done.await(5, TimeUnit.SECONDS)); - } - else { + } else { // final redlivery gets poisoned before dispatch assertFalse("listener not done @" + i, done.await(1, TimeUnit.SECONDS)); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java index ff1c6c67d7..9b120dbb83 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.net.URI; -import java.util.Iterator; -import java.util.Set; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -33,6 +24,9 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.net.URI; +import java.util.Iterator; +import java.util.Set; import org.apache.activemq.advisory.DestinationSource; import org.apache.activemq.artemis.api.core.SimpleString; @@ -46,6 +40,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class RemoveDestinationTest { private static final String TCP_BROKER_URL = "tcp://localhost:61616?create=false"; @@ -130,8 +129,7 @@ public class RemoveDestinationTest { try { amqConnection.destroyDestination((ActiveMQDestination) topic); fail("expect exception on destroy if comsumer present"); - } - catch (JMSException expected) { + } catch (JMSException expected) { assertTrue(expected.getMessage().indexOf(amqTopic.getTopicName()) != -1); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java index bea4d4ec14..67ec96c8a3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TestSupport.java index 9ab35dc620..2c55c8f788 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TestSupport.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq; -import java.io.File; -import java.io.IOException; -import java.util.Map; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.TextMessage; +import java.io.File; +import java.io.IOException; +import java.util.Map; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.DestinationStatistics; @@ -55,8 +54,7 @@ public abstract class TestSupport extends CombinationTestSupport { protected Destination createDestination(String subject) { if (topic) { return new ActiveMQTopic(subject); - } - else { + } else { return new ActiveMQQueue(subject); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java index d4234422be..67267ac5b2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.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, @@ -39,6 +39,7 @@ public class TimeStampTest extends TestCase { public void setUp() throws Exception { BrokerService.disableWrapper = true; } + @Override public void tearDown() { ArtemisBrokerHelper.stopArtemisBroker(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java index a0bcced65e..9b1e09d71e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.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, @@ -16,12 +16,8 @@ */ package org.apache.activemq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.TransactionRolledBackException; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.transaction.Synchronization; import org.apache.activemq.transport.tcp.TcpTransportFactory; @@ -29,6 +25,9 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + public class TransactionContextTest { TransactionContext underTest; @@ -40,8 +39,7 @@ public class TransactionContextTest { try { connection = factory.createActiveMQConnection(); underTest = new TransactionContext(connection); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; } @@ -102,8 +100,7 @@ public class TransactionContextTest { try { underTest.commit(); fail("exepcted rollback exception"); - } - catch (TransactionRolledBackException expected) { + } catch (TransactionRolledBackException expected) { } assertEquals("beforeEnd A called once", 1, beforeEndCountA.get()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java index c171e4b07d..6c829167f0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.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, @@ -58,8 +58,7 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport { try { consumer.setMessageListener(listener); fail("Should have thrown JMSException as we cannot use MessageListener with zero prefetch"); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Received expected exception : " + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java index 5889689f58..4f6c066eeb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.advisory; -import java.util.ArrayList; -import java.util.List; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -30,6 +27,8 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.Topic; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java index d399eb22a9..0dc8b6d173 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ConsumerListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ConsumerListenerTest.java index feb9bc8129..20ec2d9d63 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ConsumerListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ConsumerListenerTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.advisory; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -27,6 +23,9 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.slf4j.Logger; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java index 1f00df77f2..5c968f573f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/DestinationListenerTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.advisory; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.jms.Session; -import javax.jms.MessageProducer; -import javax.jms.TextMessage; - import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.BrokerService; @@ -34,7 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.isIn; /** * @@ -98,8 +97,7 @@ public class DestinationListenerTest extends EmbeddedBrokerTestSupport implement if (event.isAddOperation()) { LOG.info("Added: " + destination); newDestinations.add(destination); - } - else { + } else { LOG.info("Removed: " + destination); newDestinations.remove(destination); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java index 3f443e6559..720282945e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.advisory; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.slf4j.Logger; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestDeleteTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestDeleteTest.java index 958acd5818..b10f3cb0bd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestDeleteTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestDeleteTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.advisory; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -28,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.Topic; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.region.RegionBroker; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestLoadTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestLoadTest.java index 19e5edf0d2..f3ead0bcca 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestLoadTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempDestLoadTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java index 04be79aaac..2b93b8b58d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.advisory; -import java.util.Vector; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -27,6 +25,7 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TemporaryQueue; +import java.util.Vector; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.region.RegionBroker; @@ -65,8 +64,7 @@ public class TempQueueMemoryTest extends EmbeddedBrokerTestSupport { serverSession.commit(); } producer.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -103,13 +101,11 @@ public class TempQueueMemoryTest extends EmbeddedBrokerTestSupport { consumer.close(); if (deleteTempQueue) { replyTo.delete(); - } - else { + } else { // temp queue will be cleaned up on clientConnection.close } } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/BlobTransferPolicyUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/BlobTransferPolicyUriTest.java index 940d03ac9c..21fac1dd86 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/BlobTransferPolicyUriTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/BlobTransferPolicyUriTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java index 43e463945c..87679fae02 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.blob; +import javax.jms.JMSException; import java.io.File; import java.io.FileWriter; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import javax.jms.JMSException; - import org.apache.activemq.command.ActiveMQBlobMessage; public class FTPBlobDownloadStrategyTest extends FTPTestSupport { @@ -64,8 +63,7 @@ public class FTPBlobDownloadStrategyTest extends FTPTestSupport { strategy.deleteFile(message); assertFalse(uploadFile.exists()); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); assertTrue(false); } @@ -77,12 +75,10 @@ public class FTPBlobDownloadStrategyTest extends FTPTestSupport { try { message.setURL(new URL("ftp://" + userNamePass + "_wrong:" + userNamePass + "@localhost:" + ftpPort + "/ftptest/")); strategy.getInputStream(message); - } - catch (JMSException e) { + } catch (JMSException e) { assertEquals("Wrong Exception", "Cant Authentificate to FTP-Server", e.getMessage()); return; - } - catch (Exception e) { + } catch (Exception e) { System.out.println(e); assertTrue("Wrong Exception " + e, false); return; @@ -97,12 +93,10 @@ public class FTPBlobDownloadStrategyTest extends FTPTestSupport { try { message.setURL(new URL("ftp://" + userNamePass + ":" + userNamePass + "@localhost:" + 422 + "/ftptest/")); strategy.getInputStream(message); - } - catch (JMSException e) { + } catch (JMSException e) { assertEquals("Wrong Exception", "Problem connecting the FTP-server", e.getMessage()); return; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); assertTrue("Wrong Exception " + e, false); return; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java index 57387fb052..20958f14ef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.blob; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.InputStream; - import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.InputStream; import org.apache.activemq.ActiveMQSession; import org.apache.activemq.BlobMessage; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java index b8238c7612..29306c654e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.blob; +import javax.jms.JMSException; +import javax.jms.Session; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; -import javax.jms.JMSException; -import javax.jms.Session; - import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQSession; import org.apache.activemq.command.ActiveMQBlobMessage; @@ -64,8 +63,7 @@ public class FTPBlobUploadStrategyTest extends FTPTestSupport { message.setJMSMessageID("testmessage"); try { message.onSend(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); return; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPTestSupport.java index 0793b043ee..84c59a3cdf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FTPTestSupport.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.blob; +import javax.jms.Connection; import java.io.File; import java.util.ArrayList; import java.util.List; -import javax.jms.Connection; - import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.util.IOHelper; import org.apache.ftpserver.FtpServer; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java index 51949bbbb4..7f0a769976 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.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, @@ -16,16 +16,15 @@ */ package org.apache.activemq.blob; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.InputStream; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.InputStream; import org.apache.activemq.ActiveMQSession; import org.apache.activemq.BlobMessage; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java index ddb46c89e8..0326596943 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.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, @@ -121,18 +121,15 @@ public class BrokerBenchmark extends BrokerTestSupport { if (msg != null) { connection.send(createAck(consumerInfo, msg, counter, MessageAck.STANDARD_ACK_TYPE)); - } - else if (receiveCounter.get() < consumeCount) { + } else if (receiveCounter.get() < consumeCount) { LOG.info("Consumer stall, waiting for message #" + receiveCounter.get() + 1); } } connection.send(closeConsumerInfo(consumerInfo)); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); - } - finally { + } finally { consumersFinished.release(); } } @@ -167,11 +164,9 @@ public class BrokerBenchmark extends BrokerTestSupport { connection.send(message); printer.increment(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); - } - finally { + } finally { producersFinished.release(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java index a34fc9043b..8b2692d176 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.broker; -import java.util.concurrent.TimeUnit; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -92,8 +92,7 @@ public class BrokerRedeliveryTest extends org.apache.activemq.TestSupport { assertNotNull("Got message from dql", dlqMessage); assertEquals("message matches", message.getStringProperty("data"), dlqMessage.getStringProperty("data")); consumerSession.commit(); - } - else { + } else { // consume/commit ok message = consumer.receive(3000); assertNotNull("got message", message); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRestartTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRestartTestSupport.java index be5720c811..c09b3e7036 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRestartTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRestartTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerServiceTest.java index 2611c411e4..5a22421bfd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerServiceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerServiceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java index dbe90e745d..861e360e03 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.broker; +import javax.jms.DeliveryMode; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.jms.DeliveryMode; - import junit.framework.Test; import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java index e79d51163a..d7e0ef3051 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTestSupport.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.broker; +import javax.jms.DeliveryMode; +import javax.jms.MessageNotWriteableException; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; @@ -25,9 +27,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.TimeUnit; -import javax.jms.DeliveryMode; -import javax.jms.MessageNotWriteableException; - import org.apache.activemq.CombinationTestSupport; import org.apache.activemq.broker.region.RegionBroker; import org.apache.activemq.broker.region.policy.FixedCountSubscriptionRecoveryPolicy; @@ -147,8 +146,7 @@ public class BrokerTestSupport extends CombinationTestSupport { message.setPersistent(false); try { message.setText("Test Message Payload."); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } return message; } @@ -261,12 +259,10 @@ public class BrokerTestSupport extends CombinationTestSupport { if (md.getMessage() != null) { i++; connection.send(createAck(consumerInfo, md.getMessage(), 1, MessageAck.STANDARD_ACK_TYPE)); - } - else { + } else { break; } - } - else { + } else { skipped.add(m); } m = connection.getDispatchQueue().poll(maxWait, TimeUnit.MILLISECONDS); @@ -296,8 +292,7 @@ public class BrokerTestSupport extends CombinationTestSupport { DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType); connection.send(info); return info.getDestination(); - } - else { + } else { return ActiveMQDestination.createDestination(queueName, destinationType); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ConcurrentConnectSimulationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ConcurrentConnectSimulationTest.java index 1f83947268..b52d37b579 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ConcurrentConnectSimulationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ConcurrentConnectSimulationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java index c5fc22a38f..85dd17ebbb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/CreateDestinationsOnStartupViaXBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DedicatedTaskRunnerBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DedicatedTaskRunnerBrokerTest.java index 5a71517b42..156339ffe1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DedicatedTaskRunnerBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DedicatedTaskRunnerBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DoubleSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DoubleSubscriptionTest.java index 1f8d1ae1cb..b0bafe95a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DoubleSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DoubleSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DurablePersistentFalseRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DurablePersistentFalseRestartTest.java index 1d1c7cf40e..3cec506066 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DurablePersistentFalseRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/DurablePersistentFalseRestartTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/JdbcXARecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/JdbcXARecoveryBrokerTest.java index 30650349a2..467519ff24 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/JdbcXARecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/JdbcXARecoveryBrokerTest.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, @@ -69,8 +69,7 @@ public class JdbcXARecoveryBrokerTest extends XARecoveryBrokerTest { try { ds.setShutdownDatabase("shutdown"); ds.getConnection(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/Main.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/Main.java index 4fa4174477..d5bfc39bd3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/Main.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/Main.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, @@ -73,13 +73,11 @@ public final class Main { session.createConsumer(new ActiveMQQueue("Orders.MSFT"), "price > 100"); Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); session2.createConsumer(new ActiveMQQueue("Orders.MSFT"), "price > 200"); - } - else { + } else { // Lets wait for the broker broker.waitUntilStopped(); } - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Failed: " + e); e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MarshallingBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MarshallingBrokerTest.java index 0733e39d10..52ba940536 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MarshallingBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MarshallingBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java index f4f1b0e80b..6d5ef5c54f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MessageExpirationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/MessageExpirationTest.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, @@ -116,8 +116,7 @@ public class MessageExpirationTest extends BrokerTestSupport { connection.send(m2); connection.send(m3); connection.send(m4); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/NioQueueSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/NioQueueSubscriptionTest.java index 3d0f54aee8..e905774a97 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/NioQueueSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/NioQueueSubscriptionTest.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, @@ -16,17 +16,6 @@ */ package org.apache.activemq.broker; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.region.policy.PolicyEntry; -import org.apache.activemq.broker.region.policy.PolicyMap; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.ConnectionFactory; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -41,6 +30,17 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -93,8 +93,7 @@ public class NioQueueSubscriptionTest extends QueueSubscriptionTest { connection.start(); assertNotNull(connection.getBrokerName()); connections.add(connection); - } - catch (Exception e) { + } catch (Exception e) { LOG.error(">>>> Exception in run() on thread " + innerId, e); exceptions.put(Thread.currentThread(), e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java index f644d2ce24..fa9d09e37f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ProgressPrinter.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ProgressPrinter.java index 361f2a1f77..0d799f71f8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ProgressPrinter.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ProgressPrinter.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java index 5e2839c956..711409b272 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.broker; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import javax.jms.MessageProducer; import javax.jms.Session; import javax.management.ObjectName; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.apache.activemq.TestSupport; import org.apache.activemq.command.ActiveMQQueue; @@ -121,4 +120,4 @@ public class QueueMbeanRestartTest extends TestSupport { broker.setDeleteAllMessagesOnStartup(deleteAll); broker.start(); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueSubscriptionTest.java index c1fed67b96..ac282f886b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/QueueSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ReconnectWithJMXEnabledTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ReconnectWithJMXEnabledTest.java index bd04635fce..7bcfe913d3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ReconnectWithJMXEnabledTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ReconnectWithJMXEnabledTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RecoveryBrokerTest.java index da79961dee..9c6aa1fc9b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RecoveryBrokerTest.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, @@ -16,9 +16,8 @@ */ package org.apache.activemq.broker; -import java.util.ArrayList; - import javax.jms.DeliveryMode; +import java.util.ArrayList; import junit.framework.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartTest.java index 51af6011cf..302f9f2e5f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartTest.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, @@ -16,7 +16,6 @@ */ package org.apache.activemq.broker; -import java.util.Arrays; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; @@ -25,6 +24,7 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.TopicSubscriber; +import java.util.Arrays; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java index d977107d3b..9e653ee9f8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.broker; -import java.io.File; -import java.io.IOException; -import java.util.Set; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -27,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.io.File; +import java.io.IOException; +import java.util.Set; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -111,8 +111,7 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { assertTrue("Should not receive the 5th message", i < 4); //The first 4 messages will be ok but the 5th one should hit an exception in updateMessage and should not be delivered } - } - catch (Exception e) { + } catch (Exception e) { //Expecting an exception and disconnect on the 5th message LOG.info("Got expected:", e); expectedException = e; @@ -175,8 +174,7 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { assertTrue("Should not receive the 5th message", i < 4); //The first 4 messages will be ok but the 5th one should hit an exception in updateMessage and should not be delivered } - } - catch (Exception e) { + } catch (Exception e) { //Expecting an exception and disconnect on the 5th message LOG.info("Got expected:", e); expectedException = e; @@ -425,16 +423,14 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { if (numBeforeException > 0) { numBeforeException--; super.updateMessage(message); - } - else { + } else { // lets only do it once so we can validate transient store failure throwExceptionOnUpdate = false; //A message that has never been delivered will hit this exception throw new IOException("Hit our simulated exception writing the update to disk"); } - } - else { + } else { super.updateMessage(message); } } @@ -456,15 +452,13 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { if (numBeforeException > 0) { numBeforeException--; super.updateMessage(message); - } - else { + } else { //A message that has never been delivered will hit this exception throw new IOException("Hit our simulated exception writing the update to disk"); } - } - else { + } else { super.updateMessage(message); } } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/SpringTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/SpringTest.java index e7f22c667c..3ca1e3f88b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/SpringTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/SpringTest.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, @@ -17,11 +17,10 @@ package org.apache.activemq.broker; +import javax.jms.Message; import java.io.File; import java.util.List; -import javax.jms.Message; - import junit.framework.TestCase; import org.apache.activemq.spring.SpringConsumer; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubBroker.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubBroker.java index cc9627a781..0fe04fe1c7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubBroker.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubBroker.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubConnection.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubConnection.java index 4d6e59a306..ff50c45523 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubConnection.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/StubConnection.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, @@ -66,8 +66,7 @@ public class StubConnection implements Service { shuttingDown = true; } StubConnection.this.dispatch(command); - } - catch (Exception e) { + } catch (Exception e) { onException(new IOException("" + e)); } } @@ -106,8 +105,7 @@ public class StubConnection implements Service { ExceptionResponse er = (ExceptionResponse) response; throw JMSExceptionSupport.create(er.getException()); } - } - else if (transport != null) { + } else if (transport != null) { transport.oneway(command); } } @@ -125,8 +123,7 @@ public class StubConnection implements Service { throw JMSExceptionSupport.create(er.getException()); } return response; - } - else if (transport != null) { + } else if (transport != null) { Response response = (Response) transport.request(command); if (response != null && response.isException()) { ExceptionResponse er = (ExceptionResponse) response; @@ -155,8 +152,7 @@ public class StubConnection implements Service { if (transport != null) { try { transport.oneway(new ShutdownInfo()); - } - catch (IOException e) { + } catch (IOException e) { } ServiceSupport.dispose(transport); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/TopicSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/TopicSubscriptionTest.java index a90493522b..98ccbc5615 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/TopicSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/TopicSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/XARecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/XARecoveryBrokerTest.java index 3a008dce67..344dba8f91 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/XARecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/XARecoveryBrokerTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.broker; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.TimeUnit; - import javax.jms.JMSException; import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -33,7 +32,20 @@ import org.apache.activemq.broker.jmx.PersistenceAdapterViewMBean; import org.apache.activemq.broker.jmx.RecoveredXATransactionViewMBean; import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.command.ConnectionInfo; +import org.apache.activemq.command.ConsumerInfo; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.Message; +import org.apache.activemq.command.MessageAck; +import org.apache.activemq.command.ProducerInfo; +import org.apache.activemq.command.Response; +import org.apache.activemq.command.SessionInfo; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.command.TransactionInfo; +import org.apache.activemq.command.XATransactionId; import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; import org.apache.activemq.util.JMXSupport; import org.slf4j.Logger; @@ -114,8 +126,7 @@ public class XARecoveryBrokerTest extends BrokerRestartTestSupport { if (i % 2 == 0) { mbean.heuristicCommit(); commitCount++; - } - else { + } else { mbean.heuristicRollback(); } } @@ -134,8 +145,7 @@ public class XARecoveryBrokerTest extends BrokerRestartTestSupport { RecoveredXATransactionViewMBean gone = getProxyToPreparedTransactionViewMBean(first); gone.heuristicRollback(); fail("Excepted not found"); - } - catch (InstanceNotFoundException expectedNotfound) { + } catch (InstanceNotFoundException expectedNotfound) { } } @@ -251,12 +261,10 @@ public class XARecoveryBrokerTest extends BrokerRestartTestSupport { DestinationViewMBean destinationView = getProxyToDestination(new ActiveMQQueue(SharedDeadLetterStrategy.DEFAULT_DEAD_LETTER_QUEUE_NAME)); assertEquals("nothing on dlq", 0, destinationView.getQueueSize()); assertEquals("nothing added to dlq", 0, destinationView.getEnqueueCount()); - } - catch (java.lang.reflect.UndeclaredThrowableException maybeOk) { + } catch (java.lang.reflect.UndeclaredThrowableException maybeOk) { if (maybeOk.getUndeclaredThrowable() instanceof javax.management.InstanceNotFoundException) { // perfect no dlq - } - else { + } else { throw maybeOk; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java index b82503cd48..37b396e1e8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryDuplexNetworkBridgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryDuplexNetworkBridgeTest.java index fe214d447d..5b00d629bd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryDuplexNetworkBridgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryDuplexNetworkBridgeTest.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.broker.advisory; +import java.net.URI; + import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; -import java.net.URI; - public class AdvisoryDuplexNetworkBridgeTest extends AdvisoryNetworkBridgeTest { @Override diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java index ca73238a8b..003dfb8aff 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.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, @@ -16,14 +16,10 @@ */ package org.apache.activemq.broker.advisory; -import org.apache.activemq.EmbeddedBrokerTestSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.jmx.BrokerViewMBean; -import org.apache.activemq.broker.jmx.ManagementContext; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.command.DestinationInfo; - -import javax.jms.*; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.Session; import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; @@ -31,6 +27,13 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; +import org.apache.activemq.EmbeddedBrokerTestSupport; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.jmx.BrokerViewMBean; +import org.apache.activemq.broker.jmx.ManagementContext; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.DestinationInfo; + public class AdvisoryJmxTest extends EmbeddedBrokerTestSupport { @Override diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryNetworkBridgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryNetworkBridgeTest.java index 2e9601485f..f2b368c993 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryNetworkBridgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/advisory/AdvisoryNetworkBridgeTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.broker.advisory; +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import java.net.URI; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -25,11 +30,6 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.BrokerInfo; -import javax.jms.Connection; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import java.net.URI; - public class AdvisoryNetworkBridgeTest extends TestCase { BrokerService broker1; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java index f5c42f0a12..bfcec02e46 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.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,14 +41,12 @@ public class DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest extends DbRestartJDBC protected void delayTillRestartRequired() { if (restartDelay > 2000) { LOG.info("delay for more than lease quantum. While Db is offline, master should stay alive but could loose lease"); - } - else { + } else { LOG.info("delay for less than lease quantum. While Db is offline, master should stay alive"); } try { TimeUnit.MILLISECONDS.sleep(restartDelay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -57,8 +55,7 @@ public class DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest extends DbRestartJDBC protected void verifyExpectedBroker(int inflightMessageCount) { if (inflightMessageCount == 0 || (inflightMessageCount == failureCount + 10 && restartDelay <= 500)) { assertEquals("connected to master", master.getBrokerName(), ((ActiveMQConnection) sendConnection).getBrokerName()); - } - else { + } else { // lease expired while DB was offline, either or master/slave can grab it so assert is not deterministic // but we still need to validate sent == received } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java index e46daa305b..807b3e2149 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java index 5669ffc62c..d743d46001 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.broker.ft; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -27,6 +23,10 @@ import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TransactionRolledBackException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.broker.BrokerService; @@ -66,8 +66,7 @@ public class DbRestartJDBCQueueMasterSlaveTest extends JDBCQueueMasterSlaveTest protected void verifyExpectedBroker(int inflightMessageCount) { if (inflightMessageCount == 0) { assertEquals("connected to master", master.getBrokerName(), ((ActiveMQConnection) sendConnection).getBrokerName()); - } - else if (inflightMessageCount == failureCount + 10) { + } else if (inflightMessageCount == failureCount + 10) { assertEquals("connected to slave, count:" + inflightMessageCount, slave.get().getBrokerName(), ((ActiveMQConnection) sendConnection).getBrokerName()); } } @@ -94,13 +93,11 @@ public class DbRestartJDBCQueueMasterSlaveTest extends JDBCQueueMasterSlaveTest try { receiveSession.commit(); super.consumeMessage(message, messageList); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Failed to commit message receipt: " + message, e); try { receiveSession.rollback(); - } - catch (JMSException ignored) { + } catch (JMSException ignored) { } if (e instanceof TransactionRolledBackException) { @@ -135,19 +132,15 @@ public class DbRestartJDBCQueueMasterSlaveTest extends JDBCQueueMasterSlaveTest // message is gone, so lets count it as consumed LOG.info("On TransactionRolledBackException we know that the ack/commit got there b/c message is gone so we count it: " + mqMessage); super.consumeMessage(message, messageList); - } - else { + } else { LOG.info("On TransactionRolledBackException we know that the ack/commit was lost so we expect a replay of: " + mqMessage); } - } - catch (Exception dbe) { + } catch (Exception dbe) { dbe.printStackTrace(); - } - finally { + } finally { try { dbConnection.close(); - } - catch (SQLException e1) { + } catch (SQLException e1) { e1.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueTest.java index f1720749c0..2d21fa198a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.ft; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.ExceptionListener; @@ -25,6 +23,8 @@ import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.JmsTopicSendReceiveWithTwoConnectionsTest; @@ -87,8 +87,7 @@ public class DbRestartJDBCQueueTest extends JmsTopicSendReceiveWithTwoConnection protected Session createSendSession(Connection sendConnection) throws Exception { if (transactedSends) { return sendConnection.createSession(true, Session.SESSION_TRANSACTED); - } - else { + } else { return sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); } } @@ -108,8 +107,7 @@ public class DbRestartJDBCQueueTest extends JmsTopicSendReceiveWithTwoConnection ds.setShutdownDatabase("shutdown"); try { ds.getConnection(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } LOG.info("DB STOPPED!@!!!!"); @@ -119,8 +117,7 @@ public class DbRestartJDBCQueueTest extends JmsTopicSendReceiveWithTwoConnection LOG.info("Sleeping for 10 seconds before allowing db restart"); try { restartDBLatch.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } ds.setShutdownDatabase("false"); @@ -149,13 +146,11 @@ public class DbRestartJDBCQueueTest extends JmsTopicSendReceiveWithTwoConnection } sent = true; - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception on producer send:", e); try { Thread.sleep(2000); - } - catch (InterruptedException ignored) { + } catch (InterruptedException ignored) { } } } while (!sent); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/JDBCQueueMasterSlaveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/JDBCQueueMasterSlaveTest.java index b85b0073bd..9faf3af2a3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/JDBCQueueMasterSlaveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/JDBCQueueMasterSlaveTest.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, @@ -16,9 +16,9 @@ */ package org.apache.activemq.broker.ft; +import javax.sql.DataSource; import java.io.IOException; import java.net.URI; -import javax.sql.DataSource; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; @@ -90,10 +90,8 @@ public class JDBCQueueMasterSlaveTest extends QueueMasterSlaveTestSupport { broker.start(); slave.set(broker); slaveStarted.countDown(); - } - catch (IllegalStateException expectedOnShutdown) { - } - catch (Exception e) { + } catch (IllegalStateException expectedOnShutdown) { + } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java index 355fd5290b..c318687647 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveSingleUrlTest.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, @@ -73,8 +73,7 @@ public class QueueMasterSlaveSingleUrlTest extends QueueMasterSlaveTestSupport { broker.start(); slave.set(broker); slaveStarted.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestSupport.java index c7d571a096..9f8ab5c327 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestSupport.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.broker.ft; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.TextMessage; import java.io.File; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.TextMessage; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.JmsTopicSendReceiveWithTwoConnectionsTest; import org.apache.activemq.advisory.AdvisorySupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestUsingSharedFileTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestUsingSharedFileTest.java index 93377f0caa..5d204aa022 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestUsingSharedFileTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/QueueMasterSlaveTestUsingSharedFileTest.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,8 +36,7 @@ public class QueueMasterSlaveTestUsingSharedFileTest extends QueueMasterSlaveTes public void run() { try { QueueMasterSlaveTestUsingSharedFileTest.super.createSlave(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/SyncCreateDataSource.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/SyncCreateDataSource.java index c565b497db..c795f8e058 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/SyncCreateDataSource.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/SyncCreateDataSource.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq.broker.ft; +import javax.sql.DataSource; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; -import javax.sql.DataSource; import org.apache.derby.jdbc.EmbeddedDataSource; @@ -86,4 +86,4 @@ public class SyncCreateDataSource implements DataSource { public Logger getParentLogger() throws SQLFeatureNotSupportedException { return null; } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/kahaDbJdbcLeaseQueueMasterSlaveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/kahaDbJdbcLeaseQueueMasterSlaveTest.java index 65de05ee81..9a684b6bc4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/kahaDbJdbcLeaseQueueMasterSlaveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/kahaDbJdbcLeaseQueueMasterSlaveTest.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, @@ -16,9 +16,9 @@ */ package org.apache.activemq.broker.ft; +import javax.sql.DataSource; import java.io.IOException; import java.net.URI; -import javax.sql.DataSource; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; @@ -94,10 +94,8 @@ public class kahaDbJdbcLeaseQueueMasterSlaveTest extends QueueMasterSlaveTestSup broker.start(); slave.set(broker); slaveStarted.countDown(); - } - catch (IllegalStateException expectedOnShutdown) { - } - catch (Exception e) { + } catch (IllegalStateException expectedOnShutdown) { + } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/mKahaDbQueueMasterSlaveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/mKahaDbQueueMasterSlaveTest.java index cbde640024..222e8e3b88 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/mKahaDbQueueMasterSlaveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/ft/mKahaDbQueueMasterSlaveTest.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,10 +83,8 @@ public class mKahaDbQueueMasterSlaveTest extends QueueMasterSlaveTestSupport { broker.start(); slave.set(broker); slaveStarted.countDown(); - } - catch (IllegalStateException expectedOnShutdown) { - } - catch (Exception e) { + } catch (IllegalStateException expectedOnShutdown) { + } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mKahaDBXARecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mKahaDBXARecoveryBrokerTest.java index a34759a8b0..87f7b74354 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mKahaDBXARecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mKahaDBXARecoveryBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mLevelDBXARecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mLevelDBXARecoveryBrokerTest.java index bdaaeb3be6..e34baa0983 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mLevelDBXARecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/mLevelDBXARecoveryBrokerTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.broker; +import java.util.LinkedList; +import java.util.List; + import junit.framework.Test; import org.apache.activemq.command.ActiveMQDestination; @@ -24,9 +27,6 @@ import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter; import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter; import org.apache.activemq.store.leveldb.LevelDBPersistenceAdapter; -import java.util.LinkedList; -import java.util.List; - public class mLevelDBXARecoveryBrokerTest extends XARecoveryBrokerTest { @Override diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/message/security/MessageAuthenticationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/message/security/MessageAuthenticationTest.java index 82ca73199e..4474867bb6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/message/security/MessageAuthenticationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/message/security/MessageAuthenticationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,22 +16,21 @@ */ package org.apache.activemq.broker.message.security; -import java.io.IOException; - import javax.jms.Connection; -import javax.jms.Session; import javax.jms.Destination; +import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; +import javax.jms.Session; import javax.jms.TextMessage; -import javax.jms.JMSException; +import java.io.IOException; +import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; -import org.apache.activemq.command.Message; import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.Message; import org.apache.activemq.security.MessageAuthorizationPolicy; -import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.spring.ConsumerBean; /** @@ -88,8 +86,7 @@ public class MessageAuthenticationTest extends EmbeddedBrokerTestSupport { try { Object value = message.getProperty("myHeader"); return "abc".equals(value); - } - catch (IOException e) { + } catch (IOException e) { System.out.println("Caught: " + e); e.printStackTrace(); return false; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/partition/SpringPartitionBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/partition/SpringPartitionBrokerTest.java index 382db21b7c..f419967884 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/partition/SpringPartitionBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/partition/SpringPartitionBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer0Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer0Test.java index 38e74232ab..067fb6e690 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer0Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer0Test.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, @@ -16,15 +16,11 @@ */ package org.apache.activemq.broker.policy; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.concurrent.TimeUnit; - import javax.jms.ConnectionFactory; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -38,6 +34,9 @@ import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + @RunWith(value = Parameterized.class) public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test { @@ -114,8 +113,7 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test { try { consumer.receive(5000); fail("Slow consumer not aborted."); - } - catch (Exception ex) { + } catch (Exception ex) { } } @@ -144,8 +142,7 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test { try { consumer.receive(5000); fail("Idle consumer not aborted."); - } - catch (Exception ex) { + } catch (Exception ex) { } } @@ -174,8 +171,7 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test { try { consumer.receive(5000); fail("Idle consumer not aborted."); - } - catch (Exception ex) { + } catch (Exception ex) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer1Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer1Test.java index d6ee00c4da..fd1558be23 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer1Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer1Test.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer2Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer2Test.java index ea7714f64c..1f896ec70c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer2Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowAckConsumer2Test.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer0Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer0Test.java index 59245382ae..9efc5da508 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer0Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer0Test.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.broker.policy; -import java.lang.reflect.UndeclaredThrowableException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -30,6 +25,11 @@ import javax.management.InstanceNotFoundException; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; import javax.management.openmbean.TabularData; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQMessageConsumer; @@ -49,7 +49,10 @@ import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; @RunWith(value = Parameterized.class) public class AbortSlowConsumer0Test extends AbortSlowConsumerBase { @@ -124,8 +127,7 @@ public class AbortSlowConsumer0Test extends AbortSlowConsumerBase { try { abortPolicy.getSlowConsumers(); fail("expect not found post destination removal"); - } - catch (UndeclaredThrowableException expected) { + } catch (UndeclaredThrowableException expected) { assertTrue("correct exception: " + expected.getCause(), expected.getCause() instanceof InstanceNotFoundException); } } @@ -222,8 +224,7 @@ public class AbortSlowConsumer0Test extends AbortSlowConsumerBase { boolean closed = false; try { messageconsumer.receive(400); - } - catch (javax.jms.IllegalStateException expected) { + } catch (javax.jms.IllegalStateException expected) { closed = expected.toString().contains("closed"); } return closed; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer1Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer1Test.java index 90d6d85770..d27408cada 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer1Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer1Test.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.broker.policy; -import org.apache.activemq.util.MessageIdList; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.Session; @@ -31,6 +24,13 @@ import java.util.Collection; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; +import org.apache.activemq.util.MessageIdList; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertTrue; @RunWith(value = Parameterized.class) diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer2Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer2Test.java index b664122e0a..4a6e4dbf1f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer2Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumer2Test.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.broker.policy; +import javax.jms.Connection; +import javax.jms.MessageConsumer; import java.util.Arrays; import java.util.Collection; import java.util.Map.Entry; -import javax.jms.Connection; -import javax.jms.MessageConsumer; import org.apache.activemq.util.MessageIdList; import org.junit.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerBase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerBase.java index 32adb255b1..a12868d478 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerBase.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerBase.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.broker.policy; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.JmsMultipleClientsTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy; @@ -25,11 +30,6 @@ import org.junit.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import java.util.ArrayList; -import java.util.List; - public class AbortSlowConsumerBase extends JmsMultipleClientsTestSupport implements ExceptionListener { private static final Logger LOG = LoggerFactory.getLogger(AbortSlowConsumerBase.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTest.java index 148a0dba72..665026c251 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTestSupport.java index e636d35e28..4a85a0f12a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterTestSupport.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, @@ -109,8 +109,7 @@ public abstract class DeadLetterTestSupport extends TestSupport { LOG.info("Consuming from: " + destination); if (durableSubscriber) { consumer = session.createDurableSubscriber((Topic) destination, destination.toString()); - } - else { + } else { consumer = session.createConsumer(destination); } } @@ -200,8 +199,7 @@ public abstract class DeadLetterTestSupport extends TestSupport { private void validateConsumerPrefetch(String destination, long expectedCount) { try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker(); for (org.apache.activemq.broker.region.Destination dest : regionBroker.getQueueRegion().getDestinationMap().values()) { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DestinationCursorConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DestinationCursorConfigTest.java index faab3acbf1..54013358e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DestinationCursorConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DestinationCursorConfigTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DiscardingDeadLetterPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DiscardingDeadLetterPolicyTest.java index d360286c0d..f28d8f0c9a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DiscardingDeadLetterPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/DiscardingDeadLetterPolicyTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java index fdb5eba4a5..b6e287a8ce 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.broker.policy; -import java.util.Enumeration; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Queue; +import java.util.Enumeration; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterViaXmlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterViaXmlTest.java index eed3e0855e..3d0c218114 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterViaXmlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterViaXmlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageGroupConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageGroupConfigTest.java index e5e815b657..0b93472153 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageGroupConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageGroupConfigTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageListenerDeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageListenerDeadLetterTest.java index 312f62e589..c7a88ddaed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageListenerDeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageListenerDeadLetterTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.broker.policy; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.Session; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -138,15 +137,13 @@ public class MessageListenerDeadLetterTest extends DeadLetterTestSupport { } session.rollback(); - } - catch (Throwable e) { + } catch (Throwable e) { LOG.error("unexpected exception:" + e, e); // propagating assertError to execution task will cause a hang // at shutdown if (e instanceof Error) { error[0] = (Error) e; - } - else { + } else { fail("unexpected exception: " + e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoConsumerDeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoConsumerDeadLetterTest.java index 8adcd93ff6..5761400b07 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoConsumerDeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoConsumerDeadLetterTest.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, @@ -108,8 +108,7 @@ public class NoConsumerDeadLetterTest extends DeadLetterTestSupport { protected Destination createDlqDestination() { if (this.topic) { return AdvisorySupport.getNoTopicConsumersAdvisoryTopic((ActiveMQDestination) getDestination()); - } - else { + } else { return AdvisorySupport.getNoQueueConsumersAdvisoryTopic((ActiveMQDestination) getDestination()); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java index 2abb21637f..f7e991db2c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java index e5c095ca8d..d44a49e968 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java index 0d318cbdbe..f0f42f86fe 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.policy; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.List; @@ -36,6 +34,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class PriorityNetworkDispatchPolicyTest { PriorityNetworkDispatchPolicy underTest = new PriorityNetworkDispatchPolicy(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/RoundRobinDispatchPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/RoundRobinDispatchPolicyTest.java index 4d123fe2dc..82743d7fd7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/RoundRobinDispatchPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/RoundRobinDispatchPolicyTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.broker.policy; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.Session; + import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.QueueSubscriptionTest; import org.apache.activemq.broker.region.policy.PolicyEntry; @@ -25,11 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.Session; - @RunWith(BlockJUnit4ClassRunner.class) public class RoundRobinDispatchPolicyTest extends QueueSubscriptionTest { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SecureDLQTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SecureDLQTest.java index 4e5f2c7b52..e7e4f4e9c4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SecureDLQTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SecureDLQTest.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, @@ -16,16 +16,25 @@ */ package org.apache.activemq.broker.policy; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.Session; + import org.apache.activemq.broker.BrokerPlugin; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.filter.DestinationMap; -import org.apache.activemq.security.*; +import org.apache.activemq.security.AuthorizationMap; +import org.apache.activemq.security.AuthorizationPlugin; +import org.apache.activemq.security.DefaultAuthorizationMap; +import org.apache.activemq.security.SimpleAuthorizationMap; +import org.apache.activemq.security.SimpleSecurityBrokerSystemTest; -import javax.jms.*; - -import static org.apache.activemq.security.SimpleSecurityBrokerSystemTest.*; +import static org.apache.activemq.security.SimpleSecurityBrokerSystemTest.ADMINS; +import static org.apache.activemq.security.SimpleSecurityBrokerSystemTest.USERS; +import static org.apache.activemq.security.SimpleSecurityBrokerSystemTest.WILDCARD; public class SecureDLQTest extends DeadLetterTestSupport { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java index 570473055e..fe183eef84 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.broker.policy; +import javax.jms.MessageConsumer; +import java.util.Iterator; + import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.QueueSubscriptionTest; import org.apache.activemq.broker.region.policy.FixedCountSubscriptionRecoveryPolicy; @@ -27,9 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; -import javax.jms.MessageConsumer; -import java.util.Iterator; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -77,8 +77,7 @@ public class SimpleDispatchPolicyTest extends QueueSubscriptionTest { if (count > 0) { if (found) { fail("No other consumers should have received any messages"); - } - else { + } else { assertEquals("Consumer should have received all messages.", messageCount, count); found = true; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java index c655a48b11..c82d94a27c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.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, @@ -16,9 +16,8 @@ */ package org.apache.activemq.broker.policy; -import java.util.Iterator; - import javax.jms.MessageConsumer; +import java.util.Iterator; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TopicSubscriptionTest; @@ -30,7 +29,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; @RunWith(BlockJUnit4ClassRunner.class) public class StrictOrderDispatchPolicyTest extends TopicSubscriptionTest { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java index 27375e5c36..6480c1e721 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.broker.region; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationRemoveRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationRemoveRestartTest.java index 38a0846e88..d4e52b453f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationRemoveRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationRemoveRestartTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java index 4eaf3a67fa..3ac79d4698 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.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, @@ -17,6 +17,8 @@ package org.apache.activemq.broker.region; +import javax.jms.InvalidSelectorException; +import javax.management.ObjectName; import java.io.IOException; import java.util.List; import java.util.Vector; @@ -24,15 +26,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.InvalidSelectorException; -import javax.management.ObjectName; - import junit.framework.TestCase; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.broker.region.SubscriptionStatistics; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTextMessage; @@ -56,11 +54,10 @@ import org.slf4j.LoggerFactory; * @see https://issues.apache.org/activemq/browse/AMQ-2020 **/ public class QueueDuplicatesFromStoreTest extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(QueueDuplicatesFromStoreTest.class); - ActiveMQQueue destination = new ActiveMQQueue("queue-" - + QueueDuplicatesFromStoreTest.class.getSimpleName()); + private static final Logger LOG = LoggerFactory.getLogger(QueueDuplicatesFromStoreTest.class); + + ActiveMQQueue destination = new ActiveMQQueue("queue-" + QueueDuplicatesFromStoreTest.class.getSimpleName()); BrokerService brokerService; final static String mesageIdRoot = "11111:22222:"; @@ -91,7 +88,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } public void testNoDuplicateAfterCacheFullAndAckedWithLargeAuditDepth() throws Exception { - doTestNoDuplicateAfterCacheFullAndAcked(1024*10); + doTestNoDuplicateAfterCacheFullAndAcked(1024 * 10); } public void testNoDuplicateAfterCacheFullAndAckedWithSmallAuditDepth() throws Exception { @@ -99,15 +96,13 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } public void doTestNoDuplicateAfterCacheFullAndAcked(final int auditDepth) throws Exception { - final PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter(); - final MessageStore queueMessageStore = - persistenceAdapter.createQueueMessageStore(destination); + final PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter(); + final MessageStore queueMessageStore = persistenceAdapter.createQueueMessageStore(destination); final ConnectionContext contextNotInTx = new ConnectionContext(); final ConsumerInfo consumerInfo = new ConsumerInfo(); final DestinationStatistics destinationStatistics = new DestinationStatistics(); consumerInfo.setExclusive(true); - final Queue queue = new Queue(brokerService, destination, - queueMessageStore, destinationStatistics, brokerService.getTaskRunnerFactory()); + final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, brokerService.getTaskRunnerFactory()); // a workaround for this issue // queue.setUseCache(false); @@ -148,19 +143,16 @@ public class QueueDuplicatesFromStoreTest extends TestCase { @Override public void add(MessageReference node) throws Exception { if (enqueueCounter.get() != node.getMessageId().getProducerSequenceId()) { - errors.add("Not in sequence at: " + enqueueCounter.get() + ", received: " - + node.getMessageId().getProducerSequenceId()); + errors.add("Not in sequence at: " + enqueueCounter.get() + ", received: " + node.getMessageId().getProducerSequenceId()); } - assertEquals("is in order", enqueueCounter.get(), node - .getMessageId().getProducerSequenceId()); + assertEquals("is in order", enqueueCounter.get(), node.getMessageId().getProducerSequenceId()); receivedLatch.countDown(); enqueueCounter.incrementAndGet(); node.decrementReferenceCount(); } @Override - public void add(ConnectionContext context, Destination destination) - throws Exception { + public void add(ConnectionContext context, Destination destination) throws Exception { } @Override @@ -266,8 +258,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public boolean matches(MessageReference node, - MessageEvaluationContext context) throws IOException { + public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException { return true; } @@ -277,13 +268,11 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public void processMessageDispatchNotification( - MessageDispatchNotification mdn) throws Exception { + public void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception { } @Override - public Response pullMessage(ConnectionContext context, - MessagePull pull) throws Exception { + public Response pullMessage(ConnectionContext context, MessagePull pull) throws Exception { return null; } @@ -293,8 +282,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public List remove(ConnectionContext context, - Destination destination) throws Exception { + public List remove(ConnectionContext context, Destination destination) throws Exception { return null; } @@ -303,9 +291,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public void setSelector(String selector) - throws InvalidSelectorException, - UnsupportedOperationException { + public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException { } @Override @@ -313,8 +299,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public boolean addRecoveredMessage(ConnectionContext context, - MessageReference message) throws Exception { + public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception { return false; } @@ -324,18 +309,16 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public void acknowledge(ConnectionContext context, MessageAck ack) - throws Exception { + public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception { } @Override - public int getCursorMemoryHighWaterMark(){ + public int getCursorMemoryHighWaterMark() { return 0; } @Override - public void setCursorMemoryHighWaterMark( - int cursorMemoryHighWaterMark) { + public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) { } @Override @@ -358,12 +341,12 @@ public class QueueDuplicatesFromStoreTest extends TestCase { } @Override - public void incrementConsumedCount(){ + public void incrementConsumedCount() { } @Override - public void resetConsumedCount(){ + public void resetConsumedCount() { } @@ -388,12 +371,9 @@ public class QueueDuplicatesFromStoreTest extends TestCase { for (int j = 0; j < ackBatchSize; j++, removeIndex++) { ackedCount.incrementAndGet(); MessageAck ack = new MessageAck(); - ack.setLastMessageId(new MessageId(mesageIdRoot - + removeIndex)); + ack.setLastMessageId(new MessageId(mesageIdRoot + removeIndex)); ack.setMessageCount(1); - queue.removeMessage(contextNotInTx, subscription, - new IndirectMessageReference( - getMessage(removeIndex)), ack); + queue.removeMessage(contextNotInTx, subscription, new IndirectMessageReference(getMessage(removeIndex)), ack); queue.wakeup(); } @@ -408,8 +388,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase { assertTrue("There are no errors: " + errors, errors.isEmpty()); assertEquals(count, enqueueCounter.get()); - assertEquals("store count is correct", count - removeIndex, - queueMessageStore.getMessageCount()); + assertEquals("store count is correct", count - removeIndex, queueMessageStore.getMessageCount()); } private Message getMessage(int i) throws Exception { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueOptimizedDispatchExceptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueOptimizedDispatchExceptionTest.java index 95e4ab88de..333ee95571 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueOptimizedDispatchExceptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueOptimizedDispatchExceptionTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.region; -import static org.junit.Assert.*; - import java.io.IOException; import org.apache.activemq.broker.BrokerService; @@ -43,6 +41,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + public class QueueOptimizedDispatchExceptionTest { private static final Logger LOG = LoggerFactory.getLogger(QueueOptimizedDispatchExceptionTest.class); @@ -233,8 +234,7 @@ public class QueueOptimizedDispatchExceptionTest { try { queue.wakeup(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Queue threw an unexpected exception: " + e.toString()); fail("Should not throw an exception."); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java index 3e1abff911..799ae715b1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.broker.region; -import java.io.File; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -30,6 +27,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import java.io.File; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.CombinationTestSupport; @@ -122,8 +121,7 @@ public class QueuePurgeTest extends CombinationTestSupport { proxy.purge(); - } - finally { + } finally { log4jLogger.setLevel(level); log4jLogger.removeAppender(appender); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueResendDuringShutdownTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueResendDuringShutdownTest.java index 3782350393..dd2c4140e5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueResendDuringShutdownTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueResendDuringShutdownTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.region; -import static org.junit.Assert.*; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -28,13 +26,15 @@ import javax.jms.Queue; import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.broker.BrokerService; - +import org.apache.activemq.command.ActiveMQQueue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.junit.*; +import static org.junit.Assert.assertEquals; /** * Confirm that the broker does not resend unacknowledged messages during a broker shutdown. @@ -122,8 +122,7 @@ public class QueueResendDuringShutdownTest { } try { testRedeliverAtBrokerShutdownAutoAckMsgListener(); - } - catch (Throwable thrown) { + } catch (Throwable thrown) { iterationFoundFailure = true; throw thrown; } @@ -215,8 +214,7 @@ public class QueueResendDuringShutdownTest { protected void closeConnection(Connection conn) { try { conn.close(); - } - catch (JMSException jmsExc) { + } catch (JMSException jmsExc) { LOG.info("failed to cleanup connection", jmsExc); } } @@ -229,8 +227,7 @@ public class QueueResendDuringShutdownTest { protected void delay(long delayMs, String desc) { try { Thread.sleep(delayMs); - } - catch (InterruptedException intExc) { + } catch (InterruptedException intExc) { LOG.warn("sleep interrupted: " + desc, intExc); } } @@ -245,8 +242,7 @@ public class QueueResendDuringShutdownTest { this.messageReceiveSync.wait(delayMs); } } - } - catch (InterruptedException intExc) { + } catch (InterruptedException intExc) { LOG.warn("sleep interrupted: wait for message to arrive"); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java index f3e6752214..d0ed8ef9c1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java @@ -6,7 +6,22 @@ * (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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -32,6 +47,8 @@ */ package org.apache.activemq.broker.region; +import javax.jms.InvalidSelectorException; +import javax.management.ObjectName; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -40,8 +57,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.InvalidSelectorException; -import javax.management.ObjectName; + +import junit.framework.TestCase; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; @@ -61,7 +78,6 @@ import org.apache.activemq.filter.MessageEvaluationContext; import org.apache.activemq.state.ProducerState; import org.apache.activemq.store.MessageStore; import org.apache.activemq.thread.TaskRunnerFactory; -import junit.framework.TestCase; public class SubscriptionAddRemoveQueueTest extends TestCase { @@ -111,8 +127,7 @@ public class SubscriptionAddRemoveQueueTest extends TestCase { msg.setDestination(destination); msg.setMessageId(new MessageId(producerIdAndIncrement + ":0:" + id.getAndIncrement())); queue.send(producerBrokerExchange, msg); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail("unexpected exception in sendMessage, ex:" + e); } @@ -126,8 +141,7 @@ public class SubscriptionAddRemoveQueueTest extends TestCase { for (Subscription sub : subs) { try { queue.removeSubscription(context, sub, 0); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail("unexpected exception in removeSubscription, ex:" + e); } @@ -177,8 +191,7 @@ public class SubscriptionAddRemoveQueueTest extends TestCase { public class SimpleImmediateDispatchSubscription implements Subscription, LockOwner { private SubscriptionStatistics subscriptionStatistics = new SubscriptionStatistics(); - List dispatched = - Collections.synchronizedList(new ArrayList()); + List dispatched = Collections.synchronizedList(new ArrayList()); @Override public long getPendingMessageSize() { @@ -186,14 +199,13 @@ public class SubscriptionAddRemoveQueueTest extends TestCase { } @Override - public void acknowledge(ConnectionContext context, MessageAck ack) - throws Exception { + public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception { } @Override public void add(MessageReference node) throws Exception { // immediate dispatch - QueueMessageReference qmr = (QueueMessageReference)node; + QueueMessageReference qmr = (QueueMessageReference) node; qmr.lock(this); dispatched.add(qmr); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java index 9c13f832e0..8ac46231c8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.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, @@ -17,6 +17,14 @@ package org.apache.activemq.broker.region; +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy; @@ -24,10 +32,6 @@ import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.broker.region.policy.UniquePropertyMessageEvictionStrategy; -import javax.jms.*; -import java.util.ArrayList; -import java.util.List; - public class UniquePropertyMessageEvictionStrategyTest extends EmbeddedBrokerTestSupport { @Override @@ -86,8 +90,7 @@ public class UniquePropertyMessageEvictionStrategyTest extends EmbeddedBrokerTes if (i == 0) { assertEquals(0, seqI); assertEquals(0, seqJ); - } - else { + } else { assertEquals(9, seqJ); assertEquals(i - 1, seqI); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorDurableTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorDurableTest.java index fc5d5e6bfe..30296899a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorDurableTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorDurableTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorQueueStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorQueueStoreTest.java index f5f3e4c553..5a0123136e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorQueueStoreTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorQueueStoreTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorSupport.java index 59dadcabef..43cfb00cc7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/CursorSupport.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, @@ -16,17 +16,6 @@ */ package org.apache.activemq.broker.region.cursors; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.CombinationTestSupport; -import org.apache.activemq.broker.BrokerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -37,6 +26,17 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.CombinationTestSupport; +import org.apache.activemq.broker.BrokerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -122,8 +122,7 @@ public abstract class CursorSupport extends CombinationTestSupport { // which will force a mix of direct and polled dispatching // using the cursor on the broker Thread.sleep(50); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } consumerList.add(msg); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java index b512657f3a..c66f45cdbd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.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 FilePendingMessageCursorTestSupport { try { underTest.hasNext(); fail("expect npe on use of iterator after release"); - } - catch (NullPointerException expected) { + } catch (NullPointerException expected) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/OrderPendingListTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/OrderPendingListTest.java index a60cf0ce21..6667cf17b0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/OrderPendingListTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/OrderPendingListTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.broker.region.cursors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; @@ -32,6 +28,10 @@ import org.apache.activemq.command.MessageId; import org.apache.activemq.util.IdGenerator; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class OrderPendingListTest { @Test @@ -303,8 +303,7 @@ public class OrderPendingListTest { public PendingNode remove(MessageReference message) { if (theList.remove(message)) { return new PendingNode(null, message); - } - else { + } else { return null; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/PrioritizedPendingListTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/PrioritizedPendingListTest.java index 4ce427d1f0..ec9b78d2a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/PrioritizedPendingListTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/PrioritizedPendingListTest.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, @@ -17,10 +17,6 @@ package org.apache.activemq.broker.region.cursors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.util.Iterator; import org.apache.activemq.broker.region.Destination; @@ -32,6 +28,10 @@ import org.apache.activemq.command.MessageId; import org.apache.activemq.util.IdGenerator; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class PrioritizedPendingListTest { @Test diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreBasedCursorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreBasedCursorTest.java index 55430ae19c..0936144dd4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreBasedCursorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreBasedCursorTest.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, @@ -21,14 +21,13 @@ package org.apache.activemq.broker.region.cursors; * */ -import java.util.Date; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Date; import junit.framework.TestCase; @@ -126,8 +125,7 @@ public class StoreBasedCursorTest extends TestCase { TextMessage message = session.createTextMessage(createMessageText(i)); producer.send(message); } - } - catch (javax.jms.ResourceAllocationException e) { + } catch (javax.jms.ResourceAllocationException e) { e.printStackTrace(); fail(e.getMessage() + " num msgs = " + i + ". percentUsage = " + broker.getSystemUsage().getMemoryUsage().getPercentUsage()); } @@ -161,4 +159,4 @@ public class StoreBasedCursorTest extends TestCase { configureBroker(memoryLimit, 10 * memoryLimit); sendMessages(DeliveryMode.NON_PERSISTENT); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorJDBCNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorJDBCNoDuplicateTest.java index 1320432ba6..f13b70436b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorJDBCNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorJDBCNoDuplicateTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorKahaDBNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorKahaDBNoDuplicateTest.java index 265e96557d..eb679e1918 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorKahaDBNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorKahaDBNoDuplicateTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorLevelDBNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorLevelDBNoDuplicateTest.java index a227bce71f..05f801ce9b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorLevelDBNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorLevelDBNoDuplicateTest.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, @@ -17,9 +17,10 @@ package org.apache.activemq.broker.region.cursors; +import java.io.File; + import org.apache.activemq.broker.BrokerService; import org.apache.activemq.leveldb.LevelDBStore; -import java.io.File; /** * @author gtully diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorMemoryNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorMemoryNoDuplicateTest.java index a22fe621be..b5c6dddf99 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorMemoryNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorMemoryNoDuplicateTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorNoDuplicateTest.java index abfb005fe4..f783ffaf58 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorNoDuplicateTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorOrderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorOrderTest.java index 58f3528877..c3dc38b828 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorOrderTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/StoreQueueCursorOrderTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupHashBucketTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupHashBucketTest.java index f51de26b23..5a5f3f8414 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupHashBucketTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupHashBucketTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupMapTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupMapTest.java index a890ea39a0..bcc21466e8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupMapTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupMapTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupTest.java index aa7501e480..a8101f7541 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/group/MessageGroupTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsCronSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsCronSchedulerTest.java index 6dd8b84b5a..f4c7d3d302 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsCronSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsCronSchedulerTest.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, @@ -16,18 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Date; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -36,12 +24,23 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Date; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ScheduledMessage; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class JmsCronSchedulerTest extends JobSchedulerTestSupport { private static final Logger LOG = LoggerFactory.getLogger(JmsCronSchedulerTest.class); @@ -67,8 +66,7 @@ public class JmsCronSchedulerTest extends JobSchedulerTestSupport { TextMessage tm = (TextMessage) message; try { LOG.info("Received [{}] count: {} ", tm.getText(), count.get()); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("Unexpected exception in onMessage", e); fail("Unexpected exception in onMessage: " + e.getMessage()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java index 25c9b6f907..ba2a60d537 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -32,6 +24,10 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ScheduledMessage; @@ -39,6 +35,9 @@ import org.apache.activemq.util.ProducerThread; import org.apache.activemq.util.Wait; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class JmsSchedulerTest extends JobSchedulerTestSupport { @Test @@ -129,8 +128,7 @@ public class JmsSchedulerTest extends JobSchedulerTestSupport { public void onMessage(Message message) { try { session.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } latch.countDown(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerBrokerShutdownTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerBrokerShutdownTest.java index d9bada00f9..85698158fa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerBrokerShutdownTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerBrokerShutdownTest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.broker.scheduler; -import java.io.File; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.Session; +import java.io.File; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.ScheduledMessage; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerJmxManagementTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerJmxManagementTests.java index b8ea674603..388aaab600 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerJmxManagementTests.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerJmxManagementTests.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, @@ -17,18 +17,12 @@ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - import javax.jms.Connection; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.management.openmbean.TabularData; +import java.util.List; import org.apache.activemq.ScheduledMessage; import org.apache.activemq.broker.jmx.JobSchedulerViewMBean; @@ -37,6 +31,11 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * Tests of the JMX JobSchedulerStore management MBean. */ diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerManagementTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerManagementTest.java index afedf7aad9..47efffa2a6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerManagementTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerManagementTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Message; @@ -32,6 +24,8 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ScheduledMessage; import org.apache.activemq.util.IdGenerator; @@ -39,6 +33,11 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + public class JobSchedulerManagementTest extends JobSchedulerTestSupport { private static final transient Logger LOG = LoggerFactory.getLogger(JobSchedulerManagementTest.class); @@ -320,8 +319,7 @@ public class JobSchedulerManagementTest extends JobSchedulerTestSupport { remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVE); remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID, message.getStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID)); producer.send(remove); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -348,8 +346,7 @@ public class JobSchedulerManagementTest extends JobSchedulerTestSupport { remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL); remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID, new IdGenerator().generateId()); producer.send(remove); - } - catch (Exception e) { + } catch (Exception e) { fail("Caught unexpected exception during remove of unscheduled message."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreCheckpointTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreCheckpointTest.java index 7abf7fb272..0f45259ab6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreCheckpointTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreCheckpointTest.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, @@ -17,9 +17,6 @@ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.util.concurrent.CountDownLatch; @@ -35,6 +32,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class JobSchedulerStoreCheckpointTest { static final Logger LOG = LoggerFactory.getLogger(JobSchedulerStoreCheckpointTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreTest.java index 2afa60e98e..c278da5f57 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerStoreTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; - import java.io.File; import java.util.ArrayList; import java.util.List; @@ -29,6 +27,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; + public class JobSchedulerStoreTest { private static final Logger LOG = LoggerFactory.getLogger(JobSchedulerStoreTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTest.java index b77d0eb4a5..e3f700f762 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.util.Calendar; import java.util.List; @@ -34,6 +31,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class JobSchedulerTest { private static final Logger LOG = LoggerFactory.getLogger(JobSchedulerTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTestSupport.java index 6e2933602b..07d81e5587 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTestSupport.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, @@ -17,12 +17,11 @@ package org.apache.activemq.broker.scheduler; -import java.io.File; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Queue; import javax.management.ObjectName; +import java.io.File; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTxTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTxTest.java index 3e9769e80d..578ded802d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTxTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTxTest.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, @@ -17,11 +17,6 @@ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -29,10 +24,14 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ScheduledMessage; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class JobSchedulerTxTest extends JobSchedulerTestSupport { @Test diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerIndexRebuildTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerIndexRebuildTest.java index 3d6ee1682d..31c460bb63 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerIndexRebuildTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerIndexRebuildTest.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, @@ -16,20 +16,15 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.security.ProtectionDomain; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.io.File; +import java.io.IOException; +import java.security.ProtectionDomain; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ScheduledMessage; @@ -43,6 +38,10 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class KahaDBSchedulerIndexRebuildTest { static final Logger LOG = LoggerFactory.getLogger(KahaDBSchedulerIndexRebuildTest.class); @@ -56,8 +55,7 @@ public class KahaDBSchedulerIndexRebuildTest { try { ProtectionDomain protectionDomain = SchedulerDBVersionTest.class.getProtectionDomain(); basedir = new File(new File(protectionDomain.getCodeSource().getLocation().getPath()), "../.").getCanonicalPath(); - } - catch (IOException e) { + } catch (IOException e) { basedir = "."; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerMissingJournalLogsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerMissingJournalLogsTest.java index 338e4718ce..ebfa3eed0d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerMissingJournalLogsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/KahaDBSchedulerMissingJournalLogsTest.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, @@ -17,9 +17,11 @@ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - +import javax.jms.Connection; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; import java.io.File; import java.io.IOException; import java.security.ProtectionDomain; @@ -27,12 +29,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ScheduledMessage; import org.apache.activemq.broker.BrokerService; @@ -45,6 +41,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test that the store recovers even if some log files are missing. */ @@ -63,8 +62,7 @@ public class KahaDBSchedulerMissingJournalLogsTest { try { ProtectionDomain protectionDomain = SchedulerDBVersionTest.class.getProtectionDomain(); basedir = new File(new File(protectionDomain.getCodeSource().getLocation().getPath()), "../.").getCanonicalPath(); - } - catch (IOException e) { + } catch (IOException e) { basedir = "."; } } @@ -122,8 +120,7 @@ public class KahaDBSchedulerMissingJournalLogsTest { try { createBroker(); fail("Should not start when logs are missing."); - } - catch (Exception e) { + } catch (Exception e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/LostScheduledMessagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/LostScheduledMessagesTest.java index 7b31771f87..180cb050b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/LostScheduledMessagesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/LostScheduledMessagesTest.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, @@ -17,13 +17,6 @@ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Message; @@ -31,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.File; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ScheduledMessage; @@ -41,6 +37,9 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class LostScheduledMessagesTest { private BrokerService broker; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/SchedulerDBVersionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/SchedulerDBVersionTest.java index db2d9ed00c..fac55454e5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/SchedulerDBVersionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/SchedulerDBVersionTest.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.broker.scheduler; -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.IOException; -import java.security.ProtectionDomain; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -33,6 +24,12 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.io.File; +import java.io.IOException; +import java.security.ProtectionDomain; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ScheduledMessage; @@ -45,6 +42,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; + public class SchedulerDBVersionTest { static String basedir; @@ -53,8 +52,7 @@ public class SchedulerDBVersionTest { try { ProtectionDomain protectionDomain = SchedulerDBVersionTest.class.getProtectionDomain(); basedir = new File(new File(protectionDomain.getCodeSource().getLocation().getPath()), "../..").getCanonicalPath(); - } - catch (IOException e) { + } catch (IOException e) { basedir = "."; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemeoryJmsSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemeoryJmsSchedulerTest.java index 8d72dfb297..e67d799db1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemeoryJmsSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemeoryJmsSchedulerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJmsCronSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJmsCronSchedulerTest.java index bad8368080..e3ec990a5f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJmsCronSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJmsCronSchedulerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerJmxManagementTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerJmxManagementTests.java index 2bd923e7de..b2c2c367e3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerJmxManagementTests.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerJmxManagementTests.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerManagementTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerManagementTest.java index d305321c8d..bd7becd6b1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerManagementTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerManagementTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerStoreTest.java index 6bf8b0faee..fbc11b162f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerStoreTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerStoreTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.broker.scheduler.memory; -import static org.junit.Assert.assertEquals; - import java.io.File; import java.util.ArrayList; import java.util.List; @@ -30,6 +28,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; + /** * */ diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java index 0cce465240..3a9fe3effb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTxTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTxTest.java index ab9e8095d8..b1bb119da1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTxTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTxTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java index 49d5bd5d6b..a3587ad0a0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreRecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreRecoveryBrokerTest.java index 7aa2d13f49..a7e0c323a2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreRecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/DefaultStoreRecoveryBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java index 212c955370..56eac03745 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.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, @@ -16,16 +16,15 @@ */ package org.apache.activemq.broker.store; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - import javax.jms.BytesMessage; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import junit.framework.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/RecoverExpiredMessagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/RecoverExpiredMessagesTest.java index 16b0cf6fb4..91ca43075d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/RecoverExpiredMessagesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/store/RecoverExpiredMessagesTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/DestinationsPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/DestinationsPluginTest.java index 9f65a3c1e0..79af861cec 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/DestinationsPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/DestinationsPluginTest.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, @@ -24,7 +24,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DestinationsPluginTest { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/PluginBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/PluginBrokerTest.java index cc4b36aba4..45abf362db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/PluginBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/PluginBrokerTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.broker.util; -import java.net.URI; - import javax.jms.JMSException; import javax.jms.Message; +import java.net.URI; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; @@ -68,12 +67,10 @@ public class PluginBrokerTest extends JmsTopicSendReceiveTest { if (index == 7) { // check custom expiration assertTrue("expiration is in range, depends on two distinct calls to System.currentTimeMillis", 1500 < amqMsg.getExpiration() - amqMsg.getTimestamp()); - } - else if (index == 9) { + } else if (index == 9) { // check ceiling assertTrue("expiration ceeling is in range, depends on two distinct calls to System.currentTimeMillis", 59500 < amqMsg.getExpiration() - amqMsg.getTimestamp()); - } - else { + } else { // check default expiration assertEquals(1000, amqMsg.getExpiration() - amqMsg.getTimestamp()); } @@ -84,11 +81,9 @@ public class PluginBrokerTest extends JmsTopicSendReceiveTest { protected void sendMessage(int index, Message message) throws Exception { if (index == 7) { producer.send(producerDestination, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, 2000); - } - else if (index == 9) { + } else if (index == 9) { producer.send(producerDestination, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, 200000); - } - else { + } else { super.sendMessage(index, message); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/RedeliveryPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/RedeliveryPluginTest.java index 06e3ab868b..62832d8c56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/RedeliveryPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/RedeliveryPluginTest.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, @@ -50,8 +50,7 @@ public class RedeliveryPluginTest extends TestCase { try { underTest.installPlugin(broker); fail("expect exception on no scheduler support"); - } - catch (Exception expected) { + } catch (Exception expected) { LOG.info("expected: " + expected); } @@ -59,8 +58,7 @@ public class RedeliveryPluginTest extends TestCase { try { underTest.installPlugin(broker); fail("expect exception on small initial delay"); - } - catch (Exception expected) { + } catch (Exception expected) { LOG.info("expected: " + expected); } @@ -70,8 +68,7 @@ public class RedeliveryPluginTest extends TestCase { try { underTest.installPlugin(broker); fail("expect exception on small redelivery delay"); - } - catch (Exception expected) { + } catch (Exception expected) { LOG.info("expected: " + expected); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TimeStampingBrokerPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TimeStampingBrokerPluginTest.java index d14caaa0e8..b43b05e996 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TimeStampingBrokerPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TimeStampingBrokerPluginTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TraceBrokerPathPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TraceBrokerPathPluginTest.java index cd55d4ddd7..7171ddd57b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TraceBrokerPathPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/util/TraceBrokerPathPluginTest.java @@ -6,14 +6,13 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.apache.activemq.broker.util; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java index 7551258f43..ca20489017 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.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, @@ -64,15 +64,13 @@ public class ActiveMQBytesMessageTest extends TestCase { for (int i = 0; i < len; i++) { msg.writeLong(5L); } - } - catch (JMSException ex) { + } catch (JMSException ex) { ex.printStackTrace(); } try { msg.reset(); assertTrue(msg.getBodyLength() == (len * 8)); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); assertTrue(false); } @@ -84,8 +82,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeBoolean(true); msg.reset(); assertTrue(msg.readBoolean()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -97,8 +94,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeByte((byte) 2); msg.reset(); assertTrue(msg.readByte() == 2); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -110,8 +106,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeByte((byte) 2); msg.reset(); assertTrue(msg.readUnsignedByte() == 2); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -123,8 +118,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeShort((short) 3000); msg.reset(); assertTrue(msg.readShort() == 3000); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -136,8 +130,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeShort((short) 3000); msg.reset(); assertTrue(msg.readUnsignedShort() == 3000); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -149,8 +142,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeChar('a'); msg.reset(); assertTrue(msg.readChar() == 'a'); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -162,8 +154,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeInt(3000); msg.reset(); assertTrue(msg.readInt() == 3000); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -175,8 +166,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeLong(3000); msg.reset(); assertTrue(msg.readLong() == 3000); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -188,8 +178,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeFloat(3.3f); msg.reset(); assertTrue(msg.readFloat() == 3.3f); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -201,8 +190,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeDouble(3.3d); msg.reset(); assertTrue(msg.readDouble() == 3.3d); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -215,8 +203,7 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeUTF(str); msg.reset(); assertTrue(msg.readUTF().equals(str)); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -239,8 +226,7 @@ public class ActiveMQBytesMessageTest extends TestCase { for (int i = 0; i < test.length; i++) { assertTrue(test[i] == i); } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -259,15 +245,13 @@ public class ActiveMQBytesMessageTest extends TestCase { msg.writeObject(new Float(3.3f)); msg.writeObject(new Double(3.3)); msg.writeObject(new byte[3]); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { fail("objectified primitives should be allowed"); } try { msg.writeObject(new Object()); fail("only objectified primitives are allowed"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } } @@ -280,10 +264,8 @@ public class ActiveMQBytesMessageTest extends TestCase { assertFalse(bytesMessage.isReadOnlyBody()); bytesMessage.writeInt(1); bytesMessage.readInt(); - } - catch (MessageNotReadableException mnwe) { - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotReadableException mnwe) { + } catch (MessageNotWriteableException mnwe) { assertTrue(false); } } @@ -293,8 +275,7 @@ public class ActiveMQBytesMessageTest extends TestCase { try { message.writeDouble(24.5); message.writeLong(311); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("should be writeable"); } message.reset(); @@ -302,15 +283,13 @@ public class ActiveMQBytesMessageTest extends TestCase { assertTrue(message.isReadOnlyBody()); assertEquals(message.readDouble(), 24.5, 0); assertEquals(message.readLong(), 311); - } - catch (MessageNotReadableException mnre) { + } catch (MessageNotReadableException mnre) { fail("should be readable"); } try { message.writeInt(33); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } @@ -331,8 +310,7 @@ public class ActiveMQBytesMessageTest extends TestCase { message.writeShort((short) 1); message.writeShort((short) 1); message.writeUTF("utfstring"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("Should be writeable"); } message.reset(); @@ -351,81 +329,68 @@ public class ActiveMQBytesMessageTest extends TestCase { message.readShort(); message.readUnsignedShort(); message.readUTF(); - } - catch (MessageNotReadableException mnwe) { + } catch (MessageNotReadableException mnwe) { fail("Should be readable"); } try { message.writeBoolean(true); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeByte((byte) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeBytes(new byte[1]); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeBytes(new byte[3], 0, 2); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeChar('a'); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeDouble(1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeFloat((float) 1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeInt(1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeLong(1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeObject("stringobj"); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeShort((short) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeUTF("utfstring"); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } @@ -447,93 +412,78 @@ public class ActiveMQBytesMessageTest extends TestCase { message.writeShort((short) 1); message.writeShort((short) 1); message.writeUTF("utfstring"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("Should be writeable"); } try { message.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException mnwe) { + } catch (MessageNotReadableException mnwe) { } try { message.readByte(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readUnsignedByte(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readBytes(new byte[1]); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readBytes(new byte[2], 2); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readChar(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readDouble(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readFloat(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readInt(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readLong(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readUTF(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readShort(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readUnsignedShort(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readUTF(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java index 4864c31d6c..41616d77e3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.command; +import javax.jms.JMSException; +import javax.jms.Queue; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.Topic; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -24,12 +29,6 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.TemporaryQueue; -import javax.jms.TemporaryTopic; -import javax.jms.Topic; - import junit.framework.Test; public class ActiveMQDestinationTest extends DataStructureTestSupport { @@ -98,14 +97,12 @@ public class ActiveMQDestinationTest extends DataStructureTestSupport { try { ActiveMQDestination.transform(new CombyDest(null, null)); fail("expect ex as cannot disambiguate"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } try { ActiveMQDestination.transform(new CombyDest("Q", "T")); fail("expect ex as cannot disambiguate"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } @@ -121,8 +118,7 @@ public class ActiveMQDestinationTest extends DataStructureTestSupport { try { new ActiveMQQueue(""); fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } @@ -131,8 +127,7 @@ public class ActiveMQDestinationTest extends DataStructureTestSupport { try { new ActiveMQTopic(""); fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java index 4725279d59..0fda067ac9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.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, @@ -16,17 +16,16 @@ */ package org.apache.activemq.command; +import javax.jms.JMSException; +import javax.jms.MessageFormatException; +import javax.jms.MessageNotReadableException; +import javax.jms.MessageNotWriteableException; import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.List; -import javax.jms.JMSException; -import javax.jms.MessageFormatException; -import javax.jms.MessageNotReadableException; -import javax.jms.MessageNotWriteableException; - import junit.framework.TestCase; import org.slf4j.Logger; @@ -135,8 +134,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setShort(this.name, (short) 1); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getShort(this.name) == (short) 1); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -148,8 +146,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setChar(this.name, 'a'); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getChar(this.name) == 'a'); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -161,8 +158,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setInt(this.name, 1); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getInt(this.name) == 1); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -174,8 +170,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setLong(this.name, 1); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getLong(this.name) == 1); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -187,8 +182,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setFloat(this.name, 1.5f); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getFloat(this.name) == 1.5f); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -200,8 +194,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setDouble(this.name, 1.5); msg = (ActiveMQMapMessage) msg.copy(); assertTrue(msg.getDouble(this.name) == 1.5); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -214,8 +207,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setString(this.name, str); msg = (ActiveMQMapMessage) msg.copy(); assertEquals(msg.getString(this.name), str); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -232,8 +224,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg = (ActiveMQMapMessage) msg.copy(); assertTrue(Arrays.equals(msg.getBytes(this.name), bytes1)); assertEquals(msg.getBytes(this.name + "2").length, bytes2.length); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -263,8 +254,7 @@ public class ActiveMQMapMessageTest extends TestCase { msg.setObject("long", longValue); msg.setObject("short", shortValue); msg.setObject("string", stringValue); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { LOG.warn("Caught: " + mfe); mfe.printStackTrace(); fail("object formats should be correct"); @@ -307,8 +297,7 @@ public class ActiveMQMapMessageTest extends TestCase { try { msg.setObject("object", new Object()); fail("should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -405,81 +394,68 @@ public class ActiveMQMapMessageTest extends TestCase { msg.getObject("object"); msg.getShort("short"); msg.getString("string"); - } - catch (MessageNotReadableException mnre) { + } catch (MessageNotReadableException mnre) { fail("should be readable"); } try { msg.setBoolean("boolean", true); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setByte("byte", (byte) 1); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setBytes("bytes", new byte[1]); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setBytes("bytes2", new byte[3], 0, 2); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setChar("char", 'a'); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setDouble("double", 1.5); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setFloat("float", 1.5f); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setInt("int", 1); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setLong("long", 1); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setObject("object", "stringObj"); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setShort("short", (short) 1); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { msg.setString("string", "string"); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java index 4bca7eb8e5..f1143afe70 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.command; -import java.io.IOException; -import java.util.Enumeration; -import java.util.Map; - import javax.jms.DeliveryMode; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageFormatException; import javax.jms.MessageNotWriteableException; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Map; import junit.framework.TestCase; @@ -113,11 +112,9 @@ public class ActiveMQMessageTest extends TestCase { boolean test = false; try { msg.setIntProperty("test", 1); - } - catch (MessageNotWriteableException me) { + } catch (MessageNotWriteableException me) { test = true; - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(System.err); test = false; } @@ -452,21 +449,18 @@ public class ActiveMQMessageTest extends TestCase { msg.setObjectProperty(name, Double.valueOf("1.1")); msg.setObjectProperty(name, Boolean.TRUE); msg.setObjectProperty(name, null); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { fail("should accept object primitives and String"); } try { msg.setObjectProperty(name, new byte[5]); fail("should accept only object primitives and String"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.setObjectProperty(name, new Object()); fail("should accept only object primitives and String"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -546,8 +540,7 @@ public class ActiveMQMessageTest extends TestCase { try { msg.setStringProperty(null, "Cheese"); fail("Should have thrown exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { LOG.info("Worked, caught: " + e); } } @@ -558,8 +551,7 @@ public class ActiveMQMessageTest extends TestCase { try { msg.setStringProperty("", "Cheese"); fail("Should have thrown exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { LOG.info("Worked, caught: " + e); } } @@ -589,38 +581,32 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getLongProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -638,20 +624,17 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -668,26 +651,22 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -703,32 +682,27 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -743,38 +717,32 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -789,32 +757,27 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getLongProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -828,38 +791,32 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getLongProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -889,38 +846,32 @@ public class ActiveMQMessageTest extends TestCase { try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { msg.getLongProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } assertFalse(msg.getBooleanProperty(propertyName)); } @@ -933,56 +884,47 @@ public class ActiveMQMessageTest extends TestCase { ((org.apache.activemq.command.Message) msg).setProperty(propertyName, obj); // bypass // object // check - } - catch (IOException e) { + } catch (IOException e) { } try { msg.getStringProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getBooleanProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getByteProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getShortProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getIntProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getLongProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getFloatProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { msg.getDoubleProperty(propertyName); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -995,56 +937,47 @@ public class ActiveMQMessageTest extends TestCase { try { msg.setObjectProperty(propertyName, new Object()); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setStringProperty(propertyName, "test"); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setBooleanProperty(propertyName, true); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setByteProperty(propertyName, (byte) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setShortProperty(propertyName, (short) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setIntProperty(propertyName, 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setLongProperty(propertyName, 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setFloatProperty(propertyName, (float) 1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { msg.setDoubleProperty(propertyName, 1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQObjectMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQObjectMessageTest.java index 94f0d93a61..1203fbcb22 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQObjectMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQObjectMessageTest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.command; -import java.io.IOException; - import javax.jms.JMSException; import javax.jms.MessageNotReadableException; import javax.jms.MessageNotWriteableException; +import java.io.IOException; import junit.framework.TestCase; @@ -84,8 +83,7 @@ public class ActiveMQObjectMessageTest extends TestCase { assertNull(objectMessage.getObject()); objectMessage.setObject("String"); objectMessage.getObject(); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("should be writeable"); } } @@ -96,15 +94,13 @@ public class ActiveMQObjectMessageTest extends TestCase { msg.setReadOnlyBody(true); try { msg.getObject(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); } try { msg.setObject("test"); fail("should throw exception"); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } } @@ -114,8 +110,7 @@ public class ActiveMQObjectMessageTest extends TestCase { try { msg.setObject("test"); msg.getObject(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); } msg.setReadOnlyBody(true); @@ -123,11 +118,9 @@ public class ActiveMQObjectMessageTest extends TestCase { msg.getObject(); msg.setObject("test"); fail("should throw exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java index d554102d66..bc3a36347d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.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, @@ -74,60 +74,51 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readLong(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -152,39 +143,33 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -207,46 +192,39 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -265,60 +243,51 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readLong(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -339,53 +308,45 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -404,65 +365,56 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readDouble(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg = new ActiveMQStreamMessage(); msg.writeObject(new Long("1")); // reset so it's readable now msg.reset(); assertEquals(new Long("1"), msg.readObject()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -483,53 +435,45 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readLong(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -548,60 +492,51 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readLong(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readBytes(new byte[1]); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -650,8 +585,7 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } msg.clearBody(); msg.writeString("777"); @@ -659,12 +593,10 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readBytes(new byte[3]); fail("Should have thrown exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -684,8 +616,7 @@ public class ActiveMQStreamMessageTest extends TestCase { msg.reset(); assertEquals(bigString, msg.readString()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -709,53 +640,45 @@ public class ActiveMQStreamMessageTest extends TestCase { try { msg.readByte(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readShort(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readInt(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readLong(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readFloat(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readChar(); fail("Should have thrown exception"); - } - catch (MessageFormatException mfe) { + } catch (MessageFormatException mfe) { } msg.reset(); try { msg.readString(); fail("Should have thrown exception"); + } catch (MessageFormatException mfe) { } - catch (MessageFormatException mfe) { - } - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -822,8 +745,7 @@ public class ActiveMQStreamMessageTest extends TestCase { msg.reset(); assertTrue(((Boolean) msg.readObject()).booleanValue()); - } - catch (JMSException jmsEx) { + } catch (JMSException jmsEx) { jmsEx.printStackTrace(); assertTrue(false); } @@ -838,10 +760,8 @@ public class ActiveMQStreamMessageTest extends TestCase { streamMessage.writeObject(new Long(2)); streamMessage.readObject(); fail("should throw exception"); - } - catch (MessageNotReadableException mnwe) { - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotReadableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("should be writeable"); } } @@ -851,8 +771,7 @@ public class ActiveMQStreamMessageTest extends TestCase { try { streamMessage.writeDouble(24.5); streamMessage.writeLong(311); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("should be writeable"); } streamMessage.reset(); @@ -860,15 +779,13 @@ public class ActiveMQStreamMessageTest extends TestCase { assertTrue(streamMessage.isReadOnlyBody()); assertEquals(streamMessage.readDouble(), 24.5, 0); assertEquals(streamMessage.readLong(), 311); - } - catch (MessageNotReadableException mnre) { + } catch (MessageNotReadableException mnre) { fail("should be readable"); } try { streamMessage.writeInt(33); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } @@ -887,8 +804,7 @@ public class ActiveMQStreamMessageTest extends TestCase { message.writeObject("stringobj"); message.writeShort((short) 1); message.writeString("string"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("Should be writeable"); } message.reset(); @@ -907,81 +823,68 @@ public class ActiveMQStreamMessageTest extends TestCase { message.readString(); message.readShort(); message.readString(); - } - catch (MessageNotReadableException mnwe) { + } catch (MessageNotReadableException mnwe) { fail("Should be readable"); } try { message.writeBoolean(true); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeByte((byte) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeBytes(new byte[1]); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeBytes(new byte[3], 0, 2); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeChar('a'); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeDouble(1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeFloat((float) 1.5); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeInt(1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeLong(1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeObject("stringobj"); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeShort((short) 1); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } try { message.writeString("string"); fail("Should have thrown exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } @@ -1001,81 +904,68 @@ public class ActiveMQStreamMessageTest extends TestCase { message.writeObject("stringobj"); message.writeShort((short) 1); message.writeString("string"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("Should be writeable"); } try { message.readBoolean(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException mnwe) { + } catch (MessageNotReadableException mnwe) { } try { message.readByte(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readBytes(new byte[1]); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readBytes(new byte[2]); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readChar(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readDouble(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readFloat(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readInt(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readLong(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readString(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readShort(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } try { message.readString(); fail("Should have thrown exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } } @@ -1092,8 +982,7 @@ public class ActiveMQStreamMessageTest extends TestCase { message.writeObject(new Long(2L)); message.writeObject(new Float(2.0f)); message.writeObject(new Double(2.0d)); - } - catch (Exception e) { + } catch (Exception e) { fail(e.getMessage()); } try { @@ -1101,11 +990,9 @@ public class ActiveMQStreamMessageTest extends TestCase { message.clearBody(); message.writeObject(new Object()); fail("should throw an exception"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { - } - catch (Exception e) { + } catch (Exception e) { fail(e.getMessage()); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQTextMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQTextMessageTest.java index cfbba33cb2..fbb6baee0d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQTextMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQTextMessageTest.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, @@ -16,17 +16,15 @@ */ package org.apache.activemq.command; -import java.io.DataOutputStream; -import java.io.IOException; - import javax.jms.JMSException; import javax.jms.MessageNotReadableException; import javax.jms.MessageNotWriteableException; +import java.io.DataOutputStream; +import java.io.IOException; import junit.framework.TestCase; import junit.textui.TestRunner; - import org.apache.activemq.util.ByteArrayOutputStream; import org.apache.activemq.util.ByteSequence; import org.apache.activemq.util.MarshallingSupport; @@ -59,8 +57,7 @@ public class ActiveMQTextMessageTest extends TestCase { try { msg.setText(str); assertEquals(msg.getText(), str); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -87,11 +84,9 @@ public class ActiveMQTextMessageTest extends TestCase { try { textMessage.setText("String"); textMessage.getText(); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { fail("should be writeable"); - } - catch (MessageNotReadableException mnre) { + } catch (MessageNotReadableException mnre) { fail("should be readable"); } } @@ -102,15 +97,13 @@ public class ActiveMQTextMessageTest extends TestCase { textMessage.setReadOnlyBody(true); try { textMessage.getText(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); } try { textMessage.setText("test"); fail("should throw exception"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } @@ -120,8 +113,7 @@ public class ActiveMQTextMessageTest extends TestCase { try { textMessage.setText("test"); textMessage.getText(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); } textMessage.setReadOnlyBody(true); @@ -129,11 +121,9 @@ public class ActiveMQTextMessageTest extends TestCase { textMessage.getText(); textMessage.setText("test"); fail("should throw exception"); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { fail("should be readable"); - } - catch (MessageNotWriteableException mnwe) { + } catch (MessageNotWriteableException mnwe) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/DataStructureTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/DataStructureTestSupport.java index 6cdee065dc..ea16d5de48 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/DataStructureTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/DataStructureTestSupport.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, @@ -99,8 +99,7 @@ public abstract class DataStructureTestSupport extends CombinationTestSupport { if (!ok) { throw new AssertionFailedError("Arrays not equal"); } - } - else { + } else { Object expectArray[] = (Object[]) expect; Object wasArray[] = (Object[]) was; if (expectArray.length != wasArray.length) { @@ -111,8 +110,7 @@ public abstract class DataStructureTestSupport extends CombinationTestSupport { } } - } - else if (expect instanceof Command) { + } else if (expect instanceof Command) { assertEquals(expect.getClass(), was.getClass()); Method[] methods = expect.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { @@ -123,28 +121,22 @@ public abstract class DataStructureTestSupport extends CombinationTestSupport { try { if (method.getName().startsWith("get")) { expect.getClass().getMethod(method.getName().replaceFirst("get", "set"), new Class[]{method.getReturnType()}); - } - else { + } else { expect.getClass().getMethod(method.getName().replaceFirst("is", "set"), new Class[]{method.getReturnType()}); } - } - catch (Throwable ignore) { + } catch (Throwable ignore) { continue; } try { assertEquals(method.invoke(expect, (Object) null), method.invoke(was, (Object) null)); - } - catch (IllegalArgumentException e) { - } - catch (IllegalAccessException e) { - } - catch (InvocationTargetException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { } } } - } - else { + } else { TestCase.assertEquals(expect, was); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageCompressionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageCompressionTest.java index 01dbe6c225..d80b743ba0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageCompressionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageCompressionTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.command; -import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.MapMessage; @@ -27,6 +24,8 @@ import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.StreamMessage; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import junit.framework.TestCase; @@ -113,7 +112,7 @@ public class MessageCompressionTest extends TestCase { boolean booleanVal = mapMessage.getBoolean("boolean-type"); assertTrue(booleanVal); byte byteVal = mapMessage.getByte("byte-type"); - assertEquals((byte)10, byteVal); + assertEquals((byte) 10, byteVal); byte[] bytesVal = mapMessage.getBytes("bytes-type"); byte[] originVal = TEXT.getBytes(); assertEquals(originVal.length, bytesVal.length); @@ -160,7 +159,7 @@ public class MessageCompressionTest extends TestCase { boolean booleanVal = streamMessage.readBoolean(); assertTrue(booleanVal); byte byteVal = streamMessage.readByte(); - assertEquals((byte)10, byteVal); + assertEquals((byte) 10, byteVal); byte[] originVal = TEXT.getBytes(); byte[] bytesVal = new byte[originVal.length]; streamMessage.readBytes(bytesVal); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageSendTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageSendTest.java index a436754cc8..22c7b1ee3d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageSendTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageSendTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageTest.java index b849849758..0a4d2269f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/MessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerPropertiesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerPropertiesTest.java index f7744d3f2a..c1e674e80a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerPropertiesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerPropertiesTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java index 8d658e75d8..883b1a9e02 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.config; -import java.io.File; -import java.util.Hashtable; - import javax.naming.Context; import javax.naming.InitialContext; +import java.io.File; +import java.util.Hashtable; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsTest; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigTest.java index b93babc836..1509e04d02 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java index f0640b630a..fd2adef9bb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.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, @@ -16,22 +16,16 @@ */ package org.apache.activemq.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.util.List; - import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Session; import javax.jms.Topic; import javax.sql.DataSource; +import java.io.File; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.util.List; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -64,6 +58,11 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class ConfigTest { protected static final String JOURNAL_ROOT = "target/test-data/"; @@ -117,8 +116,7 @@ public class ConfigTest { assertTrue(broker.getSystemUsage().getStoreUsage().getStore() instanceof JournalPersistenceAdapter); LOG.info("Success"); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -282,8 +280,7 @@ public class ConfigTest { LOG.info("Success"); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -309,8 +306,7 @@ public class ConfigTest { assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(), journalFile.exists()); LOG.info("Success"); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -341,8 +337,7 @@ public class ConfigTest { assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists()); LOG.info("Success"); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -381,8 +376,7 @@ public class ConfigTest { try { session.createProducer(topic); fail("Should have got an exception on exceeding MAX_PRODUCERS"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } try { @@ -391,13 +385,11 @@ public class ConfigTest { assertNotNull(consumer); } fail("Should have caught an exception"); - } - catch (JMSException e) { + } catch (JMSException e) { } LOG.info("Success"); - } - finally { + } finally { broker.stop(); } } @@ -409,8 +401,7 @@ public class ConfigTest { broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml")); try { assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName()); - } - finally { + } finally { if (broker != null) { broker.stop(); } @@ -419,8 +410,7 @@ public class ConfigTest { broker = createBroker("org/apache/activemq/config/config.xml"); try { assertEquals("Broker Config Error (brokerName)", "brokerXmlConfigHelper", broker.getBrokerName()); - } - finally { + } finally { if (broker != null) { broker.stop(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java index b85e6bc728..8637c53305 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.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, @@ -58,8 +58,7 @@ public class ConfigUsingDestinationOptions extends TestCase { try { cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test||1"); fail("Selector should be invalid" + cons); - } - catch (InvalidSelectorException e) { + } catch (InvalidSelectorException e) { } @@ -67,8 +66,7 @@ public class ConfigUsingDestinationOptions extends TestCase { try { cons = (ActiveMQMessageConsumer) sess.createConsumer(queue); fail("Selector should be invalid" + cons); - } - catch (InvalidSelectorException e) { + } catch (InvalidSelectorException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java index 3b7b83ca77..507869779e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.File; import org.apache.activemq.broker.BrokerService; @@ -34,6 +31,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class JDBCConfigTest { protected static final String JOURNAL_ROOT = "target/test-data/"; @@ -65,8 +65,7 @@ public class JDBCConfigTest { assertTrue("Should have created a DefaultWireFormat", ((JDBCPersistenceAdapter) adapter).getWireFormat() instanceof ObjectStreamWireFormat); LOG.info("Success"); - } - finally { + } finally { if (broker != null) { broker.stop(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java index 317fd55835..52b523f53e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.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, @@ -116,8 +116,7 @@ public class AMQ3410Test extends TestCase { try { command.execute(tokens); - } - catch (Throwable cause) { + } catch (Throwable cause) { while (null != cause) { if (cause instanceof java.lang.ClassNotFoundException) return; @@ -143,8 +142,7 @@ public class AMQ3410Test extends TestCase { try { command.execute(tokens); - } - catch (Throwable e) { + } catch (Throwable e) { Throwable cause = e; while (null != cause) { if (cause instanceof java.lang.NoSuchMethodException) @@ -172,8 +170,7 @@ public class AMQ3410Test extends TestCase { try { command.execute(tokens); - } - catch (Throwable cause) { + } catch (Throwable cause) { while (null != cause) { if (cause instanceof java.lang.NoSuchMethodException) return; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java index 9ca9d18126..4d1650744b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.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, @@ -152,8 +152,7 @@ public class AMQ3411Test extends TestCase { try { command.execute(tokens); - } - catch (Throwable e) { + } catch (Throwable e) { Throwable cause = e; while (null != cause) { if (cause instanceof java.lang.ClassNotFoundException) @@ -183,8 +182,7 @@ public class AMQ3411Test extends TestCase { try { command.execute(tokens); - } - catch (Throwable e) { + } catch (Throwable e) { Throwable cause = e; while (null != cause) { if (cause instanceof java.lang.ClassCastException) diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java index 7af0facc2e..0219436352 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.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, @@ -16,10 +16,10 @@ */ package org.apache.activemq.console.command; -import org.apache.activemq.ActiveMQConnectionFactory; - import java.net.URI; +import org.apache.activemq.ActiveMQConnectionFactory; + public class DummyConnectionFactory extends ActiveMQConnectionFactory { public DummyConnectionFactory() { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java index fa57684a28..3e5d2126d8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java index f8e47957d9..7219be2752 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/PurgeCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/PurgeCommandTest.java index b238452914..f41f614a4c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/PurgeCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/PurgeCommandTest.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.console.command; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; - import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -37,6 +30,12 @@ import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectInstance; import javax.management.ObjectName; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; import junit.framework.TestCase; @@ -219,8 +218,7 @@ public class PurgeCommandTest extends TestCase { validateCounts(0, MESSAGE_COUNT, MESSAGE_COUNT); - } - finally { + } finally { purgeAllMessages(); } } @@ -245,8 +243,7 @@ public class PurgeCommandTest extends TestCase { purgeCommand.execute(tokens); validateCounts(0, MESSAGE_COUNT, MESSAGE_COUNT); - } - finally { + } finally { purgeAllMessages(); } } @@ -283,8 +280,7 @@ public class PurgeCommandTest extends TestCase { assertEquals("Expected allCount to be " + MESSAGE_COUNT + " was " + allCount, MESSAGE_COUNT, allCount); LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n"); - } - finally { + } finally { purgeAllMessages(); } } @@ -299,8 +295,7 @@ public class PurgeCommandTest extends TestCase { LOG.info("String matches."); else LOG.info("string does not match."); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(ex.getMessage()); } @@ -334,8 +329,7 @@ public class PurgeCommandTest extends TestCase { assertEquals("Expected allCount to be " + MESSAGE_COUNT + " was " + allCount, MESSAGE_COUNT, allCount); LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n"); - } - finally { + } finally { purgeAllMessages(); } } @@ -372,8 +366,7 @@ public class PurgeCommandTest extends TestCase { assertEquals("Expected allCount to be 0 but was " + allCount, 0, allCount); LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n"); - } - finally { + } finally { purgeAllMessages(); } } @@ -388,8 +381,7 @@ public class PurgeCommandTest extends TestCase { LOG.info("String matches."); else LOG.info("string does not match."); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(ex.getMessage()); } @@ -427,8 +419,7 @@ public class PurgeCommandTest extends TestCase { LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n"); */ - } - finally { + } finally { purgeAllMessages(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/DefaultQueueSender.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/DefaultQueueSender.java index bef0550d25..ec67b7f1b2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/DefaultQueueSender.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/DefaultQueueSender.java @@ -6,13 +6,21 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * The SimpleQueueSender class consists only of a main method, + * which sends several messages to a queue. + * + * Run this program in conjunction with SimpleQueueReceiver. + * Specify a queue name on the command line when you run the + * program. By default, the program sends one message. Specify + * a number after the queue name to send that number of messages. */ /** @@ -89,16 +97,13 @@ public final class DefaultQueueSender { Message message = session.createTextMessage(text); producer.send(message); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception occurred: " + e.toString()); - } - finally { + } finally { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleConsumer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleConsumer.java index ee8899b118..7e9145fc03 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleConsumer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleConsumer.java @@ -6,13 +6,19 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * The SimpleQueueReceiver class consists only of a main method, + * which fetches one or more messages from a queue using + * synchronous message delivery. Run this program in conjunction + * with SimpleQueueSender. Specify a queue name on the command + * line when you run the program. */ /** @@ -74,8 +80,7 @@ public final class SimpleConsumer { */ try { jndiContext = new InitialContext(); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("Could not create JNDI API " + "context: " + e.toString()); System.exit(1); } @@ -86,8 +91,7 @@ public final class SimpleConsumer { try { connectionFactory = (ConnectionFactory) jndiContext.lookup("ConnectionFactory"); destination = (Destination) jndiContext.lookup(destinationName); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("JNDI API lookup failed: " + e.toString()); System.exit(1); } @@ -110,22 +114,18 @@ public final class SimpleConsumer { if (m instanceof TextMessage) { TextMessage message = (TextMessage) m; LOG.info("Reading message: " + message.getText()); - } - else { + } else { break; } } } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception occurred: " + e); - } - finally { + } finally { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java index 6e5fb4c051..9ab1acf3b7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java @@ -6,13 +6,21 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * The SimpleQueueSender class consists only of a main method, + * which sends several messages to a queue. + * + * Run this program in conjunction with SimpleQueueReceiver. + * Specify a queue name on the command line when you run the + * program. By default, the program sends one message. Specify + * a number after the queue name to send that number of messages. */ /** @@ -75,8 +83,7 @@ public final class SimpleProducer { LOG.info("Destination name is " + destinationName); if (args.length == 2) { numMsgs = (new Integer(args[1])).intValue(); - } - else { + } else { numMsgs = 1; } @@ -85,8 +92,7 @@ public final class SimpleProducer { */ try { jndiContext = new InitialContext(); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("Could not create JNDI API context: " + e.toString()); System.exit(1); } @@ -97,8 +103,7 @@ public final class SimpleProducer { try { connectionFactory = (ConnectionFactory) jndiContext.lookup("ConnectionFactory"); destination = (Destination) jndiContext.lookup(destinationName); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("JNDI API lookup failed: " + e); System.exit(1); } @@ -124,16 +129,13 @@ public final class SimpleProducer { * Send a non-text control message indicating end of messages. */ producer.send(session.createMessage()); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception occurred: " + e); - } - finally { + } finally { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueReceiver.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueReceiver.java index 73ee6b1326..14f3ed536f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueReceiver.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueReceiver.java @@ -6,13 +6,19 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * The SimpleQueueReceiver class consists only of a main method, + * which fetches one or more messages from a queue using + * synchronous message delivery. Run this program in conjunction + * with SimpleQueueSender. Specify a queue name on the command + * line when you run the program. */ /** @@ -77,8 +83,7 @@ public final class SimpleQueueReceiver { */ try { jndiContext = new InitialContext(); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("Could not create JNDI API " + "context: " + e.toString()); System.exit(1); } @@ -89,8 +94,7 @@ public final class SimpleQueueReceiver { try { queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory"); queue = (Queue) jndiContext.lookup(queueName); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("JNDI API lookup failed: " + e.toString()); System.exit(1); } @@ -113,22 +117,18 @@ public final class SimpleQueueReceiver { if (m instanceof TextMessage) { message = (TextMessage) m; LOG.info("Reading message: " + message.getText()); - } - else { + } else { break; } } } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception occurred: " + e.toString()); - } - finally { + } finally { if (queueConnection != null) { try { queueConnection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueSender.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueSender.java index 59490ef7c8..35d2ee39b1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueSender.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/demo/SimpleQueueSender.java @@ -6,13 +6,21 @@ * (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * The SimpleQueueSender class consists only of a main method, + * which sends several messages to a queue. + * + * Run this program in conjunction with SimpleQueueReceiver. + * Specify a queue name on the command line when you run the + * program. By default, the program sends one message. Specify + * a number after the queue name to send that number of messages. */ /** @@ -75,8 +83,7 @@ public final class SimpleQueueSender { LOG.info("Queue name is " + queueName); if (args.length == 2) { numMsgs = (new Integer(args[1])).intValue(); - } - else { + } else { numMsgs = 1; } @@ -85,8 +92,7 @@ public final class SimpleQueueSender { */ try { jndiContext = new InitialContext(); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("Could not create JNDI API context: " + e.toString()); System.exit(1); } @@ -97,8 +103,7 @@ public final class SimpleQueueSender { try { queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory"); queue = (Queue) jndiContext.lookup(queueName); - } - catch (NamingException e) { + } catch (NamingException e) { LOG.info("JNDI API lookup failed: " + e); System.exit(1); } @@ -124,16 +129,13 @@ public final class SimpleQueueSender { * Send a non-text control message indicating end of messages. */ queueSender.send(queueSession.createMessage()); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Exception occurred: " + e.toString()); - } - finally { + } finally { if (queueConnection != null) { try { queueConnection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java index c1899715f7..98126f6777 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationFilterTest.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.filter; +import junit.framework.TestCase; + import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; -import junit.framework.TestCase; - public class DestinationFilterTest extends TestCase { public void testPrefixFilter() throws Exception { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapMemoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapMemoryTest.java index 480a854e11..0da8c0d693 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapMemoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapMemoryTest.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,8 +41,7 @@ public class DestinationMapMemoryTest extends TestCase { ActiveMQDestination d1 = createDestination(name); DestinationMap map = new DestinationMap(); map.put(d1, d1); - } - catch (Throwable e) { + } catch (Throwable e) { fail("Destination name too long: " + name + " : " + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTempDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTempDestinationTest.java index 2a2d2fcf01..8d64e8b9c5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTempDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTempDestinationTest.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, @@ -42,4 +42,4 @@ public class DestinationMapTempDestinationTest extends TestCase { assertTrue(set.isEmpty()); } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTest.java index 2930fdf45f..4b80ac1739 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationMapTest.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, @@ -23,12 +23,12 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import junit.framework.TestCase; + import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; -import junit.framework.TestCase; - public class DestinationMapTest extends TestCase { protected DestinationMap map = new DestinationMap(); @@ -412,11 +412,9 @@ public class DestinationMapTest extends TestCase { List expectedList = null; if (expected == null) { expectedList = Collections.EMPTY_LIST; - } - else if (expected instanceof List) { + } else if (expected instanceof List) { expectedList = (List) expected; - } - else { + } else { expectedList = new ArrayList(); expectedList.add(expected); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationPathTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationPathTest.java index f3972a7035..2484585e31 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationPathTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DestinationPathTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicy.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicy.java index e3cf9e8733..9cfff27e9a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicy.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicy.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyEntry.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyEntry.java index 547d2c913b..ea8a871f7a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyEntry.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyEntry.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyTest.java index 0b94174fa8..14d1a02548 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/filter/DummyPolicyTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java index 450ef33178..c6738fa75d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.jmx; +import javax.management.ObjectName; + import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.jmx.BrokerViewMBean; import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean; import org.junit.Test; -import javax.management.ObjectName; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/OpenTypeSupportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/OpenTypeSupportTest.java index 1f71e14e24..818b9f2628 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/OpenTypeSupportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jmx/OpenTypeSupportTest.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, @@ -81,8 +81,7 @@ public class OpenTypeSupportTest { toSend.writeBytes(BYTESMESSAGE_TEXT.getBytes()); MessageProducer producer = session.createProducer(queue); producer.send(queue, toSend); - } - finally { + } finally { conn.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java index 86904729c9..247b8dcada 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java index a89c94ce25..922bd13935 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQWASInitialContextFactoryTest.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, @@ -16,9 +16,8 @@ */ package org.apache.activemq.jndi; -import java.util.Hashtable; - import javax.naming.Context; +import java.util.Hashtable; public class ActiveMQWASInitialContextFactoryTest extends JNDITestSupport { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/CustomConnectionFactoryNameTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/CustomConnectionFactoryNameTest.java index 2395974ebb..cf8b3c66a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/CustomConnectionFactoryNameTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/CustomConnectionFactoryNameTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/DestinationNameWithSlashTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/DestinationNameWithSlashTest.java index 8bdf2273d6..223fb7da19 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/DestinationNameWithSlashTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/DestinationNameWithSlashTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java index 575ab880f4..adffb4a43b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.jndi; -import java.util.Properties; - import javax.naming.Context; import javax.naming.InitialContext; +import java.util.Properties; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/JNDITestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/JNDITestSupport.java index a00ffee7c7..bbb5853384 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/JNDITestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/JNDITestSupport.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.jndi; -import java.util.Hashtable; - import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; @@ -26,6 +24,7 @@ import javax.naming.Context; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; +import java.util.Hashtable; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ObjectFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ObjectFactoryTest.java index d322278170..e6855beb0e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ObjectFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ObjectFactoryTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java index 801c475d13..5b205c0503 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/ActiveMQAdmin.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/ActiveMQAdmin.java index b3383f30f1..de226d5cbc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/ActiveMQAdmin.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/ActiveMQAdmin.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.joramtests; -import java.io.File; -import java.net.URI; -import java.util.Hashtable; - import javax.jms.ConnectionFactory; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import java.io.File; +import java.net.URI; +import java.util.Hashtable; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -46,8 +45,7 @@ public class ActiveMQAdmin implements Admin { env.put("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory"); env.put("java.naming.factory.url.pkgs", "org.eclipse.jetty.jndi"); context = new InitialContext(env); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -95,8 +93,7 @@ public class ActiveMQAdmin implements Admin { public void createQueue(String name) { try { context.bind(name, new ActiveMQQueue(name)); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -105,8 +102,7 @@ public class ActiveMQAdmin implements Admin { public void createTopic(String name) { try { context.bind(name, new ActiveMQTopic(name)); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -116,8 +112,7 @@ public class ActiveMQAdmin implements Admin { // BrokerTestSupport.delete_queue((Broker)base.broker, name); try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -126,8 +121,7 @@ public class ActiveMQAdmin implements Admin { public void deleteTopic(String name) { try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -138,8 +132,7 @@ public class ActiveMQAdmin implements Admin { final ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); ((ActiveMQConnectionFactory) factory).setNestedMapAndListEnabled(false); context.bind(name, factory); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -148,8 +141,7 @@ public class ActiveMQAdmin implements Admin { public void deleteConnectionFactory(String name) { try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/JoramJmsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/JoramJmsTest.java index 0955294bf1..a15f32b89a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/JoramJmsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/joramtests/JoramJmsTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBStoreBrokerTest.java index 7854af035a..6ec80f2623 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBStoreBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBStoreBrokerTest.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, @@ -16,15 +16,15 @@ */ package org.apache.activemq.leveldb; +import java.io.File; +import java.io.IOException; + import junit.framework.Test; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerTest; import org.apache.activemq.store.PersistenceAdapter; -import java.io.File; -import java.io.IOException; - /** * @author Hiram Chirino */ diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBXARecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBXARecoveryBrokerTest.java index ca1a72a597..1c7b7f92fd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBXARecoveryBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/leveldb/LevelDBXARecoveryBrokerTest.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, @@ -45,8 +45,7 @@ public class LevelDBXARecoveryBrokerTest extends XARecoveryBrokerTest { try { File levelDbDir = new File(levelDbDirectoryName); FileUtils.deleteDirectory(levelDbDir); - } - catch (IOException e) { + } catch (IOException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadClient.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadClient.java index 4a0146cc9a..556f06da0b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadClient.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadClient.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, @@ -93,13 +93,11 @@ public class LoadClient implements Runnable { if (result != null) { send(result); rate.increment(); - } - else if (running) { + } else if (running) { LOG.error(name + " Failed to consume!"); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadController.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadController.java index 31ea4c1f47..78d93eb9a5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadController.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadController.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.load; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * @@ -67,11 +66,9 @@ public class LoadController extends LoadClient { } } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); - } - finally { + } finally { stopped.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadTest.java index 2d9443db92..0eb45d2f6a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/load/LoadTest.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,15 +83,13 @@ public class LoadTest extends TestCase { Destination inDestination = null; if (i == 0) { inDestination = startDestination; - } - else { + } else { inDestination = createDestination(managementSession, getClass() + ".client." + (i)); } Destination outDestination = null; if (i == (numberOfClients - 1)) { outDestination = endDestination; - } - else { + } else { outDestination = createDestination(managementSession, getClass() + ".client." + (i + 1)); } LoadClient client = new LoadClient("client(" + i + ")", factory); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundaryStatisticTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundaryStatisticTest.java index 0ce7a01054..f53a06e8f4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundaryStatisticTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundaryStatisticTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundedRangeStatisticTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundedRangeStatisticTest.java index ded835b771..1c5d497a95 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundedRangeStatisticTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/BoundedRangeStatisticTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/CountStatisticTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/CountStatisticTest.java index 4c7a658874..fff320df32 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/CountStatisticTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/CountStatisticTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/RangeStatisticTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/RangeStatisticTest.java index 887527edac..a44dc6108b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/RangeStatisticTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/RangeStatisticTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/StatisticTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/StatisticTestSupport.java index 9e01f3d932..c96287ef20 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/StatisticTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/StatisticTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/TimeStatisticTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/TimeStatisticTest.java index b32f8ce7b7..de20b19fde 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/TimeStatisticTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/management/TimeStatisticTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/MemoryPropertyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/MemoryPropertyTest.java index 701f5e7dfa..f4d904f9b5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/MemoryPropertyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/MemoryPropertyTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/DummyMessage.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/DummyMessage.java index 368b971a01..74946b3f16 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/DummyMessage.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/DummyMessage.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java index 9ddfc65a6a..f7e0260e5d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/MemoryBufferTestSupport.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, @@ -19,8 +19,6 @@ package org.apache.activemq.memory.buffer; import junit.framework.TestCase; import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.memory.buffer.MessageBuffer; -import org.apache.activemq.memory.buffer.MessageQueue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java index b89b0a5200..8ddf594499 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/OrderBasedMemoryBufferTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.memory.buffer; -import org.apache.activemq.memory.buffer.MessageBuffer; -import org.apache.activemq.memory.buffer.OrderBasedMessageBuffer; - /** * * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java index ed7575e467..2329c5f0ae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/memory/buffer/SizeBasedMessageBufferTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.memory.buffer; -import org.apache.activemq.memory.buffer.MessageBuffer; -import org.apache.activemq.memory.buffer.SizeBasedMessageBuffer; - /** * * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/BrokerNetworkWithStuckMessagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/BrokerNetworkWithStuckMessagesTest.java index c483715a65..ce7c5eae9d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/BrokerNetworkWithStuckMessagesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/BrokerNetworkWithStuckMessagesTest.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, @@ -16,11 +16,14 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageNotWriteableException; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; import java.io.File; import java.io.IOException; import java.net.URI; @@ -33,16 +36,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.MessageNotWriteableException; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.Session; -import javax.management.ObjectName; - -import javax.management.openmbean.CompositeData; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerTestSupport; @@ -75,6 +68,11 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + /** * This class duplicates most of the functionality in {@link NetworkTestSupport} * and {@link BrokerTestSupport} because more control was needed over how brokers @@ -496,8 +494,7 @@ public class BrokerNetworkWithStuckMessagesTest { list.add(enumn.nextElement()); } messages = list.toArray(); - } - finally { + } finally { if (session != null) { session.close(); } @@ -570,8 +567,7 @@ public class BrokerNetworkWithStuckMessagesTest { DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType); connection.send(info); return info.getDestination(); - } - else { + } else { return ActiveMQDestination.createDestination(queueName, destinationType); } } @@ -589,8 +585,7 @@ public class BrokerNetworkWithStuckMessagesTest { message.setPersistent(false); try { message.setText("Test Message Payload."); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } return message; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CheckDuplicateMessagesOnDuplexTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CheckDuplicateMessagesOnDuplexTest.java index 19122151bf..7fa257b1f1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CheckDuplicateMessagesOnDuplexTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CheckDuplicateMessagesOnDuplexTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.network; -import java.io.File; -import java.io.IOException; -import java.net.Socket; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -32,6 +24,13 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.net.ServerSocketFactory; +import java.io.File; +import java.io.IOException; +import java.net.Socket; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -57,7 +56,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; /** * @author x22koe @@ -285,8 +286,7 @@ public class CheckDuplicateMessagesOnDuplexTest { private PersistenceAdapter persistenceAdapterFactory(String path) { if (useLevelDB) { return persistenceAdapterFactory_LevelDB(path); - } - else { + } else { return persistenceAdapterFactory_KahaDB(path); } } @@ -347,8 +347,7 @@ public class CheckDuplicateMessagesOnDuplexTest { log.warn("\n\nclosing connection before response is sent\n\n"); try { ((NIOTransport) next).stop(); - } - catch (Exception ex) { + } catch (Exception ex) { log.error("couldn't stop niotransport", ex); } // don't send response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java index 2ae7bc7663..19beb7f550 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.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, @@ -16,16 +16,6 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.UUID; -import java.util.concurrent.ConcurrentMap; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -35,6 +25,11 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.StreamMessage; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -58,6 +53,10 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class CompressionOverNetworkTest { protected static final int RECEIVE_TIMEOUT_MILLS = 10000; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeFilterTest.java index dacc9f05f6..164e01adec 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeFilterTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.network; +import java.util.Arrays; + import junit.framework.Test; import org.apache.activemq.broker.StubConnection; @@ -26,8 +28,6 @@ import org.apache.activemq.command.Message; import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.SessionInfo; -import java.util.Arrays; - public class DemandForwardingBridgeFilterTest extends NetworkTestSupport { private DemandForwardingBridge bridge; @@ -191,4 +191,4 @@ public class DemandForwardingBridgeFilterTest extends NetworkTestSupport { bridge.start(); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java index aac61ff102..48794286c0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DemandForwardingBridgeTest.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, @@ -139,8 +139,7 @@ public class DemandForwardingBridgeTest extends NetworkTestSupport { // subscriptions. try { Thread.sleep(1000); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { ie.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java index 526f0e531c..eb0773f51f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.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, @@ -16,19 +16,18 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeNotNull; - +import javax.management.ObjectName; import java.net.MalformedURLException; import java.util.Set; -import javax.management.ObjectName; - import org.apache.activemq.broker.BrokerService; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeNotNull; + public class DuplexNetworkMBeanTest { protected static final Logger LOG = LoggerFactory.getLogger(DuplexNetworkMBeanTest.class); @@ -66,8 +65,7 @@ public class DuplexNetworkMBeanTest { assertEquals(1, countMbeans(networkedBroker, "networkBridge", 2000)); assertEquals(1, countMbeans(broker, "networkBridge", 2000)); assertEquals(2, countMbeans(broker, "connectionName")); - } - finally { + } finally { networkedBroker.stop(); networkedBroker.waitUntilStopped(); } @@ -79,8 +77,7 @@ public class DuplexNetworkMBeanTest { assertEquals(0, countMbeans(networkedBroker, "connector")); assertEquals(0, countMbeans(networkedBroker, "connectionName")); assertEquals(1, countMbeans(broker, "connector")); - } - finally { + } finally { broker.stop(); broker.waitUntilStopped(); } @@ -102,8 +99,7 @@ public class DuplexNetworkMBeanTest { broker.start(); assertEquals(1, countMbeans(networkedBroker, "networkBridge", 5000)); assertEquals("restart number: " + i, 2, countMbeans(broker, "connectionName", 10000)); - } - finally { + } finally { broker.stop(); broker.waitUntilStopped(); } @@ -113,8 +109,7 @@ public class DuplexNetworkMBeanTest { assertEquals(1, countMbeans(networkedBroker, "connector=networkConnectors")); assertEquals(0, countMbeans(networkedBroker, "connectionName")); assertEquals(0, countMbeans(broker, "connectionName")); - } - finally { + } finally { networkedBroker.stop(); networkedBroker.waitUntilStopped(); } @@ -143,8 +138,7 @@ public class DuplexNetworkMBeanTest { mbeans = broker.getManagementContext().queryNames(beanName, null); if (mbeans != null) { count = mbeans.size(); - } - else { + } else { logAllMbeans(broker); } } while ((mbeans == null || mbeans.isEmpty()) && expiryTime > System.currentTimeMillis()); @@ -166,8 +160,7 @@ public class DuplexNetworkMBeanTest { for (ObjectName on : all) { LOG.info(on.toString()); } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.warn("getMBeanServer ex: " + ignored); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java index ddfba7d91a..1f89eca86f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import javax.jms.MessageProducer; import javax.jms.TemporaryQueue; @@ -26,6 +23,9 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.util.Wait; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class DuplexNetworkTest extends SimpleNetworkTest { @Override diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DynamicallyIncludedDestinationsDuplexNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DynamicallyIncludedDestinationsDuplexNetworkTest.java index 1f7cbb5ad2..2d6544562b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DynamicallyIncludedDestinationsDuplexNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/DynamicallyIncludedDestinationsDuplexNetworkTest.java @@ -16,15 +16,10 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import java.lang.reflect.Field; -import java.util.concurrent.CopyOnWriteArrayList; - import javax.jms.MessageProducer; import javax.jms.TemporaryQueue; +import java.lang.reflect.Field; +import java.util.concurrent.CopyOnWriteArrayList; import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.broker.BrokerService; @@ -32,6 +27,10 @@ import org.apache.activemq.broker.TransportConnection; import org.apache.activemq.broker.TransportConnector; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + /** * @author Christian Posta */ diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java index d541a15642..49dc7f863e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.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, @@ -16,20 +16,6 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Vector; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -39,6 +25,16 @@ import javax.jms.Session; import javax.management.ObjectName; import javax.net.ssl.KeyManager; import javax.net.ssl.TrustManager; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Vector; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -56,6 +52,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class FailoverStaticNetworkTest { protected static final Logger LOG = LoggerFactory.getLogger(FailoverStaticNetworkTest.class); @@ -215,8 +214,7 @@ public class FailoverStaticNetworkTest { public void run() { try { slave.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.add(e); } @@ -260,8 +258,7 @@ public class FailoverStaticNetworkTest { public void run() { try { slave.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -358,8 +355,7 @@ public class FailoverStaticNetworkTest { // restart after peer taken over brokerA1.waitUntilStarted(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info("A create/start, unexpected: " + ignored, ignored); } } @@ -389,8 +385,7 @@ public class FailoverStaticNetworkTest { // restart after peer taken over brokerA.waitUntilStarted(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info("A1 create/start, unexpected: " + ignored, ignored); } } @@ -445,8 +440,7 @@ public class FailoverStaticNetworkTest { }); try { consConn.close(); - } - catch (JMSException ignored) { + } catch (JMSException ignored) { } assertTrue("consumer on A got message", gotMessage); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/ForwardingBridgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/ForwardingBridgeTest.java index 30df2b4254..441fc4ddf2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/ForwardingBridgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/ForwardingBridgeTest.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, @@ -68,8 +68,7 @@ public class ForwardingBridgeTest extends NetworkTestSupport { // Give forwarding bridge a chance to finish setting up try { Thread.sleep(1000); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { ie.printStackTrace(); } @@ -114,8 +113,7 @@ public class ForwardingBridgeTest extends NetworkTestSupport { // Give forwarding bridge a chance to finish setting up try { Thread.sleep(1000); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { ie.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java index 4ee1adb7b8..744dd381a2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.network; -import java.net.URI; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -28,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import javax.management.ObjectName; +import java.net.URI; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -155,8 +154,7 @@ public class MQTTNetworkOfBrokersFailoverTest extends NetworkTestSupport { try { session.close(); connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MulticastNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MulticastNetworkTest.java index 0bf10d4f6c..c2b9cd9167 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MulticastNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MulticastNetworkTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java index 1c89002af0..dfe16579c7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkBrokerDetachTest.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Message; @@ -30,6 +23,10 @@ import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.TopicSubscriber; import javax.management.ObjectName; +import java.io.File; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQPrefetchPolicy; @@ -46,6 +43,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + public class NetworkBrokerDetachTest { private final static String BROKER_NAME = "broker"; @@ -254,8 +253,7 @@ public class NetworkBrokerDetachTest { if (destination.isQueue()) { destinations = broker.getAdminView().getQueues(); - } - else { + } else { destinations = broker.getAdminView().getTopics(); } @@ -272,8 +270,7 @@ public class NetworkBrokerDetachTest { } } - } - catch (Exception ignoreAndRetry) { + } catch (Exception ignoreAndRetry) { } return result; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkConnectionsTest.java index 0d5639c08c..bc9422b279 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkConnectionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkConnectionsTest.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, @@ -16,6 +16,12 @@ */ package org.apache.activemq.network; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -25,8 +31,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; - public class NetworkConnectionsTest extends TestCase { private static final Logger LOG = LoggerFactory.getLogger(NetworkConnectionsTest.class); @@ -244,4 +248,4 @@ public class NetworkConnectionsTest extends TestCase { remoteBroker = null; } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkDestinationFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkDestinationFilterTest.java index b1db5af703..a16f9b0d91 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkDestinationFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkDestinationFilterTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.network; +import java.util.ArrayList; +import java.util.List; + import junit.framework.TestCase; import org.apache.activemq.advisory.AdvisorySupport; @@ -24,9 +27,6 @@ import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTempQueue; import org.apache.activemq.command.ActiveMQTopic; -import java.util.ArrayList; -import java.util.List; - public class NetworkDestinationFilterTest extends TestCase { public void testFilter() throws Exception { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkFailoverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkFailoverTest.java index 5e24b5e30a..1475254068 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkFailoverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkFailoverTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.network; -import java.io.IOException; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -30,6 +27,8 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; @@ -82,18 +81,15 @@ public class NetworkFailoverTest extends TestCase { remoteProducer.send(replyTo, textMsg); LOG.info("replied with: " + textMsg.getJMSMessageID()); - } - catch (DestinationDoesNotExistException expected) { + } catch (DestinationDoesNotExistException expected) { // been removed but not yet recreated replyToNonExistDest.incrementAndGet(); try { LOG.info("NED: " + textMsg.getJMSMessageID()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } - } - catch (Exception e) { + } catch (Exception e) { LOG.warn("*** Responder listener caught exception: ", e); e.printStackTrace(); } @@ -112,8 +108,7 @@ public class NetworkFailoverTest extends TestCase { public void onMessage(Message message) { try { LOG.info("dlq " + message.getJMSMessageID()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } remoteDLQCount.incrementAndGet(); @@ -161,19 +156,16 @@ public class NetworkFailoverTest extends TestCase { try { localConnection.close(); remoteConnection.close(); - } - catch (Exception ex) { + } catch (Exception ex) { } try { localBroker.stop(); - } - catch (Exception ex) { + } catch (Exception ex) { } try { remoteBroker.stop(); - } - catch (Exception ex) { + } catch (Exception ex) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoadTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoadTest.java index 5471218f48..fbf261c1ff 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoadTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoadTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.network; -import java.net.URI; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -33,6 +25,13 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import junit.framework.TestCase; @@ -96,8 +95,7 @@ public class NetworkLoadTest extends TestCase { try { producer.send(msg); forwardCounter.incrementAndGet(); - } - catch (JMSException e) { + } catch (JMSException e) { // this is caused by the connection getting closed. } } @@ -269,8 +267,7 @@ public class NetworkLoadTest extends TestCase { producer.send(msg); producedMessages.incrementAndGet(); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java index 34c9a1bde4..a9ffceeebc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.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, @@ -16,14 +16,14 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.util.Wait; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class NetworkLoopBackTest { @Test @@ -33,8 +33,7 @@ public class NetworkLoopBackTest { TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0"); // connection filter is bypassed when scheme is different - final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" - + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")"); + final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")"); brokerServce.start(); brokerServce.waitUntilStarted(); @@ -59,9 +58,8 @@ public class NetworkLoopBackTest { assertEquals("No peer brokers", 0, brokerServce.getBroker().getPeerBrokerInfos().length); - } - finally { + } finally { brokerServce.stop(); } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkReconnectTest.java index 8e345f491f..0639fb1b80 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkReconnectTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.network; -import java.net.URI; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -28,6 +23,10 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; @@ -201,13 +200,11 @@ public class NetworkReconnectTest extends TestCase { disposeConsumerConnections(); try { stopProducerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } try { stopConsumerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -216,8 +213,7 @@ public class NetworkReconnectTest extends TestCase { Connection connection = iter.next(); try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -275,12 +271,10 @@ public class NetworkReconnectTest extends TestCase { Message message = session.createMessage(); producer.send(message); return message.getJMSMessageID(); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRemovesSubscriptionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRemovesSubscriptionsTest.java index 7c2a61d22d..f95db967f6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRemovesSubscriptionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRemovesSubscriptionsTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartPlainTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartPlainTest.java index 02cbbcd023..30eda2de23 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartPlainTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartPlainTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartTest.java index d100c54e01..eb09903d19 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRestartTest.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, @@ -16,6 +16,13 @@ */ package org.apache.activemq.network; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; import org.apache.activemq.broker.BrokerService; @@ -26,8 +33,6 @@ import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import javax.jms.*; - public class NetworkRestartTest extends TestSupport { private static final Logger LOG = LoggerFactory.getLogger(NetworkRestartTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRouteTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRouteTest.java index 1b0390bafa..f712349c13 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRouteTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkRouteTest.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, @@ -339,4 +339,4 @@ public class NetworkRouteTest { Assert.assertTrue(latch.await(timeout, unit)); } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkTestSupport.java index 722459c492..f5ceabd227 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SSHTunnelNetworkReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SSHTunnelNetworkReconnectTest.java index ba10f4536d..a07f8210e7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SSHTunnelNetworkReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SSHTunnelNetworkReconnectTest.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, @@ -70,8 +70,7 @@ public class SSHTunnelNetworkReconnectTest extends NetworkReconnectTest { while ((c = is.read()) >= 0) { System.out.write(c); } - } - catch (IOException e) { + } catch (IOException e) { } } }.start(); @@ -84,8 +83,7 @@ public class SSHTunnelNetworkReconnectTest extends NetworkReconnectTest { while ((c = is.read()) >= 0) { System.err.write(c); } - } - catch (IOException e) { + } catch (IOException e) { } } }.start(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java index 171fae1385..b5005021c5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.network; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.net.URI; -import java.util.Arrays; -import java.util.concurrent.ConcurrentMap; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -36,6 +28,9 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.TopicRequestor; import javax.jms.TopicSession; +import java.net.URI; +import java.util.Arrays; +import java.util.concurrent.ConcurrentMap; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -56,6 +51,10 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + public class SimpleNetworkTest { protected static final int MESSAGE_COUNT = 10; @@ -113,8 +112,7 @@ public class SimpleNetworkTest { textMsg.clearBody(); textMsg.setText(payload); remoteProducer.send(replyTo, textMsg); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -177,7 +175,7 @@ public class SimpleNetworkTest { LOG.info(brokerService + " bridges " + Arrays.toString(bridges)); DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0]; ConcurrentMap forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap(); - LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges); + LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges); if (!forwardingBridges.isEmpty()) { for (DemandSubscription demandSubscription : forwardingBridges.values()) { if (demandSubscription.getLocalInfo().getDestination().equals(destination)) { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeStandaloneReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeStandaloneReconnectTest.java index b76c85924b..04c416fb01 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeStandaloneReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeStandaloneReconnectTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.network.jms; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Iterator; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -29,6 +24,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Iterator; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -38,6 +35,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; + public class QueueBridgeStandaloneReconnectTest { private SimpleJmsQueueConnector jmsQueueConnector; @@ -228,19 +227,16 @@ public class QueueBridgeStandaloneReconnectTest { try { jmsQueueConnector.stop(); jmsQueueConnector = null; - } - catch (Exception e) { + } catch (Exception e) { } try { stopLocalBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } try { stopForeignBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -249,8 +245,7 @@ public class QueueBridgeStandaloneReconnectTest { Connection connection = iter.next(); try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -325,12 +320,10 @@ public class QueueBridgeStandaloneReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -344,12 +337,10 @@ public class QueueBridgeStandaloneReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeTest.java index 9355714195..e53025c73d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeTest.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, @@ -106,8 +106,7 @@ public class QueueBridgeTest extends TestCase implements MessageListener { textMsg.clearBody(); textMsg.setText(payload); requestServerProducer.send(replyTo, textMsg); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeXBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeXBeanTest.java index 120792c376..ac31262525 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeXBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueBridgeXBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueOutboundBridgeReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueOutboundBridgeReconnectTest.java index 04e2a29d38..be6d2eee85 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueOutboundBridgeReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/QueueOutboundBridgeReconnectTest.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.network.jms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -33,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -42,6 +36,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + /** * These test cases are used to verify that queue outbound bridge connections get * re-established in all broker restart scenarios. This is possible when the @@ -232,13 +231,11 @@ public class QueueOutboundBridgeReconnectTest { disposeConsumerConnections(); try { stopProducerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } try { stopConsumerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -247,8 +244,7 @@ public class QueueOutboundBridgeReconnectTest { Connection connection = iter.next(); try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -327,12 +323,10 @@ public class QueueOutboundBridgeReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeSpringTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeSpringTest.java index bd3336266f..9c00180b95 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeSpringTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeSpringTest.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, @@ -102,8 +102,7 @@ public class TopicBridgeSpringTest extends TestCase implements MessageListener { textMsg.setText(payload); LOG.info("Sending response: " + textMsg); requestServerProducer.send(replyTo, textMsg); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeStandaloneReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeStandaloneReconnectTest.java index 34236ff6e4..81f7d9380b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeStandaloneReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeStandaloneReconnectTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.network.jms; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Iterator; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -29,6 +24,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Iterator; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -38,6 +35,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; + public class TopicBridgeStandaloneReconnectTest { private SimpleJmsTopicConnector jmsTopicConnector; @@ -225,19 +224,16 @@ public class TopicBridgeStandaloneReconnectTest { try { jmsTopicConnector.stop(); jmsTopicConnector = null; - } - catch (Exception e) { + } catch (Exception e) { } try { stopLocalBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } try { stopForeignBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -246,8 +242,7 @@ public class TopicBridgeStandaloneReconnectTest { Connection connection = iter.next(); try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -322,12 +317,10 @@ public class TopicBridgeStandaloneReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -341,12 +334,10 @@ public class TopicBridgeStandaloneReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeXBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeXBeanTest.java index 747d59cb5c..72913ada0c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeXBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicBridgeXBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicOutboundBridgeReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicOutboundBridgeReconnectTest.java index dfcf4a850f..f7eadfaec0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicOutboundBridgeReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/jms/TopicOutboundBridgeReconnectTest.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.network.jms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -33,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -42,6 +36,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + /** * These test cases are used to verify that queue outbound bridge connections get * re-established in all broker restart scenarios. This is possible when the @@ -220,13 +219,11 @@ public class TopicOutboundBridgeReconnectTest { disposeConsumerConnections(); try { stopProducerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } try { stopConsumerBroker(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -235,8 +232,7 @@ public class TopicOutboundBridgeReconnectTest { Connection connection = iter.next(); try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } @@ -314,12 +310,10 @@ public class TopicOutboundBridgeReconnectTest { TextMessage message = session.createTextMessage(); message.setText(text); producer.send(message); - } - finally { + } finally { try { connection.close(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java index e31aece154..3fa3376cf6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.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, @@ -79,8 +79,7 @@ public class BooleanStreamTest extends TestCase { for (int i = 0; i < numberOfBytes; i++) { try { assertMarshalBooleans(i, valueSet); - } - catch (Throwable e) { + } catch (Throwable e) { throw (AssertionFailedError) new AssertionFailedError("Iteration failed at: " + i).initCause(e); } } @@ -104,8 +103,7 @@ public class BooleanStreamTest extends TestCase { bs = new BooleanStream(); try { bs.unmarshal(dis); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail("Failed to unmarshal: " + count + " booleans: " + e); } @@ -118,8 +116,7 @@ public class BooleanStreamTest extends TestCase { try { boolean actual = bs.readBoolean(); assertEquals("value of object: " + i + " was: " + actual, expected, actual); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); fail("Failed to parse boolean: " + i + " out of: " + count + " due to: " + e); } @@ -131,8 +128,7 @@ public class BooleanStreamTest extends TestCase { try { dis.readByte(); fail("Should have reached the end of the stream"); - } - catch (IOException e) { + } catch (IOException e) { // worked! } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BrokerInfoData.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BrokerInfoData.java index 6b4e09023d..acf667e001 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BrokerInfoData.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/BrokerInfoData.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGenerator.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGenerator.java index 029ee7128c..6660579874 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGenerator.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGenerator.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, @@ -71,8 +71,7 @@ public abstract class DataFileGenerator extends org.junit.Assert { try { // System.out.println("Processing: "+object.getClass()); element.generateControlFile(); - } - catch (Exception e) { + } catch (Exception e) { // System.err.println("Error while processing: // "+object.getClass() + ". Reason: " + e); } @@ -133,8 +132,7 @@ public abstract class DataFileGenerator extends org.junit.Assert { assertEquals(a, b); } is2.close(); - } - finally { + } finally { is1.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java index cbaa099ff5..af22acbc5d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.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, @@ -75,8 +75,7 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport { URL resource = DataFileGeneratorTestSupport.class.getResource("DataFileGeneratorTestSupport.class"); URI baseURI = new URI(resource.toString()).resolve("../../../../.."); basedir = new File(baseURI).getCanonicalFile(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } MODULE_BASE_DIR = basedir; @@ -131,8 +130,7 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport { try { expectedValue = method.invoke(expected, EMPTY_ARGUMENTS); actualValue = method.invoke(actual, EMPTY_ARGUMENTS); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Failed to access property: " + name); } assertPropertyValuesEqual(message + name, comparedObjects, expectedValue, actualValue); @@ -147,27 +145,20 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport { String message = "Property " + name + " not equal"; if (expectedValue == null) { assertNull("Property " + name + " should be null", actualValue); - } - else if (expectedValue instanceof Object[]) { + } else if (expectedValue instanceof Object[]) { assertArrayEqual(message, comparedObjects, (Object[]) expectedValue, (Object[]) actualValue); - } - else if (expectedValue.getClass().isArray()) { + } else if (expectedValue.getClass().isArray()) { assertPrimitiveArrayEqual(message, comparedObjects, expectedValue, actualValue); - } - else { + } else { if (expectedValue instanceof Exception) { assertExceptionsEqual(message, (Exception) expectedValue, actualValue); - } - else if (expectedValue instanceof ByteSequence) { + } else if (expectedValue instanceof ByteSequence) { assertByteSequencesEqual(message, (ByteSequence) expectedValue, actualValue); - } - else if (expectedValue instanceof DataStructure) { + } else if (expectedValue instanceof DataStructure) { assertBeansEqual(message + name, comparedObjects, expectedValue, actualValue); - } - else if (expectedValue instanceof Enumeration) { + } else if (expectedValue instanceof Enumeration) { assertEnumerationEqual(message + name, comparedObjects, (Enumeration) expectedValue, (Enumeration) actualValue); - } - else { + } else { assertEquals(message, expectedValue, actualValue); } @@ -269,8 +260,7 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport { assertEquals("Data does not match control file: " + dataFile + " at byte position " + pos, a, b); } is2.close(); - } - finally { + } finally { is1.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/ItStillMarshallsTheSameTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/ItStillMarshallsTheSameTest.java index 186f028bc8..bfc0a2765d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/ItStillMarshallsTheSameTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/ItStillMarshallsTheSameTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/NumberRangesWhileMarshallingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/NumberRangesWhileMarshallingTest.java index a31a7d2025..f1741ff285 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/NumberRangesWhileMarshallingTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/NumberRangesWhileMarshallingTest.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, @@ -87,8 +87,7 @@ public class NumberRangesWhileMarshallingTest extends TestCase { try { byte value = dis.readByte(); fail("Should have reached the end of the stream: " + value); - } - catch (IOException e) { + } catch (IOException e) { // worked! } } @@ -110,8 +109,7 @@ public class NumberRangesWhileMarshallingTest extends TestCase { try { wf.unmarshal(dis); - } - catch (IOException ioe) { + } catch (IOException ioe) { return; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoData.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoData.java index c9689393af..edfea65e2d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoData.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoData.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQBytesMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQBytesMessageTest.java index 1a4fcf7d80..7f2e278e98 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQBytesMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQBytesMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQDestinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQDestinationTestSupport.java index 4c5a0db3ff..1a93c1440f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQDestinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQDestinationTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMapMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMapMessageTest.java index f9ec5d1943..e548b637ff 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMapMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMapMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMessageTest.java index bac2c5357c..07a41d9a29 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQObjectMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQObjectMessageTest.java index d67cb6ef00..62e8b490bf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQObjectMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQObjectMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQQueueTest.java index 8b57bcfb8c..c8d1955ab4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQStreamMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQStreamMessageTest.java index 3af498d189..4358efd9d6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQStreamMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQStreamMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempDestinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempDestinationTestSupport.java index 816715a9a6..9ee4501f71 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempDestinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempDestinationTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempQueueTest.java index 20f6f26980..4f384dc7af 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempTopicTest.java index d06c2f8113..19184c9b57 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTempTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTextMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTextMessageTest.java index 402c9e139c..c05c4192fa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTextMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTextMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTopicTest.java index fe8f74acd7..1ff226a9f7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ActiveMQTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BaseCommandTestSupport.java index 86357bd056..36cd2757c3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerIdTest.java index 2db742ce3b..e836e230ab 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerInfoTest.java index cd1bc98fd7..8996b0a31d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/BrokerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionControlTest.java index de4f29ec4d..4dc09ceb9b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionErrorTest.java index 5acd495198..a15fcccd28 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionErrorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionIdTest.java index 0ea97ea356..9ed08acd77 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionInfoTest.java index 3c1e8fa10d..0694637d1b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConnectionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerControlTest.java index 32727c60da..650e5e20a5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerIdTest.java index 1d37eb98a8..a93e8d9714 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerInfoTest.java index 10d4fab99e..9016caed6d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ConsumerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ControlCommandTest.java index b9393540cf..f260b2285f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ControlCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataArrayResponseTest.java index 92842b61ca..c118e8ef2e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataArrayResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataResponseTest.java index d360fa48c9..08e17cc2bd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DataResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DestinationInfoTest.java index 2c8b858785..4d8ea7cf35 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DestinationInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DiscoveryEventTest.java index 40a14c8b43..c09273695b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/DiscoveryEventTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ExceptionResponseTest.java index 126ced0d95..0a0929519e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ExceptionResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/FlushCommandTest.java index ced5ebfb0f..81d047482a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/FlushCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/IntegerResponseTest.java index 1d7231d8d1..8dd7570d09 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/IntegerResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalQueueAckTest.java index b9cc450545..24a8c99d84 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalQueueAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTopicAckTest.java index 66f6d797bb..e2060abb0a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTopicAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTraceTest.java index 2d3c9a35f8..61aca453b9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTraceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTransactionTest.java index ad79551bd3..1f2fd80da1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/JournalTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/KeepAliveInfoTest.java index 55b98c0a4f..2fd3077521 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/KeepAliveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LastPartialCommandTest.java index 3f7403ae5f..fb4fa73a14 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LastPartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LocalTransactionIdTest.java index 41041303ce..62692ef98e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/LocalTransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageAckTest.java index 1bf1bd985d..9e488d2629 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchNotificationTest.java index a211d95144..4d55a407a7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchNotificationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchTest.java index 2b0654a1db..5000a64bb9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageDispatchTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageIdTest.java index 6db063b9bc..2b78a68183 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java index 2313d61cbe..4de4329819 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java index 2798641778..ed7aa2124a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/PartialCommandTest.java index a2ee4b8564..2727aba2c6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/PartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerIdTest.java index 3e976e1a3b..0e60e062a5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerInfoTest.java index 67c7248e4a..fcae934fd4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ProducerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveInfoTest.java index 6f0986c9e2..b563a997fe 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveSubscriptionInfoTest.java index fd6751507a..a7b26c121f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/RemoveSubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ReplayCommandTest.java index 5dc3a8a14d..39af441c65 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ReplayCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ResponseTest.java index a063d007db..225980d789 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionIdTest.java index e01bd74e8b..93abd5b8dd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionInfoTest.java index 1b8cc8a30c..7436e9c03f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SessionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ShutdownInfoTest.java index 1b6da82cc5..f51c1eb10d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/ShutdownInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SubscriptionInfoTest.java index f049d1c1e8..923634fb52 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/SubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionIdTestSupport.java index 47a3fef8ab..bfac9fa615 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionIdTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionInfoTest.java index e9a08b4c99..9005a90b04 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/TransactionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/WireFormatInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/WireFormatInfoTest.java index bb639fce8b..36316f9a04 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/WireFormatInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/WireFormatInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/XATransactionIdTest.java index 8175154798..faa0039fe7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v1/XATransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQBytesMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQBytesMessageTest.java index 0dcaba04c0..10570fee6c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQBytesMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQBytesMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQDestinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQDestinationTestSupport.java index 3476e4310c..06738a8007 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQDestinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQDestinationTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMapMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMapMessageTest.java index a39cd08d06..c1087fcd0d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMapMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMapMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMessageTest.java index 4dd1f0b590..40315f3e29 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQObjectMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQObjectMessageTest.java index 8d5ef4bd95..03fa813936 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQObjectMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQObjectMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQQueueTest.java index dd13b5ed14..d840cc3733 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQStreamMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQStreamMessageTest.java index d96959a224..77251b044a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQStreamMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQStreamMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempDestinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempDestinationTestSupport.java index 480c16299e..ce188d3d84 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempDestinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempDestinationTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempQueueTest.java index d3ba1c9ced..0216d3d6b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempTopicTest.java index 9ddb5d7b23..583d4c6252 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTempTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTextMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTextMessageTest.java index 01d9cd107e..76a5e8f56a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTextMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTextMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTopicTest.java index 7ff1ad91c1..8d83dda7e7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ActiveMQTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BaseCommandTestSupport.java index 0e6e0eac9f..651723d010 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerIdTest.java index 52ec352ddf..3b2948763c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerInfoTest.java index cdc71b4880..825097e5d0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/BrokerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionControlTest.java index e048b27225..09cc02aaf4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionErrorTest.java index c82a1272c2..5c3523ab2a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionErrorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionIdTest.java index dbb5bffe08..9901348b56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionInfoTest.java index 729469d836..780ee49e7c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConnectionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerControlTest.java index 56a951214a..a83ec6b743 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerIdTest.java index f53b2d740c..6f71774496 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerInfoTest.java index 1290440f39..4d28d4f5e4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ConsumerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ControlCommandTest.java index ef5e90f5e7..f4ae6597c4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ControlCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataArrayResponseTest.java index b8696def12..84b9c92166 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataArrayResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataResponseTest.java index 43ef32f046..2b703510f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DataResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DestinationInfoTest.java index 9a0cb979cf..01d503c8d7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DestinationInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DiscoveryEventTest.java index cda035fdad..2487eb298e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/DiscoveryEventTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ExceptionResponseTest.java index 46b1170c94..1f762c7887 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ExceptionResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/FlushCommandTest.java index 22077ea1a1..a89b7ddb60 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/FlushCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/IntegerResponseTest.java index 67048f07be..0bf14b824c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/IntegerResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalQueueAckTest.java index f44661cfb8..22ee7597b9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalQueueAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTopicAckTest.java index c6397c7cb5..b12e594709 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTopicAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTraceTest.java index 7111b4fef9..1159ee9be1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTraceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTransactionTest.java index 890bc893a8..1e539b3f69 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/JournalTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/KeepAliveInfoTest.java index 0590fd45c8..51b0a83115 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/KeepAliveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LastPartialCommandTest.java index 58fefe703a..50cf355587 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LastPartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LocalTransactionIdTest.java index d5ff795482..5d76310f56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/LocalTransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageAckTest.java index ec07890425..c3f7d4523e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchNotificationTest.java index 2724d64db0..77e43276f0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchNotificationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchTest.java index ba6784dc24..576f7ff7a2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageDispatchTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageIdTest.java index 3c439383ca..be69084282 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessagePullTest.java index 3667df38e4..1dd49efe09 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessagePullTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java index ae4c3c7922..4664ec5397 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/NetworkBridgeFilterTest.java index 4520dd4736..6b3569d5b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/NetworkBridgeFilterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/PartialCommandTest.java index 6458d75d36..8b3e25110c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/PartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerIdTest.java index c3cb1c545a..1aaccca415 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerInfoTest.java index 33f33296b9..d43f9ef0a4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ProducerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveInfoTest.java index 512f9c762d..5b42d2cd42 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveSubscriptionInfoTest.java index 47218075e7..fb66887f3b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/RemoveSubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ReplayCommandTest.java index 3165b29977..b20df2eb0e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ReplayCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ResponseTest.java index 1723da590b..912107418f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionIdTest.java index ced44eecce..1a822fbce5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionInfoTest.java index 3d5b4a0d65..cee12fe5e7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SessionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ShutdownInfoTest.java index e94caed563..4aee0ab18d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/ShutdownInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SubscriptionInfoTest.java index 67799f3bf0..af5e5f73a0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/SubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionIdTestSupport.java index f1810bdfdb..68d9036bd0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionIdTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionInfoTest.java index 8978478858..1603680c6c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/TransactionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/WireFormatInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/WireFormatInfoTest.java index 94f51bac0f..581ec6a3d3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/WireFormatInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/WireFormatInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/XATransactionIdTest.java index 3d9ea6c30a..f9351f4f7c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v2/XATransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BaseCommandTestSupport.java index 1619b26d1a..e3a7fd51c8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerIdTest.java index e4ef68466f..a354bbb28c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerInfoTest.java index 494d7d2fee..514a17ef32 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/BrokerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionControlTest.java index 3106db476d..3428f67d56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionErrorTest.java index 8d23282fbd..9dcd8b0f7b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionErrorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionIdTest.java index 2a371b4ca1..174b805386 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionInfoTest.java index 9bc45ec271..a2435de7be 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConnectionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerControlTest.java index db11e7f1e9..a7daac91b8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerIdTest.java index 25e526f259..c0f465b2db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerInfoTest.java index c5c7253a4d..2dc4ac8d3f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ConsumerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ControlCommandTest.java index 4a1d72d589..ebd647e01d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ControlCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataArrayResponseTest.java index 877671a048..da7a7abfb0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataArrayResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataResponseTest.java index 3db762d5e0..434f7e883d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DataResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DestinationInfoTest.java index 6ee9f152dc..bfe7c6c76b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DestinationInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DiscoveryEventTest.java index 76b1ff5b66..af08c8da2d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/DiscoveryEventTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ExceptionResponseTest.java index fe90b22a5a..8dfcdcb6f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ExceptionResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/FlushCommandTest.java index c653d30fae..fd53a2b1aa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/FlushCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/IntegerResponseTest.java index e22c3ac9d2..e876406190 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/IntegerResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalQueueAckTest.java index 775caaca96..215bc0f1cc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalQueueAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTopicAckTest.java index 5883b8311c..01e094d72a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTopicAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTraceTest.java index 5df78b5009..eeeafdaeaa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTraceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTransactionTest.java index de9b925e16..f3bbc99a7d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/JournalTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/KeepAliveInfoTest.java index 932f1ba390..0d74b32e8a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/KeepAliveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LastPartialCommandTest.java index 694c4ccdcb..9a3035c84a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LastPartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LocalTransactionIdTest.java index 303266d63a..2ebe4ed5aa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/LocalTransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageAckTest.java index 0a5ce94bc5..1bdef6221d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchNotificationTest.java index 099adb091c..079b66cf36 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchNotificationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchTest.java index c6d29c014d..0a8bbe73ef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageDispatchTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageIdTest.java index a82b8f4687..8b51a81905 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessagePullTest.java index 5ce9770c6c..07a7bada89 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessagePullTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageTestSupport.java index 549d116378..589a483293 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/MessageTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/NetworkBridgeFilterTest.java index 625f000229..0e49d25edd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/NetworkBridgeFilterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/PartialCommandTest.java index 73da1c6003..f4b8ecb57c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/PartialCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerAckTest.java index 672ea8958e..bbfd34ce43 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerAckTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerIdTest.java index 1cab659c99..79c88ae78c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerInfoTest.java index 8e6ac5e137..b8b8c154fe 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ProducerInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveInfoTest.java index 92e4b2e707..5b440499dc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveSubscriptionInfoTest.java index 594cf9fcb5..fe66ee9ef9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/RemoveSubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ReplayCommandTest.java index 3b763f323b..0a7026cf08 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ReplayCommandTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ResponseTest.java index 5172b33907..6e006f973d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ResponseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionIdTest.java index 3947980594..9bf765c359 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionInfoTest.java index b51fb2f663..ab41bda733 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SessionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ShutdownInfoTest.java index cd635e9d58..e0c2c9c0bb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/ShutdownInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SubscriptionInfoTest.java index cbab21ffcd..fce5584505 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/SubscriptionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionIdTestSupport.java index 2bc91720eb..2c72ecaf3b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionIdTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionInfoTest.java index 4e0f84f9ea..c3206849f7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/TransactionInfoTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/XATransactionIdTest.java index be42e181bd..62dfe2b310 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v3/XATransactionIdTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BaseCommandTestSupport.java index ed5d454717..52be65f196 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerIdTest.java index 85ad9eb8bf..f4964e9322 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerInfoTest.java index 3d42b9984d..24aaa2a043 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionControlTest.java index f38169deae..b726603229 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionErrorTest.java index 56833239ce..a309991f19 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionIdTest.java index e4a9fb4eb2..2c3b61aa41 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionInfoTest.java index aa201848d8..7a872521b2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerControlTest.java index d537d80ddc..5a2f4e4c84 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerIdTest.java index 76e18e7783..6c6b669cef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerInfoTest.java index 6cf29b8355..f701062353 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ControlCommandTest.java index f68a8790d7..2bab9b6fb8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataArrayResponseTest.java index 9652b3eeb7..88b00c55a7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataResponseTest.java index b7e9480fa6..cc0e3631b5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DestinationInfoTest.java index b6e57ffdc8..e2c0afc781 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DiscoveryEventTest.java index 502664e56c..d4f67c5b5e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ExceptionResponseTest.java index 3167823cd2..e55479c829 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/FlushCommandTest.java index be1a2364a7..514713307a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/IntegerResponseTest.java index 45422ed62b..77133c638e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalQueueAckTest.java index f08a16c2f4..e6f8e97ae6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTopicAckTest.java index d9995398fa..8b52ed4eb9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTraceTest.java index 0510801b2b..e9c02432b1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTransactionTest.java index 0a06e7e74a..120763534d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/KeepAliveInfoTest.java index baf14c6717..eaf19db9a6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LastPartialCommandTest.java index e5a139322c..03070cd34e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LocalTransactionIdTest.java index 614a88c833..4822a7fc0e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageAckTest.java index 4bb868ad19..ccff13ba29 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchNotificationTest.java index ded1417b1b..bd0314b12f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchTest.java index 6d409fa81e..8303a173fa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageIdTest.java index 2cca89e5f9..09f4250923 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessagePullTest.java index 5a8da2ce01..d274e55b85 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageTestSupport.java index f84ddc97c2..21cd2af36c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/NetworkBridgeFilterTest.java index 3f84e5b548..56418e4c04 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/PartialCommandTest.java index 5b09d38f0c..3573136587 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerAckTest.java index 87fdd40e4c..3b3cf08751 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerIdTest.java index 74f6e13e1e..d6e2f90169 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerInfoTest.java index 76b6775493..6c854bcce9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveInfoTest.java index daf391b6ed..21ca091ea2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveSubscriptionInfoTest.java index ea0ebb47fc..a12b3cd0da 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ReplayCommandTest.java index 420147e31e..8824d6e708 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ResponseTest.java index 5f82253707..05fee2035e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionIdTest.java index bb5c27dd6b..9ba222b34f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionInfoTest.java index 28ce0d1806..ab8839ca91 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ShutdownInfoTest.java index dac9f3eeee..ffa3077723 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SubscriptionInfoTest.java index a682521183..8422d417e8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionIdTestSupport.java index d4cde65185..1898c46a38 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionInfoTest.java index 6ca9ea8d7c..309bdf0def 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/XATransactionIdTest.java index 65ec2573e2..cbf946277e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v4/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v4; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BaseCommandTestSupport.java index b3ba4e92e8..3c931926d3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerIdTest.java index 9b01645bdc..6af4001f41 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerInfoTest.java index b3cdfb03c4..59dff788f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionControlTest.java index 62dec7d1dc..d045984a6e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionErrorTest.java index a82a16f0c5..822fdbd63d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionIdTest.java index ec17470329..38f9967c5c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionInfoTest.java index f6a8485b19..e293217f13 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerControlTest.java index a1a2c59b40..0c192a38cf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerIdTest.java index 96455c66d5..f636235577 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerInfoTest.java index e41e91a80c..5ed6454236 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ControlCommandTest.java index 9f9b1f0849..e66b74f401 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataArrayResponseTest.java index d6e68f7486..787022f6c9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataResponseTest.java index 0eaf748dfd..191de06687 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DestinationInfoTest.java index 1bea2b2527..88bc918a13 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DiscoveryEventTest.java index 7ad1e811a4..8fec1235ce 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ExceptionResponseTest.java index adc0c8a780..df41e48ea5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/FlushCommandTest.java index cdd6a6a207..54638400e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/IntegerResponseTest.java index ef2addbb19..8b170d5223 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalQueueAckTest.java index df6ba9f417..e519ea2537 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTopicAckTest.java index e8af0d05d4..326914bc24 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTraceTest.java index 7a34e1f32c..ab874b8a95 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTransactionTest.java index 36e07613c5..f13943779d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/KeepAliveInfoTest.java index f265b915f9..1960c566a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LastPartialCommandTest.java index 1a22abadec..7f3fbf7c7b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LocalTransactionIdTest.java index 2d2cc71cde..93ec402995 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageAckTest.java index 65a1430d1f..ba20468415 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchNotificationTest.java index 08dad35d83..5fcf93e094 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchTest.java index a9e2db5128..8c9368205a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageIdTest.java index 8db2c7bb2e..f9404eedef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessagePullTest.java index 909ecf76c4..0972030bd2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageTestSupport.java index fc1345775f..697b051d80 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/NetworkBridgeFilterTest.java index 453001db35..0c9891b7a3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/PartialCommandTest.java index 91a838bb37..bbe24dd83d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerAckTest.java index 86bab603cb..b64e0c9319 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerIdTest.java index a261c2ba1f..5d7885604f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerInfoTest.java index d185753848..eb6a5d0c90 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveInfoTest.java index 98815db1ca..1f71d6404b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveSubscriptionInfoTest.java index 34a925dbd3..25e4410a96 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ReplayCommandTest.java index ee4b774a75..a6530f5ad4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ResponseTest.java index d7d4df7959..f63c26b442 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionIdTest.java index 1d3f0ddd8a..3cef0b03c9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionInfoTest.java index 4b44d15459..d06511a9fe 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ShutdownInfoTest.java index d6765abafc..1d2fca7a04 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SubscriptionInfoTest.java index 68d09ae46b..e945365de4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionIdTestSupport.java index 65c1763639..d6ea459077 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionInfoTest.java index 5912cce72d..5b29d31606 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/XATransactionIdTest.java index d20e621e13..a26668be0a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v5/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v5; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BaseCommandTestSupport.java index 108315ed15..1ac0e080b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerIdTest.java index baeca15c4f..71179b96d5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerInfoTest.java index c78ec217f8..e00f1f91ee 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionControlTest.java index f6d24459c9..e9cde78364 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionErrorTest.java index f29d4e60ea..32d0e36306 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionIdTest.java index 82b030a8ab..e25effeaf7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionInfoTest.java index 2eae19ed19..96e840c25f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerControlTest.java index 8f50bd8846..08402135ff 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerIdTest.java index 378576ea82..acefe2c66b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerInfoTest.java index c7c2c09593..3500e9cdc8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ControlCommandTest.java index 69dd3e5c08..c2ba00b87d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataArrayResponseTest.java index ebcb6a7503..fd8db144bc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataResponseTest.java index 3fe1e1b54a..a662b818b5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DestinationInfoTest.java index f170c94ad3..9f48c744e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DiscoveryEventTest.java index 8e59bfd2c9..c09d32e3e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ExceptionResponseTest.java index ae2c2c7265..3d27755ac5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/FlushCommandTest.java index 02fc89b4ff..abe7cfbddb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/IntegerResponseTest.java index 3dcd6059dc..6545cd3699 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalQueueAckTest.java index 00da5c72d3..01cbd668ca 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTopicAckTest.java index 5ff65cef82..5f7933306a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTraceTest.java index 25e956d9fe..9d0c6eb4f0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTransactionTest.java index 9a3f17b0e6..c930bc720e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/KeepAliveInfoTest.java index 1ddbc88c73..4ed368cd71 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LastPartialCommandTest.java index dbbd5d1482..0f3a14fbf4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LocalTransactionIdTest.java index a1b9e9a0f4..7ab143bc6c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageAckTest.java index 14e2809dd4..4d320dc3ac 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchNotificationTest.java index 4cc75f09da..8abbf04212 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchTest.java index 36c7d5c02d..8dde5a0177 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageIdTest.java index fb8ebdcff9..4d52b01eaa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessagePullTest.java index 9a0da9981a..fc49eeec81 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageTestSupport.java index 684ebddcf4..e8f61365e2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/NetworkBridgeFilterTest.java index 15da6e50ec..e4f5fec429 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/PartialCommandTest.java index ca5f5014f8..20f5556667 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerAckTest.java index 36285a03fc..957341ef1a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerIdTest.java index 10e3d74331..c3097ec6dd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerInfoTest.java index 6eaf17ef85..8e90b7ef08 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveInfoTest.java index 663ed3d64b..9539048663 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveSubscriptionInfoTest.java index e9791ea20a..d61422ece4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ReplayCommandTest.java index 5eb8091e99..ea048be68c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ResponseTest.java index 12e755b2da..eda8c7d82b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionIdTest.java index cc05667a5f..213c3ed801 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionInfoTest.java index 6849a1974b..3104d49452 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ShutdownInfoTest.java index 2821a90dcd..4d66b6e750 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SubscriptionInfoTest.java index b2522a814b..1748daf227 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionIdTestSupport.java index 277cbd21b9..c5d50dbf89 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionInfoTest.java index 7154c06fe8..ea5bddc869 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/XATransactionIdTest.java index fb2f5c8d94..72d8c3da4d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v6/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v6; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BaseCommandTestSupport.java index d78bf96a00..1e43e9700d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerIdTest.java index 7b6ce30e38..aebdbfcfb5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerInfoTest.java index 61dea9a02c..2ce6a44a6b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionControlTest.java index 58bbb62a0d..a687c889a3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionErrorTest.java index 2136544e0f..8d2624352c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionIdTest.java index 6f4b1a9485..a75aa4fa0f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionInfoTest.java index 1cc482ebdc..764ef2022c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerControlTest.java index 9bdacbac68..ce8f34eafd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerIdTest.java index 8e19d2e725..04437e238b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerInfoTest.java index 6df88721fe..8e2a847d1c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ControlCommandTest.java index 00271ebd4b..bdc7877c9d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataArrayResponseTest.java index 85e7ff2bd3..df71bd6a94 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataResponseTest.java index 24a3854a12..9c73ee4635 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DestinationInfoTest.java index c690e46276..b914fe0af0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DiscoveryEventTest.java index 1d4db3dbca..cb001cb076 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ExceptionResponseTest.java index 3057312ae6..f478646b4b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/FlushCommandTest.java index 9f1ea9bb6c..00d31cc504 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/IntegerResponseTest.java index c742a65980..2dc7f1e1f7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalQueueAckTest.java index 57ebdeed00..7147841564 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTopicAckTest.java index 3ccee12786..bee453c533 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTraceTest.java index 6b08025d91..94280d7bd7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTransactionTest.java index 9a9e2c22e6..79b687f5bc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/KeepAliveInfoTest.java index 006a6e94a6..9e961ca7e7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LastPartialCommandTest.java index 537bf1576a..7e145eba4b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LocalTransactionIdTest.java index 92d3b06943..b9591cb5ef 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageAckTest.java index 462b9b7f18..879647f109 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchNotificationTest.java index 31a5fbbb43..e8ec793681 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchTest.java index ed5c8bac03..119982aa0f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageIdTest.java index 0c395bde40..5fcd781067 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessagePullTest.java index 27f239df36..648dde8097 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageTestSupport.java index eb28e156ba..c96df4a03c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/NetworkBridgeFilterTest.java index c5f08f59ce..97d6acfe0d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/PartialCommandTest.java index 93566e3dd4..cb8d7a9c2c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerAckTest.java index da0565e7bc..97825a04cf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerIdTest.java index 6b1d550369..70252902a8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerInfoTest.java index a70e7b115c..1cac6a2e76 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveInfoTest.java index c21804e462..df6319100a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveSubscriptionInfoTest.java index b8591f4afc..2e80c3afa2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ReplayCommandTest.java index a32bbd6132..908e560272 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ResponseTest.java index 299e1c75ba..034f0f1042 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionIdTest.java index 20403986a5..98b2504ef6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionInfoTest.java index 06ba8f217a..f80ab0e5cf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ShutdownInfoTest.java index ac4c08e847..d392e42c15 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SubscriptionInfoTest.java index a79b9dd6c2..e1c68dc5d9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionIdTestSupport.java index db71b11906..45016958e7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionInfoTest.java index 5f84e6f5ca..3b6eb63eae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/XATransactionIdTest.java index e8bc118e62..d9e9c9de07 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v7/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v7; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BaseCommandTestSupport.java index 3999913562..bf5ad9c88f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerIdTest.java index e4ee6c4013..c6a9d5e102 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerInfoTest.java index 34eb10a79f..df55ec484f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionControlTest.java index 533739ba61..cdfba13c23 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionErrorTest.java index 12af9b5cec..892b1f2a1d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionIdTest.java index e52892fc64..416081046f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionInfoTest.java index f223056926..976938b262 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerControlTest.java index 24e1389877..f4ef443623 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerIdTest.java index dfe29aed00..a9d35ed220 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerInfoTest.java index 1a95bafe8c..f429221412 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ControlCommandTest.java index 9b922ce991..b196ec6d77 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataArrayResponseTest.java index 0f2352b75b..7ed08b9eec 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataResponseTest.java index a8eef233a7..9e9593efb9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DestinationInfoTest.java index 7aab0050a8..d0704d36b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DiscoveryEventTest.java index 51fcf6c676..3f9a539465 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ExceptionResponseTest.java index 66ab129623..65bffc25b9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/FlushCommandTest.java index 98cfa01ea0..ee156aab0e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/IntegerResponseTest.java index 0c8399d7f5..c4f472ef8b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalQueueAckTest.java index a961ec3408..eb8c02a393 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTopicAckTest.java index 49d636dbc8..5b90c927fd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTraceTest.java index 0841544958..e72e96e395 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTransactionTest.java index 4c03e35df7..5718f31d85 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/KeepAliveInfoTest.java index a1d737d711..8797f54618 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LastPartialCommandTest.java index a0d9419f70..a87c2bd856 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LocalTransactionIdTest.java index 38bc7d9d75..bbce26c5a5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageAckTest.java index 70a3b57b51..f69b0e8419 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchNotificationTest.java index 5bca814600..7defbe9d54 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchTest.java index 5976190685..b4d6764b66 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageIdTest.java index 1b30a8e8b4..30ce2f6c00 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessagePullTest.java index f1e218f83b..94a725bb52 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageTestSupport.java index 30b83bb38e..4069a8c28d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/NetworkBridgeFilterTest.java index 044327a108..bdc52b3ba9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/PartialCommandTest.java index 6b3f50997d..0d32644be9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerAckTest.java index 6a52af8210..744c109263 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerIdTest.java index 8b34b9820f..a19a21283d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerInfoTest.java index 9f909307dc..610853cee3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveInfoTest.java index 05e651402e..cbab4679de 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveSubscriptionInfoTest.java index 2ad747c779..ec499e7409 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ReplayCommandTest.java index 2c88ead4d1..cb8f45633b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ResponseTest.java index 8b46dfe71e..39211f014f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionIdTest.java index fb3d2ee58e..00163b11e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionInfoTest.java index 35a262a9c6..89dab1531b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ShutdownInfoTest.java index 65def5d91b..f46ff203cf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SubscriptionInfoTest.java index dcc5dbe4b7..9e63a087b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionIdTestSupport.java index fce60e8f22..3374fe38f9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionInfoTest.java index c61d5e3dde..f9baf742b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/XATransactionIdTest.java index 8f371dc6c6..a2efe70145 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v8/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v8; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BaseCommandTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BaseCommandTestSupport.java index 88a75f2077..62e1805d14 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BaseCommandTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BaseCommandTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerIdTest.java index d7276335d6..894410c6ed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for BrokerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerInfoTest.java index 2a06143fba..248d1692a2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/BrokerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerInfo; /** * Test case for the OpenWire marshalling for BrokerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionControlTest.java index 9a290aaec0..2f10f11b06 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionControl; /** * Test case for the OpenWire marshalling for ConnectionControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionErrorTest.java index 665f64d1b8..13deecf7b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionErrorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionErrorTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionError; /** * Test case for the OpenWire marshalling for ConnectionError diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionIdTest.java index 17f40a8bdf..2a5aaab05b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConnectionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConnectionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionInfoTest.java index 75c9760f5f..ae978e6f38 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConnectionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConnectionInfo; /** * Test case for the OpenWire marshalling for ConnectionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerControlTest.java index a30bcf75ac..55d4b41aae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerControlTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerControl; /** * Test case for the OpenWire marshalling for ConsumerControl diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerIdTest.java index c251676c20..c74230e079 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ConsumerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerInfoTest.java index 4eba574497..bed16cbc5a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ConsumerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,9 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ConsumerId; +import org.apache.activemq.command.ConsumerInfo; /** * Test case for the OpenWire marshalling for ConsumerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ControlCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ControlCommandTest.java index f4de3a44bc..183c4c0ea2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ControlCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ControlCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ControlCommand; /** * Test case for the OpenWire marshalling for ControlCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataArrayResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataArrayResponseTest.java index 563d9adf1e..aca2c7cf71 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataArrayResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataArrayResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataArrayResponse; +import org.apache.activemq.command.DataStructure; /** * Test case for the OpenWire marshalling for DataArrayResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataResponseTest.java index ad1a5686b4..a2b85025c4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DataResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DataResponse; /** * Test case for the OpenWire marshalling for DataResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DestinationInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DestinationInfoTest.java index 2ed960dd78..978aa3a1d2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DestinationInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DestinationInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.DestinationInfo; /** * Test case for the OpenWire marshalling for DestinationInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DiscoveryEventTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DiscoveryEventTest.java index cde3ecc414..579369b5ce 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DiscoveryEventTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/DiscoveryEventTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.DiscoveryEvent; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for DiscoveryEvent diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ExceptionResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ExceptionResponseTest.java index 12de46a623..650ac2f04e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ExceptionResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ExceptionResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ExceptionResponse; /** * Test case for the OpenWire marshalling for ExceptionResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/FlushCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/FlushCommandTest.java index 4bea5c41f0..2f9d7eecd6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/FlushCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/FlushCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.FlushCommand; /** * Test case for the OpenWire marshalling for FlushCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/IntegerResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/IntegerResponseTest.java index 26be970cce..9f35c0d70e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/IntegerResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/IntegerResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.IntegerResponse; /** * Test case for the OpenWire marshalling for IntegerResponse diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalQueueAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalQueueAckTest.java index 5043d85697..2d27ab03fd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalQueueAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalQueueAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalQueueAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalQueueAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTopicAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTopicAckTest.java index 4f52c930a2..44f823350e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTopicAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTopicAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTopicAck; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTopicAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTraceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTraceTest.java index 7ad542b147..dfe1c5731c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTraceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTraceTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTrace; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTrace diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTransactionTest.java index 75d22b47a5..afb53d2c56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/JournalTransactionTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.JournalTransaction; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for JournalTransaction diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/KeepAliveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/KeepAliveInfoTest.java index c2325217af..f3104e1a96 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/KeepAliveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/KeepAliveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.KeepAliveInfo; /** * Test case for the OpenWire marshalling for KeepAliveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LastPartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LastPartialCommandTest.java index 73883de1b1..8513ec22b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LastPartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LastPartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LastPartialCommand; /** * Test case for the OpenWire marshalling for LastPartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LocalTransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LocalTransactionIdTest.java index bc8e7599da..7288f4aa76 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LocalTransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/LocalTransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.LocalTransactionId; /** * Test case for the OpenWire marshalling for LocalTransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageAckTest.java index b87b3e8b81..e6ea66628e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageAck; /** * Test case for the OpenWire marshalling for MessageAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchNotificationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchNotificationTest.java index 008376ac2b..75ccd390d4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchNotificationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchNotificationTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatchNotification; /** * Test case for the OpenWire marshalling for MessageDispatchNotification diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchTest.java index 61c87199bb..742bf93698 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageDispatchTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageDispatch; /** * Test case for the OpenWire marshalling for MessageDispatch diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageIdTest.java index 59a7852932..9da767467c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for MessageId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessagePullTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessagePullTest.java index fd5971b0e1..ccf53522fa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessagePullTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessagePullTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.MessagePull; /** * Test case for the OpenWire marshalling for MessagePull diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageTestSupport.java index 355464e87a..d9560e20e6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/MessageTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.Message; /** * Test case for the OpenWire marshalling for Message diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/NetworkBridgeFilterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/NetworkBridgeFilterTest.java index feba0aa025..476c22928c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/NetworkBridgeFilterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/NetworkBridgeFilterTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.NetworkBridgeFilter; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for NetworkBridgeFilter diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/PartialCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/PartialCommandTest.java index 8c2d8ca3d0..892a9e62df 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/PartialCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/PartialCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.PartialCommand; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for PartialCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerAckTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerAckTest.java index 549b1871e7..08da62202b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerAckTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerAckTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerAck; /** * Test case for the OpenWire marshalling for ProducerAck diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerIdTest.java index bf6b002fef..4dbfd5d093 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ProducerId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for ProducerId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerInfoTest.java index 3a25602f8b..fdd3cb973d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ProducerInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.BrokerId; +import org.apache.activemq.command.ProducerInfo; /** * Test case for the OpenWire marshalling for ProducerInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveInfoTest.java index 036e20f61a..bcdcbdabe9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveInfo; /** * Test case for the OpenWire marshalling for RemoveInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveSubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveSubscriptionInfoTest.java index 8deb495b92..08c163380d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveSubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/RemoveSubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.RemoveSubscriptionInfo; /** * Test case for the OpenWire marshalling for RemoveSubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ReplayCommandTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ReplayCommandTest.java index 4bafb9fa27..c31b82aca6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ReplayCommandTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ReplayCommandTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ReplayCommand; /** * Test case for the OpenWire marshalling for ReplayCommand diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ResponseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ResponseTest.java index db86fb5e7c..e22b6660db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ResponseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ResponseTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.Response; /** * Test case for the OpenWire marshalling for Response diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionIdTest.java index 862e06a963..3ac063cc4e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SessionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionInfoTest.java index ca7f96d726..5e9b2fe853 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SessionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SessionInfo; /** * Test case for the OpenWire marshalling for SessionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ShutdownInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ShutdownInfoTest.java index 36b78bbdc1..cd9989c3a9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ShutdownInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/ShutdownInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ShutdownInfo; /** * Test case for the OpenWire marshalling for ShutdownInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SubscriptionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SubscriptionInfoTest.java index a5378ec4da..fa9cbe7d1a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SubscriptionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/SubscriptionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.SubscriptionInfo; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for SubscriptionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionIdTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionIdTestSupport.java index 6aadb3da07..634858410c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionIdTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionIdTestSupport.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,8 +16,8 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.openwire.*; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionId; +import org.apache.activemq.openwire.DataFileGeneratorTestSupport; /** * Test case for the OpenWire marshalling for TransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionInfoTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionInfoTest.java index 7d27137adf..7f6645b741 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionInfoTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/TransactionInfoTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.TransactionInfo; /** * Test case for the OpenWire marshalling for TransactionInfo diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/XATransactionIdTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/XATransactionIdTest.java index afbb0a2114..5af329f381 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/XATransactionIdTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/openwire/v9/XATransactionIdTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -17,7 +16,7 @@ */ package org.apache.activemq.openwire.v9; -import org.apache.activemq.command.*; +import org.apache.activemq.command.XATransactionId; /** * Test case for the OpenWire marshalling for XATransactionId diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java index fdb1d96524..f2a7afb6e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.perf; -import java.util.ArrayList; -import java.util.List; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java index 748d5a9483..f3b21be7d7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.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, @@ -105,12 +105,10 @@ public class InactiveDurableTopicTest extends TestCase { subscriber.close(); session.close(); connection.close(); - } - catch (JMSException ex) { + } catch (JMSException ex) { try { connection.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } throw new AssertionFailedError("Create Subscription caught: " + ex); } @@ -146,12 +144,10 @@ public class InactiveDurableTopicTest extends TestCase { session.close(); connection.stop(); connection.stop(); - } - catch (JMSException ex) { + } catch (JMSException ex) { try { connection.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } throw new AssertionFailedError("Create Subscription caught: " + ex); } @@ -184,12 +180,10 @@ public class InactiveDurableTopicTest extends TestCase { subscriber.close(); session.close(); connection.close(); - } - catch (JMSException ex) { + } catch (JMSException ex) { try { connection.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } throw new AssertionFailedError("Create Subscription caught: " + ex); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java index ec34a967ba..52834dcd7a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTopicTest.java index 0d9f002802..cd84183a64 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTransactedTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTransactedTopicTest.java index b1453c0c03..792e0ee92f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTransactedTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBDurableTransactedTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBQueueTest.java index b03e284450..11a3ef5a54 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaDBQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaQueueTest.java index efc5500288..194a0bcaad 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/KahaQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBDurableTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBDurableTopicTest.java index 48d217c79a..254cb865ae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBDurableTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBDurableTopicTest.java @@ -1,12 +1,12 @@ /** - revision 946600 * Licensed to the Apache Software Foundation (ASF) under one or more + * revision 946600 * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBStoreQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBStoreQueueTest.java index 4137cf96cc..d9f772dbe3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBStoreQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/LevelDBStoreQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java index 37be517e4d..8a7a27356c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.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, @@ -74,8 +74,7 @@ public class MemoryAllocationTest extends TestCase { if (dest instanceof TemporaryTopic) { TemporaryTopic tt = (TemporaryTopic) dest; tt.delete(); - } - else if (dest instanceof TemporaryQueue) { + } else if (dest instanceof TemporaryQueue) { TemporaryQueue tq = (TemporaryQueue) dest; tq.delete(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java index 215456bf7d..c057083e34 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.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, @@ -29,7 +29,6 @@ import javax.jms.Topic; import junit.framework.TestCase; import junit.textui.TestRunner; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.network.NetworkConnector; @@ -85,13 +84,11 @@ public class NetworkedSyncTest extends TestCase { if (!broker1.isStarted()) { LOG.info("Broker broker1 not yet started. Kicking it off now."); broker1.start(); - } - else { + } else { LOG.info("Broker broker1 already started. Not kicking it off a second time."); broker1.waitUntilStopped(); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Error: " + e.getMessage()); throw e; // brokerService.stop(); @@ -107,13 +104,11 @@ public class NetworkedSyncTest extends TestCase { if (!broker2.isStarted()) { LOG.info("Broker broker2 not yet started. Kicking it off now."); broker2.start(); - } - else { + } else { LOG.info("Broker broker2 already started. Not kicking it off a second time."); broker2.waitUntilStopped(); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Error: " + e.getMessage()); throw e; } @@ -137,15 +132,13 @@ public class NetworkedSyncTest extends TestCase { if (broker1 != null && broker1.isStarted()) { LOG.info("Broker1 still running, stopping it now."); broker1.stop(); - } - else { + } else { LOG.info("Broker1 not running, nothing to shutdown."); } if (broker2 != null && broker2.isStarted()) { LOG.info("Broker2 still running, stopping it now."); broker2.stop(); - } - else { + } else { LOG.info("Broker2 not running, nothing to shutdown."); } @@ -224,12 +217,10 @@ class Producer implements Runnable { LOG.info("sent " + counter + " messages"); } - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(ex.toString()); return; - } - finally { + } finally { try { if (producer != null) producer.close(); @@ -237,8 +228,7 @@ class Producer implements Runnable { session.close(); if (connection != null) connection.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Problem closing down JMS objects: " + e); } } @@ -289,8 +279,7 @@ class Consumer implements Runnable { TextMessage textMessage = (TextMessage) message2; textMessage.getText(); // logger.info("Received: " + text); - } - else { + } else { LOG.error("Received message of unsupported type. Expecting TextMessage. " + message2); } counter++; @@ -298,12 +287,10 @@ class Consumer implements Runnable { LOG.info("received " + counter + " messages"); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Error in Consumer: " + e); return; - } - finally { + } finally { try { if (consumer != null) consumer.close(); @@ -311,8 +298,7 @@ class Consumer implements Runnable { session.close(); if (connection != null) connection.close(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error("Error closing down JMS objects: " + ex); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NumberOfDestinationsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NumberOfDestinationsTest.java index 165b8bfa9d..632ec5e2e2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NumberOfDestinationsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/NumberOfDestinationsTest.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, @@ -21,7 +21,6 @@ package org.apache.activemq.perf; * */ -import java.io.File; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -29,6 +28,7 @@ import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.File; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfConsumer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfConsumer.java index edbe4ef931..38afaadfcb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfConsumer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfConsumer.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, @@ -53,8 +53,7 @@ public class PerfConsumer implements MessageListener { Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); if (dest instanceof Topic && consumerName != null && consumerName.length() > 0) { consumer = s.createDurableSubscriber((Topic) dest, consumerName); - } - else { + } else { consumer = s.createConsumer(dest); } consumer.setMessageListener(this); @@ -88,8 +87,7 @@ public class PerfConsumer implements MessageListener { if (getInitialDelay() > 0) { try { Thread.sleep(getInitialDelay()); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } @@ -102,16 +100,14 @@ public class PerfConsumer implements MessageListener { LOG.error("Duplicate Message!" + msg); } lastMsgId = msg.getJMSMessageID(); - } - catch (JMSException e1) { + } catch (JMSException e1) { e1.printStackTrace(); } try { if (sleepDuration != 0) { Thread.sleep(sleepDuration); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfProducer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfProducer.java index dee2f83792..fec7b6da48 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfProducer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfProducer.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.perf; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -25,6 +23,8 @@ import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * @@ -53,8 +53,7 @@ public class PerfProducer implements Runnable { this.transacted = transacted; if (transacted) { session = connection.createSession(true, Session.SESSION_TRANSACTED); - } - else { + } else { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } producer = session.createProducer(dest); @@ -117,11 +116,9 @@ public class PerfProducer implements Runnable { Thread.sleep(sleep); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); - } - finally { + } finally { stopped.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfRate.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfRate.java index 043b65278d..7033c7465c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfRate.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/PerfRate.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java index 900ece0461..87164af1b8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java index 4b08ad50ed..aa8f6fc558 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.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, @@ -58,8 +58,7 @@ public class RunBroker { broker.start(); System.err.println("Running"); Thread.sleep(Long.MAX_VALUE); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java index f870d20fdf..b5474a44a6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java index 125b320bb0..0af3e4680b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleDurableTopicTest.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, @@ -16,15 +16,15 @@ */ package org.apache.activemq.perf; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.leveldb.LevelDBStoreFactory; - import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.leveldb.LevelDBStoreFactory; + /** * */ diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java index 531a9388c3..ec2e030c52 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueNetworkTest.java index eb45c681db..e0c1afbe88 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueNetworkTest.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, @@ -17,14 +17,13 @@ package org.apache.activemq.perf; -import java.util.ArrayList; -import java.util.List; - import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.PolicyEntry; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java index 38dddd6794..0c22d84812 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq.perf; -import java.util.ArrayList; -import java.util.List; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.PolicyEntry; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentTopicTest.java index e1ac924a11..df0b8c55b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleNonPersistentTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java index 9761784d37..615c2e110f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java index c93a7f6e22..d32d705858 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumer.java index 24eaad24b7..a79721673a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumer.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, @@ -45,8 +45,7 @@ public class SlowConsumer extends PerfConsumer { LOG.debug("GOT A MSG " + msg); try { Thread.sleep(10000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java index 8a4dd22e1b..fbdd0ad28d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowDurableConsumerTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowDurableConsumerTopicTest.java index b827ee3cfc..42e03e868c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowDurableConsumerTopicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/SlowDurableConsumerTopicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/TemporaryTopicMemoryAllocationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/TemporaryTopicMemoryAllocationTest.java index c7d307bbab..aca01b73d8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/TemporaryTopicMemoryAllocationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/perf/TemporaryTopicMemoryAllocationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/plugin/BrokerStatisticsPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/plugin/BrokerStatisticsPluginTest.java index 04bbebed52..4cb2c46e09 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/plugin/BrokerStatisticsPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/plugin/BrokerStatisticsPluginTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.plugin; -import java.net.URI; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MapMessage; @@ -26,6 +24,7 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.net.URI; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/pool/JmsSendReceiveTwoConnectionsWithSenderUsingPoolTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/pool/JmsSendReceiveTwoConnectionsWithSenderUsingPoolTest.java index aded50340b..0792b2e540 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/pool/JmsSendReceiveTwoConnectionsWithSenderUsingPoolTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/pool/JmsSendReceiveTwoConnectionsWithSenderUsingPoolTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/AMQ4889Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/AMQ4889Test.java index df05d7f9ee..b0d11436a5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/AMQ4889Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/AMQ4889Test.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, @@ -17,6 +17,14 @@ package org.apache.activemq.proxy; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSSecurityException; +import javax.jms.Session; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerPlugin; import org.apache.activemq.broker.BrokerService; @@ -30,14 +38,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSSecurityException; -import javax.jms.Session; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -111,16 +111,14 @@ public class AMQ4889Test { Connection connection = connectionFactory.createConnection(USER, WRONG_PASSWORD); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); fail("createSession should fail"); - } - else { + } else { LOG.debug("Iteration {} adding good connection", i); Connection connection = connectionFactory.createConnection(USER, GOOD_USER_PASSWORD); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); expectedConnectionCount++; } // - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { } LOG.debug("Iteration {} Connections? {}", i, proxyConnector.getConnectionCount()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyConnectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyConnectorTest.java index 74c971a94d..82bc7f77e4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyConnectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyConnectorTest.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, @@ -82,8 +82,7 @@ public class ProxyConnectorTest extends ProxyTestSupport { // Either that or make consumer retroactive try { Thread.sleep(2000); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyFailoverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyFailoverTest.java index 79dc784c23..561de3f7dc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyFailoverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyFailoverTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.proxy; +import javax.jms.Connection; +import javax.jms.Session; +import java.net.URI; +import java.util.concurrent.TimeUnit; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -23,12 +28,6 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.util.ConsumerThread; import org.apache.activemq.util.ProducerThread; -import java.util.concurrent.TimeUnit; - -import javax.jms.Connection; -import javax.jms.Session; -import java.net.URI; - public class ProxyFailoverTest extends TestCase { BrokerService proxyBroker; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java index 02284dfd86..7e6e1c603b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/proxy/ProxyTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java index 902ee107c0..76e4c981c3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.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, @@ -16,10 +16,10 @@ */ package org.apache.activemq.security; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import javax.naming.Context; +import javax.naming.NameClassPair; +import javax.naming.NamingEnumeration; +import javax.naming.directory.DirContext; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -29,11 +29,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import javax.naming.Context; -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; -import javax.naming.directory.DirContext; - import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.jaas.GroupPrincipal; @@ -50,6 +45,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends AbstractLdapTestUnit { static final GroupPrincipal GUESTS = new GroupPrincipal("guests"); @@ -70,8 +69,7 @@ public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends Abstr if (connection != null) { try { connection.close(); - } - catch (IOException e) { + } catch (IOException e) { // Ignore } } @@ -316,8 +314,7 @@ public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends Abstr public boolean isSatisified() throws Exception { if (sync) { return !map.isContextAlive(); - } - else { + } else { return map.context == null; } } @@ -385,8 +382,7 @@ public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends Abstr while (namingEnum.hasMore()) { dns.add(namingEnum.next().getNameInNamespace()); } - } - else { + } else { context.unbind(name); dns.remove(dns.size() - 1); } @@ -415,8 +411,7 @@ public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends Abstr try { mainMethod.invoke(null, new Object[]{new String[]{"-v", "-h", ldapHost, "-p", String.valueOf(ldapPort), "-D", ldapUser, "-w", ldapPass, "-a", "-f", file.toString()}}); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { if (!(e.getTargetException() instanceof SecurityException)) { throw e; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationModuleTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationModuleTest.java index 353a140c98..a5b2963f13 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationModuleTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationModuleTest.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, @@ -16,13 +16,13 @@ */ package org.apache.activemq.security; +import java.util.Set; + import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.jaas.UserPrincipal; import org.apache.directory.shared.ldap.model.message.ModifyRequest; import org.junit.Test; -import java.util.Set; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java index e0796ba09e..d8b0ee35f2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.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, @@ -102,8 +102,7 @@ public class AuthorizationMapTest extends TestCase { entry.setRead("*"); entry.setWrite("*"); entry.setAdmin("admins"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } @@ -114,8 +113,7 @@ public class AuthorizationMapTest extends TestCase { TempDestinationAuthorizationEntry tEntry = new TempDestinationAuthorizationEntry(); try { tEntry.setAdmin("*"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } @@ -136,8 +134,7 @@ public class AuthorizationMapTest extends TestCase { entry.setQueue(">"); try { entry.setRead("admins"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } @@ -147,8 +144,7 @@ public class AuthorizationMapTest extends TestCase { entry.setQueue("USERS.>"); try { entry.setRead("users"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } entries.add(entry); @@ -168,8 +164,7 @@ public class AuthorizationMapTest extends TestCase { entry.setQueue(">"); try { entry.setRead("admins"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } entries.add(entry); @@ -178,8 +173,7 @@ public class AuthorizationMapTest extends TestCase { entry.setQueue("USERS.>"); try { entry.setRead("users"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } entries.add(entry); @@ -190,8 +184,7 @@ public class AuthorizationMapTest extends TestCase { TempDestinationAuthorizationEntry tEntry = new TempDestinationAuthorizationEntry(); try { tEntry.setAdmin("tempDestAdmins"); - } - catch (Exception e) { + } catch (Exception e) { fail(e.toString()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyOpenLDAPTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyOpenLDAPTest.java index 1fc07234c2..88a1af9d51 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyOpenLDAPTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyOpenLDAPTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyTest.java index 91dff53de6..f6586fe2ed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleLegacyTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.security; +import java.io.IOException; +import java.io.InputStream; + import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.apache.directory.server.annotations.CreateLdapServer; @@ -26,9 +29,6 @@ import org.apache.directory.shared.ldap.model.exception.LdapException; import org.apache.directory.shared.ldap.model.name.Dn; import org.junit.runner.RunWith; -import java.io.IOException; -import java.io.InputStream; - @RunWith(FrameworkRunner.class) @CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP")}) @ApplyLdifFiles( diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleOpenLDAPTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleOpenLDAPTest.java index c8190291db..3fa02fe969 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleOpenLDAPTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleOpenLDAPTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.security; +import java.io.IOException; +import java.io.InputStream; + import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.apache.directory.shared.ldap.model.exception.LdapException; @@ -24,9 +27,6 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; -import java.io.InputStream; - /** * Test of the {@link SimpleCachedLDAPAuthorizationMap} that tests against a basic OpenLDAP instance. * Disabled by default because it requires external setup to provide the OpenLDAP instance. diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleTest.java index 523f902f6f..31f56f0fd2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPAuthorizationModuleTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.security; +import java.io.InputStream; + import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.apache.directory.server.annotations.CreateLdapServer; @@ -25,8 +27,6 @@ import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.directory.shared.ldap.model.name.Dn; import org.junit.runner.RunWith; -import java.io.InputStream; - @RunWith(FrameworkRunner.class) @CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP")}) @ApplyLdifFiles( diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityLegacyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityLegacyTest.java index 5fe8517968..eb4292dc96 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityLegacyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityLegacyTest.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, @@ -16,6 +16,14 @@ */ package org.apache.activemq.security; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; @@ -30,8 +38,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.jms.*; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -87,8 +93,7 @@ public class CachedLDAPSecurityLegacyTest extends AbstractLdapTestUnit { try { sess.createProducer(queue); fail("expect auth exception"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } @@ -103,8 +108,7 @@ public class CachedLDAPSecurityLegacyTest extends AbstractLdapTestUnit { try { sess.createProducer(queue); fail("expect auth exception"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityTest.java index 4e96818e2e..bba3ba256a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/CachedLDAPSecurityTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/DoSTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/DoSTest.java index 90fc4faeea..aa9f193edf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/DoSTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/DoSTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.security; +import javax.jms.Connection; +import javax.jms.JMSException; import java.net.URI; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.jms.Connection; -import javax.jms.JMSException; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.JmsTestSupport; import org.apache.activemq.broker.BrokerFactory; @@ -64,8 +63,7 @@ public class DoSTest extends JmsTestSupport { connection = factory.createConnection("bad", "krap"); connection.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { // ignore exception and don't close e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java index 07b007af5f..6ed2fda011 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.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, @@ -17,15 +17,14 @@ package org.apache.activemq.security; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; import java.security.Principal; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import javax.security.auth.login.AppConfigurationEntry; -import javax.security.auth.login.Configuration; - import junit.framework.TestCase; import org.apache.activemq.broker.ConnectionContext; @@ -107,8 +106,7 @@ public class JaasCertificateAuthenticationBrokerTest extends TestCase { try { authBroker.addConnection(connectionContext, connectionInfo); - } - catch (Exception e) { + } catch (Exception e) { fail("Call to addConnection failed: " + e.getMessage()); } @@ -126,21 +124,17 @@ public class JaasCertificateAuthenticationBrokerTest extends TestCase { if (currentPrincipal instanceof UserPrincipal) { if (userNames.remove(currentPrincipal.getName())) { // Nothing, we did good. - } - else { + } else { // Found an unknown userName. fail("Unknown UserPrincipal found"); } - } - else if (currentPrincipal instanceof GroupPrincipal) { + } else if (currentPrincipal instanceof GroupPrincipal) { if (groupNames.remove(currentPrincipal.getName())) { // Nothing, we did good. - } - else { + } else { fail("Unknown GroupPrincipal found."); } - } - else { + } else { fail("Unexpected Principal subclass found."); } } @@ -167,11 +161,9 @@ public class JaasCertificateAuthenticationBrokerTest extends TestCase { boolean connectFailed = false; try { authBroker.addConnection(connectionContext, connectionInfo); - } - catch (SecurityException e) { + } catch (SecurityException e) { connectFailed = true; - } - catch (Exception e) { + } catch (Exception e) { fail("Failed to connect for unexpected reason: " + e.getMessage()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java index a3a5cd6a89..fe561587de 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.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, @@ -17,16 +17,15 @@ package org.apache.activemq.security; +import javax.net.ssl.SSLServerSocket; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; import java.net.URI; import java.security.Principal; import java.util.HashMap; import java.util.Iterator; import java.util.Set; -import javax.net.ssl.SSLServerSocket; -import javax.security.auth.login.AppConfigurationEntry; -import javax.security.auth.login.Configuration; - import junit.framework.TestCase; import org.apache.activemq.broker.ConnectionContext; @@ -97,8 +96,7 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { try { sslTransportServer = new SslTransportServer(null, new URI("ssl://localhost:61616?needClientAuth=true"), socketFactory); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to create SslTransportServer."); } sslTransportServer.setNeedClientAuth(true); @@ -106,8 +104,7 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { try { nonSslTransportServer = new TcpTransportServer(null, new URI("tcp://localhost:61613"), socketFactory); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to create TcpTransportServer."); } @@ -128,8 +125,7 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { try { authBroker.addConnection(connectionContext, connectionInfo); - } - catch (Exception e) { + } catch (Exception e) { fail("Call to addConnection failed: " + e.getMessage()); } @@ -148,19 +144,16 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { if (currentPrincipal instanceof UserPrincipal) { assertEquals("UserPrincipal is '" + DN_USERNAME + "'", DN_USERNAME, currentPrincipal.getName()); - } - else if (currentPrincipal instanceof GroupPrincipal) { + } else if (currentPrincipal instanceof GroupPrincipal) { assertEquals("GroupPrincipal is '" + DN_GROUP + "'", DN_GROUP, currentPrincipal.getName()); - } - else { + } else { fail("Unexpected Principal subclass found."); } } try { authBroker.removeConnection(connectionContext, connectionInfo, null); - } - catch (Exception e) { + } catch (Exception e) { fail("Call to removeConnection failed: " + e.getMessage()); } assertEquals("Number of removeConnection calls to underlying Broker must match number of calls made to " + "AuthenticationBroker.", 1, receiveBroker.removeConnectionData.size()); @@ -173,8 +166,7 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { try { authBroker.addConnection(connectionContext, connectionInfo); - } - catch (Exception e) { + } catch (Exception e) { fail("Call to addConnection failed: " + e.getMessage()); } @@ -192,19 +184,16 @@ public class JaasDualAuthenticationBrokerTest extends TestCase { if (currentPrincipal instanceof UserPrincipal) { assertEquals("UserPrincipal is '" + INSECURE_USERNAME + "'", INSECURE_USERNAME, currentPrincipal.getName()); - } - else if (currentPrincipal instanceof GroupPrincipal) { + } else if (currentPrincipal instanceof GroupPrincipal) { assertEquals("GroupPrincipal is '" + INSECURE_GROUP + "'", INSECURE_GROUP, currentPrincipal.getName()); - } - else { + } else { fail("Unexpected Principal subclass found."); } } try { authBroker.removeConnection(connectionContext, connectionInfo, null); - } - catch (Exception e) { + } catch (Exception e) { fail("Call to removeConnection failed: " + e.getMessage()); } assertEquals("Number of removeConnection calls to underlying Broker must match number of calls made to " + "AuthenticationBroker.", 1, receiveBroker.removeConnectionData.size()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasNetworkTest.java index dd2eec3d9f..dcdd32ae08 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/JaasNetworkTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.security; -import java.net.URI; - import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthenticationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthenticationTest.java index cbe3d7c4e5..e8f5dfe4fc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthenticationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthenticationTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.security; -import static org.junit.Assert.fail; - import javax.jms.Connection; import javax.jms.Session; @@ -35,6 +33,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.fail; + @RunWith(FrameworkRunner.class) @CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP", port = 1024)}) @ApplyLdifFiles( @@ -66,11 +66,10 @@ public class LDAPAuthenticationTest extends AbstractLdapTestUnit { Connection conn = factory.createQueueConnection("*", "sunflower"); try { conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return; } fail("Should have failed connecting"); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java index 76986a3aea..6a674f71ea 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.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, @@ -16,16 +16,12 @@ */ package org.apache.activemq.security; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - import javax.naming.NameClassPair; import javax.naming.NamingEnumeration; import javax.naming.directory.DirContext; +import java.text.MessageFormat; +import java.util.HashSet; +import java.util.Set; import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.command.ActiveMQDestination; @@ -42,6 +38,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * This test assumes setup like in file 'AMQauth.ldif'. Contents of this file is attached below in comments. * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java index 46b516cd14..d5c4472a5a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.security; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -42,6 +39,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + @RunWith(FrameworkRunner.class) @CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP", port = 1024)}) @ApplyLdifFiles( @@ -111,8 +111,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("test")); fail("expect auth exception"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } @@ -128,8 +127,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("test")); fail("expect auth exception"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java index ab85bb41fb..feed55b635 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.security; -import java.net.URI; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.QueueBrowser; @@ -30,6 +26,9 @@ import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; +import java.net.URI; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityTestSupport.java index 6afe0aa141..f773738258 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SecurityTestSupport.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, @@ -59,8 +59,7 @@ public class SecurityTestSupport extends JmsTestSupport { connections.add(c); c.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { } try { @@ -69,8 +68,7 @@ public class SecurityTestSupport extends JmsTestSupport { connections.add(c); c.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { } try { @@ -79,8 +77,7 @@ public class SecurityTestSupport extends JmsTestSupport { connections.add(c); c.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -131,8 +128,7 @@ public class SecurityTestSupport extends JmsTestSupport { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sendMessages(session, destination, 1); - } - catch (JMSException e) { + } catch (JMSException e) { // If test is expected to fail, the cause must only be a // SecurityException // otherwise rethrow the exception @@ -144,8 +140,7 @@ public class SecurityTestSupport extends JmsTestSupport { Message m = consumer.receive(1000); if (fail) { assertNull(m); - } - else { + } else { assertNotNull(m); assertEquals("0", ((TextMessage) m).getText()); assertNull(consumer.receiveNoWait()); @@ -166,8 +161,7 @@ public class SecurityTestSupport extends JmsTestSupport { if (fail) { fail("Expected failure due to security constraint."); } - } - catch (JMSException e) { + } catch (JMSException e) { if (fail && e.getCause() instanceof SecurityException) { return null; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java index 2e0adcc0cd..dfa54908b0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.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, @@ -50,8 +50,7 @@ public class SimpleAnonymousPluginTest extends SimpleAuthenticationPluginTest { connections.add(c); c.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { } try { @@ -60,8 +59,7 @@ public class SimpleAnonymousPluginTest extends SimpleAuthenticationPluginTest { connections.add(c); c.start(); fail("Expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginSeparatorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginSeparatorTest.java index cfbada4633..82d27b423c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginSeparatorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginSeparatorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java index 6d246a8b76..e8b68709d1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.security; -import java.net.URI; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.JMSSecurityException; @@ -26,6 +24,7 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TemporaryTopic; import javax.management.ObjectName; +import java.net.URI; import junit.framework.Test; @@ -95,8 +94,7 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport { TemporaryTopic temp = sess.createTemporaryTopic(); name += ",Destination=" + temp.getTopicName().replaceAll(":", "_"); fail("Should have failed creating a temp topic"); - } - catch (Exception ignore) { + } catch (Exception ignore) { } ObjectName objName = new ObjectName(name); @@ -104,8 +102,7 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport { try { System.out.println(mbean.getName()); fail("Shouldn't have created a temp topic"); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } @@ -115,10 +112,8 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport { try { connection.start(); fail("Should throw JMSSecurityException"); - } - catch (JMSSecurityException jmsEx) { - } - catch (Exception e) { + } catch (JMSSecurityException jmsEx) { + } catch (Exception e) { LOG.info("Expected JMSSecurityException but was: {}", e.getClass()); fail("Should throw JMSSecurityException"); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthorizationMapTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthorizationMapTest.java index 5a7da39a26..d45c79e2c6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthorizationMapTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthorizationMapTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleSecurityBrokerSystemTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleSecurityBrokerSystemTest.java index 6f02e3e944..5139bf0fa9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleSecurityBrokerSystemTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/SimpleSecurityBrokerSystemTest.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, @@ -16,6 +16,13 @@ */ package org.apache.activemq.security; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; import java.lang.management.ManagementFactory; import java.net.URL; import java.security.Principal; @@ -38,11 +45,6 @@ import org.apache.activemq.jaas.GroupPrincipal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.openmbean.CompositeData; - /** * Tests that the broker allows/fails access to destinations based on the * security policy installed on the broker. @@ -59,8 +61,7 @@ public class SimpleSecurityBrokerSystemTest extends SecurityTestSupport { static { try { WILDCARD = (Principal) DefaultAuthorizationMap.createGroupPrincipal("*", GroupPrincipal.class.getName()); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Failed to make wildcard principal", e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDoNothingCallbackHandler.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDoNothingCallbackHandler.java index bb56430e2d..da9cb0ff34 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDoNothingCallbackHandler.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDoNothingCallbackHandler.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, @@ -17,11 +17,10 @@ package org.apache.activemq.security; -import java.io.IOException; - import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; +import java.io.IOException; public class StubDoNothingCallbackHandler implements CallbackHandler { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDualJaasConfiguration.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDualJaasConfiguration.java index b91f019ee1..34d2d9a84e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDualJaasConfiguration.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubDualJaasConfiguration.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, @@ -34,8 +34,7 @@ public class StubDualJaasConfiguration extends Configuration { public AppConfigurationEntry[] getAppConfigurationEntry(String name) { if ("activemq-domain".equals(name)) { return new AppConfigurationEntry[]{nonSslConfigEntry}; - } - else { + } else { return new AppConfigurationEntry[]{sslConfigEntry}; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubJaasConfiguration.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubJaasConfiguration.java index a30216e394..0023d5b0a1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubJaasConfiguration.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubJaasConfiguration.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java index f494a6e0e5..72bdd0b1f6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.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, @@ -17,13 +17,12 @@ package org.apache.activemq.security; -import java.util.Map; - import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.login.FailedLoginException; import javax.security.auth.login.LoginException; import javax.security.auth.spi.LoginModule; +import java.util.Map; import org.apache.activemq.jaas.GroupPrincipal; import org.apache.activemq.jaas.UserPrincipal; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubSecurityContext.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubSecurityContext.java index 8bcead7cca..11317b787b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubSecurityContext.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/StubSecurityContext.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityTest.java index 81c360dbf1..90dcf397b2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestNoCredentialsOnlyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestNoCredentialsOnlyTest.java index e7fe6640fb..00537c3584 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestNoCredentialsOnlyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestNoCredentialsOnlyTest.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, @@ -16,13 +16,13 @@ */ package org.apache.activemq.security; -import java.net.URI; import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; import junit.framework.Test; @@ -57,8 +57,7 @@ public class XBeanSecurityWithGuestNoCredentialsOnlyTest extends JmsTestSupport try { doSend(true); fail("expect exception on connect"); - } - catch (JMSException expected) { + } catch (JMSException expected) { assertTrue("cause as expected", expected.getCause() instanceof SecurityException); } } @@ -96,8 +95,7 @@ public class XBeanSecurityWithGuestNoCredentialsOnlyTest extends JmsTestSupport Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sendMessages(session, destination, 1); - } - catch (JMSException e) { + } catch (JMSException e) { // If test is expected to fail, the cause must only be a // SecurityException // otherwise rethrow the exception @@ -109,8 +107,7 @@ public class XBeanSecurityWithGuestNoCredentialsOnlyTest extends JmsTestSupport Message m = consumer.receive(1000); if (fail) { assertNull(m); - } - else { + } else { assertNotNull(m); assertEquals("0", ((TextMessage) m).getText()); assertNull(consumer.receiveNoWait()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestTest.java index 004a5d1b5b..4b7db21b0c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSecurityWithGuestTest.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, @@ -16,13 +16,13 @@ */ package org.apache.activemq.security; -import java.net.URI; import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; import junit.framework.Test; @@ -93,8 +93,7 @@ public class XBeanSecurityWithGuestTest extends JmsTestSupport { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sendMessages(session, destination, 1); - } - catch (JMSException e) { + } catch (JMSException e) { // If test is expected to fail, the cause must only be a // SecurityException // otherwise rethrow the exception @@ -106,8 +105,7 @@ public class XBeanSecurityWithGuestTest extends JmsTestSupport { Message m = consumer.receive(1000); if (fail) { assertNull(m); - } - else { + } else { assertNotNull(m); assertEquals("0", ((TextMessage) m).getText()); assertNull(consumer.receiveNoWait()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSslContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSslContextTest.java index cfa9206bb1..2e7c2da3e1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSslContextTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/security/XBeanSslContextTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java index e16df69413..bb0d2c4278 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.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, @@ -46,8 +46,7 @@ public class SelectorParserTest extends TestCase { try { parse("DoesNotExist('sales.*', group)"); fail("expect ex on non existent function"); - } - catch (InvalidSelectorException expected) { + } catch (InvalidSelectorException expected) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java index eecc510a5c..c2e88f797f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.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, @@ -373,8 +373,7 @@ public class SelectorTest extends TestCase { try { SelectorParser.parse(text); fail("Created a valid selector"); - } - catch (InvalidSelectorException e) { + } catch (InvalidSelectorException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/UnknownHandlingSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/UnknownHandlingSelectorTest.java index e5be653fac..32c5d1874c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/UnknownHandlingSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/selector/UnknownHandlingSelectorTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.selector; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import javax.jms.JMSException; import javax.jms.Message; @@ -29,6 +26,9 @@ import org.apache.activemq.filter.MessageEvaluationContext; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class UnknownHandlingSelectorTest { private Message message; @@ -180,4 +180,4 @@ public class UnknownHandlingSelectorTest { private static String not(String selector) { return "not(" + selector + ")"; } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ActiveMQConnectionFactoryFactoryBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ActiveMQConnectionFactoryFactoryBeanTest.java index cfa6443be5..1b2c5cd77b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ActiveMQConnectionFactoryFactoryBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ActiveMQConnectionFactoryFactoryBeanTest.java @@ -1,5 +1,4 @@ /** - * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java index c6abef89b3..ed721e7dc5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.spring; -import java.util.ArrayList; -import java.util.List; - import javax.jms.Message; import javax.jms.MessageListener; +import java.util.ArrayList; +import java.util.List; import org.junit.Assert; import org.slf4j.Logger; @@ -79,8 +78,7 @@ public class ConsumerBean extends Assert implements MessageListener { while (hasReceivedMessage()) { messages.wait(4000); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.info("Caught: " + e); } } @@ -111,8 +109,7 @@ public class ConsumerBean extends Assert implements MessageListener { if (hasReceivedMessages(messageCount) || System.currentTimeMillis() > endTime) { break; } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.info("Caught: " + e); } maxRemainingMessageCount = Math.max(0, messageCount - messages.size()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesTest.java index 136e9bb182..667323e86d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesTest.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, @@ -21,4 +21,4 @@ public class Spring2XmlNamespacesTest extends SpringTestSupport { public void testUsingSpringXmlNamespacesWithPublicXsdLocation() throws Exception { assertSenderConfig("spring-embedded-xbean.xml"); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesWithoutRemoteSchemaTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesWithoutRemoteSchemaTest.java index deae99b892..3921ca6265 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesWithoutRemoteSchemaTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/Spring2XmlNamespacesWithoutRemoteSchemaTest.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, @@ -21,4 +21,4 @@ public class Spring2XmlNamespacesWithoutRemoteSchemaTest extends SpringTestSuppo public void testUsingSpring2NamespacesForANonExistingXsdDocument() throws Exception { assertSenderConfig("spring-embedded-xbean-noversion.xml"); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringConsumer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringConsumer.java index c96515c0d4..5f3b6d13cc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringConsumer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringConsumer.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, @@ -59,8 +59,7 @@ public class SpringConsumer extends ConsumerBean implements MessageListener { session = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE); consumer = session.createConsumer(destination, selector, false); consumer.setMessageListener(this); - } - catch (JMSException ex) { + } catch (JMSException ex) { LOG.error("", ex); throw ex; } @@ -83,8 +82,7 @@ public class SpringConsumer extends ConsumerBean implements MessageListener { super.onMessage(message); try { message.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("Failed to acknowledge: " + e, e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringProducer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringProducer.java index 7049c2358d..07f23a3d2d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringProducer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringProducer.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTest.java index 0d8886db54..f55544726f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java index b470c4d50c..ecfeb0a511 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.spring; +import javax.jms.Message; import java.util.Iterator; import java.util.List; -import javax.jms.Message; - import junit.framework.TestCase; import org.slf4j.Logger; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java index 45be088116..c85d14c16a 100755 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.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, @@ -35,224 +35,226 @@ import org.apache.activemq.ActiveMQConnectionFactory; */ public class JmsResourceProvider { - private String serverUri = "vm://localhost?broker.persistent=false"; - private boolean transacted; - private int ackMode = Session.AUTO_ACKNOWLEDGE; - private boolean isTopic; - private int deliveryMode = DeliveryMode.PERSISTENT; - private String durableName = "DummyName"; - private String clientID = getClass().getName(); + private String serverUri = "vm://localhost?broker.persistent=false"; + private boolean transacted; + private int ackMode = Session.AUTO_ACKNOWLEDGE; + private boolean isTopic; + private int deliveryMode = DeliveryMode.PERSISTENT; + private String durableName = "DummyName"; + private String clientID = getClass().getName(); - /** - * Creates a connection factory. - * - * @see org.apache.activemq.test.JmsResourceProvider#createConnectionFactory() - */ - public ConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory(serverUri); - } + /** + * Creates a connection factory. + * + * @see org.apache.activemq.test.JmsResourceProvider#createConnectionFactory() + */ + public ConnectionFactory createConnectionFactory() throws Exception { + return new ActiveMQConnectionFactory(serverUri); + } - /** - * Creates a connection. - * - * @see org.apache.activemq.test.JmsResourceProvider#createConnection(javax.jms.ConnectionFactory) - */ - public Connection createConnection(ConnectionFactory cf) throws JMSException { - Connection connection = cf.createConnection(); - if (getClientID() != null) { - connection.setClientID(getClientID()); - } - return connection; - } + /** + * Creates a connection. + * + * @see org.apache.activemq.test.JmsResourceProvider#createConnection(javax.jms.ConnectionFactory) + */ + public Connection createConnection(ConnectionFactory cf) throws JMSException { + Connection connection = cf.createConnection(); + if (getClientID() != null) { + connection.setClientID(getClientID()); + } + return connection; + } - /** - * @see org.apache.activemq.test.JmsResourceProvider#createSession(javax.jms.Connection) - */ - public Session createSession(Connection conn) throws JMSException { - return conn.createSession(transacted, ackMode); - } + /** + * @see org.apache.activemq.test.JmsResourceProvider#createSession(javax.jms.Connection) + */ + public Session createSession(Connection conn) throws JMSException { + return conn.createSession(transacted, ackMode); + } - /** - * @see org.apache.activemq.test.JmsResourceProvider#createConsumer(javax.jms.Session, - * javax.jms.Destination) - */ - public MessageConsumer createConsumer(Session session, Destination destination) throws JMSException { - if (isDurableSubscriber()) { - return session.createDurableSubscriber((Topic)destination, durableName); - } - return session.createConsumer(destination); - } + /** + * @see org.apache.activemq.test.JmsResourceProvider#createConsumer(javax.jms.Session, + * javax.jms.Destination) + */ + public MessageConsumer createConsumer(Session session, Destination destination) throws JMSException { + if (isDurableSubscriber()) { + return session.createDurableSubscriber((Topic) destination, durableName); + } + return session.createConsumer(destination); + } - /** - * Creates a connection for a consumer. - * - * @param ssp - ServerSessionPool - * @return ConnectionConsumer - */ - public ConnectionConsumer createConnectionConsumer(Connection connection, Destination destination, ServerSessionPool ssp) throws JMSException { - return connection.createConnectionConsumer(destination, null, ssp, 1); - } + /** + * Creates a connection for a consumer. + * + * @param ssp - ServerSessionPool + * @return ConnectionConsumer + */ + public ConnectionConsumer createConnectionConsumer(Connection connection, + Destination destination, + ServerSessionPool ssp) throws JMSException { + return connection.createConnectionConsumer(destination, null, ssp, 1); + } - /** - * Creates a producer. - * - * @see org.apache.activemq.test.JmsResourceProvider#createProducer(javax.jms.Session, - * javax.jms.Destination) - */ - public MessageProducer createProducer(Session session, Destination destination) throws JMSException { - MessageProducer producer = session.createProducer(destination); - producer.setDeliveryMode(deliveryMode); - return producer; - } + /** + * Creates a producer. + * + * @see org.apache.activemq.test.JmsResourceProvider#createProducer(javax.jms.Session, + * javax.jms.Destination) + */ + public MessageProducer createProducer(Session session, Destination destination) throws JMSException { + MessageProducer producer = session.createProducer(destination); + producer.setDeliveryMode(deliveryMode); + return producer; + } - /** - * Creates a destination, which can either a topic or a queue. - * - * @see org.apache.activemq.test.JmsResourceProvider#createDestination(javax.jms.Session, - * String) - */ - public Destination createDestination(Session session, String name) throws JMSException { - if (isTopic) { - return session.createTopic("TOPIC." + name); - } else { - return session.createQueue("QUEUE." + name); - } - } + /** + * Creates a destination, which can either a topic or a queue. + * + * @see org.apache.activemq.test.JmsResourceProvider#createDestination(javax.jms.Session, + * String) + */ + public Destination createDestination(Session session, String name) throws JMSException { + if (isTopic) { + return session.createTopic("TOPIC." + name); + } else { + return session.createQueue("QUEUE." + name); + } + } - /** - * Returns true if the subscriber is durable. - * - * @return isDurableSubscriber - */ - public boolean isDurableSubscriber() { - return isTopic && durableName != null; - } + /** + * Returns true if the subscriber is durable. + * + * @return isDurableSubscriber + */ + public boolean isDurableSubscriber() { + return isTopic && durableName != null; + } - /** - * Returns the acknowledgement mode. - * - * @return Returns the ackMode. - */ - public int getAckMode() { - return ackMode; - } + /** + * Returns the acknowledgement mode. + * + * @return Returns the ackMode. + */ + public int getAckMode() { + return ackMode; + } - /** - * Sets the acnknowledgement mode. - * - * @param ackMode The ackMode to set. - */ - public void setAckMode(int ackMode) { - this.ackMode = ackMode; - } + /** + * Sets the acnknowledgement mode. + * + * @param ackMode The ackMode to set. + */ + public void setAckMode(int ackMode) { + this.ackMode = ackMode; + } - /** - * Returns true if the destination is a topic, false if the destination is a - * queue. - * - * @return Returns the isTopic. - */ - public boolean isTopic() { - return isTopic; - } + /** + * Returns true if the destination is a topic, false if the destination is a + * queue. + * + * @return Returns the isTopic. + */ + public boolean isTopic() { + return isTopic; + } - /** - * @param isTopic The isTopic to set. - */ - public void setTopic(boolean isTopic) { - this.isTopic = isTopic; - } + /** + * @param isTopic The isTopic to set. + */ + public void setTopic(boolean isTopic) { + this.isTopic = isTopic; + } - /** - * Returns the server URI. - * - * @return Returns the serverUri. - */ - public String getServerUri() { - return serverUri; - } + /** + * Returns the server URI. + * + * @return Returns the serverUri. + */ + public String getServerUri() { + return serverUri; + } - /** - * Sets the server URI. - * - * @param serverUri - the server URI to set. - */ - public void setServerUri(String serverUri) { - this.serverUri = serverUri; - } + /** + * Sets the server URI. + * + * @param serverUri - the server URI to set. + */ + public void setServerUri(String serverUri) { + this.serverUri = serverUri; + } - /** - * Return true if the session is transacted. - * - * @return Returns the transacted. - */ - public boolean isTransacted() { - return transacted; - } + /** + * Return true if the session is transacted. + * + * @return Returns the transacted. + */ + public boolean isTransacted() { + return transacted; + } - /** - * Sets the session to be transacted. - * - * @param transacted - */ - public void setTransacted(boolean transacted) { - this.transacted = transacted; - if (transacted) { - setAckMode(Session.SESSION_TRANSACTED); - } - } + /** + * Sets the session to be transacted. + * + * @param transacted + */ + public void setTransacted(boolean transacted) { + this.transacted = transacted; + if (transacted) { + setAckMode(Session.SESSION_TRANSACTED); + } + } - /** - * Returns the delivery mode. - * - * @return deliveryMode - */ - public int getDeliveryMode() { - return deliveryMode; - } + /** + * Returns the delivery mode. + * + * @return deliveryMode + */ + public int getDeliveryMode() { + return deliveryMode; + } - /** - * Sets the delivery mode. - * - * @param deliveryMode - */ - public void setDeliveryMode(int deliveryMode) { - this.deliveryMode = deliveryMode; - } + /** + * Sets the delivery mode. + * + * @param deliveryMode + */ + public void setDeliveryMode(int deliveryMode) { + this.deliveryMode = deliveryMode; + } - /** - * Returns the client id. - * - * @return clientID - */ - public String getClientID() { - return clientID; - } + /** + * Returns the client id. + * + * @return clientID + */ + public String getClientID() { + return clientID; + } - /** - * Sets the client id. - * - * @param clientID - */ - public void setClientID(String clientID) { - this.clientID = clientID; - } + /** + * Sets the client id. + * + * @param clientID + */ + public void setClientID(String clientID) { + this.clientID = clientID; + } - /** - * Returns the durable name of the provider. - * - * @return durableName - */ - public String getDurableName() { - return durableName; - } + /** + * Returns the durable name of the provider. + * + * @return durableName + */ + public String getDurableName() { + return durableName; + } - /** - * Sets the durable name of the provider. - * - * @param durableName - */ - public void setDurableName(String durableName) { - this.durableName = durableName; - } + /** + * Sets the durable name of the provider. + * + * @param durableName + */ + public void setDurableName(String durableName) { + this.durableName = durableName; + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java index a970190620..a973fe9975 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; @@ -32,6 +25,12 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; import junit.framework.AssertionFailedError; @@ -88,8 +87,7 @@ public abstract class JmsSendReceiveTestSupport extends org.apache.activemq.Test protected String createMessageText(int i) { if (largeMessages) { return createMessageBodyText(); - } - else { + } else { return "Text for message: " + i + " at " + new Date(); } } @@ -181,8 +179,7 @@ public abstract class JmsSendReceiveTestSupport extends org.apache.activemq.Test Message received = receivedMessages.get(i); try { assertMessageValid(i, received); - } - catch (AssertionFailedError e) { + } catch (AssertionFailedError e) { for (int j = 0; j < data.length; j++) { Message m = receivedMessages.get(j); System.out.println(j + " => " + m.getJMSMessageID()); @@ -216,8 +213,7 @@ public abstract class JmsSendReceiveTestSupport extends org.apache.activemq.Test while (messages.size() < data.length && waitTime >= 0) { try { lock.wait(200); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java index ddc6cd8dd8..4529c874cc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.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, @@ -62,8 +62,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } @@ -105,8 +104,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { protected Session createConsumerSession() throws JMSException { if (useSeparateSession) { return connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - else { + } else { return session; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java index f2cf9e33d6..e42dd85ae3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.test; -import java.util.List; - import javax.jms.JMSException; import javax.jms.Message; +import java.util.List; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndByteSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndByteSelectorTest.java index adc7b55108..208ef94330 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndByteSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndByteSelectorTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest.java index 4ad1aa4e63..fe7c7a5342 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java index c999d9ac51..2ac16e9dde 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.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, @@ -77,8 +77,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java index d44d2d93d8..dc87782890 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java index be328771cf..96565bfcba 100755 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.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, @@ -39,218 +39,221 @@ import org.slf4j.LoggerFactory; * */ public abstract class TestSupport extends TestCase { - private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class); - protected ActiveMQConnectionFactory connectionFactory; - protected boolean topic = true; + private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class); - public TestSupport() { - super(); - } + protected ActiveMQConnectionFactory connectionFactory; + protected boolean topic = true; - public TestSupport(String name) { - super(name); - } + public TestSupport() { + super(); + } - /** - * Creates an ActiveMQMessage. - * - * @return ActiveMQMessage - */ - protected ActiveMQMessage createMessage() { - return new ActiveMQMessage(); - } + public TestSupport(String name) { + super(name); + } - /** - * Creates a destination. - * - * @param subject - topic or queue name. - * @return Destination - either an ActiveMQTopic or ActiveMQQUeue. - */ - protected Destination createDestination(String subject) { - if (topic) { - return new ActiveMQTopic(subject); - } else { - return new ActiveMQQueue(subject); - } - } + /** + * Creates an ActiveMQMessage. + * + * @return ActiveMQMessage + */ + protected ActiveMQMessage createMessage() { + return new ActiveMQMessage(); + } - /** - * Tests if firstSet and secondSet are equal. - * - * @param messsage - string to be displayed when the assertion fails. - * @param firstSet[] - set of messages to be compared with its counterpart - * in the secondset. - * @param secondSet[] - set of messages to be compared with its counterpart - * in the firstset. - * @throws javax.jms.JMSException - */ - protected void assertTextMessagesEqual(Message[] firstSet, Message[] secondSet) throws JMSException { - assertTextMessagesEqual("", firstSet, secondSet); - } + /** + * Creates a destination. + * + * @param subject - topic or queue name. + * @return Destination - either an ActiveMQTopic or ActiveMQQUeue. + */ + protected Destination createDestination(String subject) { + if (topic) { + return new ActiveMQTopic(subject); + } else { + return new ActiveMQQueue(subject); + } + } - /** - * Tests if firstSet and secondSet are equal. - * - * @param messsage - string to be displayed when the assertion fails. - * @param firstSet[] - set of messages to be compared with its counterpart - * in the secondset. - * @param secondSet[] - set of messages to be compared with its counterpart - * in the firstset. - */ - protected void assertTextMessagesEqual(String messsage, Message[] firstSet, Message[] secondSet) throws JMSException { - assertEquals("Message count does not match: " + messsage, firstSet.length, secondSet.length); + /** + * Tests if firstSet and secondSet are equal. + * + * @param messsage - string to be displayed when the assertion fails. + * @param firstSet[] - set of messages to be compared with its counterpart + * in the secondset. + * @param secondSet[] - set of messages to be compared with its counterpart + * in the firstset. + * @throws javax.jms.JMSException + */ + protected void assertTextMessagesEqual(Message[] firstSet, Message[] secondSet) throws JMSException { + assertTextMessagesEqual("", firstSet, secondSet); + } - for (int i = 0; i < secondSet.length; i++) { - TextMessage m1 = (TextMessage)firstSet[i]; - TextMessage m2 = (TextMessage)secondSet[i]; - assertTextMessageEqual("Message " + (i + 1) + " did not match : ", m1, m2); - } - } + /** + * Tests if firstSet and secondSet are equal. + * + * @param messsage - string to be displayed when the assertion fails. + * @param firstSet[] - set of messages to be compared with its counterpart + * in the secondset. + * @param secondSet[] - set of messages to be compared with its counterpart + * in the firstset. + */ + protected void assertTextMessagesEqual(String messsage, + Message[] firstSet, + Message[] secondSet) throws JMSException { + assertEquals("Message count does not match: " + messsage, firstSet.length, secondSet.length); - /** - * Tests if m1 and m2 are equal. - * - * @param m1 - message to be compared with m2. - * @param m2 - message to be compared with m1. - * @throws javax.jms.JMSException - */ - protected void assertEquals(TextMessage m1, TextMessage m2) throws JMSException { - assertEquals("", m1, m2); - } + for (int i = 0; i < secondSet.length; i++) { + TextMessage m1 = (TextMessage) firstSet[i]; + TextMessage m2 = (TextMessage) secondSet[i]; + assertTextMessageEqual("Message " + (i + 1) + " did not match : ", m1, m2); + } + } - /** - * Tests if m1 and m2 are equal. - * - * @param message - string to be displayed when the assertion fails. - * @param m1 - message to be compared with m2. - * @param m2 - message to be compared with m1. - */ - protected void assertTextMessageEqual(String message, TextMessage m1, TextMessage m2) throws JMSException { - assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); + /** + * Tests if m1 and m2 are equal. + * + * @param m1 - message to be compared with m2. + * @param m2 - message to be compared with m1. + * @throws javax.jms.JMSException + */ + protected void assertEquals(TextMessage m1, TextMessage m2) throws JMSException { + assertEquals("", m1, m2); + } - if (m1 == null) { - return; - } + /** + * Tests if m1 and m2 are equal. + * + * @param message - string to be displayed when the assertion fails. + * @param m1 - message to be compared with m2. + * @param m2 - message to be compared with m1. + */ + protected void assertTextMessageEqual(String message, TextMessage m1, TextMessage m2) throws JMSException { + assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); - assertEquals(message, m1.getText(), m2.getText()); - } + if (m1 == null) { + return; + } - /** - * Tests if m1 and m2 are equal. - * - * @param m1 - message to be compared with m2. - * @param m2 - message to be compared with m1. - * @throws javax.jms.JMSException - */ - protected void assertEquals(Message m1, Message m2) throws JMSException { - assertEquals("", m1, m2); - } + assertEquals(message, m1.getText(), m2.getText()); + } - /** - * Tests if m1 and m2 are equal. - * - * @param message - error message. - * @param m1 - message to be compared with m2. - * @param m2 -- message to be compared with m1. - */ - protected void assertEquals(String message, Message m1, Message m2) throws JMSException { - assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); + /** + * Tests if m1 and m2 are equal. + * + * @param m1 - message to be compared with m2. + * @param m2 - message to be compared with m1. + * @throws javax.jms.JMSException + */ + protected void assertEquals(Message m1, Message m2) throws JMSException { + assertEquals("", m1, m2); + } - if (m1 == null) { - return; - } + /** + * Tests if m1 and m2 are equal. + * + * @param message - error message. + * @param m1 - message to be compared with m2. + * @param m2 -- message to be compared with m1. + */ + protected void assertEquals(String message, Message m1, Message m2) throws JMSException { + assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null); - assertTrue(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1.getClass() == m2.getClass()); + if (m1 == null) { + return; + } - if (m1 instanceof TextMessage) { - assertTextMessageEqual(message, (TextMessage)m1, (TextMessage)m2); - } else { - assertEquals(message, m1, m2); - } - } + assertTrue(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1.getClass() == m2.getClass()); - /** - * Test if base directory contains spaces - */ - protected void assertBaseDirectoryContainsSpaces() { - assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" ")); - } + if (m1 instanceof TextMessage) { + assertTextMessageEqual(message, (TextMessage) m1, (TextMessage) m2); + } else { + assertEquals(message, m1, m2); + } + } - /** - * Creates an ActiveMQConnectionFactory. - * - * @return ActiveMQConnectionFactory - * @throws Exception - */ - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { - return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); - } + /** + * Test if base directory contains spaces + */ + protected void assertBaseDirectoryContainsSpaces() { + assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" ")); + } - /** - * Factory method to create a new connection. - * - * @return connection - * @throws Exception - */ - protected Connection createConnection() throws Exception { - return getConnectionFactory().createConnection(); - } + /** + * Creates an ActiveMQConnectionFactory. + * + * @return ActiveMQConnectionFactory + * @throws Exception + */ + protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { + return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); + } - /** - * Creates an ActiveMQ connection factory. - * - * @return connectionFactory - * @throws Exception - */ - public ActiveMQConnectionFactory getConnectionFactory() throws Exception { - if (connectionFactory == null) { - connectionFactory = createConnectionFactory(); - assertTrue("Should have created a connection factory!", connectionFactory != null); - } + /** + * Factory method to create a new connection. + * + * @return connection + * @throws Exception + */ + protected Connection createConnection() throws Exception { + return getConnectionFactory().createConnection(); + } - return connectionFactory; - } + /** + * Creates an ActiveMQ connection factory. + * + * @return connectionFactory + * @throws Exception + */ + public ActiveMQConnectionFactory getConnectionFactory() throws Exception { + if (connectionFactory == null) { + connectionFactory = createConnectionFactory(); + assertTrue("Should have created a connection factory!", connectionFactory != null); + } - /** - * Returns the consumer subject. - * - * @return String - */ - protected String getConsumerSubject() { - return getSubject(); - } + return connectionFactory; + } - /** - * Returns the producer subject. - * - * @return String - */ - protected String getProducerSubject() { - return getSubject(); - } + /** + * Returns the consumer subject. + * + * @return String + */ + protected String getConsumerSubject() { + return getSubject(); + } - /** - * Returns the subject. - * - * @return String - */ - protected String getSubject() { - return getClass().getName() + "." + getName(); - } + /** + * Returns the producer subject. + * + * @return String + */ + protected String getProducerSubject() { + return getSubject(); + } - protected void assertArrayEqual(String message, Object[] expected, Object[] actual) { - assertEquals(message + ". Array length", expected.length, actual.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(message + ". element: " + i, expected[i], actual[i]); - } - } + /** + * Returns the subject. + * + * @return String + */ + protected String getSubject() { + return getClass().getName() + "." + getName(); + } - protected void assertPrimitiveArrayEqual(String message, Object expected, Object actual) { - int length = Array.getLength(expected); - assertEquals(message + ". Array length", length, Array.getLength(actual)); - for (int i = 0; i < length; i++) { - assertEquals(message + ". element: " + i, Array.get(expected, i), Array.get(actual, i)); - } - } + protected void assertArrayEqual(String message, Object[] expected, Object[] actual) { + assertEquals(message + ". Array length", expected.length, actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals(message + ". element: " + i, expected[i], actual[i]); + } + } + + protected void assertPrimitiveArrayEqual(String message, Object expected, Object actual) { + int length = Array.getLength(expected); + assertEquals(message + ". Array length", length, Array.getLength(actual)); + for (int i = 0; i < length; i++) { + assertEquals(message + ". element: " + i, Array.get(expected, i), Array.get(actual, i)); + } + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java index 34489ae163..d5d87aba43 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.test.message; +import javax.jms.JMSException; +import javax.jms.Message; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.jms.JMSException; -import javax.jms.Message; - import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapMessageTest.java index 1bf7319dae..052ff17b1b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapMessageTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.test.message; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; - import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsAndEmbeddedBrokerTest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/DummyMessageQuery.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/DummyMessageQuery.java index ae841f988d..7136ac8890 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/DummyMessageQuery.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/DummyMessageQuery.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithDestinationBasedBufferTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithDestinationBasedBufferTest.java index 467aa9ae5d..399177fdc4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithDestinationBasedBufferTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithDestinationBasedBufferTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java index 7640f9c183..5e78c6959e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java index dbfc7f7189..ace29ef1d7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.test.retroactive; -import java.net.URI; -import java.util.Date; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,6 +23,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.Date; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithTimePolicyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithTimePolicyTest.java index 220ba99a8e..b334d88ff3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithTimePolicyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithTimePolicyTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerWithMessageQueryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerWithMessageQueryTest.java index 7e9188c3de..d91a1fd316 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerWithMessageQueryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerWithMessageQueryTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.test.retroactive; -import java.net.URI; -import java.util.Date; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.Date; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/CloseRollbackRedeliveryQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/CloseRollbackRedeliveryQueueTest.java index 41e12e20ee..ca67d57858 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/CloseRollbackRedeliveryQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/CloseRollbackRedeliveryQueueTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/DelegatingTransactionalMessageListener.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/DelegatingTransactionalMessageListener.java index 8288925dad..bd1de387b8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/DelegatingTransactionalMessageListener.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/DelegatingTransactionalMessageListener.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, @@ -45,8 +45,7 @@ public class DelegatingTransactionalMessageListener implements MessageListener { session = connection.createSession(transacted, ackMode); MessageConsumer consumer = session.createConsumer(destination); consumer.setMessageListener(this); - } - catch (JMSException e) { + } catch (JMSException e) { throw new IllegalStateException("Could not listen to " + destination, e); } } @@ -56,8 +55,7 @@ public class DelegatingTransactionalMessageListener implements MessageListener { try { underlyingListener.onMessage(message); session.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { rollback(); } } @@ -65,8 +63,7 @@ public class DelegatingTransactionalMessageListener implements MessageListener { private void rollback() { try { session.rollback(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("Failed to rollback: " + e, e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/RollbacksWhileConsumingLargeQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/RollbacksWhileConsumingLargeQueueTest.java index d748fd2f44..e648fd743b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/RollbacksWhileConsumingLargeQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/rollback/RollbacksWhileConsumingLargeQueueTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.test.rollback; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +24,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; @@ -74,8 +73,7 @@ public class RollbacksWhileConsumingLargeQueueTest extends EmbeddedBrokerTestSup try { onMessage(message); session.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { session.rollback(); } } @@ -157,15 +155,13 @@ public class RollbacksWhileConsumingLargeQueueTest extends EmbeddedBrokerTestSup try { msgId = message.getJMSMessageID(); msgText = ((TextMessage) message).getText(); - } - catch (JMSException e) { + } catch (JMSException e) { setFailure(e); } try { assertEquals("Message: " + ackCounter.get(), msgText); - } - catch (Throwable e) { + } catch (Throwable e) { setFailure(e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java index 56d1546afe..f5fb85580b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java index 18e7ba8719..89846cf754 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.transport; -import java.net.URI; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -27,6 +23,10 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.config.Configuration; @@ -106,8 +106,7 @@ public class SoWriteTimeoutClientTest extends OpenwireArtemisBaseTest { public void run() { try { sendMessages(pc, dest, messageCount); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } @@ -122,12 +121,10 @@ public class SoWriteTimeoutClientTest extends OpenwireArtemisBaseTest { } Assert.assertNull(consumer.receive(5000)); - } - finally { + } finally { pc.close(); } - } - finally { + } finally { proxy.close(); c.close(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutTest.java index bf7bb25759..589a3fd3df 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutTest.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, @@ -16,16 +16,15 @@ */ package org.apache.activemq.transport; -import java.net.Socket; -import java.net.SocketException; -import java.net.URI; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.net.Socket; +import java.net.SocketException; +import java.net.URI; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -95,8 +94,7 @@ public class SoWriteTimeoutTest extends JmsTestSupport { try { session.commit(); fail("expect commit to fail as server has aborted writeTimeout connection"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } } @@ -153,8 +151,7 @@ public class SoWriteTimeoutTest extends JmsTestSupport { stompConnection.send("jms.queue." + dest.getPhysicalName(), "ShouldBeDeadConnectionText" + i); } fail("expected send to fail with timeout out connection"); - } - catch (SocketException expected) { + } catch (SocketException expected) { LOG.info("got exception on send after timeout: " + expected); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubCompositeTransport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubCompositeTransport.java index 108249a4f0..bd9a059acf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubCompositeTransport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubCompositeTransport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransport.java index 5db291e043..c4bad7e89a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransportListener.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransportListener.java index a35003dc72..b017b985f5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransportListener.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/StubTransportListener.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java index 704f97b2f9..cbf42a1bcd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.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, @@ -17,8 +17,6 @@ package org.apache.activemq.transport; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -29,6 +27,7 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; @@ -89,8 +88,7 @@ public class TopicClusterTest extends OpenwireArtemisBaseTest implements Message } LOG.info("Sleeping to ensure cluster is fully connected"); Thread.sleep(5000); - } - finally { + } finally { System.setProperty("activemq.store.dir", root); } } @@ -133,8 +131,7 @@ public class TopicClusterTest extends OpenwireArtemisBaseTest implements Message protected Destination createDestination(String name) { if (topic) { return new ActiveMQTopic(name); - } - else { + } else { return new ActiveMQQueue(name); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java index 380f4853be..539267e989 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java index 48aa82bc7c..d36ae118ea 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.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, @@ -16,15 +16,12 @@ */ package org.apache.activemq.transport.discovery; -import static org.junit.Assert.assertTrue; - +import javax.management.ObjectInstance; +import javax.management.ObjectName; import java.net.URI; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import javax.management.ObjectInstance; -import javax.management.ObjectName; - import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.jmx.ManagementContext; import org.apache.activemq.util.SocketProxy; @@ -45,6 +42,8 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + @RunWith(JMock.class) public class DiscoveryNetworkReconnectTest { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportBrokerTest.java index 1238eac696..f6373aa34d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportBrokerTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.transport.discovery; +import javax.jms.DeliveryMode; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import javax.jms.DeliveryMode; - import junit.framework.Test; import org.apache.activemq.broker.StubConnection; @@ -96,8 +95,7 @@ public class DiscoveryTransportBrokerTest extends NetworkTestSupport { connectionA = connection1; connectionB = connection2; serverA = connector; - } - else { + } else { connectionA = connection2; connectionB = connection1; serverA = remoteConnector; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java index d244dab768..a529e6c610 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.transport.discovery; +import javax.jms.Connection; +import javax.jms.JMSException; import java.net.URI; import java.util.Map; import java.util.Vector; -import javax.jms.Connection; -import javax.jms.JMSException; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.CombinationTestSupport; import org.apache.activemq.broker.BrokerService; @@ -92,8 +91,7 @@ public class DiscoveryTransportNoBrokerTest extends CombinationTestSupport { Connection connection = factory.createConnection(); connection.setClientID("test"); fail("Did not fail to connect as expected."); - } - catch (JMSException expected) { + } catch (JMSException expected) { assertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException); } } @@ -114,8 +112,7 @@ public class DiscoveryTransportNoBrokerTest extends CombinationTestSupport { Connection connection = factory.createConnection(); connection.setClientID("test"); fail("Did not fail to connect as expected."); - } - catch (JMSException expected) { + } catch (JMSException expected) { assertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException); long duration = System.currentTimeMillis() - startT; assertTrue("took at least initialReconnectDelay time: " + duration + " e:" + expected, duration >= initialReconnectDelay); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryUriTest.java index b902c2533a..20434d3d3e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryUriTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/DiscoveryUriTest.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, @@ -17,14 +17,18 @@ package org.apache.activemq.transport.discovery; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import java.net.URI; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; -import javax.jms.*; -import java.net.URI; - public class DiscoveryUriTest extends EmbeddedBrokerTestSupport { @Override @@ -57,8 +61,7 @@ public class DiscoveryUriTest extends EmbeddedBrokerTestSupport { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://default?group=test1)?reconnectDelay=1000&startupMaxReconnectAttempts=3&useExponentialBackOff=false"); Connection conn = factory.createConnection(); conn.start(); - } - catch (Exception e) { + } catch (Exception e) { return; } fail("Expected connection failure"); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/ZeroconfDiscoverTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/ZeroconfDiscoverTransportTest.java index 8656d07e9a..598a3014d2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/ZeroconfDiscoverTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/discovery/ZeroconfDiscoverTransportTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java index bc7b44bc84..7723fb6802 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.transport.failover; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.ExceptionListener; @@ -33,6 +26,12 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.TransactionRolledBackException; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.api.core.SimpleString; @@ -86,8 +85,7 @@ public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionLis bs.start(); restarted.set(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -142,8 +140,7 @@ public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionLis bs.start(); restarted.set(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -251,19 +248,16 @@ public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionLis Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER)); try { session.commit(); - } - catch (TransactionRolledBackException expectedOnOccasion) { + } catch (TransactionRolledBackException expectedOnOccasion) { log.info("got rollback: " + expectedOnOccasion); i--; } } Assert.assertNull(consumer.receive(500)); - } - catch (Exception eee) { + } catch (Exception eee) { log.error("got exception", eee); throw eee; - } - finally { + } finally { consumer.close(); session.close(); connection.close(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java index 3765bb3dc7..1625bc2255 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.transport.failover; +import javax.jms.Connection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; -import javax.jms.Connection; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; @@ -84,8 +83,7 @@ public class ConnectionHangOnStartupTest extends OpenwireArtemisBaseTest { try { conn.set(createConnectionFactory().createConnection()); conn.get().start(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error("could not create or start connection", ex); } connStarted.countDown(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java index 4fc5c42299..63e62eb848 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertTrue; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.Session; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.api.jms.management.JMSServerControl; @@ -36,7 +35,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.TimeUnit; +import static org.junit.Assert.assertTrue; /** * Ensures connections aren't leaked when when we use backup=true and randomize=false @@ -127,19 +126,16 @@ public class FailoverBackupLeakTest extends OpenwireArtemisBaseTest { try { conn = local.createConnection(); sess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE); - } - finally { + } finally { try { if (sess != null) sess.close(); - } - catch (JMSException ignore) { + } catch (JMSException ignore) { } try { if (conn != null) conn.close(); - } - catch (JMSException ignore) { + } catch (JMSException ignore) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java index 9e19b90970..1ba1d19599 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.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, @@ -49,7 +49,6 @@ public class FailoverClusterTest extends OpenwireArtemisBaseTest { EmbeddedJMS server1; EmbeddedJMS server2; - @Before public void setUp() throws Exception { Map params = new HashMap<>(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java index b518ad5dab..6386d7ace7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTestSupport.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.transport.failover; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -23,12 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.Session; - import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnection; @@ -81,8 +80,7 @@ public class FailoverClusterTestSupport extends TestCase { double count = clientConnectionCounts.get(key); count += 1.0; clientConnectionCounts.put(key, count); - } - else { + } else { clientConnectionCounts.put(key, 1.0); } } @@ -125,8 +123,7 @@ public class FailoverClusterTestSupport extends TestCase { try { b.stop(); b.waitUntilStopped(); - } - catch (Exception e) { + } catch (Exception e) { // Keep on going, we want to try and stop them all. logger.info("Error while stopping broker[" + b.getBrokerName() + "] continuing..."); } @@ -159,8 +156,7 @@ public class FailoverClusterTestSupport extends TestCase { connector.setRebalanceClusterClients(true); connector.setUpdateClusterClients(true); connector.setUpdateClusterClientsOnRemove(true); - } - else { + } else { connector.setRebalanceClusterClients(false); connector.setUpdateClusterClients(false); connector.setUpdateClusterClientsOnRemove(false); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java index 66cb09a339..f9c4015b2a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.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, @@ -58,7 +58,6 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest { private static final int NUMBER_OF_CLIENTS = 30; private final List connections = new ArrayList<>(); - @Before public void setUp() throws Exception { } @@ -117,7 +116,6 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest { runTests(false, null, null, null); } - /** * Tests a 3 broker configuration to ensure that the backup is random and * supported in a cluster. useExponentialBackOff is set to false and @@ -425,8 +423,7 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest { double count = clientConnectionCounts.get(key); count += 1.0; clientConnectionCounts.put(key, count); - } - else { + } else { clientConnectionCounts.put(key, 1.0); } } @@ -437,8 +434,7 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest { double count = clientConnectionCounts.get(key); double percentage = count / total; if (percentage < minimumPercentage || percentage > maximumPercentage) { - errorMsgs.add("Connections distribution expected to be within range [ " + minimumPercentage - + ", " + maximumPercentage + "]. Actuall distribution was " + percentage + " for connection " + key); + errorMsgs.add("Connections distribution expected to be within range [ " + minimumPercentage + ", " + maximumPercentage + "]. Actuall distribution was " + percentage + " for connection " + key); } if (errorMsgs.size() > 0) { for (String err : errorMsgs) { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java index c31aba2bbe..ed397dd2dd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java @@ -16,17 +16,6 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -35,6 +24,10 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -44,11 +37,17 @@ import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; import org.jboss.byteman.contrib.bmunit.BMRule; import org.jboss.byteman.contrib.bmunit.BMRules; import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.After; +import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.junit.After; -import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; @RunWith(BMUnitRunner.class) public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTest { @@ -124,8 +123,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe try { consumerSession.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } commitDoneLatch.countDown(); @@ -141,10 +139,8 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe LOG.info("producer started"); try { produceMessage(producerSession, destination, prefetch * 2); - } - catch (javax.jms.IllegalStateException SessionClosedExpectedOnShutdown) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException SessionClosedExpectedOnShutdown) { + } catch (JMSException e) { e.printStackTrace(); fail("unexpceted ex on producer: " + e); } @@ -152,7 +148,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe } }.start(); - // will be stopped by the plugin + // will be stopped by the plugin brokerStopLatch.await(); server.stop(); server = createBroker(); @@ -167,14 +163,13 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe @Test @BMRules( - rules = { - @BMRule( - name = "set no return response", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processCommitTransactionOnePhase", - targetLocation = "ENTRY", - binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()", - action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"), + rules = {@BMRule( + name = "set no return response", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processCommitTransactionOnePhase", + targetLocation = "ENTRY", + binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()", + action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"), @BMRule( name = "stop broker before commit", @@ -241,8 +236,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe produceMessage(consumerSession, signalDestination, 1); LOG.info("commit session"); consumerSession.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("commit exception", e); gotCommitException.set(true); } @@ -259,10 +253,8 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe LOG.info("producer started"); try { produceMessage(producerSession, destination, prefetch * 2); - } - catch (javax.jms.IllegalStateException SessionClosedExpectedOnShutdown) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException SessionClosedExpectedOnShutdown) { + } catch (JMSException e) { e.printStackTrace(); fail("unexpceted ex on producer: " + e); } @@ -371,11 +363,9 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe LOG.info("Stopping broker in transaction..."); try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { brokerStopLatch.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java index 05116a5a95..f2ab9f463f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertTrue; - -import java.util.Vector; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; @@ -32,6 +24,11 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Vector; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -49,17 +46,20 @@ import org.apache.activemq.util.Wait; import org.jboss.byteman.contrib.bmunit.BMRule; import org.jboss.byteman.contrib.bmunit.BMRules; import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.junit.After; -import org.junit.Test; + +import static org.junit.Assert.assertTrue; // see https://issues.apache.org/activemq/browse/AMQ-2573 @RunWith(BMUnitRunner.class) public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { + private static final Logger LOG = LoggerFactory.getLogger(FailoverConsumerUnconsumedTest.class); private static final String QUEUE_NAME = "FailoverWithUnconsumed"; private static final AtomicBoolean doByteman = new AtomicBoolean(false); @@ -88,15 +88,12 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processAddConsumer", - targetLocation = "ENTRY", - action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processAddConsumer", + targetLocation = "ENTRY", + action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)")}) public void testFailoverConsumerDups() throws Exception { watchTopicAdvisories.set(true); doTestFailoverConsumerDups(true); @@ -104,15 +101,12 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processAddConsumer", - targetLocation = "ENTRY", - action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processAddConsumer", + targetLocation = "ENTRY", + action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)")}) public void testFailoverConsumerDupsNoAdvisoryWatch() throws Exception { watchTopicAdvisories.set(false); doTestFailoverConsumerDups(false); @@ -120,15 +114,12 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processAddConsumer", - targetLocation = "ENTRY", - action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processAddConsumer", + targetLocation = "ENTRY", + action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker($0)")}) public void testFailoverClientAckMissingRedelivery() throws Exception { maxConsumers = 2; brokerStopLatch = new CountDownLatch(1); @@ -153,8 +144,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { public void onMessage(Message message) { try { LOG.info("onMessage:" + message.getJMSMessageID()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -189,8 +179,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { public void onMessage(Message message) { try { LOG.info("onMessage:" + message.getJMSMessageID()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -198,8 +187,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { testConsumers.add(testConsumer); shutdownConsumerAdded.countDown(); LOG.info("done add last consumer"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -280,8 +268,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { testConsumers.add(new TestConsumer(consumerSession, destination, connection)); shutdownConsumerAdded.countDown(); LOG.info("done add last consumer"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -373,8 +360,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { try { broker.stop(); brokerStopLatch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -394,8 +380,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest { broker.stop(); Assert.assertEquals(1, brokerStopLatch.getCount()); brokerStopLatch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java index e2654e76f8..ae0d0e85ae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.transport.failover; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -30,6 +25,10 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection; @@ -88,15 +87,12 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processMessage", - targetLocation = "EXIT", - action = "org.apache.activemq.transport.failover.FailoverDuplicateTest.holdResponseAndStopConn($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processMessage", + targetLocation = "EXIT", + action = "org.apache.activemq.transport.failover.FailoverDuplicateTest.holdResponseAndStopConn($0)")}) public void testFailoverSendReplyLost() throws Exception { broker = createBroker(); @@ -134,8 +130,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest { LOG.info("doing async send..."); try { produceMessage(sendSession, destination, "will resend", 1); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("got send exception: ", e); Assert.fail("got unexpected send exception" + e); } @@ -221,8 +216,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest { Assert.assertTrue("new producers done on time", producersDone.await(120, TimeUnit.SECONDS)); LOG.info("Stopping connection post send and receive and multiple producers"); context.getContext().getConnection().fail(null, "test Failoverduplicatetest"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java index 959631761d..ae82e3d48a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java @@ -109,8 +109,7 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest { } receiveDone.countDown(); LOG.info("done receive"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -149,11 +148,9 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest { public void run() { try { broker.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { brokerStopLatch.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java index 3b7e1807d4..68db9c0077 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.failover; +import javax.jms.Connection; +import javax.jms.JMSException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -35,9 +37,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.Connection; -import javax.jms.JMSException; - public class FailoverPriorityTest extends OpenwireArtemisBaseTest { protected final Logger LOG = LoggerFactory.getLogger(getClass()); @@ -195,8 +194,7 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest { LOG.info("Stopping " + primaryID); stopBroker(primaryID); Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1)); - } - else { + } else { LOG.info("Stopping " + secondaryID); stopBroker(secondaryID); Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1)); @@ -205,8 +203,7 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest { if (primary) { assertAllConnectedTo(urls.get(secondaryID)); - } - else { + } else { assertAllConnectedTo(urls.get(primaryID)); } @@ -220,8 +217,7 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest { Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total)); Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total)); - } - else { + } else { Configuration config = createConfig("127.0.0.1", secondaryID); deployClusterConfiguration(config, primaryID); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java index 8500cdad00..0708221946 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.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, @@ -17,6 +17,10 @@ package org.apache.activemq.transport.failover; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.config.Configuration; @@ -28,10 +32,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - public class FailoverRandomTest extends OpenwireArtemisBaseTest { private EmbeddedJMS server0, server1; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java index 06f15c8f6c..2ecc02336b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java index 72b8c435d6..fc2a1e4f9d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.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, @@ -16,17 +16,12 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.net.URI; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -40,6 +35,10 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class FailoverTimeoutTest extends OpenwireArtemisBaseTest { private static final Logger LOG = LoggerFactory.getLogger(FailoverTimeoutTest.class); @@ -77,8 +76,7 @@ public class FailoverTimeoutTest extends OpenwireArtemisBaseTest { try { connection.start(); fail("Should have failed to connect"); - } - catch (JMSException ex) { + } catch (JMSException ex) { LOG.info("Caught exception on call to start: {}", ex.getMessage()); } @@ -106,8 +104,7 @@ public class FailoverTimeoutTest extends OpenwireArtemisBaseTest { try { producer.send(message); - } - catch (JMSException jmse) { + } catch (JMSException jmse) { assertEquals("Failover timeout of " + timeout + " ms reached.", jmse.getMessage()); } @@ -119,8 +116,7 @@ public class FailoverTimeoutTest extends OpenwireArtemisBaseTest { server.stop(); server = null; - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -138,8 +134,7 @@ public class FailoverTimeoutTest extends OpenwireArtemisBaseTest { URI[] bunchOfUnknownAndOneKnown = new URI[]{new URI("tcp://unknownHost:" + tcpUri.getPort()), new URI("tcp://unknownHost2:" + tcpUri.getPort()), new URI("tcp://localhost:2222")}; failoverTransport.add(false, bunchOfUnknownAndOneKnown); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java index 44f2f438b3..2b7895afc0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.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, @@ -16,26 +16,6 @@ */ package org.apache.activemq.transport.failover; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.AutoFailTestSupport; -import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; -import org.apache.activemq.transport.TransportListener; -import org.apache.activemq.util.SocketProxy; -import org.jboss.byteman.contrib.bmunit.BMRule; -import org.jboss.byteman.contrib.bmunit.BMRules; -import org.jboss.byteman.contrib.bmunit.BMUnitRunner; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -60,6 +40,26 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.AutoFailTestSupport; +import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection; +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; +import org.apache.activemq.transport.TransportListener; +import org.apache.activemq.util.SocketProxy; +import org.jboss.byteman.contrib.bmunit.BMRule; +import org.jboss.byteman.contrib.bmunit.BMRules; +import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + // see https://issues.apache.org/activemq/browse/AMQ-2473 // https://issues.apache.org/activemq/browse/AMQ-2590 @@ -136,15 +136,12 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processCommitTransactionOnePhase", - targetLocation = "EXIT", - action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processCommitTransactionOnePhase", + targetLocation = "EXIT", + action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")}) public void testFailoverCommitReplyLost() throws Exception { LOG.info(this + " running test testFailoverCommitReplyLost"); @@ -170,8 +167,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("doing async commit..."); try { session.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { Assert.assertTrue(e instanceof TransactionRolledBackException); LOG.info("got commit exception: ", e); } @@ -231,16 +227,13 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processMessage", - targetLocation = "EXIT", - binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()", - action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processMessage", + targetLocation = "EXIT", + binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()", + action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")}) public void testFailoverSendReplyLost() throws Exception { LOG.info(this + " running test testFailoverSendReplyLost"); broker = createBroker(); @@ -263,8 +256,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("doing async send..."); try { produceMessage(session, destination); - } - catch (JMSException e) { + } catch (JMSException e) { //assertTrue(e instanceof TransactionRolledBackException); LOG.error("got send exception: ", e); Assert.fail("got unexpected send exception" + e); @@ -316,15 +308,12 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processMessage", - targetLocation = "EXIT", - action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopProxyOnFirstSend($0)") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processMessage", + targetLocation = "EXIT", + action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopProxyOnFirstSend($0)")}) public void testFailoverConnectionSendReplyLost() throws Exception { LOG.info(this + " running test testFailoverConnectionSendReplyLost"); broker = createBroker(); @@ -352,8 +341,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("doing async send..."); try { produceMessage(session, destination); - } - catch (JMSException e) { + } catch (JMSException e) { //assertTrue(e instanceof TransactionRolledBackException); LOG.info("got send exception: ", e); } @@ -514,39 +502,38 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { Assert.assertNotNull("Failed to get message: " + count, received); } session.commit(); - } - finally { + } finally { connection.close(); } Assert.assertTrue("connectionconsumer did not get a message", connectionConsumerGotOne.await(10, TimeUnit.SECONDS)); } -// @Test -// @BMRules( -// rules = { -// @BMRule( -// name = "set no return response and stop the broker", -// targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", -// targetMethod = "processMessageAck", -// targetLocation = "ENTRY", -// action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)") -// } -// ) -// public void testFailoverConsumerAckLost() throws Exception { -// LOG.info(this + " running test testFailoverConsumerAckLost"); -// // as failure depends on hash order of state tracker recovery, do a few times -// for (int i = 0; i < 3; i++) { -// try { -// LOG.info("Iteration: " + i); -// doTestFailoverConsumerAckLost(i); -// } -// finally { -// stopBroker(); -// } -// } -// } -// + // @Test + // @BMRules( + // rules = { + // @BMRule( + // name = "set no return response and stop the broker", + // targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + // targetMethod = "processMessageAck", + // targetLocation = "ENTRY", + // action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)") + // } + // ) + // public void testFailoverConsumerAckLost() throws Exception { + // LOG.info(this + " running test testFailoverConsumerAckLost"); + // // as failure depends on hash order of state tracker recovery, do a few times + // for (int i = 0; i < 3; i++) { + // try { + // LOG.info("Iteration: " + i); + // doTestFailoverConsumerAckLost(i); + // } + // finally { + // stopBroker(); + // } + // } + // } + // public void doTestFailoverConsumerAckLost(final int pauseSeconds) throws Exception { broker = createBroker(); broker.start(); @@ -614,22 +601,19 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("committing consumer1 session: " + receivedMessages.size() + " messsage(s)"); try { consumerSession1.commit(); - } - catch (JMSException expectedSometimes) { + } catch (JMSException expectedSometimes) { LOG.info("got exception ex on commit", expectedSometimes); if (expectedSometimes instanceof TransactionRolledBackException) { gotTransactionRolledBackException.set(true); // ok, message one was not replayed so we expect the rollback - } - else { + } else { throw expectedSometimes; } } commitDoneLatch.countDown(); LOG.info("done async commit"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -656,8 +640,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("post: from consumer1 received: " + msg); if (gotTransactionRolledBackException.get()) { Assert.assertNotNull("should be available again after commit rollback ex", msg); - } - else { + } else { Assert.assertNull("should be nothing left for consumer as receive should have committed", msg); } consumerSession1.commit(); @@ -670,8 +653,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { Assert.assertNotNull("got second message on consumer2", msg); consumerSession2.commit(); } - } - finally { + } finally { for (Connection c : connections) { c.close(); } @@ -700,8 +682,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { } LOG.info("Sweep received: " + msg); Assert.assertNull("no messges left dangling but got: " + msg, msg); - } - finally { + } finally { connection.close(); broker.stop(); } @@ -709,15 +690,12 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { @Test @BMRules( - rules = { - @BMRule( - name = "set no return response and stop the broker", - targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", - targetMethod = "processRemoveConsumer", - targetLocation = "ENTRY", - action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter()") - } - ) + rules = {@BMRule( + name = "set no return response and stop the broker", + targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor", + targetMethod = "processRemoveConsumer", + targetLocation = "ENTRY", + action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter()")}) public void testPoolingNConsumesAfterReconnect() throws Exception { LOG.info(this + " running test testPoolingNConsumesAfterReconnect"); count = 0; @@ -788,10 +766,8 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("calling close() " + ((ActiveMQMessageConsumer) localConsumer).getConsumerId()); localConsumer.close(); - } - catch (NoSuchElementException nse) { - } - catch (Exception ignored) { + } catch (NoSuchElementException nse) { + } catch (Exception ignored) { LOG.error("Ex on: " + ((ActiveMQMessageConsumer) localConsumer).getConsumerId(), ignored); } } @@ -833,8 +809,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("post: from consumer1 received: " + msg); Assert.assertNotNull("got message after failover", msg); msg.acknowledge(); - } - finally { + } finally { executorService.shutdown(); for (Connection c : connections) { c.close(); @@ -876,16 +851,14 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { try { consumerSession.commit(); Assert.fail("expected transaction rolledback ex"); - } - catch (TransactionRolledBackException expected) { + } catch (TransactionRolledBackException expected) { } broker.stop(); broker = createBroker(); broker.start(); Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000)); - } - finally { + } finally { connection.close(); } } @@ -925,8 +898,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { try { consumerSession.commit(); commitDone.countDown(); - } - catch (JMSException ignored) { + } catch (JMSException ignored) { } } }.start(); @@ -980,11 +952,9 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("doing async commit..."); try { consumerSession.commit(); - } - catch (JMSException ex) { + } catch (JMSException ex) { exceptions.add(ex); - } - finally { + } finally { commitDone.countDown(); } } @@ -1000,8 +970,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { if (exceptions.isEmpty()) { LOG.info("commit succeeded, message was redelivered to the correct consumer after restart so commit was fine"); Assert.assertNull("consumer2 not get a second message consumed by 1", consumer2.receive(2000)); - } - else { + } else { LOG.info("commit failed, consumer2 should get it", exceptions.get(0)); Assert.assertNotNull("consumer2 got message", consumer2.receive(2000)); consumerSession.commit(); @@ -1029,11 +998,9 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { try { broker.stop(); broker = null; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { brokerStopLatch.countDown(); } } @@ -1052,8 +1019,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { LOG.info("Stopping connection post send..."); try { proxy.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1076,11 +1042,9 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest { broker = null; } LOG.info("broker stopped."); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { brokerStopLatch.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java index 149af92530..564a6415c5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.net.URI; @@ -35,6 +31,10 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class FailoverTransportBackupsTest extends OpenwireArtemisBaseTest { private static final Logger LOG = LoggerFactory.getLogger(FailoverTransportBackupsTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java index fcd409ee40..18f418cd56 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.failover; +import javax.jms.DeliveryMode; +import javax.jms.MessageNotWriteableException; import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -23,9 +25,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.concurrent.TimeUnit; -import javax.jms.DeliveryMode; -import javax.jms.MessageNotWriteableException; - import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; @@ -67,14 +66,8 @@ public class FailoverTransportBrokerTest extends OpenwireArtemisBaseTest { public static final boolean FAST_NO_MESSAGE_LEFT_ASSERT = System.getProperty("FAST_NO_MESSAGE_LEFT_ASSERT", "true").equals("true"); @Parameterized.Parameters - public static Collection getParams() - { - return Arrays.asList(new Object[][] { - {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")}, - {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")}, - {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")}, - {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")} - }); + public static Collection getParams() { + return Arrays.asList(new Object[][]{{Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")}, {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")}, {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")}, {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")}}); } private EmbeddedJMS server; @@ -103,19 +96,16 @@ public class FailoverTransportBrokerTest extends OpenwireArtemisBaseTest { for (StubConnection conn : connections) { try { conn.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } try { remoteServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { } try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -173,8 +163,7 @@ public class FailoverTransportBrokerTest extends OpenwireArtemisBaseTest { message.setPersistent(false); try { message.setText("Test Message Payload."); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } return message; } @@ -257,15 +246,13 @@ public class FailoverTransportBrokerTest extends OpenwireArtemisBaseTest { StubConnection connectionA; StubConnection connectionB; - EmbeddedJMS serverA; if (new URI(newURI(0)).equals(ft.getConnectedTransportURI())) { connectionA = connection1; connectionB = connection2; serverA = server; - } - else { + } else { connectionA = connection2; connectionB = connection1; serverA = remoteServer; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java index 982306383e..d390a9891c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.net.URI; @@ -38,6 +34,10 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class FailoverTransportTest { protected Transport transport; @@ -106,15 +106,13 @@ public class FailoverTransportTest { tracker.track(connection); try { this.transport.oneway(new RemoveInfo(new ConnectionId("1"))); - } - catch (Exception e) { + } catch (Exception e) { fail("Should not have failed to remove this known connection"); } try { this.transport.oneway(new RemoveInfo(new ConnectionId("2"))); - } - catch (Exception e) { + } catch (Exception e) { fail("Should not have failed to remove this unknown connection"); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java index d64cc58914..e50a7363a1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.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, @@ -16,14 +16,15 @@ */ package org.apache.activemq.transport.failover; -import static org.junit.Assert.*; - import java.lang.reflect.Field; import java.net.URI; import java.util.Collection; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class FailoverTransportUriHandlingTest { @Test diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java index b7863e1a71..a8d0eebe14 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.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, @@ -16,18 +16,17 @@ */ package org.apache.activemq.transport.failover; -import java.io.File; -import java.io.FileOutputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.io.File; +import java.io.FileOutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.config.Configuration; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java index a0288329e5..69eff0f999 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java index 44c2010e84..4af0ec7fa6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.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, @@ -16,15 +16,15 @@ */ package org.apache.activemq.transport.failover; -import java.io.IOException; -import java.util.Date; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.io.IOException; +import java.util.Date; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.core.config.Configuration; @@ -39,7 +39,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class InitalReconnectDelayTest extends OpenwireArtemisBaseTest { @@ -132,8 +134,7 @@ public class InitalReconnectDelayTest extends OpenwireArtemisBaseTest { try { producer.send(destination, message); fail("Expect IOException to bubble up on send"); - } - catch (javax.jms.IllegalStateException producerClosed) { + } catch (javax.jms.IllegalStateException producerClosed) { } assertEquals("Only an exception is reported to the listener", 0x1, calls.get()); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java index 83d43affe5..0f95a7e307 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.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, @@ -16,6 +16,12 @@ */ package org.apache.activemq.transport.failover; +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -23,12 +29,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -115,12 +115,10 @@ public class ReconnectTest extends OpenwireArtemisBaseTest { if (!stopped.await(5, TimeUnit.SECONDS)) { connection.close(); stopped.await(5, TimeUnit.SECONDS); - } - else { + } else { connection.close(); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -149,11 +147,9 @@ public class ReconnectTest extends OpenwireArtemisBaseTest { iterations.incrementAndGet(); } session.close(); - } - catch (JMSException e) { + } catch (JMSException e) { setError(e); - } - finally { + } finally { stopped.countDown(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java index ed6040d286..7441abbf05 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.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, @@ -16,13 +16,15 @@ */ package org.apache.activemq.transport.failover; -import java.io.IOException; -import java.net.*; -import java.util.*; -import java.util.concurrent.CountDownLatch; - import javax.jms.Connection; import javax.net.ServerSocketFactory; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.util.Wait; @@ -51,8 +53,7 @@ public class SlowConnectionTest { public void run() { try { connection.start(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } }).start(); @@ -97,23 +98,18 @@ public class SlowConnectionTest { while (!interrupted()) { inProgress.add(ss.accept()); // eat socket } - } - catch (java.net.SocketTimeoutException expected) { - } - catch (Exception e) { + } catch (java.net.SocketTimeoutException expected) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { try { ss.close(); - } - catch (IOException ignored) { + } catch (IOException ignored) { } for (Socket s : inProgress) { try { s.close(); - } - catch (IOException ignored) { + } catch (IOException ignored) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java index 9daa4415ac..88c8e42fa1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.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, @@ -16,17 +16,6 @@ */ package org.apache.activemq.transport.failover; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import javax.jms.MessageConsumer; import javax.jms.Queue; import javax.jms.Session; @@ -38,6 +27,17 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + public class TwoBrokerFailoverClusterTest extends OpenwireArtemisBaseTest { private static final int NUMBER_OF_CLIENTS = 30; @@ -76,7 +76,6 @@ public class TwoBrokerFailoverClusterTest extends OpenwireArtemisBaseTest { assertClientsConnectionsEvenlyDistributed(.35); } - @Before public void setUp() throws Exception { HashMap map = new HashMap<>(); @@ -146,8 +145,7 @@ public class TwoBrokerFailoverClusterTest extends OpenwireArtemisBaseTest { double count = clientConnectionCounts.get(key); count += 1.0; clientConnectionCounts.put(key, count); - } - else { + } else { clientConnectionCounts.put(key, 1.0); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java index a9ebe9630a..9c291fd5fc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java index 49a67c8e3c..cea8010233 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.fanout; +import javax.jms.DeliveryMode; +import javax.jms.MessageNotWriteableException; import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -24,9 +26,6 @@ import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.jms.DeliveryMode; -import javax.jms.MessageNotWriteableException; - import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; @@ -59,6 +58,7 @@ import org.slf4j.LoggerFactory; @RunWith(Parameterized.class) public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { + public static final boolean FAST_NO_MESSAGE_LEFT_ASSERT = System.getProperty("FAST_NO_MESSAGE_LEFT_ASSERT", "true").equals("true"); protected ArrayList connections = new ArrayList<>(); @@ -74,15 +74,9 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { private ActiveMQDestination destination; private int deliveryMode; - @Parameterized.Parameters(name="test-{index}") - public static Collection getParams() - { - return Arrays.asList(new Object[][]{ - {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")}, - {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")}, - {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")}, - {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")} - }); + @Parameterized.Parameters(name = "test-{index}") + public static Collection getParams() { + return Arrays.asList(new Object[][]{{Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")}, {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")}, {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")}, {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")}}); } public FanoutTransportBrokerTest(int deliveryMode, ActiveMQDestination destination) { @@ -100,24 +94,22 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { remoteServer.start(); } + @After public void tearDown() throws Exception { for (StubConnection conn : connections) { try { conn.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } try { remoteServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { } try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -233,8 +225,7 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { // Send the message using the fail over publisher. try { connection3.request(createMessage(producerInfo3, destination, deliveryMode)); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } publishDone.countDown(); @@ -271,7 +262,6 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { return connection; } - protected StubConnection createConnection() throws Exception { Transport transport = TransportFactory.connect(new URI(newURI(0))); StubConnection connection = new StubConnection(transport); @@ -326,8 +316,7 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { message.setPersistent(false); try { message.setText("Test Message Payload."); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } return message; } @@ -368,6 +357,7 @@ public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest { } } } + protected void restartRemoteBroker() throws Exception { remoteServer.stop(); Thread.sleep(2000); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/multicast/MulticastTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/multicast/MulticastTransportTest.java index e76542bd6c..190a6d6495 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/multicast/MulticastTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/multicast/MulticastTransportTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsDurableTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsDurableTopicSendReceiveTest.java index 24f69ea80f..e6f1688c8b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsDurableTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsDurableTopicSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsSendAndReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsSendAndReceiveTest.java index 1c81ab0538..d0a91ae839 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsSendAndReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOJmsSendAndReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOPersistentSendAndReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOPersistentSendAndReceiveTest.java index 1cb6c39fb4..766793bcc1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOPersistentSendAndReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOPersistentSendAndReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java index d27003b836..6876730c4e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLConcurrencyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLConcurrencyTest.java index e854f8a0fc..e8f30cc91b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLConcurrencyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLConcurrencyTest.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, @@ -166,24 +166,20 @@ public class NIOSSLConcurrencyTest extends TestCase { Message msg = consumer.receive(3000); if (msg != null) { LOG.info("Received test message: " + received++); - } - else { + } else { if (breakOnNull) { break; } } } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); failed = true; - } - finally { + } finally { if (consumer != null) { try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -226,17 +222,14 @@ public class NIOSSLConcurrencyTest extends TestCase { Thread.sleep(sleep); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed = true; - } - finally { + } finally { if (producer != null) { try { producer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLLoadTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLLoadTest.java index 05f26f0164..c68beadc00 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLLoadTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLLoadTest.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, @@ -16,6 +16,10 @@ */ package org.apache.activemq.transport.nio; +import javax.jms.Connection; +import javax.jms.Queue; +import javax.jms.Session; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -25,10 +29,6 @@ import org.apache.activemq.util.ConsumerThread; import org.apache.activemq.util.ProducerThread; import org.apache.activemq.util.Wait; -import javax.jms.Connection; -import javax.jms.Queue; -import javax.jms.Session; - public class NIOSSLLoadTest extends TestCase { BrokerService broker; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java index 34c7dbcff7..497de97564 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLWindowSizeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLWindowSizeTest.java index 3f41802b41..fc13cc782b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLWindowSizeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLWindowSizeTest.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, @@ -16,12 +16,6 @@ */ package org.apache.activemq.transport.nio; -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.MessageConsumer; @@ -29,6 +23,12 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import junit.framework.TestCase; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; + @SuppressWarnings("javadoc") public class NIOSSLWindowSizeTest extends TestCase { @@ -98,16 +98,14 @@ public class NIOSSLWindowSizeTest extends TestCase { BytesMessage msg = session.createBytesMessage(); msg.writeBytes(messageData); prod.send(msg); - } - finally { + } finally { prod.close(); } MessageConsumer cons = null; try { cons = session.createConsumer(dest); assertNotNull(cons.receive(30000L)); - } - finally { + } finally { cons.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOTransportBrokerTest.java index a8422d31c0..532ad726e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOTransportBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/peer/PeerTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/peer/PeerTransportTest.java index a7d164749c..aaca6ed807 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/peer/PeerTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/peer/PeerTransportTest.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, @@ -129,8 +129,7 @@ public class PeerTransportTest extends TestCase { protected ActiveMQDestination createDestination(String name) { if (topic) { return new ActiveMQTopic(name); - } - else { + } else { return new ActiveMQQueue(name); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/DropCommandStrategy.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/DropCommandStrategy.java index 5ee7bab0b7..176016e6e3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/DropCommandStrategy.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/DropCommandStrategy.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/ReliableTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/ReliableTransportTest.java index 19edf10101..329452d292 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/ReliableTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/ReliableTransportTest.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, @@ -115,8 +115,7 @@ public class ReliableTransportTest extends TestCase { assertEquals("number of messages received", expectedCount, commands.size()); assertEquals("Should have no buffered commands", 0, transport.getBufferedCommandCount()); - } - else { + } else { assertTrue("Should have received an exception!", exceptions.size() > 0); Exception e = (Exception) exceptions.remove(); LOG.info("Caught expected response: " + e); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramChannel.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramChannel.java index c9e7cb0e99..16377cfd3d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramChannel.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramChannel.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, @@ -62,8 +62,7 @@ public class UnreliableCommandDatagramChannel extends CommandDatagramChannel { // lets still add it to the replay buffer though! getReplayBuffer().addBuffer(commandId, writeBuffer); - } - else { + } else { super.sendWriteBuffer(commandId, address, writeBuffer, redelivery); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramSocket.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramSocket.java index f315b0b688..e3f7ee8e95 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramSocket.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableCommandDatagramSocket.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, @@ -60,8 +60,7 @@ public class UnreliableCommandDatagramSocket extends CommandDatagramSocket { if (bufferCache != null && !redelivery) { bufferCache.addBuffer(commandId, data); } - } - else { + } else { super.sendWriteBuffer(commandId, address, data, redelivery); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransport.java index 0148595eca..7c68cc7bf8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransportTest.java index bd1db95fa1..426544aed4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransportTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java index 01f6963350..231b818123 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.SocketFactory; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import javax.net.SocketFactory; - import org.apache.activemq.CombinationTestSupport; import org.apache.activemq.command.WireFormatInfo; import org.apache.activemq.openwire.OpenWireFormat; @@ -123,8 +122,7 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra if (server != null) { server.stop(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } super.tearDown(); @@ -161,8 +159,7 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra } }); serverTransport.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -242,9 +239,9 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra public void initCombosForTestNoClientHangWithServerBlock() throws Exception { startClient(); - addCombinationValues("clientInactivityLimit", new Object[] {Long.valueOf(1000)}); - addCombinationValues("serverInactivityLimit", new Object[] {Long.valueOf(1000)}); - addCombinationValues("serverRunOnCommand", new Object[] {new Runnable() { + addCombinationValues("clientInactivityLimit", new Object[]{Long.valueOf(1000)}); + addCombinationValues("serverInactivityLimit", new Object[]{Long.valueOf(1000)}); + addCombinationValues("serverRunOnCommand", new Object[]{new Runnable() { @Override public void run() { try { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/QualityOfServiceUtilsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/QualityOfServiceUtilsTest.java index 84e8133c94..c955f387ed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/QualityOfServiceUtilsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/QualityOfServiceUtilsTest.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, @@ -96,8 +96,7 @@ public class QualityOfServiceUtilsTest extends TestCase { int dscp = -1; try { dscp = QualityOfServiceUtils.getDSCP(name); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { fail("IllegalArgumentException thrown for valid Differentiated " + " Services name: " + name); } // Make sure it adjusted for any system ECN values. @@ -108,8 +107,7 @@ public class QualityOfServiceUtilsTest extends TestCase { try { QualityOfServiceUtils.getDSCP(name); fail("No IllegalArgumentException thrown for invalid Differentiated" + " Services value: " + name + "."); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } @@ -118,8 +116,7 @@ public class QualityOfServiceUtilsTest extends TestCase { int dscp = QualityOfServiceUtils.getDSCP(Integer.toString(val)); // Make sure it adjusted for any system ECN values. assertEquals("Incorrect Differentiated Services Code Point " + "returned for value " + val + ".", ECN | (val << 2), dscp); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { fail("IllegalArgumentException thrown for valid Differentiated " + "Services value " + val); } } @@ -128,8 +125,7 @@ public class QualityOfServiceUtilsTest extends TestCase { try { QualityOfServiceUtils.getDSCP(Integer.toString(val)); fail("No IllegalArgumentException thrown for invalid " + "Differentiated Services value " + val + "."); - } - catch (IllegalArgumentException expected) { + } catch (IllegalArgumentException expected) { } } @@ -151,8 +147,7 @@ public class QualityOfServiceUtilsTest extends TestCase { try { int typeOfService = QualityOfServiceUtils.getToS(val); assertEquals("Incorrect Type of Services value returned for " + val + ".", val, typeOfService); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { fail("IllegalArgumentException thrown for valid Type of Service " + "value " + val + "."); } } @@ -161,8 +156,7 @@ public class QualityOfServiceUtilsTest extends TestCase { try { QualityOfServiceUtils.getToS(val); fail("No IllegalArgumentException thrown for invalid " + "Type of Service value " + val + "."); - } - catch (IllegalArgumentException expected) { + } catch (IllegalArgumentException expected) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/ServerSocketTstFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/ServerSocketTstFactory.java index 6d68166d65..6f6fffc0e5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/ServerSocketTstFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/ServerSocketTstFactory.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.util.Random; -import javax.net.ServerSocketFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SocketTstFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SocketTstFactory.java index f35fe69ffa..68c1bc287c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SocketTstFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SocketTstFactory.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, @@ -16,6 +16,7 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.SocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; @@ -24,8 +25,6 @@ import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import javax.net.SocketFactory; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,8 +66,7 @@ public class SocketTstFactory extends SocketFactory { lastDelay = closeIter.get(this.address); if (lastDelay == null) { lastDelayVal = 0; - } - else { + } else { lastDelayVal = lastDelay.intValue(); if (lastDelayVal > 10) lastDelayVal += 20; @@ -82,19 +80,16 @@ public class SocketTstFactory extends SocketFactory { try { Thread.sleep(lastDelayVal); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { this.processus.interrupt(); Thread.currentThread().interrupt(); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } this.socket.close(); closeIter.put(this.address, lastDelay); LOG.info("Client socket " + this.socket.toString() + " is closed."); - } - catch (IOException e) { + } catch (IOException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java index 5df0a9f1b9..3af39eca12 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.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, @@ -16,6 +16,14 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; @@ -25,19 +33,9 @@ import java.net.URI; import java.net.UnknownHostException; import java.security.KeyStore; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLException; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; - import junit.framework.Test; import junit.textui.TestRunner; - import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.FakeTransportConnector; @@ -72,15 +70,9 @@ public class SslBrokerServiceTest extends TransportBrokerTestSupport { service.setPersistent(false); String baseUri = getBindLocation(); - String uri0 = baseUri + "?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" - + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.SERVER_KEYSTORE + "&" - + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" - + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE; + String uri0 = baseUri + "?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.SERVER_KEYSTORE + "&" + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE; String uri1 = uri0 + "&" + TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME + "=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"; - String uri2 = uri0 + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true&" - + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.TRUST_KEYSTORE + "&" - + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" - + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE; + String uri2 = uri0 + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true&" + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.TRUST_KEYSTORE + "&" + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE; //broker side TransportConnector serverConnector0 = service.addConnector(new URI(uri0)); @@ -110,8 +102,7 @@ public class SslBrokerServiceTest extends TransportBrokerTestSupport { try { makeSSLConnection(context, null, needClientAuthConnector); fail("expected failure on no client cert"); - } - catch (SSLException expected) { + } catch (SSLException expected) { expected.printStackTrace(); } // should work with regular connector @@ -132,8 +123,7 @@ public class SslBrokerServiceTest extends TransportBrokerTestSupport { try { makeSSLConnection(context, new String[]{"SSL_RSA_WITH_RC4_128_MD5"}, limitedCipherSuites); fail("expected failure on non allowed cipher suite"); - } - catch (SSLException expectedOnNotAnAvailableSuite) { + } catch (SSLException expectedOnNotAnAvailableSuite) { } // ok with the enabled one diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextBrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextBrokerServiceTest.java index 5e5366b4ba..b3bf5801ad 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextBrokerServiceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextBrokerServiceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java index ee47e5c12c..ebbba0684e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.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, @@ -16,29 +16,28 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.net.URI; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Iterator; import java.util.Map; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; import org.junit.After; import org.junit.Before; import org.junit.Test; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class SslContextNBrokerServiceTest { @@ -65,8 +64,7 @@ public class SslContextNBrokerServiceTest { broker.waitUntilStarted(); try { result = verifySslCredentials(broker); - } - finally { + } finally { broker.stop(); } return result; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslSocketHelper.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslSocketHelper.java index 6413116b91..805306d49a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslSocketHelper.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslSocketHelper.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.transport.tcp; -import java.io.IOException; -import java.security.cert.X509Certificate; - import javax.management.remote.JMXPrincipal; import javax.net.ssl.SSLSocket; +import java.io.IOException; +import java.security.cert.X509Certificate; /** * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportBrokerTest.java index 468b27949d..1da218943c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java index a03dcd1533..32f5e75065 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.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, @@ -57,8 +57,7 @@ public class SslTransportFactoryTest extends TestCase { try { sslTransportServer = (SslTransportServer) factory.doBind(new URI("ssl://localhost:61616?" + options)); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to bind to address: " + e.getMessage()); } @@ -68,8 +67,7 @@ public class SslTransportFactoryTest extends TestCase { try { sslTransportServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to stop TransportServer: " + e.getMessage()); } } @@ -106,8 +104,7 @@ public class SslTransportFactoryTest extends TestCase { try { transport = new StubSslTransport(null, socketStub); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to create StubSslTransport: " + e.getMessage()); } @@ -125,8 +122,7 @@ public class SslTransportFactoryTest extends TestCase { // lets start the transport to force the introspection try { transport.start(); - } - catch (Exception e) { + } catch (Exception e) { // ignore bad connection } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportServerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportServerTest.java index 31acb07f1f..1675daebd0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportServerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportServerTest.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, @@ -45,8 +45,7 @@ public class SslTransportServerTest extends TestCase { try { sslTransportServer = new SslTransportServer(null, new URI("ssl://localhost:61616?" + options), socketFactory); - } - catch (Exception e) { + } catch (Exception e) { fail("Unable to create SslTransportServer."); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportTest.java index 0afb981e78..6d6ddd96b7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslTransportTest.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, @@ -17,11 +17,10 @@ package org.apache.activemq.transport.tcp; -import java.io.IOException; -import java.security.cert.X509Certificate; - import javax.management.remote.JMXPrincipal; import javax.net.ssl.SSLSocket; +import java.io.IOException; +import java.security.cert.X509Certificate; import junit.framework.TestCase; @@ -85,8 +84,7 @@ public class SslTransportTest extends TestCase { try { receivedCert = ((X509Certificate[]) receivedInfo.getTransportContext())[0]; - } - catch (Exception e) { + } catch (Exception e) { receivedCert = null; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLServerSocket.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLServerSocket.java index 1a5145c7a4..26504b25db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLServerSocket.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLServerSocket.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, @@ -17,9 +17,8 @@ package org.apache.activemq.transport.tcp; -import java.io.IOException; - import javax.net.ssl.SSLServerSocket; +import java.io.IOException; public class StubSSLServerSocket extends SSLServerSocket { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSession.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSession.java index df3a0b9709..d197e90683 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSession.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSession.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, @@ -17,13 +17,12 @@ package org.apache.activemq.transport.tcp; -import java.security.Principal; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; - import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSessionContext; +import java.security.Principal; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; class StubSSLSession implements SSLSession { @@ -34,8 +33,7 @@ class StubSSLSession implements SSLSession { if (cert != null) { this.isVerified = true; this.cert = cert; - } - else { + } else { this.isVerified = false; this.cert = null; } @@ -49,8 +47,7 @@ class StubSSLSession implements SSLSession { public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { if (this.isVerified) { return new X509Certificate[]{this.cert}; - } - else { + } else { throw new SSLPeerUnverifiedException("Socket is unverified."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocket.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocket.java index c50a0c27f1..48d44a12be 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocket.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocket.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, @@ -17,11 +17,10 @@ package org.apache.activemq.transport.tcp; -import java.io.IOException; - import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; +import java.io.IOException; public class StubSSLSocket extends SSLSocket { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocketFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocketFactory.java index 8e7b461e68..8241025a02 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocketFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSSLSocketFactory.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, @@ -17,12 +17,11 @@ package org.apache.activemq.transport.tcp; +import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; -import javax.net.ssl.SSLServerSocketFactory; - public class StubSSLSocketFactory extends SSLServerSocketFactory { private final ServerSocket retServerSocket; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSslTransport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSslTransport.java index 2e3c7fc6d2..54cd211bbc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSslTransport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubSslTransport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubX509Certificate.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubX509Certificate.java index dc75cc30af..b5fb939197 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubX509Certificate.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/StubX509Certificate.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransport.java index 0f0e6492e4..6973b93fa2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransport.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, @@ -16,17 +16,15 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.SocketFactory; import java.io.IOException; import java.net.URI; import java.net.UnknownHostException; import org.apache.activemq.Service; import org.apache.activemq.transport.Transport; - import org.apache.activemq.wireformat.WireFormat; -import javax.net.SocketFactory; - /** * An implementation of the {@link Transport} interface using raw tcp/ip * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java index 5bc9e2f361..7d11707c9c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ServerSocketFactory; +import javax.net.SocketFactory; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -23,9 +25,6 @@ import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; -import javax.net.ServerSocketFactory; -import javax.net.SocketFactory; - import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.TransportServer; import org.apache.activemq.util.IOExceptionSupport; @@ -60,8 +59,7 @@ public class TcpFaultyTransportFactory extends TcpTransportFactory { Integer.parseInt(path.substring(localPortIndex + 1, path.length())); String localString = location.getScheme() + ":/" + path; localLocation = new URI(localString); - } - catch (Exception e) { + } catch (Exception e) { LOG.warn("path isn't a valid local location for TcpTransport to use", e); } } @@ -88,8 +86,7 @@ public class TcpFaultyTransportFactory extends TcpTransportFactory { server.bind(); return server; - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportServer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportServer.java index 029fffdd33..a38f3970e4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportServer.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportServer.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.transport.tcp; +import javax.net.ServerSocketFactory; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import org.apache.activemq.util.ServiceListener; -import javax.net.ServerSocketFactory; - /** * A TCP based implementation of {@link TransportServer} * diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java index 38188cec0f..98476a4322 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.transport.tcp; -import java.util.Timer; -import java.util.TimerTask; - import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.Timer; +import java.util.TimerTask; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; @@ -60,8 +59,7 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport { public void run() { try { artemisBroker.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -71,8 +69,7 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport { try { consumer.receive(30000); fail("Should have thrown an exception"); - } - catch (Exception e) { + } catch (Exception e) { // should fail } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBrokerTest.java index 1a1be93ea0..db780df2d1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java index 110b1c2f89..dcda8f0a26 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java @@ -16,14 +16,18 @@ */ package org.apache.activemq.transport.tcp; -import junit.framework.TestCase; - -import org.apache.activemq.transport.*; - import java.net.Socket; import java.net.URI; import java.util.HashMap; +import junit.framework.TestCase; + +import org.apache.activemq.transport.Transport; +import org.apache.activemq.transport.TransportAcceptListener; +import org.apache.activemq.transport.TransportFactory; +import org.apache.activemq.transport.TransportFilter; +import org.apache.activemq.transport.TransportLogger; + /** * @author Christian Posta */ @@ -67,8 +71,7 @@ public class TcpTransportServerTest extends TestCase { } current = filter.getNext(); - } - else { + } else { end = true; } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportConnectorInvalidSocketOptionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportConnectorInvalidSocketOptionsTest.java index 870638a949..f1d1ee7684 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportConnectorInvalidSocketOptionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportConnectorInvalidSocketOptionsTest.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, @@ -31,8 +31,7 @@ public class TransportConnectorInvalidSocketOptionsTest extends TestCase { try { new ActiveMQConnectionFactory("tcp://localhost:42?foo=bar").createConnection(); fail("Should have thrown an exception"); - } - catch (Exception e) { + } catch (Exception e) { assertEquals(JMSException.class, e.getClass()); assertEquals(IllegalArgumentException.class, e.getCause().getClass()); assertEquals("Invalid connect parameters: {foo=bar}", e.getCause().getMessage()); @@ -52,14 +51,12 @@ public class TransportConnectorInvalidSocketOptionsTest extends TestCase { try { new ActiveMQConnectionFactory("tcp://localhost:61616?socket.foo=bar").createConnection(); fail("Should have thrown an exception"); - } - catch (Exception e) { + } catch (Exception e) { assertEquals(JMSException.class, e.getClass()); assertEquals(IllegalArgumentException.class, e.getCause().getClass()); assertEquals("Invalid socket parameters: {foo=bar}", e.getCause().getMessage()); } - } - finally { + } finally { if (broker != null) { broker.stop(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java index ce9aff9d77..f9f227c260 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.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, @@ -144,8 +144,7 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport { try { connection = new ActiveMQConnectionFactory(uri).createConnection(); connection.start(); - } - catch (Exception unexpected) { + } catch (Exception unexpected) { fail("Valid options '" + options + "' on URI '" + uri + "' should " + "not have caused an exception to be thrown. " + msg + " Exception: " + unexpected); } } @@ -158,8 +157,7 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport { connection = new ActiveMQConnectionFactory(uri).createConnection(); connection.start(); fail("Invalid options '" + options + "' on URI '" + uri + "' should" + " have caused an exception to be thrown. " + msg); - } - catch (Exception expected) { + } catch (Exception expected) { } } @@ -175,8 +173,7 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/WireformatNegociationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/WireformatNegociationTest.java index 27a378d055..5d7900c07f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/WireformatNegociationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/WireformatNegociationTest.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, @@ -130,8 +130,7 @@ public class WireformatNegociationTest extends CombinationTestSupport { } }); serverTransport.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -157,8 +156,7 @@ public class WireformatNegociationTest extends CombinationTestSupport { if (server != null) { server.stop(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } super.tearDown(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsAndLargeMessagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsAndLargeMessagesTest.java index c476652005..ff4b986dc6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsAndLargeMessagesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsAndLargeMessagesTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsTest.java index d3a342ca1d..c911388766 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpSendReceiveWithTwoConnectionsTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTestSupport.java index 55cee08aaa..80f699986c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTestSupport.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, @@ -16,9 +16,8 @@ */ package org.apache.activemq.transport.udp; -import java.io.IOException; - import javax.jms.MessageNotWriteableException; +import java.io.IOException; import junit.framework.TestCase; @@ -72,8 +71,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen assertEquals("Selector", expected.getSelector(), actual.getSelector()); assertEquals("isExclusive", expected.isExclusive(), actual.isExclusive()); assertEquals("getPrefetchSize", expected.getPrefetchSize(), actual.getPrefetchSize()); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Caught: " + e); e.printStackTrace(); fail("Failed to send to transport: " + e); @@ -120,8 +118,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen assertEquals("getText", expected.getText(), actual.getText()); LOG.info("Received text message with: " + actual.getText().length() + " character(s)"); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Caught: " + e); e.printStackTrace(); fail("Failed to send to transport: " + e); @@ -148,8 +145,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen consumer.setTransportListener(UdpTestSupport.this); try { consumer.start(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -197,8 +193,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen if (producer != null) { try { producer.stop(); - } - catch (Exception e) { + } catch (Exception e) { } } if (consumer != null) { @@ -214,8 +209,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen final Command command = (Command) o; if (command instanceof WireFormatInfo) { LOG.info("Got WireFormatInfo: " + command); - } - else { + } else { if (command.isResponseRequired()) { // lets send a response back... sendResponse(command); @@ -223,16 +217,14 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen } if (large) { LOG.info("### Received command: " + command.getClass() + " with id: " + command.getCommandId()); - } - else { + } else { LOG.info("### Received command: " + command); } synchronized (lock) { if (receivedCommand == null) { receivedCommand = command; - } - else { + } else { LOG.info("Ignoring superfluous command: " + command); } lock.notifyAll(); @@ -245,8 +237,7 @@ public abstract class UdpTestSupport extends TestCase implements TransportListen response.setCorrelationId(command.getCommandId()); try { consumer.oneway(response); - } - catch (IOException e) { + } catch (IOException e) { LOG.info("Caught: " + e); e.printStackTrace(); throw new RuntimeException(e); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportTest.java index d8d139d2ad..b85301533f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportUsingServerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportUsingServerTest.java index fc387d97b6..9a13931836 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportUsingServerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UdpTransportUsingServerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UpdTransportBindTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UpdTransportBindTest.java index 96436388dc..285523ec8e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UpdTransportBindTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/udp/UpdTransportBindTest.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq.transport.udp; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.EmbeddedBrokerTestSupport; - import javax.jms.Connection; import javax.jms.JMSException; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.EmbeddedBrokerTestSupport; + public class UpdTransportBindTest extends EmbeddedBrokerTestSupport { final String addr = "udp://localhost:61625"; @@ -36,8 +36,7 @@ public class UpdTransportBindTest extends EmbeddedBrokerTestSupport { try { Connection connection = new ActiveMQConnectionFactory(addr).createConnection(); connection.start(); - } - catch (JMSException e) { + } catch (JMSException e) { fail("Could not start the connection for a UDP Transport. " + "Check that the port and connector are available."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/CompositeMessageCursorUsageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/CompositeMessageCursorUsageTest.java index ff8d933a3c..52c2cc2111 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/CompositeMessageCursorUsageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/CompositeMessageCursorUsageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/JobSchedulerStoreUsageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/JobSchedulerStoreUsageTest.java index 06fd4a3ee8..c23c4e2b34 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/JobSchedulerStoreUsageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/JobSchedulerStoreUsageTest.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, @@ -17,12 +17,11 @@ package org.apache.activemq.usage; -import java.io.File; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Message; import javax.jms.Session; +import java.io.File; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; @@ -104,4 +103,4 @@ public class JobSchedulerStoreUsageTest extends EmbeddedBrokerTestSupport { assertTrue(broker.getAdminView().getJobSchedulerStorePercentUsage() < 100); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageLimitsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageLimitsTest.java index a5f53daf9a..38f5598128 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageLimitsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageLimitsTest.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, @@ -63,11 +63,9 @@ public class StoreUsageLimitsTest extends EmbeddedBrokerTestSupport { foundUsage = true; } } - } - catch (Exception e) { + } catch (Exception e) { fail(e.getMessage()); - } - finally { + } finally { br.close(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageTest.java index a133001d4f..6f4fe82acc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usage/StoreUsageTest.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, @@ -17,16 +17,16 @@ package org.apache.activemq.usage; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Session; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.util.ProducerThread; import org.apache.activemq.util.Wait; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Session; - public class StoreUsageTest extends EmbeddedBrokerTestSupport { final int WAIT_TIME_MILLS = 20 * 1000; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java index ec3d0a9d2e..49ae667017 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ2927Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ2927Test.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; +import java.net.URI; + import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQQueue; @@ -24,9 +27,6 @@ import org.apache.activemq.util.MessageIdList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.MessageConsumer; -import java.net.URI; - public class AMQ2927Test extends JmsMultipleBrokersTestSupport { private static final Logger LOG = LoggerFactory.getLogger(AMQ2927Test.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java index 1154510c8a..bb82e2a372 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.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, @@ -17,14 +17,13 @@ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; @@ -99,8 +98,7 @@ public class AMQStackOverFlowTest extends TestCase { assertEquals("test2", tm2.getText()); - } - finally { + } finally { brokerService1.stop(); brokerService1 = null; brokerService2.stop(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport.java index 47b43822aa..17f5fbc7ed 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; import java.io.File; import java.io.IOException; import java.net.URI; -import javax.jms.MessageConsumer; - import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.DestinationInterceptor; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicCleanUpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicCleanUpTest.java index fc424889c2..fa34300bf4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicCleanUpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicCleanUpTest.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, @@ -16,8 +16,11 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.*; - +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; @@ -31,7 +34,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; public class AdvisoryTopicCleanUpTest { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicDeletionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicDeletionTest.java index 6e8c8bf1d8..520142a3c4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicDeletionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicDeletionTest.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, @@ -97,8 +97,7 @@ public class AdvisoryTopicDeletionTest extends TestSupport { if (topic) { broker.getAdminView().removeTopic(((ActiveMQDestination) dest).getPhysicalName()); - } - else { + } else { broker.getAdminView().removeQueue(((ActiveMQDestination) dest).getPhysicalName()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java index e972226f01..892c27d00b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java index 9bfb5ee9bf..ae47ceba83 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.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, @@ -16,8 +16,8 @@ */ package org.apache.activemq.usecases; -import java.net.URI; import javax.jms.MessageConsumer; +import java.net.URI; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BatchedMessagePriorityConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BatchedMessagePriorityConsumerTest.java index 67401416fc..72aebb462c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BatchedMessagePriorityConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BatchedMessagePriorityConsumerTest.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, @@ -78,4 +78,4 @@ public class BatchedMessagePriorityConsumerTest extends JmsTestSupport { consumerSession.close(); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java index dd398aa947..0aba904669 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.List; -import java.util.concurrent.TimeUnit; - import javax.jms.Destination; import javax.jms.MessageConsumer; import javax.jms.TextMessage; +import java.net.URI; +import java.util.List; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -104,8 +103,7 @@ public class BrokerQueueNetworkWithDisconnectTest extends JmsMultipleBrokersTest LOG.info("sleeping for a bit in close impl to simulate load where reconnect fails due to a pending close"); TimeUnit.SECONDS.sleep(2); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } super.removeConnection(context, info, error); } @@ -205,24 +203,20 @@ public class BrokerQueueNetworkWithDisconnectTest extends JmsMultipleBrokersTest if (i == 50 || i == 150) { if (simulateStalledNetwork) { socketProxy.pause(); - } - else { + } else { socketProxy.close(); } networkDownTimeStart = System.currentTimeMillis(); - } - else if (networkDownTimeStart > 0) { + } else if (networkDownTimeStart > 0) { // restart after NETWORK_DOWN_TIME seconds if (networkDownTimeStart + NETWORK_DOWN_TIME < System.currentTimeMillis()) { if (simulateStalledNetwork) { socketProxy.goOn(); - } - else { + } else { socketProxy.reopen(); } networkDownTimeStart = 0; - } - else { + } else { // slow message production to allow bridge to recover and limit message duplication sleep(500); } @@ -233,8 +227,7 @@ public class BrokerQueueNetworkWithDisconnectTest extends JmsMultipleBrokersTest private void sleep(int milliSecondTime) { try { Thread.sleep(milliSecondTime); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } @@ -262,8 +255,7 @@ public class BrokerQueueNetworkWithDisconnectTest extends JmsMultipleBrokersTest connector.setDuplex(true); } return connector; - } - else { + } else { throw new Exception("Remote broker has no registered connectors."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseDLQTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseDLQTest.java index 0402012285..d365ca5e00 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseDLQTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseDLQTest.java @@ -16,6 +16,18 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.OpenDataException; +import javax.management.openmbean.TabularData; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; @@ -26,16 +38,8 @@ import org.apache.activemq.command.ActiveMQQueue; import org.junit.After; import org.junit.Test; -import javax.jms.*; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.OpenDataException; -import javax.management.openmbean.TabularData; - -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * @author Christian Posta diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java index 8b3b42bb02..d77642e630 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.Arrays; -import java.util.Enumeration; - import javax.jms.Destination; import javax.jms.MessageConsumer; import javax.jms.QueueBrowser; +import java.net.URI; +import java.util.Arrays; +import java.util.Enumeration; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; @@ -125,18 +124,15 @@ public class BrowseOverNetworkTest extends JmsMultipleBrokersTestSupport { LOG.info(broker + " consumer: " + message.getText() + " " + message.getDestination() + " " + message.getMessageId() + " " + Arrays.toString(message.getBrokerPath())); } } - } - else { + } else { totalCount = count; } LOG.info("browser '" + broker + "' browsed " + totalCount); Thread.sleep(1000); - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Exception browsing " + e, e); - } - finally { + } finally { try { if (browser != null) { browser.close(); @@ -144,8 +140,7 @@ public class BrowseOverNetworkTest extends JmsMultipleBrokersTestSupport { if (consumer != null) { consumer.close(); } - } - catch (Exception e) { + } catch (Exception e) { LOG.info("Exception closing browser " + e, e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java index dd7527d857..8e46da2016 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.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, @@ -17,14 +17,13 @@ package org.apache.activemq.usecases; -import java.util.HashMap; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; +import java.util.HashMap; import org.apache.activemq.test.TestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java index da838e250d..229ee4367b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.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, @@ -52,8 +52,7 @@ public class ChangeSessionDeliveryModeTest extends TestSupport implements Messag try { consumer2.receive(10); fail("Did not receive expected exception."); - } - catch (JMSException e) { + } catch (JMSException e) { assertTrue(e instanceof IllegalStateException); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java index 95242ca6a9..3c13b9534f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ClientRebalanceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java index c71f8df919..c07f0dd1b1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositeConsumeTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java index 651376a96d..aa2e3c1e10 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CompositePublishTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.List; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -25,6 +23,7 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; +import java.util.List; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.command.ActiveMQTopic; @@ -75,8 +74,7 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport { if (topic) { consumerDestination = session.createTopic(getConsumerSubject()); producerDestination = session.createTopic(getProducerSubject()); - } - else { + } else { consumerDestination = session.createQueue(getConsumerSubject()); producerDestination = session.createQueue(getProducerSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentDestinationCreationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentDestinationCreationTest.java index c577c86571..4fb283d168 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentDestinationCreationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentDestinationCreationTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; @@ -23,11 +28,6 @@ import java.util.Vector; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -94,15 +94,13 @@ public class ConcurrentDestinationCreationTest extends org.apache.activemq.TestS connection.close(); allDone.countDown(); LOG.info("Producers done!"); - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.error("unexpected ", ignored); exceptions.add(ignored); } } }); - } - else { + } else { executor.execute(new Runnable() { final ConnectionFactory factory = createConnectionFactory(); @@ -120,8 +118,7 @@ public class ConcurrentDestinationCreationTest extends org.apache.activemq.TestS connection.close(); allDone.countDown(); LOG.info("Consumers done!"); - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.error("unexpected ", ignored); exceptions.add(ignored); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java index 75922ec6ff..0df6875297 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerDurableConsumerTest.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, @@ -16,6 +16,18 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.TopicSubscriber; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -31,19 +43,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.TopicSubscriber; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQPrefetchPolicy; import org.apache.activemq.TestSupport; @@ -127,8 +126,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { consumer.setMessageListener(listener); consumers.put(consumer, listener); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("failed to start consumer", e); } } @@ -290,8 +288,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { msg.setText(initText + str); // Do not pad message text - } - else { + } else { msg.setText(initText); } @@ -314,8 +311,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { Connection conn = iter.next(); try { conn.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } broker.stop(); @@ -409,8 +405,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { int priority = 0; try { priority = message.getJMSPriority(); - } - catch (JMSException ignored) { + } catch (JMSException ignored) { } if (!messageLists.containsKey(priority)) { MessageIdList perPriorityList = new MessageIdList(); @@ -422,8 +417,7 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { firstReceipt = duration; firstReceiptLatch.countDown(); LOG.info("First receipt in " + firstReceipt + "ms"); - } - else if (count.get() % batchSize == 0) { + } else if (count.get() % batchSize == 0) { LOG.info("Consumed " + count.get() + " in " + batchReceiptAccumulator + "ms" + ", priority:" + priority); batchReceiptAccumulator = 0; } @@ -467,12 +461,10 @@ public class ConcurrentProducerDurableConsumerTest extends TestSupport { current.setValue(id); if (previous == null) { previous = current.copy(); - } - else { + } else { if (current.getProducerSequenceId() - 1 != previous.getProducerSequenceId() && current.getProducerSequenceId() - 10 != previous.getProducerSequenceId()) { return "Missing next after: " + previous + ", got: " + current; - } - else { + } else { previous = current.copy(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerQueueConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerQueueConsumerTest.java index dd126d86f0..9631a0c3f4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerQueueConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConcurrentProducerQueueConsumerTest.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, @@ -16,6 +16,17 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -30,18 +41,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - import junit.framework.Test; import org.apache.activemq.ActiveMQConnectionFactory; @@ -74,7 +73,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { public void initCombosForTestSendRateWithActivatingConsumers() throws Exception { addCombinationValues("defaultPersistenceAdapter", new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.LevelDB, /* too slow for hudson - PersistenceAdapterChoice.JDBC,*/ - PersistenceAdapterChoice.MEM}); + PersistenceAdapterChoice.MEM}); } public void testSendRateWithActivatingConsumers() throws Exception { @@ -113,8 +112,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { consumer.setMessageListener(listener); consumers.put(consumer, listener); } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("failed to start consumer", e); } } @@ -156,7 +154,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { public void x_initCombosForTestSendWithInactiveAndActiveConsumers() throws Exception { addCombinationValues("defaultPersistenceAdapter", new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.LevelDB, /* too slow for hudson - PersistenceAdapterChoice.JDBC,*/ - PersistenceAdapterChoice.MEM}); + PersistenceAdapterChoice.MEM}); } public void x_testSendWithInactiveAndActiveConsumers() throws Exception { @@ -275,8 +273,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { msg.setText(initText + str); // Do not pad message text - } - else { + } else { msg.setText(initText); } @@ -297,8 +294,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { Connection conn = iter.next(); try { conn.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } broker.stop(); @@ -364,8 +360,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { try { priority = message.getJMSPriority(); - } - catch (JMSException ignored) { + } catch (JMSException ignored) { } if (!messageLists.containsKey(priority)) { @@ -377,8 +372,7 @@ public class ConcurrentProducerQueueConsumerTest extends TestSupport { firstReceipt = duration; firstReceiptLatch.countDown(); LOG.info("First receipt in " + firstReceipt + "ms"); - } - else if (count.get() % batchSize == 0) { + } else if (count.get() % batchSize == 0) { LOG.info("Consumed " + count.get() + " in " + batchReceiptAccumulator + "ms" + ", priority:" + priority); batchReceiptAccumulator = 0; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java index fbb24c711e..85efbc2caf 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeQueuePrefetchTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java index 5c2c29e371..04c858e768 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeTopicPrefetchTest.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, @@ -16,11 +16,11 @@ */ package org.apache.activemq.usecases; -import java.util.LinkedList; import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.TextMessage; +import java.util.LinkedList; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.broker.BrokerRegistry; @@ -134,22 +134,19 @@ public class ConsumeTopicPrefetchTest extends ProducerConsumerTestSupport { LOG.info("inflight for : " + target.getName() + ": " + stats.getInflight().getCount()); if (greaterOrEqual) { return stats.getInflight().getCount() >= expectedCount; - } - else { + } else { return stats.getInflight().getCount() == expectedCount; } } }); - } - catch (Exception e) { + } catch (Exception e) { throw new JMSException(e.toString()); } DestinationStatistics stats = dest.getDestinationStatistics(); LOG.info("inflight for : " + dest.getName() + ": " + stats.getInflight().getCount()); if (greaterOrEqual) { assertTrue("inflight for: " + dest.getName() + ": " + stats.getInflight().getCount() + " > " + stats.getInflight().getCount(), stats.getInflight().getCount() >= expectedCount); - } - else { + } else { assertEquals("inflight for: " + dest.getName() + ": " + stats.getInflight().getCount() + " matches", expectedCount, stats.getInflight().getCount()); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeUncompressedCompressedMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeUncompressedCompressedMessageTest.java index 2e54fef313..5404d7ee0b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeUncompressedCompressedMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ConsumeUncompressedCompressedMessageTest.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, @@ -17,13 +17,6 @@ package org.apache.activemq.usecases; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.net.URI; - import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -33,6 +26,7 @@ import javax.jms.TextMessage; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; +import java.net.URI; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -46,6 +40,11 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class ConsumeUncompressedCompressedMessageTest { private static final Logger LOG = LoggerFactory.getLogger(ConsumeUncompressedCompressedMessageTest.class); @@ -182,8 +181,7 @@ public class ConsumeUncompressedCompressedMessageTest { assertEquals("Test Text Message: " + i, message.getText()); } - } - finally { + } finally { consumer.close(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java index 6585cced43..c259759591 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java index ff53ef84b3..b35781caa2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/CreateTemporaryQueueBeforeStartTest.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, @@ -17,14 +17,13 @@ package org.apache.activemq.usecases; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.Topic; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; @@ -81,8 +80,7 @@ public class CreateTemporaryQueueBeforeStartTest extends TestCase { count.notify(); } } - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } @@ -96,8 +94,7 @@ public class CreateTemporaryQueueBeforeStartTest extends TestCase { while (count.get() < number) { if (waitTime <= 0) { break; - } - else { + } else { count.wait(waitTime); waitTime = maxWaitTime - (System.currentTimeMillis() - start); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DiscriminatingConsumerLoadTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DiscriminatingConsumerLoadTest.java index fbff4f76f2..f7a54bf785 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DiscriminatingConsumerLoadTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DiscriminatingConsumerLoadTest.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, @@ -104,8 +104,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { try { Thread.sleep(1000); - } - catch (Exception e) { + } catch (Exception e) { } // here we pass in null for the JMS selector @@ -120,8 +119,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { try { Thread.sleep(3000); - } - catch (Exception e) { + } catch (Exception e) { } Producer producer = new Producer(producerConnection); @@ -154,8 +152,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { try { Thread.sleep(1000); - } - catch (Exception e) { + } catch (Exception e) { } // here we pass the JMS selector we intend to consume @@ -170,8 +167,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { try { Thread.sleep(3000); - } - catch (Exception e) { + } catch (Exception e) { } Producer producer = new Producer(producerConnection); @@ -184,8 +180,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { if (consumer.getCount() == (testSize / 2)) { LOG.info("test complete .... all messsages consumed!!"); - } - else { + } else { LOG.info("test failed .... Sent " + testSize + " original messages, only half of which (" + (testSize / 2) + ") were intended to be consumed: consumer paused at: " + consumer.getCount()); // System.out.println("test failed .... Sent " + testSize + " original messages, only half of which (" + // (testSize / 2) + @@ -246,8 +241,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } LOG.info("producer thread complete ... " + counterSent + " messages sent to the queue"); @@ -277,8 +271,7 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { MessageConsumer consumer = null; if (null != this.jmsSelector) { consumer = session.createConsumer(queue, "JMSType='" + this.jmsSelector + "'"); - } - else { + } else { consumer = session.createConsumer(queue); } @@ -289,15 +282,13 @@ public class DiscriminatingConsumerLoadTest extends TestSupport { // System.out.println("consuming .... JMSType = " + result.getJMSType() + " received = " + // counterReceived); LOG.info("consuming .... JMSType = " + result.getJMSType() + " received = " + counterReceived); - } - else { + } else { LOG.info("consuming .... timeout while waiting for a message ... broker must have stopped delivery ... received = " + counterReceived); deliveryHalted = true; } } session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DispatchMultipleConsumersTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DispatchMultipleConsumersTest.java index 9c8981e2bf..2dce7f6384 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DispatchMultipleConsumersTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DispatchMultipleConsumersTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -25,6 +23,8 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; @@ -98,8 +98,7 @@ public class DispatchMultipleConsumersTest extends TestCase { try { producerLatch.await(); consumerLatch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { fail("test interrupted!"); } } @@ -113,8 +112,7 @@ public class DispatchMultipleConsumersTest extends TestCase { for (int i = 0; i < consumerCount; i++) { new ConsumerThread(conn, "ConsumerThread" + i); } - } - catch (JMSException e) { + } catch (JMSException e) { logger.error("Failed to start consumers", e); } } @@ -139,8 +137,7 @@ public class DispatchMultipleConsumersTest extends TestCase { session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createConsumer(dest); start(); - } - catch (JMSException e) { + } catch (JMSException e) { logger.error("Failed to start consumer thread:" + name, e); } } @@ -160,12 +157,10 @@ public class DispatchMultipleConsumersTest extends TestCase { if (nullCount > 10) { //assume that we are not getting any more messages break; - } - else { + } else { continue; } - } - else { + } else { nullCount = 0; } Thread.sleep(100); @@ -173,18 +168,15 @@ public class DispatchMultipleConsumersTest extends TestCase { logger.trace("Message received:" + msg.getJMSMessageID()); } msgCount++; - } - catch (JMSException e) { + } catch (JMSException e) { logger.error("Failed to consume:", e); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { logger.error("Interrupted!", e); } } try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { logger.error("Failed to close consumer " + getName(), e); } consumedCount.addAndGet(msgCount); @@ -211,8 +203,7 @@ public class DispatchMultipleConsumersTest extends TestCase { session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(dest); start(); - } - catch (JMSException e) { + } catch (JMSException e) { logger.error("Failed to start producer thread:" + name, e); } } @@ -226,11 +217,9 @@ public class DispatchMultipleConsumersTest extends TestCase { Thread.sleep(500); } conn.close(); - } - catch (JMSException e) { + } catch (JMSException e) { logger.error(e.getMessage(), e); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { logger.error("Interrupted!", e); } sentCount.addAndGet(i); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTcpTest.java index c759dcf84d..afd6396b3d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTcpTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.usecases; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.net.SocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; @@ -23,10 +26,6 @@ import java.net.UnknownHostException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.net.SocketFactory; - import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -92,8 +91,7 @@ public class DurableConsumerCloseAndReconnectTcpTest extends DurableConsumerClos LOG.info("delaying close"); try { TimeUnit.MILLISECONDS.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -177,8 +175,7 @@ public class DurableConsumerCloseAndReconnectTcpTest extends DurableConsumerClos if (reconnectInExceptionListener) { try { makeConsumer(); - } - catch (Exception e) { + } catch (Exception e) { reconnectException = e; } @@ -197,8 +194,7 @@ public class DurableConsumerCloseAndReconnectTcpTest extends DurableConsumerClos try { TimeUnit.MILLISECONDS.sleep(500); makeConsumer(); - } - catch (Exception e) { + } catch (Exception e) { reconnectException = e; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java index 4e70ac01c8..11fc1b5f48 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableConsumerCloseAndReconnectTest.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, @@ -190,8 +190,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport { protected Destination createDestination() throws JMSException { if (isTopic()) { return session.createTopic(getSubject()); - } - else { + } else { return session.createQueue(getSubject()); } } @@ -229,8 +228,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport { private MessageConsumer createConsumer(String durableName) throws JMSException { if (destination instanceof Topic) { return session.createDurableSubscriber((Topic) destination, durableName); - } - else { + } else { return session.createConsumer(destination); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubDelayedUnsubscribeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubDelayedUnsubscribeTest.java index 25330980e0..42625ff337 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubDelayedUnsubscribeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubDelayedUnsubscribeTest.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, @@ -16,19 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Vector; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.ReentrantReadWriteLock; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -37,6 +24,14 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.management.ObjectName; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Vector; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -50,6 +45,10 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /* * A cut down version of DurableSubProcessWithRestartTest that focuses on kahaDB file retention */ @@ -110,19 +109,19 @@ public class DurableSubDelayedUnsubscribeTest { assertTrue("should have only one inactiveSubscriber subscribed but was: " + brokerService.getAdminView().getInactiveDurableTopicSubscribers().length, Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return brokerService.getAdminView().getInactiveDurableTopicSubscribers().length == 1; - } - }, houseKeeper.SWEEP_DELAY * 2)); + @Override + public boolean isSatisified() throws Exception { + return brokerService.getAdminView().getInactiveDurableTopicSubscribers().length == 1; + } + }, houseKeeper.SWEEP_DELAY * 2)); assertTrue("should be no subscribers subscribed but was: " + brokerService.getAdminView().getDurableTopicSubscribers().length, Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return brokerService.getAdminView().getDurableTopicSubscribers().length == 0; - } - }, TimeUnit.MINUTES.toMillis(3))); + @Override + public boolean isSatisified() throws Exception { + return brokerService.getAdminView().getDurableTopicSubscribers().length == 0; + } + }, TimeUnit.MINUTES.toMillis(3))); processLock.writeLock().lock(); @@ -140,11 +139,11 @@ public class DurableSubDelayedUnsubscribeTest { final KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); assertTrue("should be less than 3 journal file left but was: " + persistenceAdapter.getStore().getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return pa.getStore().getJournal().getFileMap().size() <= 3; - } - }, TimeUnit.MINUTES.toMillis(3))); + @Override + public boolean isSatisified() throws Exception { + return pa.getStore().getJournal().getFileMap().size() <= 3; + } + }, TimeUnit.MINUTES.toMillis(3))); // Be good and cleanup our mess a bit. this.houseKeeper.shutdown(); @@ -227,13 +226,11 @@ public class DurableSubDelayedUnsubscribeTest { processLock.readLock().lock(); try { send(); - } - finally { + } finally { processLock.readLock().unlock(); } } - } - catch (Throwable e) { + } catch (Throwable e) { exit("Server.run failed", e); } } @@ -383,8 +380,7 @@ public class DurableSubDelayedUnsubscribeTest { processLock.readLock().lock(); try { createNewClient(); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -392,8 +388,7 @@ public class DurableSubDelayedUnsubscribeTest { int size = clients.size(); sleepRandom(size * 3 * 1000, size * 6 * 1000); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ClientManager.run failed.", e); } } @@ -487,8 +482,7 @@ public class DurableSubDelayedUnsubscribeTest { processLock.readLock().lock(); try { process(online); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -497,8 +491,7 @@ public class DurableSubDelayedUnsubscribeTest { if (!ALLOW_SUBSCRIPTION_ABANDONMENT) { unsubscribe(); ALLOW_SUBSCRIPTION_ABANDONMENT = true; - } - else { + } else { LOG.info("Client abandon the subscription. " + this); @@ -506,8 +499,7 @@ public class DurableSubDelayedUnsubscribeTest { houseKeeper.abandonedSubscriptions.add(conClientId); ALLOW_SUBSCRIPTION_ABANDONMENT = false; } - } - catch (Throwable e) { + } catch (Throwable e) { exit(toString() + " failed.", e); } @@ -548,14 +540,12 @@ public class DurableSubDelayedUnsubscribeTest { inTransaction = false; transCount = 0; - } - else { + } else { inTransaction = true; transCount++; } } while (true); - } - finally { + } finally { sess.close(); con.close(); LOG.info(toString() + " OFFLINE."); @@ -631,15 +621,12 @@ public class DurableSubDelayedUnsubscribeTest { processLock.readLock().lock(); try { sweep(); - } - finally { + } finally { processLock.readLock().unlock(); } - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { break; - } - catch (Throwable e) { + } catch (Throwable e) { Exception log = new Exception("HouseKeeper failed.", e); log.printStackTrace(); } @@ -658,11 +645,9 @@ public class DurableSubDelayedUnsubscribeTest { sweeped.add(clientId); closed++; } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info("Ex on destroy sub " + ignored); - } - finally { + } finally { abandonedSubscriptions.removeAll(sweeped); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubInBrokerNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubInBrokerNetworkTest.java index 5bc73901f9..e8ba0ecf91 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubInBrokerNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubInBrokerNetworkTest.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, @@ -16,15 +16,13 @@ */ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSubscriber; - import javax.management.ObjectName; +import java.net.URI; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.network.DiscoveryNetworkConnector; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java index e04ca9c8cc..cd509a67c7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessConcurrentCommitActivateNoDuplicateTest.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, @@ -16,8 +16,12 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; - +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -30,13 +34,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; - import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQMessageConsumer; @@ -55,6 +52,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { private static final Logger LOG = LoggerFactory.getLogger(DurableSubProcessConcurrentCommitActivateNoDuplicateTest.class); @@ -117,8 +116,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { restartBroker(); } } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ProcessTest.testProcess failed.", e); } @@ -126,8 +124,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { clientManager.setEnd(true); try { Thread.sleep(60 * 1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { exit("ProcessTest.testProcess failed.", e); } @@ -135,8 +132,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { try { server.join(60 * 1000); - } - catch (Exception ignored) { + } catch (Exception ignored) { } processLock.writeLock().lock(); assertTrue("no exceptions: " + exceptions, exceptions.isEmpty()); @@ -153,8 +149,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { restartCount++; LOG.info("Broker restarted. count: " + restartCount); - } - finally { + } finally { processLock.writeLock().unlock(); } } @@ -195,13 +190,11 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { processLock.readLock().lock(); try { send(); - } - finally { + } finally { processLock.readLock().unlock(); } } - } - catch (Throwable e) { + } catch (Throwable e) { exit("Server.run failed", e); } } @@ -355,8 +348,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { processLock.readLock().lock(); try { createNewClient(); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -365,8 +357,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { //sleepRandom(1000, 4000); Thread.sleep(100); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ClientManager.run failed.", e); } } @@ -478,8 +469,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { onlineCount.incrementAndGet(); try { process(online.next()); - } - finally { + } finally { onlineCount.decrementAndGet(); processLock.readLock().unlock(); } @@ -493,8 +483,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { // housekeeper should sweep these abandoned subscriptions houseKeeper.abandonedSubscriptions.add(conClientId); } - } - catch (Throwable e) { + } catch (Throwable e) { exit(toString() + " failed.", e); } @@ -547,8 +536,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { LOG.info("Going offline during transaction commit. messageID=" + message.getIntProperty("ID")); break; } - } - else { + } else { inTransaction = true; transCount++; if (1 == transCount) { @@ -556,8 +544,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { } } } while (true); - } - finally { + } finally { sess.close(); con.close(); @@ -575,8 +562,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { if (Boolean.TRUE.equals(message.getObjectProperty("COMMIT"))) { if (Boolean.TRUE.equals(message.getObjectProperty("RELEVANT"))) waitingList.add(message); - } - else { + } else { String messageType = message.getStringProperty("TYPE"); if (clientType.isRelevant(messageType)) waitingList.add(message); @@ -616,8 +602,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { missingList.append("Missing TRANS=").append(lastTrans).append(", size=").append(transCount).append("\r\n"); lastTrans = trans; transCount = 1; - } - else + } else transCount++; } while ((nextServerMessage = waitingList.poll()) != null); @@ -630,8 +615,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { if (processed != null) processed.add(receivedId); - } - catch (Throwable e) { + } catch (Throwable e) { exit("" + this + ".onClientMessage failed.\r\n" + " received: " + message + "\r\n" + " server: " + serverMessage, e); } } @@ -665,8 +649,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { session.createDurableSubscriber(topic, SUBSCRIPTION_NAME, selector, true); session.close(); con.close(); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -680,8 +663,7 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { session.unsubscribe(SUBSCRIPTION_NAME); session.close(); con.close(); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -713,15 +695,12 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { processLock.readLock().lock(); try { sweep(); - } - finally { + } finally { processLock.readLock().unlock(); } - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { break; - } - catch (Throwable e) { + } catch (Throwable e) { Exception log = new Exception("HouseKeeper failed.", e); log.printStackTrace(); } @@ -740,11 +719,9 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { sweeped.add(clientId); closed++; } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info("Ex on destroy sub " + ignored); - } - finally { + } finally { abandonedSubscriptions.removeAll(sweeped); } @@ -899,4 +876,4 @@ public class DurableSubProcessConcurrentCommitActivateNoDuplicateTest { broker.stop(); broker = null; } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessMultiRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessMultiRestartTest.java index 4d401dcc0c..d4c3a07fe8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessMultiRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessMultiRestartTest.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, @@ -17,15 +17,6 @@ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.util.Vector; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantReadWriteLock; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -33,6 +24,11 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.File; +import java.io.IOException; +import java.util.Vector; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -46,6 +42,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class DurableSubProcessMultiRestartTest { private static final Logger LOG = LoggerFactory.getLogger(DurableSubProcessMultiRestartTest.class); @@ -98,8 +97,7 @@ public class DurableSubProcessMultiRestartTest { Thread.sleep(10000); restartBroker(); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ProcessTest.testProcess failed.", e); } @@ -107,8 +105,7 @@ public class DurableSubProcessMultiRestartTest { try { msgProducer.join(); durableSubscriber.join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(System.out); } @@ -120,11 +117,11 @@ public class DurableSubProcessMultiRestartTest { final KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); assertTrue("only less than two journal files should be left: " + pa.getStore().getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return pa.getStore().getJournal().getFileMap().size() <= 2; - } - }, TimeUnit.MINUTES.toMillis(3))); + @Override + public boolean isSatisified() throws Exception { + return pa.getStore().getJournal().getFileMap().size() <= 2; + } + }, TimeUnit.MINUTES.toMillis(3))); LOG.info("DONE."); } @@ -139,8 +136,7 @@ public class DurableSubProcessMultiRestartTest { restartCount++; LOG.info("Broker restarted. count: " + restartCount); - } - finally { + } finally { processLock.writeLock().unlock(); } } @@ -175,14 +171,12 @@ public class DurableSubProcessMultiRestartTest { processLock.readLock().lock(); try { send(); - } - finally { + } finally { processLock.readLock().unlock(); } LOG.info("MsgProducer msgCount=" + msgCount); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("Server.run failed", e); } } @@ -248,24 +242,20 @@ public class DurableSubProcessMultiRestartTest { processLock.readLock().lock(); try { process(5000); - } - finally { + } finally { processLock.readLock().unlock(); } } unsubscribe(); - } - catch (JMSException maybe) { + } catch (JMSException maybe) { if (maybe.getCause() instanceof IOException) { // ok on broker shutdown; - } - else { + } else { exit(toString() + " failed with JMSException", maybe); } - } - catch (Throwable e) { + } catch (Throwable e) { exit(toString() + " failed.", e); } @@ -290,8 +280,7 @@ public class DurableSubProcessMultiRestartTest { msgCount++; } } - } - finally { + } finally { sess.close(); con.close(); LOG.info(toString() + " OFFLINE."); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessTest.java index 8a572e93e5..cb99e1fd44 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessTest.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, @@ -16,16 +16,13 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.junit.Test; - -import javax.jms.*; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -36,6 +33,15 @@ import java.util.Vector; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + // see https://issues.apache.org/activemq/browse/AMQ-2985 // this demonstrated receiving old messages eventually along with validating order receipt public class DurableSubProcessTest extends org.apache.activemq.TestSupport { @@ -74,8 +80,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { Thread.sleep(RUNTIME); assertTrue("no exceptions: " + exceptions, exceptions.isEmpty()); - } - catch (Throwable e) { + } catch (Throwable e) { exit("DurableSubProcessTest.testProcess failed.", e); } LOG.info("DONE."); @@ -116,8 +121,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { DurableSubProcessTest.sleepRandom(SERVER_SLEEP); send(); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("Server.run failed", e); } } @@ -263,8 +267,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { int size = clients.size(); sleepRandom(size * 3 * 1000, size * 6 * 1000); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ClientManager.run failed.", e); } } @@ -382,8 +385,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { // housekeeper should sweep these abandoned subscriptions houseKeeper.abandonedSubscriptions.add(conClientId); } - } - catch (Throwable e) { + } catch (Throwable e) { exit(toString() + " failed.", e); } @@ -426,14 +428,12 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { inTransaction = false; transCount = 0; - } - else { + } else { inTransaction = true; transCount++; } } while (true); - } - finally { + } finally { sess.close(); con.close(); @@ -451,8 +451,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { if (Boolean.TRUE.equals(message.getObjectProperty("COMMIT"))) { if (Boolean.TRUE.equals(message.getObjectProperty("RELEVANT"))) waitingList.add(message); - } - else { + } else { String messageType = message.getStringProperty("TYPE"); if (clientType.isRelevant(messageType)) waitingList.add(message); @@ -478,8 +477,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { " server: " + serverMessage); checkDeliveryTime(message); - } - catch (Throwable e) { + } catch (Throwable e) { exit("" + this + ".onClientMessage failed.\r\n" + " received: " + message + "\r\n" + " server: " + serverMessage, e); @@ -546,11 +544,9 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { try { Thread.sleep(60 * 1000); sweep(); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { break; - } - catch (Throwable e) { + } catch (Throwable e) { Exception log = new Exception("HouseKeeper failed.", e); log.printStackTrace(); } @@ -569,8 +565,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { broker.getAdminView().destroyDurableSubscriber(clientId, Client.SUBSCRIPTION_NAME); closed++; } - } - finally { + } finally { abandonedSubscriptions.removeAll(sweeped); } @@ -661,8 +656,7 @@ public class DurableSubProcessTest extends org.apache.activemq.TestSupport { KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File("activemq-data/" + getName())); broker.setPersistenceAdapter(persistenceAdapter); - } - else + } else broker.setPersistent(false); broker.addConnector("tcp://localhost:61656"); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessWithRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessWithRestartTest.java index 5c778de2c5..da9afb0a1f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessWithRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessWithRestartTest.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, @@ -16,9 +16,13 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -30,14 +34,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; @@ -51,6 +47,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class DurableSubProcessWithRestartTest { private static final Logger LOG = LoggerFactory.getLogger(DurableSubProcessWithRestartTest.class); @@ -106,8 +105,7 @@ public class DurableSubProcessWithRestartTest { restartBroker(); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ProcessTest.testProcess failed.", e); } @@ -126,8 +124,7 @@ public class DurableSubProcessWithRestartTest { restartCount++; LOG.info("Broker restarted. count: " + restartCount); - } - finally { + } finally { processLock.writeLock().unlock(); } } @@ -164,13 +161,11 @@ public class DurableSubProcessWithRestartTest { processLock.readLock().lock(); try { send(); - } - finally { + } finally { processLock.readLock().unlock(); } } - } - catch (Throwable e) { + } catch (Throwable e) { exit("Server.run failed", e); } } @@ -313,8 +308,7 @@ public class DurableSubProcessWithRestartTest { processLock.readLock().lock(); try { createNewClient(); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -322,8 +316,7 @@ public class DurableSubProcessWithRestartTest { int size = clients.size(); sleepRandom(size * 3 * 1000, size * 6 * 1000); } - } - catch (Throwable e) { + } catch (Throwable e) { exit("ClientManager.run failed.", e); } } @@ -428,8 +421,7 @@ public class DurableSubProcessWithRestartTest { processLock.readLock().lock(); try { process(online.next()); - } - finally { + } finally { processLock.readLock().unlock(); } } @@ -442,8 +434,7 @@ public class DurableSubProcessWithRestartTest { // housekeeper should sweep these abandoned subscriptions houseKeeper.abandonedSubscriptions.add(conClientId); } - } - catch (Throwable e) { + } catch (Throwable e) { exit(toString() + " failed.", e); } @@ -486,14 +477,12 @@ public class DurableSubProcessWithRestartTest { inTransaction = false; transCount = 0; - } - else { + } else { inTransaction = true; transCount++; } } while (true); - } - finally { + } finally { sess.close(); con.close(); @@ -511,8 +500,7 @@ public class DurableSubProcessWithRestartTest { if (Boolean.TRUE.equals(message.getObjectProperty("COMMIT"))) { if (Boolean.TRUE.equals(message.getObjectProperty("RELEVANT"))) waitingList.add(message); - } - else { + } else { String messageType = message.getStringProperty("TYPE"); if (clientType.isRelevant(messageType)) waitingList.add(message); @@ -542,8 +530,7 @@ public class DurableSubProcessWithRestartTest { if (processed != null) processed.add(receivedId); - } - catch (Throwable e) { + } catch (Throwable e) { exit("" + this + ".onClientMessage failed.\r\n" + " received: " + message + "\r\n" + " server: " + serverMessage, e); } } @@ -612,15 +599,12 @@ public class DurableSubProcessWithRestartTest { processLock.readLock().lock(); try { sweep(); - } - finally { + } finally { processLock.readLock().unlock(); } - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { break; - } - catch (Throwable e) { + } catch (Throwable e) { Exception log = new Exception("HouseKeeper failed.", e); log.printStackTrace(); } @@ -639,11 +623,9 @@ public class DurableSubProcessWithRestartTest { sweeped.add(clientId); closed++; } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info("Ex on destroy sub " + ignored); - } - finally { + } finally { abandonedSubscriptions.removeAll(sweeped); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayTest.java index f04dd08014..f1f591a416 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +23,8 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.File; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -41,6 +38,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + public class DurableSubSelectorDelayTest { private static final Logger LOG = LoggerFactory.getLogger(DurableSubSelectorDelayTest.class); @@ -120,8 +119,7 @@ public class DurableSubSelectorDelayTest { Thread.sleep(400); send(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(System.out); throw new RuntimeException(e); } @@ -212,8 +210,7 @@ public class DurableSubSelectorDelayTest { } while (true); - } - finally { + } finally { sess.close(); con.close(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayWithRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayWithRestartTest.java index 70d9943fe6..13bcedae25 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayWithRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubSelectorDelayWithRestartTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -28,6 +23,8 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.io.File; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -41,6 +38,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + public class DurableSubSelectorDelayWithRestartTest { private static final Logger LOG = LoggerFactory.getLogger(DurableSubSelectorDelayWithRestartTest.class); @@ -127,8 +126,7 @@ public class DurableSubSelectorDelayWithRestartTest { startBroker(false); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(System.out); throw new RuntimeException(e); } @@ -222,13 +220,11 @@ public class DurableSubSelectorDelayWithRestartTest { } while (true); - } - finally { + } finally { try { sess.close(); con.close(); - } - catch (Exception e) { + } catch (Exception e) { } LOG.info(toString() + " OFFLINE."); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java index 4ccd3488f4..0b158fa56e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.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, @@ -16,17 +16,16 @@ */ package org.apache.activemq.usecases; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -157,8 +156,7 @@ public class DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest extends org } sendSession.close(); sendCon.close(); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); } } @@ -250,8 +248,7 @@ public class DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest extends org if (id != null) { try { LOG.info(id + ", " + message.getJMSMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java index 31dc6cdff3..ab3d70975e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.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, @@ -16,15 +16,15 @@ */ package org.apache.activemq.usecases; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; import junit.framework.Test; @@ -143,8 +143,7 @@ public class DurableSubsOfflineSelectorIndexUseTest extends org.apache.activemq. } sendSession.close(); sendCon.close(); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); } } @@ -225,8 +224,7 @@ public class DurableSubsOfflineSelectorIndexUseTest extends org.apache.activemq. if (id != null) { try { LOG.info(id + ", " + message.getJMSMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java index a634e98a21..3f7cc7b327 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberNonPersistentMessageTest.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, @@ -17,13 +17,6 @@ package org.apache.activemq.usecases; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; -import java.lang.management.ManagementFactory; -import java.util.Date; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -37,6 +30,12 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.management.MBeanServer; import javax.management.ObjectName; +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.lang.management.ManagementFactory; +import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; @@ -165,8 +164,7 @@ public class DurableSubscriberNonPersistentMessageTest extends TestCase { // Not sure what the behavior should be here, if the messages // expired the received count shouldn't equal total message count assertTrue(totalMsgReceived == initialMaxMsgs + cleanupMsgCount); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Exception Executing DurableSubscriberNonPersistentMessageTest: " + getStackTrace(e)); fail("Should not throw any exceptions"); } @@ -191,15 +189,13 @@ public class DurableSubscriberNonPersistentMessageTest extends TestCase { LOG.debug("Received Message: " + msg.toString()); messageReceived++; totalMsgReceived++; - } - else { + } else { LOG.debug("message " + i + " not received"); messagesNotReceived++; } Thread.sleep(sleep); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { LOG.debug("Exception: " + ie); } } @@ -209,8 +205,7 @@ public class DurableSubscriberNonPersistentMessageTest extends TestCase { LOG.info("Consumer Finished"); LOG.info("Received " + messageReceived); LOG.info("Not Received " + messagesNotReceived); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("Exception Executing SimpleConsumer: " + getStackTrace(e)); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkDisconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkDisconnectTest.java index be0d631fff..aec944918d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkDisconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkDisconnectTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.List; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -27,6 +25,8 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.List; import junit.framework.Test; @@ -97,8 +97,7 @@ public class DurableSubscriberWithNetworkDisconnectTest extends JmsMultipleBroke TextMessage textMsg = (TextMessage) msg; receivedMsgs++; LOG.info("Received messages (" + receivedMsgs + "): " + textMsg.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -117,24 +116,20 @@ public class DurableSubscriberWithNetworkDisconnectTest extends JmsMultipleBroke if (i == 50 || i == 150) { if (simulateStalledNetwork) { socketProxy.pause(); - } - else { + } else { socketProxy.close(); } networkDownTimeStart = System.currentTimeMillis(); - } - else if (networkDownTimeStart > 0) { + } else if (networkDownTimeStart > 0) { // restart after NETWORK_DOWN_TIME seconds sleep(NETWORK_DOWN_TIME); networkDownTimeStart = 0; if (simulateStalledNetwork) { socketProxy.goOn(); - } - else { + } else { socketProxy.reopen(); } - } - else { + } else { // slow message production to allow bridge to recover and limit message duplication sleep(500); } @@ -196,8 +191,7 @@ public class DurableSubscriberWithNetworkDisconnectTest extends JmsMultipleBroke private void sleep(int milliSecondTime) { try { Thread.sleep(milliSecondTime); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } @@ -219,14 +213,12 @@ public class DurableSubscriberWithNetworkDisconnectTest extends JmsMultipleBroke String options = ""; if (failover) { options = "static:(failover:(" + remoteURI; - } - else { + } else { options = "static:(" + remoteURI; } if (inactivity) { options += "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")"; - } - else { + } else { options += ")"; } @@ -244,8 +236,7 @@ public class DurableSubscriberWithNetworkDisconnectTest extends JmsMultipleBroke connector.setDuplex(true); } return connector; - } - else { + } else { throw new Exception("Remote broker has no registered connectors."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkRestartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkRestartTest.java index 20cc57ae5c..8528837d28 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkRestartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriberWithNetworkRestartTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.MalformedURLException; -import java.net.URI; -import java.util.Set; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Message; @@ -26,6 +23,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.management.ObjectName; +import java.net.MalformedURLException; +import java.net.URI; +import java.util.Set; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.JmsMultipleBrokersTestSupport; @@ -52,8 +52,7 @@ public class DurableSubscriberWithNetworkRestartTest extends JmsMultipleBrokersT dynamicOnly = true; try { testSendOnAReceiveOnBWithTransportDisconnect(); - } - finally { + } finally { dynamicOnly = false; } } @@ -166,8 +165,7 @@ public class DurableSubscriberWithNetworkRestartTest extends JmsMultipleBrokersT for (ObjectName on : all) { LOG.info(on); } - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.warn("getMBeanServer ex: " + ignored); } } @@ -228,8 +226,7 @@ public class DurableSubscriberWithNetworkRestartTest extends JmsMultipleBrokersT private void sleep(int milliSecondTime) { try { Thread.sleep(milliSecondTime); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionActivationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionActivationTest.java index 1c7e2ca625..e3964b63b6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionActivationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionActivationTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.usecases; -import java.io.File; - import javax.jms.Connection; import javax.jms.Session; +import java.io.File; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java index d7c40fdca2..06d4fa03fc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.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, @@ -16,7 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.concurrent.TimeUnit; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageProducer; @@ -26,6 +25,7 @@ import javax.jms.Topic; import javax.jms.TopicConnection; import javax.jms.TopicSession; import javax.jms.TopicSubscriber; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline1Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline1Test.java index f6cda17bac..4b41b1282e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline1Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline1Test.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.TestSupport.PersistenceAdapterChoice; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -32,6 +25,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.activemq.TestSupport.PersistenceAdapterChoice; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertEquals; @RunWith(value = Parameterized.class) diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline2Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline2Test.java index d15162f22e..c39d453fc8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline2Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline2Test.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean; -import org.apache.activemq.broker.jmx.TopicViewMBean; -import org.apache.activemq.util.Wait; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -35,7 +26,18 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import static org.junit.Assert.*; +import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean; +import org.apache.activemq.broker.jmx.TopicViewMBean; +import org.apache.activemq.util.Wait; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; @RunWith(value = Parameterized.class) public class DurableSubscriptionOffline2Test extends DurableSubscriptionOfflineTestBase { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline3Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline3Test.java index 3aff528ba4..9d621f5bf9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline3Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline3Test.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.TestSupport.PersistenceAdapterChoice; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -33,6 +26,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.activemq.TestSupport.PersistenceAdapterChoice; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -410,13 +410,11 @@ public class DurableSubscriptionOffline3Test extends DurableSubscriptionOfflineT if (b != null) { boolean c = message.getBooleanProperty("$c"); assertTrue("", c); - } - else { + } else { String d = message.getStringProperty("$d"); assertTrue("", "D1".equals(d) || "D2".equals(d)); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); exceptions.add(e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline4Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline4Test.java index adcf8fbdbb..e085926dfa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline4Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOffline4Test.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; -import org.apache.activemq.util.Wait; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -34,6 +26,14 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.apache.activemq.util.Wait; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static org.junit.Assert.assertTrue; @RunWith(value = Parameterized.class) diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java index 2198f92aa7..6aad7f0114 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.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, @@ -16,15 +16,6 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.activemq.command.MessageId; -import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; -import org.apache.activemq.store.kahadb.disk.page.PageFile; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -36,7 +27,19 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.*; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.apache.activemq.store.kahadb.disk.page.PageFile; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class DurableSubscriptionOfflineTest extends DurableSubscriptionOfflineTestBase { @@ -343,8 +346,7 @@ public class DurableSubscriptionOfflineTest extends DurableSubscriptionOfflineTe session.close(); con.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); exceptions.add(e); } @@ -367,8 +369,7 @@ public class DurableSubscriptionOfflineTest extends DurableSubscriptionOfflineTe public void run() { try { sendSession.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); exceptions.add(e); } @@ -446,8 +447,7 @@ public class DurableSubscriptionOfflineTest extends DurableSubscriptionOfflineTe session.close(); con.close(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); exceptions.add(e); } @@ -470,8 +470,7 @@ public class DurableSubscriptionOfflineTest extends DurableSubscriptionOfflineTe sendSession.commit(); LOG.info("committed: " + messageCount); con.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); exceptions.add(e); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java index c05edcbe60..636cdc9ee0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.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, @@ -16,6 +16,14 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.MessageListener; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport.PersistenceAdapterChoice; import org.apache.activemq.broker.BrokerFactory; @@ -37,14 +45,6 @@ import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.MessageListener; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import static org.junit.Assert.assertTrue; public abstract class DurableSubscriptionOfflineTestBase { @@ -127,8 +127,7 @@ public abstract class DurableSubscriptionOfflineTestBase { if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) { // ensure it kicks in during tests ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).setCleanupPeriod(2 * 1000); - } - else if (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) { + } else if (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) { // have lots of journal files ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).setJournalMaxFileLength(journalMaxFileLength); } @@ -144,8 +143,7 @@ public abstract class DurableSubscriptionOfflineTestBase { protected Destination createDestination(String subject) { if (isTopic) { return new ActiveMQTopic(subject); - } - else { + } else { return new ActiveMQQueue(subject); } } @@ -221,9 +219,8 @@ class DurableSubscriptionOfflineTestListener implements MessageListener { if (id != null) { try { LOG.info(id + ", " + message.getJMSMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionReactivationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionReactivationTest.java index 3270ff4638..3a0c522bca 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionReactivationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionReactivationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java index c08c4046d6..e356a94cab 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionSelectorTest.java index d31b6aaf29..7d7adb24f9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionSelectorTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionSelectorTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import java.lang.management.ManagementFactory; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; @@ -25,6 +23,7 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TopicSubscriber; import javax.management.MBeanServer; +import java.lang.management.ManagementFactory; import junit.framework.Test; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java index 567ced099d..fe4e94d96e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.java index 5e7cd1adfe..14d2b64b86 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.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, @@ -16,14 +16,17 @@ */ package org.apache.activemq.usecases; -import java.io.File; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.jms.*; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Session; import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import java.io.File; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; @@ -263,8 +266,7 @@ public class DurableSubscriptionUnsubscribeTest extends TestSupport { try { broker.getManagementContext().getObjectInstance(sub); count++; - } - catch (InstanceNotFoundException ignore) { + } catch (InstanceNotFoundException ignore) { // this should happen } } @@ -336,4 +338,4 @@ public class DurableSubscriptionUnsubscribeTest extends TestSupport { rc.start(); return rc; } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java index e9bbc0a611..ff38aa2828 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.usecases; -import java.lang.management.ManagementFactory; - import javax.jms.Connection; import javax.jms.MessageProducer; import javax.jms.Session; import javax.management.MBeanServer; import javax.management.ObjectName; +import java.lang.management.ManagementFactory; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java index 664e0e7469..eab3ed3f4b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.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, @@ -16,14 +16,14 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.ArrayList; -import java.util.LinkedList; import javax.jms.Connection; import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.JMSSecurityException; import javax.jms.Session; +import java.net.URI; +import java.util.ArrayList; +import java.util.LinkedList; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ConnectionFailedException; @@ -88,8 +88,7 @@ public class ExceptionListenerTest implements ExceptionListener { try { connection.start(); fail("Expect securityException"); - } - catch (JMSSecurityException expected) { + } catch (JMSSecurityException expected) { expected.printStackTrace(); assertTrue("nested security exception: " + expected, expected.getCause() instanceof SecurityException); } @@ -109,8 +108,7 @@ public class ExceptionListenerTest implements ExceptionListener { try { connection.createSession(false, Session.AUTO_ACKNOWLEDGE); fail("Expect error b/c connection is auto closed on security exception above"); - } - catch (ConnectionFailedException e) { + } catch (ConnectionFailedException e) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java index ed6fe0dcef..2df345fc4a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.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, @@ -16,6 +16,15 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import java.util.concurrent.atomic.AtomicLong; + import junit.framework.Test; import org.apache.activemq.ActiveMQConnectionFactory; @@ -32,10 +41,6 @@ import org.apache.activemq.util.Wait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; - -import java.util.concurrent.atomic.AtomicLong; - import static org.apache.activemq.TestSupport.getDestination; import static org.apache.activemq.TestSupport.getDestinationStatistics; @@ -101,8 +106,7 @@ public class ExpiredMessagesTest extends CombinationTestSupport { end = System.currentTimeMillis(); } consumer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -120,8 +124,7 @@ public class ExpiredMessagesTest extends CombinationTestSupport { producer.send(session.createTextMessage("test")); } producer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -241,8 +244,7 @@ public class ExpiredMessagesTest extends CombinationTestSupport { producer.send(message); } producer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesWithNoConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesWithNoConsumerTest.java index caf6f99f2b..e55c9f1923 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesWithNoConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesWithNoConsumerTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Message; @@ -30,6 +26,9 @@ import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.management.ObjectName; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import junit.framework.Test; @@ -145,8 +144,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { TimeUnit.SECONDS.sleep(5); } } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -171,8 +169,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { try { LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount() + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount() + ", size= " + view.getQueueSize()); return view.getDequeueCount() != 0 && view.getDequeueCount() == view.getExpiredCount() && view.getDequeueCount() == view.getEnqueueCount() && view.getQueueSize() == 0; - } - catch (Exception ignored) { + } catch (Exception ignored) { LOG.info(ignored.toString()); } return false; @@ -214,8 +211,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { tStamp = System.currentTimeMillis(); } } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -271,8 +267,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { waitCondition.await(6, TimeUnit.MINUTES); LOG.info("acking message: " + message); message.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } @@ -294,8 +289,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { tStamp = System.currentTimeMillis(); } } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -389,8 +383,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { LOG.debug("acking message: " + message); } message.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } @@ -412,8 +405,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { tStamp = System.currentTimeMillis(); } } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); } } @@ -561,8 +553,7 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport { ObjectName name; if (destination.isQueue()) { name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=test"); - } - else { + } else { name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=test"); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java index ed659719fb..2f4ec86801 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JDBCDurableSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JMXRemoveQueueThenSendIgnoredTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JMXRemoveQueueThenSendIgnoredTest.java index 52431a1631..9b0e2fb0d6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JMXRemoveQueueThenSendIgnoredTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JMXRemoveQueueThenSendIgnoredTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertEquals; - import javax.jms.DeliveryMode; import javax.jms.JMSException; import javax.jms.Message; @@ -39,6 +37,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; + public class JMXRemoveQueueThenSendIgnoredTest { private static final Logger LOG = LoggerFactory.getLogger(JMXRemoveQueueThenSendIgnoredTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JdbcDurableSubDupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JdbcDurableSubDupTest.java index 7dea0df528..0a67a15586 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JdbcDurableSubDupTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JdbcDurableSubDupTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Vector; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -34,6 +26,11 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -46,6 +43,8 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertTrue; + public class JdbcDurableSubDupTest { private static final Logger LOG = LoggerFactory.getLogger(JdbcDurableSubDupTest.class); @@ -170,19 +169,16 @@ public class JdbcDurableSubDupTest { done.set(true); } } - } - catch (Exception e) { + } catch (Exception e) { LOG.error("caught", e); exceptions.add(e); throw new RuntimeException(e); - } - finally { + } finally { if (connection != null) { try { LOG.info("consumer done (" + exceptions.isEmpty() + "), closing connection"); connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -195,8 +191,7 @@ public class JdbcDurableSubDupTest { try { Thread.sleep(0L); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } try { @@ -213,13 +208,11 @@ public class JdbcDurableSubDupTest { LOG.error("Duplicate message received at count: " + count + ", id: " + m.getJMSMessageID()); exceptions.add(new RuntimeException("Got Duplicate at: " + m.getJMSMessageID())); - } - else { + } else { dupChecker[i] = 1; } } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("caught ", e); exceptions.add(e); } @@ -265,8 +258,7 @@ public class JdbcDurableSubDupTest { int priority = 0; if (priorityModulator <= 10) { priority = msgSeqNo % priorityModulator; - } - else { + } else { priority = (msgSeqNo >= priorityModulator) ? 9 : 0; } message.setText(xmlMessage + msgSeqNo + "-" + priority); @@ -280,15 +272,13 @@ public class JdbcDurableSubDupTest { } try { Thread.sleep(1000L); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); exceptions.add(e); } } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("caught ", e); e.printStackTrace(); exceptions.add(e); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java index f2b1e1575d..b6bcd5a8b4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/JournalDurableSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/KahaDBDurableSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/KahaDBDurableSubscriptionTest.java index 23781c9c8e..2fc71c04f3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/KahaDBDurableSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/KahaDBDurableSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LargeQueueSparseDeleteTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LargeQueueSparseDeleteTest.java index 8c8f5171c6..7fe27884f6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LargeQueueSparseDeleteTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LargeQueueSparseDeleteTest.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, @@ -73,8 +73,7 @@ public class LargeQueueSparseDeleteTest extends EmbeddedBrokerTestSupport { producer.send(message); } session.commit(); - } - finally { + } finally { conn.close(); } @@ -114,8 +113,7 @@ public class LargeQueueSparseDeleteTest extends EmbeddedBrokerTestSupport { producer.send(message); } session.commit(); - } - finally { + } finally { conn.close(); } @@ -154,8 +152,7 @@ public class LargeQueueSparseDeleteTest extends EmbeddedBrokerTestSupport { producer.send(message); } session.commit(); - } - finally { + } finally { conn.close(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LevelDBDurableSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LevelDBDurableSubscriptionTest.java index 3f58d6aa8c..051eed3ca6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LevelDBDurableSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/LevelDBDurableSubscriptionTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ManagedDurableSubscriptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ManagedDurableSubscriptionTest.java index 99fbb1ebb0..51e7281827 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ManagedDurableSubscriptionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ManagedDurableSubscriptionTest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.usecases; -import java.io.File; - import javax.jms.Connection; import javax.jms.Session; import javax.management.ObjectName; +import java.io.File; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java index 8003364c33..b545056851 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.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, @@ -16,13 +16,13 @@ */ package org.apache.activemq.usecases; -import java.util.Arrays; import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Queue; import javax.jms.Session; +import java.util.Arrays; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupCloseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupCloseTest.java index 7c8e4acd44..0795466b2c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupCloseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupCloseTest.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, @@ -16,17 +16,26 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CountDownLatch; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; -import javax.jms.Queue; -import java.util.*; -import java.util.concurrent.CountDownLatch; - /* * Test plan: * Producer: publish messages into a queue, with 10 message groups, closing the group with seq=-1 on message 5 and message 10 @@ -85,8 +94,7 @@ public class MessageGroupCloseTest extends TestCase { latchMessagesCreated.countDown(); prod.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Producer failed", e); } } @@ -117,8 +125,7 @@ public class MessageGroupCloseTest extends TestCase { LOG.info("Con1: total message groups=" + messageGroups1.size()); con1.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Consumer 1 failed", e); } } @@ -150,8 +157,7 @@ public class MessageGroupCloseTest extends TestCase { session.close(); LOG.info("Con2: total messages=" + messagesRecvd2); LOG.info("Con2: total message groups=" + messageGroups2.size()); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Consumer 2 failed", e); } } @@ -187,8 +193,7 @@ public class MessageGroupCloseTest extends TestCase { public String formatMessage(Message m) { try { return "group=" + m.getStringProperty("JMSXGroupID") + ", seq=" + m.getIntProperty("JMSXGroupSeq"); - } - catch (Exception e) { + } catch (Exception e) { return e.getClass().getSimpleName() + ": " + e.getMessage(); } } @@ -212,8 +217,7 @@ public class MessageGroupCloseTest extends TestCase { errorCountWrongConsumerClose++; } messageGroups.put(groupId, 1); - } - else { + } else { // existing group if (closedGroups.contains(groupId)) { // group reassigned to same consumer diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupDelayedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupDelayedTest.java index 1ed4127596..670d20939d 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupDelayedTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupDelayedTest.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, @@ -16,17 +16,16 @@ */ package org.apache.activemq.usecases; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.CountDownLatch; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; import junit.framework.Test; @@ -224,18 +223,15 @@ public class MessageGroupDelayedTest extends JmsTestSupport { --counters[0]; update(group); Thread.sleep(500); - } - else if ("B".equals(group)) { + } else if ("B".equals(group)) { --counters[1]; update(group); Thread.sleep(100); - } - else if ("C".equals(group)) { + } else if ("C".equals(group)) { --counters[2]; update(group); Thread.sleep(10); - } - else { + } else { log.warn("unknown group"); } if (counters[0] != 0 || counters[1] != 0 || counters[2] != 0) { @@ -244,8 +240,7 @@ public class MessageGroupDelayedTest extends JmsTestSupport { } consumer.close(); sess.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupLateArrivalsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupLateArrivalsTest.java index a697a2dd6f..f99d6de939 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupLateArrivalsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupLateArrivalsTest.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, @@ -16,6 +16,12 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -24,13 +30,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CountDownLatch; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; @@ -45,7 +44,7 @@ import org.junit.runners.BlockJUnit4ClassRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; @RunWith(BlockJUnit4ClassRunner.class) public class MessageGroupLateArrivalsTest { @@ -282,16 +281,13 @@ public class MessageGroupLateArrivalsTest { if ("A".equals(group)) { --counters[0]; update(group); - } - else if ("B".equals(group)) { + } else if ("B".equals(group)) { --counters[1]; update(group); - } - else if ("C".equals(group)) { + } else if ("C".equals(group)) { --counters[2]; update(group); - } - else { + } else { log.warn(workerName + ", unknown group"); } if (counters[0] != 0 || counters[1] != 0 || counters[2] != 0) { @@ -300,8 +296,7 @@ public class MessageGroupLateArrivalsTest { } consumer.close(); sess.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupNewConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupNewConsumerTest.java index 364264965b..75d10eeb74 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupNewConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupNewConsumerTest.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, @@ -16,8 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.concurrent.CountDownLatch; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -26,13 +24,14 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.concurrent.CountDownLatch; + +import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import junit.framework.TestCase; - /* * Test plan: * Producer: publish messages into a queue, with three message groups @@ -88,8 +87,7 @@ public class MessageGroupNewConsumerTest extends TestCase { LOG.info(messagesSent + " messages sent"); prod.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Producer failed", e); } } @@ -121,8 +119,7 @@ public class MessageGroupNewConsumerTest extends TestCase { LOG.info(messagesRecvd1 + " messages received by consumer1"); con1.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Consumer 1 failed", e); } } @@ -150,8 +147,7 @@ public class MessageGroupNewConsumerTest extends TestCase { session.close(); } LOG.info(messagesRecvd2 + " messages received by consumer2"); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Consumer 2 failed", e); } } @@ -182,8 +178,7 @@ public class MessageGroupNewConsumerTest extends TestCase { public String formatMessage(Message m) { try { return m.getStringProperty("JMSXGroupID") + "-" + m.getIntProperty("JMSXGroupSeq") + "-" + m.getBooleanProperty("JMSXGroupFirstForConsumer"); - } - catch (Exception e) { + } catch (Exception e) { return e.getClass().getSimpleName() + ": " + e.getMessage(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupReconnectDistributionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupReconnectDistributionTest.java index 7b5c219aa5..9376935308 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupReconnectDistributionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupReconnectDistributionTest.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -31,6 +24,13 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -155,8 +155,7 @@ public class MessageGroupReconnectDistributionTest { if (totalConsumed.get() == numMessages) { break; - } - else { + } else { batchSize = getBatchSize(); messageConsumer = connectionSession.createConsumer(destWithPrefetch(destination)); batches.incrementAndGet(); @@ -174,8 +173,7 @@ public class MessageGroupReconnectDistributionTest { batches.incrementAndGet(); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java index 3231ec1488..40f1c20a2e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MessageReroutingTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java index 54dc36e686..7e66b7dd96 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; import java.lang.Thread.UncaughtExceptionHandler; import java.net.URI; import java.util.HashMap; @@ -24,9 +26,6 @@ import java.util.Map.Entry; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.jms.Destination; -import javax.jms.MessageConsumer; - import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.util.MessageIdList; import org.slf4j.Logger; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java index 1e1c860a5c..ab705604ba 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MultiBrokersMultiClientsUsingTcpTest.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, @@ -65,12 +65,10 @@ public class MultiBrokersMultiClientsUsingTcpTest extends MultiBrokersMultiClien bridges.add(bridge); bridge.start(); - } - else { + } else { throw new Exception("Remote broker or local broker is not using tcp connectors"); } - } - else { + } else { throw new Exception("Remote broker or local broker has no registered connectors."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java index d1e18e66f3..b316ba7b92 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MulticastDiscoveryOnFaultyNetworkTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.List; - import javax.jms.Destination; import javax.jms.MessageConsumer; import javax.jms.TextMessage; +import java.net.URI; +import java.util.List; import junit.framework.Test; @@ -100,8 +99,7 @@ public class MulticastDiscoveryOnFaultyNetworkTest extends JmsMultipleBrokersTes private void sleep(int milliSecondTime) { try { Thread.sleep(milliSecondTime); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MyObject.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MyObject.java index cdcecc062f..a8583bfbc1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MyObject.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/MyObject.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkAsyncStartTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkAsyncStartTest.java index d551b015d8..ccd3d7e5eb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkAsyncStartTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkAsyncStartTest.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, @@ -89,8 +89,7 @@ public class NetworkAsyncStartTest extends JmsMultipleBrokersTestSupport { try { brokerA.setNetworkConnectorStartAsync(true); brokerA.start(); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("start failed", e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java index 270b43726d..b9c2b262ff 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkBridgeProducerFlowControlTest.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, @@ -17,12 +17,12 @@ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; import java.net.URI; import java.util.Vector; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.MessageConsumer; import junit.framework.Test; @@ -187,8 +187,7 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest try { fastConsumerLatch.await(); fastConsumerTime.set(System.currentTimeMillis() - startTimeMillis); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { exceptions.add(ex); Assert.fail(ex.getMessage()); } @@ -201,8 +200,7 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest try { slowConsumerLatch.await(); slowConsumerTime.set(System.currentTimeMillis() - startTimeMillis); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { exceptions.add(ex); Assert.fail(ex.getMessage()); } @@ -229,8 +227,7 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest if (networkIsAlwaysSendSync) { Assert.assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 10); - } - else { + } else { Assert.assertEquals(persistentTestMessages, fastConsumerTime.get() < slowConsumerTime.get() / 10); } } @@ -298,8 +295,7 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest try { fastConsumerLatch.await(); fastConsumerTime.set(System.currentTimeMillis() - startTimeMillis); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { exceptions.add(ex); Assert.fail(ex.getMessage()); } @@ -312,8 +308,7 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest try { slowConsumerLatch.await(); slowConsumerTime.set(System.currentTimeMillis() - startTimeMillis); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { exceptions.add(ex); Assert.fail(ex.getMessage()); } @@ -349,4 +344,4 @@ public class NetworkBridgeProducerFlowControlTest extends JmsMultipleBrokersTest // Verify the behaviour as described in the description of this class. Assert.assertTrue(fastConsumerTime.get() < slowConsumerTime.get() / 10); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkOfTwentyBrokersTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkOfTwentyBrokersTest.java index 2213171f42..39e7a6a56b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkOfTwentyBrokersTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NetworkOfTwentyBrokersTest.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, @@ -112,8 +112,7 @@ public class NetworkOfTwentyBrokersTest extends JmsMultipleBrokersTestSupport { LOG.info("Waiting for complete formation"); try { Thread.sleep(20000); - } - catch (Exception e) { + } catch (Exception e) { } verifyPeerBrokerInfos(X - 1); @@ -126,8 +125,7 @@ public class NetworkOfTwentyBrokersTest extends JmsMultipleBrokersTestSupport { LOG.info("Waiting for complete stop"); try { Thread.sleep(20000); - } - catch (Exception e) { + } catch (Exception e) { } verifyPeerBrokerInfos((X / 2) - 1); @@ -144,8 +142,7 @@ public class NetworkOfTwentyBrokersTest extends JmsMultipleBrokersTestSupport { LOG.info("Waiting for complete reformation"); try { Thread.sleep(20000); - } - catch (Exception e) { + } catch (Exception e) { } verifyPeerBrokerInfos(X - 1); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java index 150d845670..5d10561fb0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.usecases; -import java.util.Set; - import javax.jms.Destination; import javax.jms.Session; +import java.util.Set; import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport; import org.apache.activemq.command.ActiveMQDestination; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java index 5058e5f98b..9148e32ec0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NoDuplicateOnTopicNetworkTest.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, @@ -16,16 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -35,6 +25,15 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; @@ -177,8 +176,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport { producer.setTopicName(TOPIC_NAME); try { producer.produce(); - } - catch (JMSException e) { + } catch (JMSException e) { fail("Unexpected " + e); } } @@ -194,8 +192,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport { consumer.consumer(); consumerStarted.countDown(); consumer.getLatch().await(60, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { fail("Unexpected " + e); } } @@ -250,8 +247,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport { if (suppressDuplicateTopicSubs || dispatchPolicy instanceof PriorityNetworkDispatchPolicy) { assertEquals("no duplicates", 0, duplicateCount); assertEquals("got all required messages: " + map.size(), consumer.getNumMessages(), map.size()); - } - else { + } else { assertTrue("we can get some duplicates: " + duplicateCount, duplicateCount >= 0); if (duplicateCount == 0) { assertEquals("got all required messages: " + map.size(), consumer.getNumMessages(), map.size()); @@ -318,8 +314,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport { private void createConsumer() throws JMSException { if (durableSub) { consumer = session.createDurableSubscriber(topic, durableID); - } - else { + } else { consumer = session.createConsumer(topic); } consumer.setMessageListener(new MessageListener() { @@ -331,8 +326,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport { LOG.debug("Received message [" + msg.getText() + "]"); receivedStrings.add(msg.getText()); receivedLatch.countDown(); - } - catch (JMSException e) { + } catch (JMSException e) { fail("Unexpected :" + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NonBlockingConsumerRedeliveryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NonBlockingConsumerRedeliveryTest.java index 00e9c2becd..cfae4a2006 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NonBlockingConsumerRedeliveryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/NonBlockingConsumerRedeliveryTest.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, @@ -16,14 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -33,6 +25,9 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -45,6 +40,10 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class NonBlockingConsumerRedeliveryTest { private static final Logger LOG = LoggerFactory.getLogger(NonBlockingConsumerRedeliveryTest.class); @@ -82,24 +81,24 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); beforeRollback.addAll(received); received.clear(); session.rollback(); assertTrue("Post-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages since rollback."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages since rollback."); + return received.size() == MSG_COUNT; + } + })); afterRollback.addAll(received); received.clear(); @@ -134,24 +133,24 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); beforeRollback.addAll(received); received.clear(); session.rollback(); assertTrue("Post-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages since rollback."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages since rollback."); + return received.size() == MSG_COUNT; + } + })); afterRollback.addAll(received); received.clear(); @@ -198,12 +197,12 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); beforeRollback.addAll(received); received.clear(); @@ -212,12 +211,12 @@ public class NonBlockingConsumerRedeliveryTest { sendMessages(); assertTrue("Post-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages since rollback."); - return received.size() == MSG_COUNT * 2; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages since rollback."); + return received.size() == MSG_COUNT * 2; + } + })); afterRollback.addAll(received); received.clear(); @@ -248,22 +247,22 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); received.clear(); session.rollback(); assertFalse("Delayed redelivery test not expecting any messages yet.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return received.size() > 0; - } - }, TimeUnit.SECONDS.toMillis(4))); + @Override + public boolean isSatisified() throws Exception { + return received.size() > 0; + } + }, TimeUnit.SECONDS.toMillis(4))); session.commit(); session.close(); @@ -289,12 +288,12 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); received.clear(); @@ -310,17 +309,14 @@ public class NonBlockingConsumerRedeliveryTest { session.rollback(); LOG.info("Rolling back session."); count = 0; - } - catch (JMSException e) { + } catch (JMSException e) { LOG.warn("Caught an unexpected exception: " + e.getMessage()); } - } - else { + } else { received.add(message); try { session.commit(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.warn("Caught an unexpected exception: " + e.getMessage()); } } @@ -330,12 +326,12 @@ public class NonBlockingConsumerRedeliveryTest { session.rollback(); assertTrue("Post-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages since rollback."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages since rollback."); + return received.size() == MSG_COUNT; + } + })); assertEquals(MSG_COUNT, received.size()); session.commit(); @@ -372,12 +368,12 @@ public class NonBlockingConsumerRedeliveryTest { connection.start(); assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + received.size() + " messages."); - return received.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + received.size() + " messages."); + return received.size() == MSG_COUNT; + } + })); session.rollback(); @@ -386,20 +382,19 @@ public class NonBlockingConsumerRedeliveryTest { public void onMessage(Message message) { try { session.rollback(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.warn("Caught an unexpected exception: " + e.getMessage()); } } }); assertTrue("Post-Rollback expects to DLQ: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - LOG.info("Consumer has received " + dlqed.size() + " messages in DLQ."); - return dlqed.size() == MSG_COUNT; - } - })); + @Override + public boolean isSatisified() throws Exception { + LOG.info("Consumer has received " + dlqed.size() + " messages in DLQ."); + return dlqed.size() == MSG_COUNT; + } + })); session.commit(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ObjectMessageNotSerializableTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ObjectMessageNotSerializableTest.java index f77cb3e3ec..bbaa266113 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ObjectMessageNotSerializableTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ObjectMessageNotSerializableTest.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, @@ -16,14 +16,14 @@ */ package org.apache.activemq.usecases; -import java.util.Vector; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.Vector; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; @@ -87,8 +87,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { numReceived.incrementAndGet(); } consumer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } @@ -111,8 +110,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { message.setObject(obj); producer.send(message); producer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } @@ -159,8 +157,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { numReceived.incrementAndGet(); } consumer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } @@ -188,8 +185,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { assertEquals("readObject called", 1, object.getReadObjectCalled()); } consumer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } @@ -217,8 +213,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { numReceived.incrementAndGet(); } consumer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } @@ -241,8 +236,7 @@ public class ObjectMessageNotSerializableTest extends CombinationTestSupport { message.setObject(obj); producer.send(message); producer.close(); - } - catch (Throwable ex) { + } catch (Throwable ex) { exceptions.add(ex); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ProducerConsumerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ProducerConsumerTestSupport.java index 2a522379b3..b9b87e6a0e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ProducerConsumerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ProducerConsumerTestSupport.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnDurableTopicConsumedMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnDurableTopicConsumedMessageTest.java index 28a1f7bf3b..6d0564900a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnDurableTopicConsumedMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnDurableTopicConsumedMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageInTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageInTransactionTest.java index c014936e1e..a6a3a9a7c7 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageInTransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageInTransactionTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.usecases; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -30,6 +25,10 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import junit.framework.TestCase; @@ -78,8 +77,7 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa for (int i = 0; i < messageCount; i++) { data[i] = "Message : " + i; } - } - catch (JMSException je) { + } catch (JMSException je) { fail("Error setting up connection : " + je.toString()); } } @@ -105,8 +103,7 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa producerSession.commit(); LOG.info("sending message :" + objectMessage); } - } - catch (Exception e) { + } catch (Exception e) { if (producerSession != null) { producerSession.rollback(); LOG.info("rollback"); @@ -126,13 +123,11 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa LOG.info("consumer received message :" + objectMessage); consumerSession.commit(); - } - catch (Exception e) { + } catch (Exception e) { try { consumerSession.rollback(); LOG.info("rolled back transaction"); - } - catch (JMSException e1) { + } catch (JMSException e1) { LOG.info(e1.toString()); e1.printStackTrace(); } @@ -164,8 +159,7 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa while (messages.size() <= data.length && waitTime >= 0) { try { lock.wait(200); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java index 60a4d69be7..1ed804ad47 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java index e028440629..e6d88aca8e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnQueueConsumedMessageUsingActivemqXMLTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java index 0364c52dc5..c40d119607 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTemporaryQueueConsumedMessageTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java index d0ae37923a..d0a6dcc5a1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumedMessageTest.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, @@ -44,8 +44,7 @@ public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTw // log.info("Sending reply: " + message); super.onMessage(message); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("Failed to send message: " + e); e.printStackTrace(); } @@ -59,8 +58,7 @@ public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTw if (topic) { replyDestination = receiveSession.createTopic("REPLY." + getSubject()); - } - else { + } else { replyDestination = receiveSession.createQueue("REPLY." + getSubject()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java index 2182143922..1e215d53ce 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/PublishOnTopicConsumerMessageUsingActivemqXMLTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLevelDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLevelDBTest.java index 8102dbb550..1ae74c3b7f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLevelDBTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLevelDBTest.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, @@ -16,12 +16,12 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.leveldb.LevelDBStore; - import java.io.File; import java.io.IOException; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.leveldb.LevelDBStore; + public class QueueBrowsingLevelDBTest extends QueueBrowsingTest { @Override diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLimitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLimitTest.java index ecd3c48b1e..86c3857f5c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLimitTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingLimitTest.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, @@ -16,14 +16,14 @@ */ package org.apache.activemq.usecases; -import java.io.IOException; -import java.net.URI; -import java.util.Enumeration; import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.QueueBrowser; import javax.jms.Session; +import java.io.IOException; +import java.net.URI; +import java.util.Enumeration; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java index 5afaf7fc56..2630b73786 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.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, @@ -16,13 +16,6 @@ */ package org.apache.activemq.usecases; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.net.URI; -import java.util.Enumeration; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -30,6 +23,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.QueueBrowser; import javax.jms.Session; +import java.io.IOException; +import java.net.URI; +import java.util.Enumeration; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -43,6 +39,9 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class QueueBrowsingTest { private static final Logger LOG = LoggerFactory.getLogger(QueueBrowsingTest.class); @@ -146,8 +145,7 @@ public class QueueBrowsingTest { LOG.info("Browsed message " + received + ": " + m.getJMSMessageID()); } assertEquals("Browsed all messages", messageToSend, received); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -168,8 +166,7 @@ public class QueueBrowsingTest { received++; } assertEquals("Consumed all messages", messageToSend, received); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java index 63740c3494..5d73386cf0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueConsumerCloseAndReconnectTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java index 4588a8eafa..221c4c1461 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.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, @@ -17,12 +17,6 @@ package org.apache.activemq.usecases; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -33,6 +27,11 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; import junit.framework.TestCase; @@ -97,8 +96,7 @@ public class QueueDuplicatesTest extends TestCase { // sleep a little while longer Thread.sleep(15000); session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -140,8 +138,7 @@ public class QueueDuplicatesTest extends TestCase { Thread.sleep(1000); } session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -158,8 +155,7 @@ public class QueueDuplicatesTest extends TestCase { String id = message.getJMSMessageID(); assertNull("Message is duplicate: " + id, msgs.get(id)); msgs.put(id, message); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueMemoryFullMultiBrokersTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueMemoryFullMultiBrokersTest.java index e1f1d21112..546891a404 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueMemoryFullMultiBrokersTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueMemoryFullMultiBrokersTest.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, @@ -16,14 +16,13 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.jms.Destination; - import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.Queue; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java index 66f747f6c1..e59f554738 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRedeliverTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRepeaterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRepeaterTest.java index 088c872757..caa21bbb94 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRepeaterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueRepeaterTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.Date; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -29,6 +25,9 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Date; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import junit.framework.TestCase; @@ -79,13 +78,11 @@ public final class QueueRepeaterTest extends TestCase { LOG.info("consumer received message :" + receivedText); consumerSession.commit(); LOG.info("committed transaction"); - } - catch (JMSException e) { + } catch (JMSException e) { try { consumerSession.rollback(); LOG.info("rolled back transaction"); - } - catch (JMSException e1) { + } catch (JMSException e1) { LOG.info(e1.toString()); e1.printStackTrace(); } @@ -103,8 +100,7 @@ public final class QueueRepeaterTest extends TestCase { tm.setText("Hello, " + new Date()); producer.send(tm); LOG.info("producer sent message :" + tm.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java index 1c5609855e..d94651962b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -30,6 +26,9 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.net.URI; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerFactory; @@ -84,8 +83,7 @@ public class ReliableReconnectTest extends org.apache.activemq.TestSupport { broker.setUseJmx(false); broker.addConnector(DEFAULT_BROKER_URL); broker.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -134,8 +132,7 @@ public class ReliableReconnectTest extends org.apache.activemq.TestSupport { synchronized (messagesReceived) { messagesReceived.notify(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyNoAdvisoryNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyNoAdvisoryNetworkTest.java index b4960be4bd..32b5037bd5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyNoAdvisoryNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyNoAdvisoryNetworkTest.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, @@ -16,6 +16,10 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -28,11 +32,6 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Vector; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQSession; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyTempDestRemovalAdvisoryRaceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyTempDestRemovalAdvisoryRaceTest.java index 9211bf2eb5..cb3203a882 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyTempDestRemovalAdvisoryRaceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyTempDestRemovalAdvisoryRaceTest.java @@ -16,16 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -36,6 +26,16 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; import junit.framework.Test; @@ -264,8 +264,7 @@ public class RequestReplyTempDestRemovalAdvisoryRaceTest extends JmsMultipleBrok consumerDemandExists.countDown(); System.err.println("Sleeping on receipt of remove info debug message: " + message); TimeUnit.SECONDS.sleep(2); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -380,27 +379,22 @@ public class RequestReplyTempDestRemovalAdvisoryRaceTest extends JmsMultipleBrok try { LOG.info("SENDER: Got a response from echo service!" + ((TextMessage) incomingMessage).getText()); responseReceived.incrementAndGet(); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("SENDER: might want to see why i'm getting non-text messages..." + incomingMessage, e); } - } - else { + } else { LOG.info("SENDER: Did not get a response this time"); } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("SENDER: Could not complete message sending properly: " + e.getMessage()); - } - finally { + } finally { try { producer.close(); consumer.close(); session.close(); connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -449,22 +443,18 @@ public class RequestReplyTempDestRemovalAdvisoryRaceTest extends JmsMultipleBrok try { producer.send(replyTo, message); LOG.info("RESPONDENT: sent reply:" + message.getJMSMessageID() + " back to: " + replyTo); - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("RESPONDENT: could not send reply message: " + e.getLocalizedMessage(), e); respondentSendError.incrementAndGet(); } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.error("RESPONDENT: could not create the reply message: " + e.getLocalizedMessage(), e); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.info("RESPONDENT could not generate a random number"); } } } - } - catch (JMSException e) { + } catch (JMSException e) { LOG.info("RESPONDENT: Could not set the message listener on the respondent"); } } @@ -481,4 +471,4 @@ public class RequestReplyTempDestRemovalAdvisoryRaceTest extends JmsMultipleBrok this.consumer = session.createConsumer(new ActiveMQQueue(QUEUE_NAME)); } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java index 001142ea06..8bd080159a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.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, @@ -17,17 +17,6 @@ package org.apache.activemq.usecases; -import static org.junit.Assert.assertTrue; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -36,6 +25,14 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQSession; @@ -47,6 +44,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Test; +import static org.junit.Assert.assertTrue; + public class RequestReplyToTopicViaThreeNetworkHopsTest { protected static final int CONCURRENT_CLIENT_COUNT = 5; @@ -139,8 +138,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { if (cons_client.getNumMsgReceived() == tot_expected) { LOG.debug("Have " + tot_expected + " messages, as-expected"); - } - else { + } else { testError = true; if (cons_client.getNumMsgReceived() == 0) @@ -158,8 +156,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { LOG.debug("SENDING REQUEST message " + msg); prod.send(msg); - } - catch (JMSException jms_exc) { + } catch (JMSException jms_exc) { System.out.println("AAA: " + jms_exc.getMessage()); throw jms_exc; } @@ -365,8 +362,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { edge1.start(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(null, ex); } } @@ -377,8 +373,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { edge2.start(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(null, ex); } } @@ -389,8 +384,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { core1.start(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(null, ex); } } @@ -401,8 +395,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { core2.start(); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error(null, ex); } } @@ -439,8 +432,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { RequestReplyToTopicViaThreeNetworkHopsTest.this.testTempTopic(edge1.getConnectionUrl(), edge2.getConnectionUrl()); - } - catch (Exception exc) { + } catch (Exception exc) { LOG.error("test exception", exc); fatalTestError = true; testError = true; @@ -507,8 +499,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { if (msg instanceof TextMessage) { msg_desc.append(((TextMessage) msg).getText()); - } - else { + } else { msg_desc.append("["); msg_desc.append(msg.getClass().getName()); msg_desc.append("]"); @@ -613,8 +604,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { if (queue_f) { prefix = "queue"; excl_dest = ActiveMQDestination.createDestination(">", ActiveMQDestination.TOPIC_TYPE); - } - else { + } else { prefix = "topic"; excl_dest = ActiveMQDestination.createDestination(">", ActiveMQDestination.QUEUE_TYPE); } @@ -661,8 +651,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { processMessages(); latch.countDown(); - } - catch (Exception exc) { + } catch (Exception exc) { LOG.error("message client error", exc); } } @@ -679,8 +668,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { latch.await(timeout, TimeUnit.MILLISECONDS); else LOG.info("echo client shutdown: client does not appear to be active"); - } - catch (InterruptedException int_exc) { + } catch (InterruptedException int_exc) { LOG.warn("wait for message client shutdown interrupted", int_exc); } } @@ -813,17 +801,14 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { processorPool.execute(new EchoRequestProcessor(sess, req)); } } - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error("error processing echo service requests", ex); - } - finally { + } finally { LOG.info("shutting down test echo service"); try { jmsConn.stop(); - } - catch (javax.jms.JMSException jms_exc) { + } catch (javax.jms.JMSException jms_exc) { LOG.warn("error on shutting down JMS connection", jms_exc); } @@ -851,12 +836,10 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { LOG.info("echo service shutdown complete"); else LOG.warn("timeout waiting for echo service shutdown"); - } - else { + } else { LOG.info("echo service shutdown: service does not appear to be active"); } - } - catch (InterruptedException int_exc) { + } catch (InterruptedException int_exc) { LOG.warn("interrupted while waiting for echo service shutdown"); } } @@ -891,8 +874,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { public void run() { try { this.processRequest(this.request); - } - catch (Exception ex) { + } catch (Exception ex) { LOG.error("Failed to process request", ex); } } @@ -916,8 +898,7 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { msg_prod.close(); msg_prod = null; - } - else { + } else { LOG.warn("invalid request: no reply-to destination given"); } } @@ -976,18 +957,15 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { msg = cons.receive(250); } - } - catch (JMSException jms_exc) { + } catch (JMSException jms_exc) { LOG.warn("traffic generator failed on jms exception", jms_exc); - } - finally { + } finally { LOG.info("Shutdown of Topic Traffic Generator; send count = " + send_count); if (conn1 != null) { try { conn1.stop(); - } - catch (JMSException jms_exc) { + } catch (JMSException jms_exc) { LOG.warn("failed to shutdown connection", jms_exc); } } @@ -995,12 +973,11 @@ public class RequestReplyToTopicViaThreeNetworkHopsTest { if (conn2 != null) { try { conn2.stop(); - } - catch (JMSException jms_exc) { + } catch (JMSException jms_exc) { LOG.warn("failed to shutdown connection", jms_exc); } } } } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardLevelDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardLevelDBTest.java index bb95cba462..44faa19519 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardLevelDBTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardLevelDBTest.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, @@ -16,11 +16,12 @@ */ package org.apache.activemq.usecases; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.leveldb.LevelDBStore; import java.io.File; import java.io.IOException; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.leveldb.LevelDBStore; + public class SingleBrokerVirtualDestinationsWithWildcardLevelDBTest extends SingleBrokerVirtualDestinationsWithWildcardTest { @Override @@ -31,4 +32,4 @@ public class SingleBrokerVirtualDestinationsWithWildcardLevelDBTest extends Sing broker.setPersistenceAdapter(kaha); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java index 0970b76e83..37637f3671 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; import java.io.File; import java.io.IOException; import java.net.URI; -import javax.jms.MessageConsumer; - import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.DestinationInterceptor; @@ -128,4 +127,4 @@ public class SingleBrokerVirtualDestinationsWithWildcardTest extends JmsMultiple kaha.setDirectory(dataFileDir); broker.setPersistenceAdapter(kaha); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java index 2776548210..3da113229b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopBrokerTest.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, @@ -16,9 +16,8 @@ */ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.JMSException; +import java.net.URI; import junit.framework.TestCase; @@ -68,8 +67,7 @@ public class StartAndStopBrokerTest extends TestCase { broker.setUseShutdownHook(false); broker.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java index b0da957ba9..b3a1449cfc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StartAndStopClientAndBrokerDoesNotLeaveThreadsRunningTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java index 7682113afa..57f271640b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.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, @@ -16,14 +16,14 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; +import java.net.URI; + import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.network.NetworkConnector; import org.apache.activemq.util.MessageIdList; -import javax.jms.MessageConsumer; -import java.net.URI; - public class StaticNetworkTest extends JmsMultipleBrokersTestSupport { public void testStaticNetwork() throws Exception { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java index 9718f7bc5f..0c86a1982c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/SubscribeClosePublishThenConsumeTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TempTopicProducerFlowControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TempTopicProducerFlowControlTest.java index b144146cbb..5d9e481b03 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TempTopicProducerFlowControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TempTopicProducerFlowControlTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java index b0f4f2a0ad..7f0dbacc0b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.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, @@ -17,8 +17,6 @@ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.DeliveryMode; @@ -28,6 +26,7 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; import junit.framework.TestCase; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java index 49ff66324c..184d0fb575 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.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, @@ -52,8 +52,7 @@ public class TestSupport extends TestCase { protected Destination createDestination(String subject) { if (topic) { return new ActiveMQTopic(subject); - } - else { + } else { return new ActiveMQQueue(subject); } } @@ -112,8 +111,7 @@ public class TestSupport extends TestCase { assertTrue(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1.getClass() == m2.getClass()); if (m1 instanceof TextMessage) { assertTextMessageEqual(message, (TextMessage) m1, (TextMessage) m2); - } - else { + } else { assertEquals(message, m1, m2); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java index 9c0a20594c..ec1d218756 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.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, @@ -16,6 +16,8 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; import java.net.URI; import java.util.Collection; import java.util.HashMap; @@ -23,8 +25,6 @@ import java.util.Iterator; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.Destination; -import javax.jms.MessageConsumer; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.Broker; @@ -537,8 +537,7 @@ public class ThreeBrokerQueueNetworkTest extends JmsMultipleBrokersTestSupport { LOG.info("Sleeping on first advisory: " + messageDispatch); try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java index 93baeca68b..effe0da115 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.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, @@ -52,12 +52,10 @@ public class ThreeBrokerQueueNetworkUsingTcpTest extends ThreeBrokerQueueNetwork bridges.add(bridge); bridge.start(); - } - else { + } else { throw new Exception("Remote broker or local broker is not using tcp connectors"); } - } - else { + } else { throw new Exception("Remote broker or local broker has no registered connectors."); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java index 1349edd31f..daac41a627 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.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, @@ -54,8 +54,7 @@ public class ThreeBrokerStompTemporaryQueueTest extends JmsMultipleBrokersTestSu localBroker.addNetworkConnector(connector); maxSetupTime = 2000; return connector; - } - else { + } else { throw new Exception("Remote broker has no registered connectors."); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempDestDemandSubscriptionCleanupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempDestDemandSubscriptionCleanupTest.java index 7b3479970f..09471339e2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempDestDemandSubscriptionCleanupTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempDestDemandSubscriptionCleanupTest.java @@ -25,6 +25,10 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.region.AbstractRegion; @@ -34,11 +38,6 @@ import org.apache.activemq.util.Wait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.URI; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - /** * @author Christian Posta */ @@ -107,8 +106,7 @@ public class ThreeBrokerTempDestDemandSubscriptionCleanupTest extends JmsMultipl responseConsumer.close(); conn.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(); } @@ -181,8 +179,7 @@ public class ThreeBrokerTempDestDemandSubscriptionCleanupTest extends JmsMultipl // responseConsumer.close(); conn.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(); } @@ -229,8 +226,7 @@ public class ThreeBrokerTempDestDemandSubscriptionCleanupTest extends JmsMultipl producer.send(response); producer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); fail("Could not respond to an echo request"); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java index 52be70bbbf..aa6a139c8a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.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, @@ -16,12 +16,11 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.Iterator; - import javax.jms.Connection; import javax.jms.Session; import javax.jms.TemporaryQueue; +import java.net.URI; +import java.util.Iterator; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.network.NetworkConnector; @@ -94,8 +93,7 @@ public class ThreeBrokerTempQueueNetworkTest extends JmsMultipleBrokersTestSuppo enableTempDestinationBridging = false; try { testTempQueueCleanup(); - } - catch (Throwable e) { + } catch (Throwable e) { // Expecting an error return; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java index 381ae0597d..b61186f7b3 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.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, @@ -16,15 +16,14 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.Topic; import java.net.URI; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.Topic; - import junit.framework.Test; import org.apache.activemq.JmsMultipleBrokersTestSupport; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java index 848193abdb..8053031f68 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.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, @@ -52,12 +52,10 @@ public class ThreeBrokerTopicNetworkUsingTcpTest extends ThreeBrokerTopicNetwork bridges.add(bridge); bridge.start(); - } - else { + } else { throw new Exception("Remote broker or local broker is not using tcp connectors"); } - } - else { + } else { throw new Exception("Remote broker or local broker has no registered connectors."); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkLevelDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkLevelDBTest.java index 0277c14442..6a20b1267e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkLevelDBTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkLevelDBTest.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, @@ -31,4 +31,4 @@ public class ThreeBrokerVirtualTopicNetworkLevelDBTest extends ThreeBrokerVirtua adapter.setDirectory(dataFileDir); broker.setPersistenceAdapter(adapter); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkTest.java index 4f6122eafe..f08499a3cb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerVirtualTopicNetworkTest.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; import java.io.File; import java.io.IOException; import java.net.URI; -import javax.jms.Destination; -import javax.jms.MessageConsumer; - import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.DestinationInterceptor; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java index b1e1db669e..02d175c077 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.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, @@ -16,11 +16,6 @@ */ package org.apache.activemq.usecases; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.util.Date; -import java.util.Vector; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.JMSException; @@ -34,6 +29,10 @@ import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.Date; +import java.util.Vector; import junit.framework.Test; @@ -133,13 +132,11 @@ public class TopicDurableConnectStatsTest extends org.apache.activemq.TestSuppor try { if (mbeanServer.isRegistered(objectName)) { LOG.info("Bean Registered: " + objectName); - } - else { + } else { LOG.info("Couldn't find Mbean! " + objectName); } - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } return objectName; @@ -248,23 +245,20 @@ public class TopicDurableConnectStatsTest extends org.apache.activemq.TestSuppor count++; try { session2.commit(); - } - catch (JMSException e1) { + } catch (JMSException e1) { e1.printStackTrace(); } if (id != null) { try { LOG.info(id + ", " + message.getJMSMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } try { Thread.sleep(2); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicProducerFlowControlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicProducerFlowControlTest.java index 31c4a8b754..663afb4547 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicProducerFlowControlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicProducerFlowControlTest.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, @@ -16,16 +16,15 @@ */ package org.apache.activemq.usecases; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import junit.framework.TestCase; @@ -142,16 +141,13 @@ public class TopicProducerFlowControlTest extends TestCase implements MessageLis LOG.info("Produced " + count + " messages"); } } - } - catch (Throwable ex) { + } catch (Throwable ex) { ex.printStackTrace(); - } - finally { + } finally { try { producer.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -187,8 +183,7 @@ public class TopicProducerFlowControlTest extends TestCase implements MessageLis if (count % 100 == 0) { try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } if (count % 10000 == 0) { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java index 03e7b9ffa0..937a3c45e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicRedeliverTest.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, @@ -16,7 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -28,6 +27,7 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.test.TestSupport; import org.apache.activemq.util.IdGenerator; @@ -91,9 +91,9 @@ public class TopicRedeliverTest extends TestSupport { sent2.setStringProperty("str", "3"); producer.send(sent3); - TextMessage msgTest = (TextMessage)consumer.receive(RECEIVE_TIMEOUT); + TextMessage msgTest = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); System.out.println("msgTest::" + msgTest + " // " + msgTest.getText()); - TextMessage rec2 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT); + TextMessage rec2 = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); System.out.println("msgTest::" + rec2 + " // " + rec2.getText()); assertNull(consumer.receiveNoWait()); @@ -104,10 +104,10 @@ public class TopicRedeliverTest extends TestSupport { sent4.setText("msg4"); producer.send(sent4); - TextMessage rec4 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT); + TextMessage rec4 = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); assertTrue(rec4.equals(sent4)); consumerSession.recover(); - rec4 = (TextMessage)consumer.receive(RECEIVE_TIMEOUT); + rec4 = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); assertTrue(rec4.equals(sent4)); assertTrue(rec4.getJMSRedelivered()); rec4.acknowledge(); @@ -129,8 +129,7 @@ public class TopicRedeliverTest extends TestSupport { MessageConsumer consumer = null; if (topic) { consumer = consumerSession.createDurableSubscriber((Topic) destination, "TESTRED"); - } - else { + } else { consumer = consumerSession.createConsumer(destination); } Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); @@ -171,8 +170,7 @@ public class TopicRedeliverTest extends TestSupport { MessageConsumer consumer = null; if (topic) { consumer = consumerSession.createConsumer(destination); - } - else { + } else { consumer = consumerSession.createConsumer(destination); } Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); @@ -216,8 +214,7 @@ public class TopicRedeliverTest extends TestSupport { MessageConsumer consumer = null; if (topic) { consumer = consumerSession.createDurableSubscriber((Topic) destination, "TESTRED"); - } - else { + } else { consumer = consumerSession.createConsumer(destination); } Session producerSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicReplicationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicReplicationTest.java index 845cb9e4db..0f252dda24 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicReplicationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicReplicationTest.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, @@ -16,13 +16,13 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; + import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.util.MessageIdList; import org.springframework.core.io.ClassPathResource; -import javax.jms.Destination; -import javax.jms.MessageConsumer; - public class TopicReplicationTest extends JmsMultipleBrokersTestSupport { public static final int MSG_COUNT = 10; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionSlowConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionSlowConsumerTest.java index 9bc8fe6eea..803c198688 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionSlowConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionSlowConsumerTest.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, @@ -16,6 +16,12 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; + import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -26,12 +32,6 @@ import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.command.ActiveMQTopic; import org.junit.Assert; -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - /** * Checks to see if "slow consumer advisory messages" are generated when * small number of messages (2) are published to a topic which has a subscriber diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionZeroPrefetchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionZeroPrefetchTest.java index 7122acc4bd..04674b891e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionZeroPrefetchTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TopicSubscriptionZeroPrefetchTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java index 0978480676..8d1752e6cc 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionRollbackOrderTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -29,6 +25,9 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; import junit.framework.TestCase; @@ -96,8 +95,7 @@ public final class TransactionRollbackOrderTest extends TestCase { msgRolledBack.add(receivedText); consumerSession.rollback(); LOG.info("[msg: " + receivedText + "] ** rolled back **"); - } - else { + } else { msgCommittedCount++; msgCommitted.add(receivedText); consumerSession.commit(); @@ -106,13 +104,11 @@ public final class TransactionRollbackOrderTest extends TestCase { if (msgCommittedCount == numMessages) { latch.countDown(); } - } - catch (JMSException e) { + } catch (JMSException e) { try { consumerSession.rollback(); LOG.info("rolled back transaction"); - } - catch (JMSException e1) { + } catch (JMSException e1) { LOG.info(e1.toString()); e1.printStackTrace(); } @@ -132,8 +128,7 @@ public final class TransactionRollbackOrderTest extends TestCase { producer.send(tm); LOG.info("producer sent message: " + tm.getText()); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java index 3ccc147497..fb6c641332 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.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, @@ -16,10 +16,6 @@ */ package org.apache.activemq.usecases; -import java.util.Date; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -29,6 +25,9 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Date; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import junit.framework.TestCase; @@ -79,13 +78,11 @@ public final class TransactionTest extends TestCase { LOG.info("consumer received message :" + receivedText); consumerSession.commit(); LOG.info("committed transaction"); - } - catch (JMSException e) { + } catch (JMSException e) { try { consumerSession.rollback(); LOG.info("rolled back transaction"); - } - catch (JMSException e1) { + } catch (JMSException e1) { LOG.info(e1.toString()); e1.printStackTrace(); } @@ -103,8 +100,7 @@ public final class TransactionTest extends TestCase { tm.setText("Hello, " + new Date()); producer.send(tm); LOG.info("producer sent message :" + tm.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java index e16b892f4c..dd74ed3fa4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TransientQueueRedeliverTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java index 5524832b67..7a314fef2a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.Destination; import javax.jms.MessageConsumer; +import java.net.URI; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.util.MessageIdList; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java index e5d20f54d0..68c8182a77 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerMulticastQueueTest.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, @@ -16,9 +16,6 @@ */ package org.apache.activemq.usecases; -import java.net.URI; -import java.util.Arrays; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -27,6 +24,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.net.URI; +import java.util.Arrays; import junit.framework.Test; @@ -230,8 +229,7 @@ public class TwoBrokerMulticastQueueTest extends CombinationTestSupport { if (waitTime > 0) { Thread.sleep(waitTime); - } - else { + } else { list.waitForMessagesToArrive(MESSAGE_COUNT); } @@ -263,8 +261,7 @@ public class TwoBrokerMulticastQueueTest extends CombinationTestSupport { msg.setText(initText + str); // Do not pad message text - } - else { + } else { msg.setText(initText); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardDynamicallyIncludedDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardDynamicallyIncludedDestinationTest.java index 6af11455fd..26716acc80 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardDynamicallyIncludedDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardDynamicallyIncludedDestinationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardStaticallyIncludedDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardStaticallyIncludedDestinationTest.java index 42439ec6d2..77612fc6db 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardStaticallyIncludedDestinationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkConnectorWildcardStaticallyIncludedDestinationTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java index e779c4f424..7b7000f3f5 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.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, @@ -16,10 +16,9 @@ */ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.Destination; import javax.jms.MessageConsumer; +import java.net.URI; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.util.MessageIdList; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java index 0e9ff3eed2..b8b7bb6046 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; import java.net.URI; import java.util.Collection; import java.util.Iterator; @@ -23,12 +28,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; - import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQPrefetchPolicy; import org.apache.activemq.JmsMultipleBrokersTestSupport; @@ -396,8 +395,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS)); LOG.info("Stopping connection post send and receive and multiple producers"); producerExchange.getConnectionContext().getConnection().stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -470,8 +468,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS)); LOG.info("Stopping connection post send and receive and multiple producers"); producerExchange.getConnectionContext().getConnection().stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueSendReceiveTest.java index b7b52056a6..524af21a59 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTempQueueAdvisoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTempQueueAdvisoryTest.java index c19f84198d..05aa3e42fd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTempQueueAdvisoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTempQueueAdvisoryTest.java @@ -6,7 +6,22 @@ * (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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -32,14 +47,13 @@ */ package org.apache.activemq.usecases; -import java.net.URI; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.management.ObjectName; +import java.net.URI; import junit.framework.Test; @@ -120,8 +134,7 @@ public class TwoBrokerTempQueueAdvisoryTest extends JmsMultipleBrokersTestSuppor NetworkConnector nc = bridgeBrokers("BrokerA", "BrokerB"); if (useDuplex) { nc.setDuplex(true); - } - else { + } else { bridgeBrokers("BrokerB", "BrokerA"); } @@ -177,8 +190,7 @@ public class TwoBrokerTempQueueAdvisoryTest extends JmsMultipleBrokersTestSuppor ObjectName name; if (type == ActiveMQDestination.QUEUE_TYPE) { name = new ObjectName(domain + ":type=Broker,brokerName=" + broker + ",destinationType=Queue,destinationName=" + destination); - } - else { + } else { name = new ObjectName(domain + ":type=Broker,brokerName=" + broker + ",destinationType=Topic,destinationName=" + destination); } return (DestinationViewMBean) brokers.get(broker).broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveLotsOfMessagesUsingTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveLotsOfMessagesUsingTcpTest.java index 7091ab3c35..8cf04f8379 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveLotsOfMessagesUsingTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveLotsOfMessagesUsingTcpTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java index 361f514065..1969f31ed1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.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, @@ -16,11 +16,10 @@ */ package org.apache.activemq.usecases; -import java.util.HashMap; -import java.util.Iterator; - import javax.jms.Connection; import javax.jms.JMSException; +import java.util.HashMap; +import java.util.Iterator; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -95,8 +94,7 @@ public class TwoBrokerTopicSendReceiveTest extends JmsTopicSendReceiveWithTwoCon return new ActiveMQConnectionFactory(connectUrl); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } return null; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.java index eae48d684b..75141f25ec 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.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, @@ -42,8 +42,7 @@ public class TwoBrokerTopicSendReceiveUsingJavaConfigurationTest extends TwoBrok ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62002"); return factory; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } @@ -62,8 +61,7 @@ public class TwoBrokerTopicSendReceiveUsingJavaConfigurationTest extends TwoBrok ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62001"); return factory; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java index b7596247b3..5fdf4fa043 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveUsingTcpTest.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, @@ -63,8 +63,7 @@ public class TwoBrokerTopicSendReceiveUsingTcpTest extends TwoBrokerTopicSendRec try { ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(receiverBroker.getTransportConnectors().get(0).getConnectUri()); return fac; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } @@ -75,8 +74,7 @@ public class TwoBrokerTopicSendReceiveUsingTcpTest extends TwoBrokerTopicSendRec try { ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(senderBroker.getTransportConnectors().get(0).getConnectUri()); return fac; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualDestDinamicallyIncludedDestTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualDestDinamicallyIncludedDestTest.java index 3852df7de7..cb7cf15fb4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualDestDinamicallyIncludedDestTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualDestDinamicallyIncludedDestTest.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, @@ -16,6 +16,12 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import java.io.File; +import java.io.IOException; +import java.net.URI; + import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.DestinationInterceptor; @@ -27,12 +33,6 @@ import org.apache.activemq.network.NetworkConnector; import org.apache.activemq.store.kahadb.KahaDBStore; import org.apache.activemq.util.MessageIdList; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import java.io.File; -import java.io.IOException; -import java.net.URI; - public class TwoBrokerVirtualDestDinamicallyIncludedDestTest extends JmsMultipleBrokersTestSupport { protected static final int MESSAGE_COUNT = 10; @@ -228,4 +228,4 @@ public class TwoBrokerVirtualDestDinamicallyIncludedDestTest extends JmsMultiple kaha.deleteAllMessages(); broker.setPersistenceAdapter(kaha); } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicForwardingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicForwardingTest.java index 7c042b991c..d78322d385 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicForwardingTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicForwardingTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.usecases; +import javax.jms.MessageConsumer; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.LinkedList; + import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.Destination; @@ -26,13 +32,7 @@ import org.apache.activemq.network.NetworkConnector; import org.apache.activemq.store.kahadb.KahaDBStore; import org.apache.activemq.util.MessageIdList; -import javax.jms.MessageConsumer; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.util.LinkedList; - -import static org.apache.activemq.TestSupport.*; +import static org.apache.activemq.TestSupport.getDestination; /** * @author Christian Posta diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoMulticastDiscoveryBrokerTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoMulticastDiscoveryBrokerTopicSendReceiveTest.java index 18c44772f2..3639168756 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoMulticastDiscoveryBrokerTopicSendReceiveTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoMulticastDiscoveryBrokerTopicSendReceiveTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoSecureBrokerRequestReplyTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoSecureBrokerRequestReplyTest.java index 3b1c6b3201..9684ae329c 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoSecureBrokerRequestReplyTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoSecureBrokerRequestReplyTest.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, @@ -16,6 +16,11 @@ */ package org.apache.activemq.usecases; +import javax.jms.ConnectionFactory; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TemporaryQueue; + import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQMessageConsumer; import org.apache.activemq.JmsMultipleBrokersTestSupport; @@ -24,11 +29,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; -import javax.jms.ConnectionFactory; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TemporaryQueue; - public class TwoSecureBrokerRequestReplyTest extends JmsMultipleBrokersTestSupport { private static final Logger LOG = LoggerFactory.getLogger(TwoSecureBrokerRequestReplyTest.class); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java index cfeef5c708..6168423807 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.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, @@ -17,12 +17,6 @@ package org.apache.activemq.usecases; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -31,6 +25,11 @@ import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.ResourceAllocationException; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; @@ -125,14 +124,12 @@ public class UnlimitedEnqueueTest { message.writeBytes(bytes); try { producer.send(message); - } - catch (ResourceAllocationException e) { + } catch (ResourceAllocationException e) { e.printStackTrace(); } session.close(); } - } - catch (JMSException e) { + } catch (JMSException e) { // expect interrupted exception on shutdownNow } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VerifyNetworkConsumersDisconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VerifyNetworkConsumersDisconnectTest.java index 5c9a3bfea7..4db4b423ac 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VerifyNetworkConsumersDisconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VerifyNetworkConsumersDisconnectTest.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, @@ -16,6 +16,9 @@ */ package org.apache.activemq.usecases; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.management.ObjectName; import java.lang.Thread.UncaughtExceptionHandler; import java.net.URI; import java.util.HashMap; @@ -25,9 +28,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.management.ObjectName; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; @@ -227,13 +227,11 @@ public class VerifyNetworkConsumersDisconnectTest extends JmsMultipleBrokersTest LOG.info("Sub IDs: " + consumerIds); if (currentCount == count) { stability.incrementAndGet(); - } - else { + } else { stability.set(0); } return stability.get() > numChecks; - } - catch (Exception e) { + } catch (Exception e) { LOG.warn(": ", e); return false; } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VirtualTopicNetworkClusterReactivationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VirtualTopicNetworkClusterReactivationTest.java index 5d24d8be22..e44d113400 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VirtualTopicNetworkClusterReactivationTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/VirtualTopicNetworkClusterReactivationTest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.usecases; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.net.URI; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.broker.BrokerService; @@ -26,9 +35,6 @@ import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.network.ConditionalNetworkBridgeFilterFactory; -import javax.jms.*; -import java.net.URI; - /** * @author Christian Posta */ @@ -157,16 +163,14 @@ public class VirtualTopicNetworkClusterReactivationTest extends JmsMultipleBroke private void sleep() { try { Thread.sleep(DEFAULT_SLEEP_MS); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } private void sleep(int milliSecondTime) { try { Thread.sleep(milliSecondTime); - } - catch (InterruptedException igonred) { + } catch (InterruptedException igonred) { } } -} \ No newline at end of file +} diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ConsumerThread.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ConsumerThread.java index 11475f3f4c..fc8a2e286a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ConsumerThread.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ConsumerThread.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, @@ -16,11 +16,16 @@ */ package org.apache.activemq.util; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; - public class ConsumerThread extends Thread { private static final Logger LOG = LoggerFactory.getLogger(ConsumerThread.class); @@ -47,23 +52,19 @@ public class ConsumerThread extends Thread { if (msg != null) { LOG.info("Received " + received + ": " + ((TextMessage) msg).getText()); received++; - } - else { + } else { if (breakOnNull) { break; } } } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); - } - finally { + } finally { if (consumer != null) { try { consumer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/DefaultTestAppender.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/DefaultTestAppender.java index 7355b64dba..241b09eddb 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/DefaultTestAppender.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/DefaultTestAppender.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LinkedNodeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LinkedNodeTest.java index 4243375a41..b0ab40a68a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LinkedNodeTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LinkedNodeTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java index 03e0d2eb8d..4fdbb0e4fa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.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,46 +25,46 @@ import static org.junit.Assert.assertTrue; public class LockFileTest { - @Test - public void testNoDeleteOnUnlockIfNotLocked() throws Exception { + @Test + public void testNoDeleteOnUnlockIfNotLocked() throws Exception { - File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest1"); - IOHelper.mkdirs(lockFile.getParentFile()); - lockFile.createNewFile(); + File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest1"); + IOHelper.mkdirs(lockFile.getParentFile()); + lockFile.createNewFile(); - LockFile underTest = new LockFile(lockFile, true); + LockFile underTest = new LockFile(lockFile, true); - underTest.lock(); + underTest.lock(); - lockFile.delete(); + lockFile.delete(); - assertFalse("no longer valid", underTest.keepAlive()); + assertFalse("no longer valid", underTest.keepAlive()); - // a slave gets in - lockFile.createNewFile(); + // a slave gets in + lockFile.createNewFile(); - underTest.unlock(); + underTest.unlock(); - assertTrue("file still exists after unlock when not locked", lockFile.exists()); + assertTrue("file still exists after unlock when not locked", lockFile.exists()); - } + } - @Test - public void testDeleteOnUnlockIfLocked() throws Exception { + @Test + public void testDeleteOnUnlockIfLocked() throws Exception { - File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest2"); - IOHelper.mkdirs(lockFile.getParentFile()); - lockFile.createNewFile(); + File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest2"); + IOHelper.mkdirs(lockFile.getParentFile()); + lockFile.createNewFile(); - LockFile underTest = new LockFile(lockFile, true); + LockFile underTest = new LockFile(lockFile, true); - underTest.lock(); + underTest.lock(); - assertTrue("valid", underTest.keepAlive()); + assertTrue("valid", underTest.keepAlive()); - underTest.unlock(); + underTest.unlock(); - assertFalse("file deleted on unlock", lockFile.exists()); + assertFalse("file deleted on unlock", lockFile.exists()); - } + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java index 8b87de57a2..ad4eca2ae2 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.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, @@ -16,13 +16,12 @@ */ package org.apache.activemq.util; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; import org.junit.Assert; import org.slf4j.Logger; @@ -113,8 +112,7 @@ public class MessageIdList extends Assert implements MessageListener { if (LOG.isDebugEnabled()) { LOG.debug("Received message: " + message); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } if (parent != null) { @@ -123,8 +121,7 @@ public class MessageIdList extends Assert implements MessageListener { if (processingDelay > 0) { try { Thread.sleep(processingDelay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } @@ -152,8 +149,7 @@ public class MessageIdList extends Assert implements MessageListener { } semaphore.wait(maximumDuration - duration); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.info("Caught: " + e); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ProducerThread.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ProducerThread.java index b6dde36f08..534b87dbd8 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ProducerThread.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ProducerThread.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, @@ -16,11 +16,15 @@ */ package org.apache.activemq.util; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Session; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; - public class ProducerThread extends Thread { private static final Logger LOG = LoggerFactory.getLogger(ProducerThread.class); @@ -48,16 +52,13 @@ public class ProducerThread extends Thread { Thread.sleep(sleep); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (producer != null) { try { producer.close(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java index 0f4b902189..1b9afd476a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ReflectionSupportTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/ReflectionSupportTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SimplePojo.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SimplePojo.java index a1f9ed353c..0291cb84ae 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SimplePojo.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SimplePojo.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java index f6e3be321c..de7503cb43 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.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, @@ -40,359 +40,358 @@ import org.slf4j.LoggerFactory; public class SocketProxy { - private static final transient Logger LOG = LoggerFactory.getLogger(SocketProxy.class); + private static final transient Logger LOG = LoggerFactory.getLogger(SocketProxy.class); - public static final int ACCEPT_TIMEOUT_MILLIS = 100; + public static final int ACCEPT_TIMEOUT_MILLIS = 100; - private URI proxyUrl; - private URI target; + private URI proxyUrl; + private URI target; - private Acceptor acceptor; - private ServerSocket serverSocket; + private Acceptor acceptor; + private ServerSocket serverSocket; - private CountDownLatch closed = new CountDownLatch(1); + private CountDownLatch closed = new CountDownLatch(1); - public final List connections = new LinkedList<>(); + public final List connections = new LinkedList<>(); - private int listenPort = 0; + private int listenPort = 0; - private int receiveBufferSize = -1; + private int receiveBufferSize = -1; - private boolean pauseAtStart = false; + private boolean pauseAtStart = false; - private int acceptBacklog = 50; + private int acceptBacklog = 50; - public SocketProxy() throws Exception { - } + public SocketProxy() throws Exception { + } - public SocketProxy(URI uri) throws Exception { - this(0, uri); - } + public SocketProxy(URI uri) throws Exception { + this(0, uri); + } - public SocketProxy(int port, URI uri) throws Exception { - listenPort = port; - target = uri; - open(); - } + public SocketProxy(int port, URI uri) throws Exception { + listenPort = port; + target = uri; + open(); + } - public void setReceiveBufferSize(int receiveBufferSize) { - this.receiveBufferSize = receiveBufferSize; - } + public void setReceiveBufferSize(int receiveBufferSize) { + this.receiveBufferSize = receiveBufferSize; + } - public void setTarget(URI tcpBrokerUri) { - target = tcpBrokerUri; - } + public void setTarget(URI tcpBrokerUri) { + target = tcpBrokerUri; + } - public void open() throws Exception { - serverSocket = createServerSocket(target); - serverSocket.setReuseAddress(true); - if (receiveBufferSize > 0) { - serverSocket.setReceiveBufferSize(receiveBufferSize); - } - if (proxyUrl == null) { - serverSocket.bind(new InetSocketAddress(listenPort), acceptBacklog); - proxyUrl = urlFromSocket(target, serverSocket); - } else { - serverSocket.bind(new InetSocketAddress(proxyUrl.getPort())); - } - acceptor = new Acceptor(serverSocket, target); - if (pauseAtStart) { - acceptor.pause(); - } - new Thread(null, acceptor, "SocketProxy-Acceptor-" + serverSocket.getLocalPort()).start(); - closed = new CountDownLatch(1); - } + public void open() throws Exception { + serverSocket = createServerSocket(target); + serverSocket.setReuseAddress(true); + if (receiveBufferSize > 0) { + serverSocket.setReceiveBufferSize(receiveBufferSize); + } + if (proxyUrl == null) { + serverSocket.bind(new InetSocketAddress(listenPort), acceptBacklog); + proxyUrl = urlFromSocket(target, serverSocket); + } else { + serverSocket.bind(new InetSocketAddress(proxyUrl.getPort())); + } + acceptor = new Acceptor(serverSocket, target); + if (pauseAtStart) { + acceptor.pause(); + } + new Thread(null, acceptor, "SocketProxy-Acceptor-" + serverSocket.getLocalPort()).start(); + closed = new CountDownLatch(1); + } - private boolean isSsl(URI target) { - return "ssl".equals(target.getScheme()); - } + private boolean isSsl(URI target) { + return "ssl".equals(target.getScheme()); + } - private ServerSocket createServerSocket(URI target) throws Exception { - if (isSsl(target)) { - return SSLServerSocketFactory.getDefault().createServerSocket(); - } - return new ServerSocket(); - } + private ServerSocket createServerSocket(URI target) throws Exception { + if (isSsl(target)) { + return SSLServerSocketFactory.getDefault().createServerSocket(); + } + return new ServerSocket(); + } - private Socket createSocket(URI target) throws Exception { - if (isSsl(target)) { - return SSLSocketFactory.getDefault().createSocket(); - } - return new Socket(); - } + private Socket createSocket(URI target) throws Exception { + if (isSsl(target)) { + return SSLSocketFactory.getDefault().createSocket(); + } + return new Socket(); + } - public URI getUrl() { - return proxyUrl; - } + public URI getUrl() { + return proxyUrl; + } - /* - * close all proxy connections and acceptor - */ - public void close() { - List connections; - synchronized(this.connections) { - connections = new ArrayList<>(this.connections); - } - LOG.info("close, numConnections=" + connections.size()); - for (Bridge con : connections) { - closeConnection(con); - } - acceptor.close(); - closed.countDown(); - } + /* + * close all proxy connections and acceptor + */ + public void close() { + List connections; + synchronized (this.connections) { + connections = new ArrayList<>(this.connections); + } + LOG.info("close, numConnections=" + connections.size()); + for (Bridge con : connections) { + closeConnection(con); + } + acceptor.close(); + closed.countDown(); + } - /* - * close all proxy receive connections, leaving acceptor - * open - */ - public void halfClose() { - List connections; - synchronized(this.connections) { - connections = new ArrayList<>(this.connections); - } - LOG.info("halfClose, numConnections=" + connections.size()); - for (Bridge con : connections) { - halfCloseConnection(con); - } - } + /* + * close all proxy receive connections, leaving acceptor + * open + */ + public void halfClose() { + List connections; + synchronized (this.connections) { + connections = new ArrayList<>(this.connections); + } + LOG.info("halfClose, numConnections=" + connections.size()); + for (Bridge con : connections) { + halfCloseConnection(con); + } + } - public boolean waitUntilClosed(long timeoutSeconds) throws InterruptedException { - return closed.await(timeoutSeconds, TimeUnit.SECONDS); - } + public boolean waitUntilClosed(long timeoutSeconds) throws InterruptedException { + return closed.await(timeoutSeconds, TimeUnit.SECONDS); + } - /* - * called after a close to restart the acceptor on the same port - */ - public void reopen() { - LOG.info("reopen"); - try { - open(); - } catch (Exception e) { - LOG.debug("exception on reopen url:" + getUrl(), e); - } - } + /* + * called after a close to restart the acceptor on the same port + */ + public void reopen() { + LOG.info("reopen"); + try { + open(); + } catch (Exception e) { + LOG.debug("exception on reopen url:" + getUrl(), e); + } + } - /* - * pause accepting new connections and data transfer through existing proxy - * connections. All sockets remain open - */ - public void pause() { - synchronized(connections) { - LOG.info("pause, numConnections=" + connections.size()); - acceptor.pause(); - for (Bridge con : connections) { - con.pause(); - } - } - } + /* + * pause accepting new connections and data transfer through existing proxy + * connections. All sockets remain open + */ + public void pause() { + synchronized (connections) { + LOG.info("pause, numConnections=" + connections.size()); + acceptor.pause(); + for (Bridge con : connections) { + con.pause(); + } + } + } - /* - * continue after pause - */ - public void goOn() { - synchronized(connections) { - LOG.info("goOn, numConnections=" + connections.size()); - for (Bridge con : connections) { - con.goOn(); - } - } - acceptor.goOn(); - } + /* + * continue after pause + */ + public void goOn() { + synchronized (connections) { + LOG.info("goOn, numConnections=" + connections.size()); + for (Bridge con : connections) { + con.goOn(); + } + } + acceptor.goOn(); + } - private void closeConnection(Bridge c) { - try { - c.close(); - } catch (Exception e) { - LOG.debug("exception on close of: " + c, e); - } - } + private void closeConnection(Bridge c) { + try { + c.close(); + } catch (Exception e) { + LOG.debug("exception on close of: " + c, e); + } + } - private void halfCloseConnection(Bridge c) { - try { - c.halfClose(); - } catch (Exception e) { - LOG.debug("exception on half close of: " + c, e); - } - } + private void halfCloseConnection(Bridge c) { + try { + c.halfClose(); + } catch (Exception e) { + LOG.debug("exception on half close of: " + c, e); + } + } - public boolean isPauseAtStart() { - return pauseAtStart; - } + public boolean isPauseAtStart() { + return pauseAtStart; + } - public void setPauseAtStart(boolean pauseAtStart) { - this.pauseAtStart = pauseAtStart; - } + public void setPauseAtStart(boolean pauseAtStart) { + this.pauseAtStart = pauseAtStart; + } - public int getAcceptBacklog() { - return acceptBacklog; - } + public int getAcceptBacklog() { + return acceptBacklog; + } - public void setAcceptBacklog(int acceptBacklog) { - this.acceptBacklog = acceptBacklog; - } + public void setAcceptBacklog(int acceptBacklog) { + this.acceptBacklog = acceptBacklog; + } - private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception { - int listenPort = serverSocket.getLocalPort(); + private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception { + int listenPort = serverSocket.getLocalPort(); - return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(), uri.getFragment()); - } + return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(), uri.getFragment()); + } - public class Bridge { + public class Bridge { - private Socket receiveSocket; - private Socket sendSocket; - private Pump requestThread; - private Pump responseThread; + private Socket receiveSocket; + private Socket sendSocket; + private Pump requestThread; + private Pump responseThread; - public Bridge(Socket socket, URI target) throws Exception { - receiveSocket = socket; - sendSocket = createSocket(target); - if (receiveBufferSize > 0) { - sendSocket.setReceiveBufferSize(receiveBufferSize); - } - sendSocket.connect(new InetSocketAddress(target.getHost(), target.getPort())); - linkWithThreads(receiveSocket, sendSocket); - LOG.info("proxy connection " + sendSocket + ", receiveBufferSize=" + sendSocket.getReceiveBufferSize()); - } + public Bridge(Socket socket, URI target) throws Exception { + receiveSocket = socket; + sendSocket = createSocket(target); + if (receiveBufferSize > 0) { + sendSocket.setReceiveBufferSize(receiveBufferSize); + } + sendSocket.connect(new InetSocketAddress(target.getHost(), target.getPort())); + linkWithThreads(receiveSocket, sendSocket); + LOG.info("proxy connection " + sendSocket + ", receiveBufferSize=" + sendSocket.getReceiveBufferSize()); + } - public void goOn() { - responseThread.goOn(); - requestThread.goOn(); - } + public void goOn() { + responseThread.goOn(); + requestThread.goOn(); + } - public void pause() { - requestThread.pause(); - responseThread.pause(); - } + public void pause() { + requestThread.pause(); + responseThread.pause(); + } - public void close() throws Exception { - synchronized(connections) { - connections.remove(this); - } - receiveSocket.close(); - sendSocket.close(); - } + public void close() throws Exception { + synchronized (connections) { + connections.remove(this); + } + receiveSocket.close(); + sendSocket.close(); + } - public void halfClose() throws Exception { - receiveSocket.close(); - } + public void halfClose() throws Exception { + receiveSocket.close(); + } - private void linkWithThreads(Socket source, Socket dest) { - requestThread = new Pump(source, dest); - requestThread.start(); - responseThread = new Pump(dest, source); - responseThread.start(); - } + private void linkWithThreads(Socket source, Socket dest) { + requestThread = new Pump(source, dest); + requestThread.start(); + responseThread = new Pump(dest, source); + responseThread.start(); + } - public class Pump extends Thread { + public class Pump extends Thread { - protected Socket src; - private Socket destination; - private AtomicReference pause = new AtomicReference<>(); + protected Socket src; + private Socket destination; + private AtomicReference pause = new AtomicReference<>(); - public Pump(Socket source, Socket dest) { - super("SocketProxy-DataTransfer-" + source.getPort() + ":" + dest.getPort()); - src = source; - destination = dest; - pause.set(new CountDownLatch(0)); - } - - public void pause() { - pause.set(new CountDownLatch(1)); - } - - public void goOn() { - pause.get().countDown(); - } - - @Override - public void run() { - byte[] buf = new byte[1024]; - try { - InputStream in = src.getInputStream(); - OutputStream out = destination.getOutputStream(); - while (true) { - int len = in.read(buf); - if (len == -1) { - LOG.debug("read eof from:" + src); - break; - } - pause.get().await(); - out.write(buf, 0, len); - } - } catch (Exception e) { - LOG.debug("read/write failed, reason: " + e.getLocalizedMessage()); - try { - if (!receiveSocket.isClosed()) { - // for halfClose, on read/write failure if we close the - // remote end will see a close at the same time. - close(); - } - } catch (Exception ignore) { - } - } - } - } - } - - public class Acceptor implements Runnable { - - private ServerSocket socket; - private URI target; - private AtomicReference pause = new AtomicReference<>(); - - - public Acceptor(ServerSocket serverSocket, URI uri) { - socket = serverSocket; - target = uri; + public Pump(Socket source, Socket dest) { + super("SocketProxy-DataTransfer-" + source.getPort() + ":" + dest.getPort()); + src = source; + destination = dest; pause.set(new CountDownLatch(0)); - try { - socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS); - } catch (SocketException e) { - e.printStackTrace(); - } - } + } - public void pause() { + public void pause() { pause.set(new CountDownLatch(1)); - } + } - public void goOn() { + public void goOn() { pause.get().countDown(); - } + } - @Override - public void run() { + @Override + public void run() { + byte[] buf = new byte[1024]; try { - while(!socket.isClosed()) { - pause.get().await(); - try { - Socket source = socket.accept(); - pause.get().await(); - if (receiveBufferSize > 0) { - source.setReceiveBufferSize(receiveBufferSize); - } - LOG.info("accepted " + source + ", receiveBufferSize:" + source.getReceiveBufferSize()); - synchronized(connections) { - connections.add(new Bridge(source, target)); - } - } catch (SocketTimeoutException expected) { - } - } + InputStream in = src.getInputStream(); + OutputStream out = destination.getOutputStream(); + while (true) { + int len = in.read(buf); + if (len == -1) { + LOG.debug("read eof from:" + src); + break; + } + pause.get().await(); + out.write(buf, 0, len); + } } catch (Exception e) { - LOG.debug("acceptor: finished for reason: " + e.getLocalizedMessage()); + LOG.debug("read/write failed, reason: " + e.getLocalizedMessage()); + try { + if (!receiveSocket.isClosed()) { + // for halfClose, on read/write failure if we close the + // remote end will see a close at the same time. + close(); + } + } catch (Exception ignore) { + } } - } + } + } + } - public void close() { - try { - socket.close(); - closed.countDown(); - goOn(); - } catch (IOException ignored) { + public class Acceptor implements Runnable { + + private ServerSocket socket; + private URI target; + private AtomicReference pause = new AtomicReference<>(); + + public Acceptor(ServerSocket serverSocket, URI uri) { + socket = serverSocket; + target = uri; + pause.set(new CountDownLatch(0)); + try { + socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS); + } catch (SocketException e) { + e.printStackTrace(); + } + } + + public void pause() { + pause.set(new CountDownLatch(1)); + } + + public void goOn() { + pause.get().countDown(); + } + + @Override + public void run() { + try { + while (!socket.isClosed()) { + pause.get().await(); + try { + Socket source = socket.accept(); + pause.get().await(); + if (receiveBufferSize > 0) { + source.setReceiveBufferSize(receiveBufferSize); + } + LOG.info("accepted " + source + ", receiveBufferSize:" + source.getReceiveBufferSize()); + synchronized (connections) { + connections.add(new Bridge(source, target)); + } + } catch (SocketTimeoutException expected) { + } } - } - } + } catch (Exception e) { + LOG.debug("acceptor: finished for reason: " + e.getLocalizedMessage()); + } + } + + public void close() { + try { + socket.close(); + closed.countDown(); + goOn(); + } catch (IOException ignored) { + } + } + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java index 244db593a1..4f762331bd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.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, @@ -17,34 +17,36 @@ package org.apache.activemq.util; - import java.util.concurrent.TimeUnit; public class Wait { - public static final long MAX_WAIT_MILLIS = 30*1000; - public static final long SLEEP_MILLIS = 1000; + public static final long MAX_WAIT_MILLIS = 30 * 1000; + public static final long SLEEP_MILLIS = 1000; - public interface Condition { - boolean isSatisified() throws Exception; - } + public interface Condition { - public static boolean waitFor(Condition condition) throws Exception { - return waitFor(condition, MAX_WAIT_MILLIS); - } + boolean isSatisified() throws Exception; + } - public static boolean waitFor(final Condition condition, final long duration) throws Exception { - return waitFor(condition, duration, SLEEP_MILLIS); - } + public static boolean waitFor(Condition condition) throws Exception { + return waitFor(condition, MAX_WAIT_MILLIS); + } - public static boolean waitFor(final Condition condition, final long duration, final long sleepMillis) throws Exception { + public static boolean waitFor(final Condition condition, final long duration) throws Exception { + return waitFor(condition, duration, SLEEP_MILLIS); + } - final long expiry = System.currentTimeMillis() + duration; - boolean conditionSatisified = condition.isSatisified(); - while (!conditionSatisified && System.currentTimeMillis() < expiry) { - TimeUnit.MILLISECONDS.sleep(sleepMillis); - conditionSatisified = condition.isSatisified(); - } - return conditionSatisified; - } + public static boolean waitFor(final Condition condition, + final long duration, + final long sleepMillis) throws Exception { + + final long expiry = System.currentTimeMillis() + duration; + boolean conditionSatisified = condition.isSatisified(); + while (!conditionSatisified && System.currentTimeMillis() < expiry) { + TimeUnit.MILLISECONDS.sleep(sleepMillis); + conditionSatisified = condition.isSatisified(); + } + return conditionSatisified; + } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java index 049816684e..c1bf9e0146 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.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, @@ -16,12 +16,18 @@ */ package org.apache.activemq.xbean; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import java.net.URI; import java.util.List; import java.util.concurrent.CountDownLatch; -import javax.jms.*; - import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; @@ -130,13 +136,11 @@ public class ConnectorXBeanConfigTest extends TestCase { Thread.sleep(5000); test.countDown(); shutdown.await(); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { } } }); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -151,8 +155,7 @@ public class ConnectorXBeanConfigTest extends TestCase { sendSecond.await(); MessageProducer producer = sess.createProducer(dest); producer.send(sess.createTextMessage("msg2")); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -166,8 +169,7 @@ public class ConnectorXBeanConfigTest extends TestCase { try { stop.await(); brokerService.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -179,16 +181,14 @@ public class ConnectorXBeanConfigTest extends TestCase { try { testSess.createConsumer(testDestination); fail("Should have failed creating a consumer!"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } try { testProducer.send(testSess.createTextMessage("msg3")); fail("Should have failed sending a message!"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceAdapterXBeanConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceAdapterXBeanConfigTest.java index b02f71a5a9..e1b8d0eb21 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceAdapterXBeanConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceAdapterXBeanConfigTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceXBeanConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceXBeanConfigTest.java index 9b22634c6d..db36fe4d74 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceXBeanConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/JDBCPersistenceXBeanConfigTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java index e3001a2cbd..7597ea3bfd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.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, @@ -16,17 +16,16 @@ */ package org.apache.activemq.xbean; -import java.net.URI; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; +import java.net.URI; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; import junit.framework.TestCase; @@ -70,8 +69,7 @@ public class ManagementContextXBeanConfigTest extends TestCase { try { JMXConnector connector = JMXConnectorFactory.connect(url, null); assertAuthentication(connector); - } - catch (SecurityException e) { + } catch (SecurityException e) { return; } fail("Should have thrown an exception"); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerAndPersistenceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerAndPersistenceTest.java index 6a6c31a18b..b9c96e8417 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerAndPersistenceTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerAndPersistenceTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java index 41eeb9e7f5..ac9b56b4ab 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringFactoryBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringFactoryBeanTest.java index 5c08e61144..15a97746f6 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringFactoryBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringFactoryBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringXBeanFactoryBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringXBeanFactoryBeanTest.java index 287b68308c..289e0dfca9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringXBeanFactoryBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithSpringXBeanFactoryBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithXBeanFactoryBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithXBeanFactoryBeanTest.java index 057cd1c4ac..a5cdd3e6fd 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithXBeanFactoryBeanTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithXBeanFactoryBeanTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanConfigTest.java index a43af8babb..05069cb283 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanConfigTest.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,7 +25,13 @@ import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.region.Topic; -import org.apache.activemq.broker.region.policy.*; +import org.apache.activemq.broker.region.policy.DispatchPolicy; +import org.apache.activemq.broker.region.policy.LastImageSubscriptionRecoveryPolicy; +import org.apache.activemq.broker.region.policy.RetainedMessageSubscriptionRecoveryPolicy; +import org.apache.activemq.broker.region.policy.RoundRobinDispatchPolicy; +import org.apache.activemq.broker.region.policy.StrictOrderDispatchPolicy; +import org.apache.activemq.broker.region.policy.SubscriptionRecoveryPolicy; +import org.apache.activemq.broker.region.policy.TimedSubscriptionRecoveryPolicy; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.ConnectionId; import org.apache.activemq.command.ConnectionInfo; @@ -95,8 +101,7 @@ public class XBeanConfigTest extends TestCase { try { broker.addConnection(context, info); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); fail(e.getMessage()); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanStartFalseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanStartFalseTest.java index f36f72cf9a..cbad360404 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanStartFalseTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanStartFalseTest.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, diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanXmlTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanXmlTest.java index f4ae587963..e8d2a763a0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanXmlTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/xbean/XBeanXmlTest.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, diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java index cde4defed5..34edc06a2d 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java @@ -135,8 +135,7 @@ public class AmqpSupport { if (data.isDirect()) { rc = new Buffer(data.remaining()); data.get(rc.data); - } - else { + } else { rc = new Buffer(data); data.position(data.position() + data.remaining()); } @@ -182,24 +181,20 @@ public class AmqpSupport { public static ActiveMQDestination createDestination(Object endpoint) throws AmqpProtocolException { if (endpoint == null) { return null; - } - else if (endpoint instanceof Coordinator) { + } else if (endpoint instanceof Coordinator) { return null; - } - else if (endpoint instanceof org.apache.qpid.proton.amqp.messaging.Terminus) { + } else if (endpoint instanceof org.apache.qpid.proton.amqp.messaging.Terminus) { org.apache.qpid.proton.amqp.messaging.Terminus terminus = (org.apache.qpid.proton.amqp.messaging.Terminus) endpoint; if (terminus.getAddress() == null || terminus.getAddress().length() == 0) { if (terminus instanceof org.apache.qpid.proton.amqp.messaging.Source) { throw new AmqpProtocolException("amqp:invalid-field", "source address not set"); - } - else { + } else { throw new AmqpProtocolException("amqp:invalid-field", "target address not set"); } } return ActiveMQDestination.createDestination(terminus.getAddress(), ActiveMQDestination.QUEUE_TYPE); - } - else { + } else { throw new RuntimeException("Unexpected terminus type: " + endpoint); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpAbstractResource.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpAbstractResource.java index 20bedcc1a2..50aa770212 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpAbstractResource.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpAbstractResource.java @@ -73,8 +73,7 @@ public abstract class AmqpAbstractResource implements AmqpRe } request.onSuccess(); - } - else { + } else { this.closeRequest = request; doDetach(); } @@ -91,8 +90,7 @@ public abstract class AmqpAbstractResource implements AmqpRe } request.onSuccess(); - } - else { + } else { this.closeRequest = request; doClose(); } @@ -215,8 +213,7 @@ public abstract class AmqpAbstractResource implements AmqpRe if (isAwaitingClose()) { LOG.debug("{} is now closed: ", this); closed(); - } - else { + } else { remotelyClosed(connection); } } @@ -227,21 +224,18 @@ public abstract class AmqpAbstractResource implements AmqpRe if (isAwaitingClose()) { LOG.debug("{} is now closed: ", this); closed(); - } - else if (isAwaitingOpen()) { + } else if (isAwaitingOpen()) { // Error on Open, create exception and signal failure. LOG.warn("Open of {} failed: ", this); Exception openError; if (hasRemoteError()) { openError = AmqpSupport.convertToException(getEndpoint().getRemoteCondition()); - } - else { + } else { openError = getOpenAbortException(); } failed(openError); - } - else { + } else { remotelyClosed(connection); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java index 3e2c5d74e5..53fb9f5489 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpConnection.java @@ -163,8 +163,7 @@ public class AmqpConnection extends AmqpAbstractResource implements if (connectTimeout <= 0) { future.sync(); - } - else { + } else { future.sync(connectTimeout, TimeUnit.MILLISECONDS); if (getEndpoint().getRemoteState() != EndpointState.ACTIVE) { throw new IOException("Failed to connect after configured timeout."); @@ -194,14 +193,12 @@ public class AmqpConnection extends AmqpAbstractResource implements if (getEndpoint() != null) { close(request); - } - else { + } else { request.onSuccess(); } pumpToProtonTransport(request); - } - catch (Exception e) { + } catch (Exception e) { LOG.debug("Caught exception while closing proton connection"); } } @@ -210,20 +207,16 @@ public class AmqpConnection extends AmqpAbstractResource implements try { if (closeTimeout <= 0) { request.sync(); - } - else { + } else { request.sync(closeTimeout, TimeUnit.MILLISECONDS); } - } - catch (IOException e) { + } catch (IOException e) { LOG.warn("Error caught while closing Provider: ", e.getMessage()); - } - finally { + } finally { if (transport != null) { try { transport.close(); - } - catch (Exception e) { + } catch (Exception e) { LOG.debug("Cuaght exception while closing down Transport: {}", e.getMessage()); } } @@ -233,8 +226,7 @@ public class AmqpConnection extends AmqpAbstractResource implements if (!serializer.awaitTermination(10, TimeUnit.SECONDS)) { LOG.warn("Serializer didn't shutdown cleanly"); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } @@ -284,11 +276,9 @@ public class AmqpConnection extends AmqpAbstractResource implements checkClosed(); try { transport.send(Unpooled.wrappedBuffer(rawData)); - } - catch (IOException e) { + } catch (IOException e) { fireClientException(e); - } - finally { + } finally { request.onSuccess(); } } @@ -481,13 +471,11 @@ public class AmqpConnection extends AmqpAbstractResource implements outbound.writeBytes(toWrite); transport.send(outbound); protonTransport.outputConsumed(); - } - else { + } else { done = true; } } - } - catch (IOException e) { + } catch (IOException e) { fireClientException(e); request.onFailure(e); } @@ -577,12 +565,10 @@ public class AmqpConnection extends AmqpAbstractResource implements getScheduler().schedule(this, rescheduleAt, TimeUnit.MILLISECONDS); } } - } - catch (Exception e) { + } catch (Exception e) { try { transport.close(); - } - catch (IOException e1) { + } catch (IOException e1) { } fireClientException(e); } @@ -598,8 +584,7 @@ public class AmqpConnection extends AmqpAbstractResource implements protected void doOpenInspection() { try { getStateInspector().inspectOpenedResource(getConnection()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -608,8 +593,7 @@ public class AmqpConnection extends AmqpAbstractResource implements protected void doClosedInspection() { try { getStateInspector().inspectClosedResource(getConnection()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -684,8 +668,7 @@ public class AmqpConnection extends AmqpAbstractResource implements if (!authenticated) { processSaslAuthentication(); } - } - catch (Exception ex) { + } catch (Exception ex) { LOG.warn("Caught Exception during update processing: {}", ex.getMessage(), ex); fireClientException(ex); } @@ -701,8 +684,7 @@ public class AmqpConnection extends AmqpAbstractResource implements authenticator = null; authenticated = true; } - } - catch (SecurityException ex) { + } catch (SecurityException ex) { failed(ex); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java index 060fc4ea1b..f39a9c5ba6 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java @@ -60,8 +60,7 @@ public class AmqpMessage { * Creates a new AmqpMessage that wraps the information necessary to handle * an outgoing message. * - * @param message - * the Proton message that is to be sent. + * @param message the Proton message that is to be sent. */ public AmqpMessage(Message message) { this(null, message, null); @@ -71,12 +70,9 @@ public class AmqpMessage { * Creates a new AmqpMessage that wraps the information necessary to handle * an incoming delivery. * - * @param receiver - * the AmqpReceiver that received this message. - * @param message - * the Proton message that was received. - * @param delivery - * the Delivery instance that produced this message. + * @param receiver the AmqpReceiver that received this message. + * @param message the Proton message that was received. + * @param delivery the Delivery instance that produced this message. */ @SuppressWarnings("unchecked") public AmqpMessage(AmqpReceiver receiver, Message message, Delivery delivery) { @@ -142,9 +138,7 @@ public class AmqpMessage { /** * Accepts the message marking it as consumed on the remote peer. * - * @param session - * The session that is used to manage acceptance of the message. - * + * @param session The session that is used to manage acceptance of the message. * @throws Exception if an error occurs during the accept. */ public void accept(AmqpSession txnSession) throws Exception { @@ -158,11 +152,8 @@ public class AmqpMessage { /** * Marks the message as Modified, indicating whether it failed to deliver and is not deliverable here. * - * @param deliveryFailed - * indicates that the delivery failed for some reason. - * @param undeliverableHere - * marks the delivery as not being able to be process by link it was sent to. - * + * @param deliveryFailed indicates that the delivery failed for some reason. + * @param undeliverableHere marks the delivery as not being able to be process by link it was sent to. * @throws Exception if an error occurs during the process. */ public void modified(Boolean deliveryFailed, Boolean undeliverableHere) throws Exception { @@ -191,8 +182,7 @@ public class AmqpMessage { /** * Sets the address which is applied to the AMQP message To field in the message properties * - * @param address - * The address that should be applied in the Message To field. + * @param address The address that should be applied in the Message To field. */ public void setAddress(String address) { checkReadOnly(); @@ -216,8 +206,7 @@ public class AmqpMessage { /** * Sets the MessageId property on an outbound message using the provided String * - * @param messageId - * the String message ID value to set. + * @param messageId the String message ID value to set. */ public void setMessageId(String messageId) { checkReadOnly(); @@ -256,8 +245,7 @@ public class AmqpMessage { /** * Sets the MessageId property on an outbound message using the provided value * - * @param messageId - * the message ID value to set. + * @param messageId the message ID value to set. */ public void setRawMessageId(Object messageId) { checkReadOnly(); @@ -268,8 +256,7 @@ public class AmqpMessage { /** * Sets the CorrelationId property on an outbound message using the provided String * - * @param correlationId - * the String Correlation ID value to set. + * @param correlationId the String Correlation ID value to set. */ public void setCorrelationId(String correlationId) { checkReadOnly(); @@ -308,8 +295,7 @@ public class AmqpMessage { /** * Sets the CorrelationId property on an outbound message using the provided value * - * @param correlationId - * the correlation ID value to set. + * @param correlationId the correlation ID value to set. */ public void setRawCorrelationId(Object correlationId) { checkReadOnly(); @@ -320,8 +306,7 @@ public class AmqpMessage { /** * Sets the GroupId property on an outbound message using the provided String * - * @param messageId - * the String Group ID value to set. + * @param messageId the String Group ID value to set. */ public void setGroupId(String groupId) { checkReadOnly(); @@ -346,8 +331,7 @@ public class AmqpMessage { /** * Sets the durable header on the outgoing message. * - * @param durable - * the boolean durable value to set. + * @param durable the boolean durable value to set. */ public void setDurable(boolean durable) { checkReadOnly(); @@ -372,10 +356,8 @@ public class AmqpMessage { /** * Sets a given application property on an outbound message. * - * @param key - * the name to assign the new property. - * @param value - * the value to set for the named property. + * @param key the name to assign the new property. + * @param value the value to set for the named property. */ public void setApplicationProperty(String key, Object value) { checkReadOnly(); @@ -387,9 +369,7 @@ public class AmqpMessage { * Gets the application property that is mapped to the given name or null * if no property has been set with that name. * - * @param key - * the name used to lookup the property in the application properties. - * + * @param key the name used to lookup the property in the application properties. * @return the property value or null if not set. */ public Object getApplicationProperty(String key) { @@ -404,10 +384,8 @@ public class AmqpMessage { * Perform a proper annotation set on the AMQP Message based on a Symbol key and * the target value to append to the current annotations. * - * @param key - * The name of the Symbol whose value is being set. - * @param value - * The new value to set in the annotations of this message. + * @param key The name of the Symbol whose value is being set. + * @param value The new value to set in the annotations of this message. */ public void setMessageAnnotation(String key, Object value) { checkReadOnly(); @@ -420,9 +398,7 @@ public class AmqpMessage { * that annotation name. If the message annotations have not been created yet * then this method will always return null. * - * @param key - * the Symbol name that should be looked up in the message annotations. - * + * @param key the Symbol name that should be looked up in the message annotations. * @return the value of the annotation if it exists, or null if not set or not accessible. */ public Object getMessageAnnotation(String key) { @@ -437,10 +413,8 @@ public class AmqpMessage { * Perform a proper delivery annotation set on the AMQP Message based on a Symbol * key and the target value to append to the current delivery annotations. * - * @param key - * The name of the Symbol whose value is being set. - * @param value - * The new value to set in the delivery annotations of this message. + * @param key The name of the Symbol whose value is being set. + * @param value The new value to set in the delivery annotations of this message. */ public void setDeliveryAnnotation(String key, Object value) { checkReadOnly(); @@ -453,9 +427,7 @@ public class AmqpMessage { * that annotation name. If the message annotations have not been created yet * then this method will always return null. * - * @param key - * the Symbol name that should be looked up in the message annotations. - * + * @param key the Symbol name that should be looked up in the message annotations. * @return the value of the annotation if it exists, or null if not set or not accessible. */ public Object getDeliveryAnnotation(String key) { @@ -472,9 +444,7 @@ public class AmqpMessage { * Sets a String value into the body of an outgoing Message, throws * an exception if this is an incoming message instance. * - * @param value - * the String value to store in the Message body. - * + * @param value the String value to store in the Message body. * @throws IllegalStateException if the message is read only. */ public void setText(String value) throws IllegalStateException { @@ -487,9 +457,7 @@ public class AmqpMessage { * Sets a byte array value into the body of an outgoing Message, throws * an exception if this is an incoming message instance. * - * @param value - * the byte array value to store in the Message body. - * + * @param value the byte array value to store in the Message body. * @throws IllegalStateException if the message is read only. */ public void setBytes(byte[] bytes) throws IllegalStateException { @@ -502,9 +470,7 @@ public class AmqpMessage { * Sets a byte array value into the body of an outgoing Message, throws * an exception if this is an incoming message instance. * - * @param value - * the byte array value to store in the Message body. - * + * @param value the byte array value to store in the Message body. * @throws IllegalStateException if the message is read only. */ public void setDescribedType(DescribedType described) throws IllegalStateException { @@ -517,7 +483,6 @@ public class AmqpMessage { * Attempts to retrieve the message body as an DescribedType instance. * * @return an DescribedType instance if one is stored in the message body. - * * @throws NoSuchElementException if the body does not contain a DescribedType. */ public DescribedType getDescribedType() throws NoSuchElementException { @@ -525,18 +490,15 @@ public class AmqpMessage { if (getWrappedMessage().getBody() == null) { return null; - } - else { + } else { if (getWrappedMessage().getBody() instanceof AmqpValue) { AmqpValue value = (AmqpValue) getWrappedMessage().getBody(); if (value.getValue() == null) { result = null; - } - else if (value.getValue() instanceof DescribedType) { + } else if (value.getValue() instanceof DescribedType) { result = (DescribedType) value.getValue(); - } - else { + } else { throw new NoSuchElementException("Message does not contain a DescribedType body"); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpReceiver.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpReceiver.java index 2802751ccc..88267133c8 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpReceiver.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpReceiver.java @@ -208,7 +208,6 @@ public class AmqpReceiver extends AmqpAbstractResource { * it is returned immediately otherwise this methods return null without waiting. * * @return a newly received message or null if there is no currently available message. - * * @throws Exception if an error occurs during the receive attempt. */ public AmqpMessage receiveNoWait() throws Exception { @@ -220,7 +219,6 @@ public class AmqpReceiver extends AmqpAbstractResource { * Request a remote peer send a Message to this client waiting until one arrives. * * @return the pulled AmqpMessage or null if none was pulled from the remote. - * * @throws IOException if an error occurs */ public AmqpMessage pull() throws IOException { @@ -273,8 +271,7 @@ public class AmqpReceiver extends AmqpAbstractResource { // Await the message arrival pullRequest = request; - } - else if (timeoutMills == 0) { + } else if (timeoutMills == 0) { // If we have no credit then we need to issue some so that we can // try to fulfill the request, then drain down what is there to // ensure we consume what is available and remove all credit. @@ -286,8 +283,7 @@ public class AmqpReceiver extends AmqpAbstractResource { // Drain immediately and wait for the message(s) to arrive, // or a flow indicating removal of the remaining credit. stop(request); - } - else if (timeoutMills > 0) { + } else if (timeoutMills > 0) { // If we have no credit then we need to issue some so that we can // try to fulfill the request, then drain down what is there to // ensure we consume what is available and remove all credit. @@ -303,8 +299,7 @@ public class AmqpReceiver extends AmqpAbstractResource { } session.pumpToProtonTransport(request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -333,8 +328,7 @@ public class AmqpReceiver extends AmqpAbstractResource { getEndpoint().flow(credit); session.pumpToProtonTransport(request); request.onSuccess(); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -361,8 +355,7 @@ public class AmqpReceiver extends AmqpAbstractResource { getEndpoint().drain(credit); session.pumpToProtonTransport(request); request.onSuccess(); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -387,8 +380,7 @@ public class AmqpReceiver extends AmqpAbstractResource { try { stop(request); session.pumpToProtonTransport(request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -414,11 +406,8 @@ public class AmqpReceiver extends AmqpAbstractResource { * caller. This allows for an accepted message to be involved in a transaction that is * being managed by some other session other than the one that created this receiver. * - * @param delivery - * the Delivery instance to accept. - * @param session - * the session under which the message is being accepted. - * + * @param delivery the Delivery instance to accept. + * @param session the session under which the message is being accepted. * @throws IOException if an error occurs while sending the accept. */ public void accept(final Delivery delivery, final AmqpSession session) throws IOException { @@ -454,16 +443,14 @@ public class AmqpReceiver extends AmqpAbstractResource { delivery.settle(); session.getTransactionContext().registerTxConsumer(AmqpReceiver.this); } - } - else { + } else { delivery.disposition(Accepted.getInstance()); delivery.settle(); } } session.pumpToProtonTransport(request); request.onSuccess(); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -505,8 +492,7 @@ public class AmqpReceiver extends AmqpAbstractResource { session.pumpToProtonTransport(request); } request.onSuccess(); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -541,8 +527,7 @@ public class AmqpReceiver extends AmqpAbstractResource { session.pumpToProtonTransport(request); } request.onSuccess(); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -627,8 +612,7 @@ public class AmqpReceiver extends AmqpAbstractResource { receiver.setTarget(target); if (isPresettle()) { receiver.setSenderSettleMode(SenderSettleMode.SETTLED); - } - else { + } else { receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED); } receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST); @@ -644,8 +628,7 @@ public class AmqpReceiver extends AmqpAbstractResource { org.apache.qpid.proton.amqp.transport.Source s = getEndpoint().getRemoteSource(); if (s != null) { super.doOpenCompletion(); - } - else { + } else { // No link terminus was created, the peer will now detach/close us. } } @@ -666,8 +649,7 @@ public class AmqpReceiver extends AmqpAbstractResource { org.apache.qpid.proton.amqp.transport.Source s = getEndpoint().getRemoteSource(); if (s != null) { return super.getOpenAbortException(); - } - else { + } else { // No link terminus was created, the peer has detach/closed us, create IDE. return new InvalidDestinationException("Link creation was refused"); } @@ -677,8 +659,7 @@ public class AmqpReceiver extends AmqpAbstractResource { protected void doOpenInspection() { try { getStateInspector().inspectOpenedResource(getReceiver()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -687,8 +668,7 @@ public class AmqpReceiver extends AmqpAbstractResource { protected void doClosedInspection() { try { getStateInspector().inspectClosedResource(getReceiver()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -697,8 +677,7 @@ public class AmqpReceiver extends AmqpAbstractResource { protected void doDetachedInspection() { try { getStateInspector().inspectDetachedResource(getReceiver()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -711,8 +690,7 @@ public class AmqpReceiver extends AmqpAbstractResource { source.setExpiryPolicy(TerminusExpiryPolicy.NEVER); source.setDurable(TerminusDurability.UNSETTLED_STATE); source.setDistributionMode(COPY); - } - else { + } else { source.setDurable(TerminusDurability.NONE); source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH); } @@ -748,18 +726,15 @@ public class AmqpReceiver extends AmqpAbstractResource { LOG.trace("{} has incoming Message(s).", this); try { processDelivery(incoming); - } - catch (Exception e) { + } catch (Exception e) { throw IOExceptionSupport.create(e); } getEndpoint().advance(); - } - else { + } else { LOG.trace("{} has a partial incoming Message(s), deferring.", this); incoming = null; } - } - else { + } else { // We have exhausted the locally queued messages on this link. // Check if we tried to stop and have now run out of credit. if (getEndpoint().getRemoteCredit() <= 0) { @@ -778,8 +753,7 @@ public class AmqpReceiver extends AmqpAbstractResource { Message message = null; try { message = decodeIncomingMessage(incoming); - } - catch (Exception e) { + } catch (Exception e) { LOG.warn("Error on transform: {}", e.getMessage()); deliveryFailed(incoming, true); return; @@ -836,12 +810,10 @@ public class AmqpReceiver extends AmqpAbstractResource { Message protonMessage = Message.Factory.create(); protonMessage.decode(messageBytes, 0, messageBytes.length); return protonMessage; - } - finally { + } finally { try { stream.close(); - } - catch (IOException e) { + } catch (IOException e) { } } } @@ -863,13 +835,11 @@ public class AmqpReceiver extends AmqpAbstractResource { if (receiver.getQueued() == 0) { // We have no remote credit and all the deliveries have been processed. request.onSuccess(); - } - else { + } else { // There are still deliveries to process, wait for them to be. stopRequest = request; } - } - else { + } else { // TODO: We don't actually want the additional messages that could be sent while // draining. We could explicitly reduce credit first, or possibly use 'echo' instead // of drain if it was supported. We would first need to understand what happens diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSender.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSender.java index ed83e02070..3b134c9079 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSender.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSender.java @@ -139,8 +139,7 @@ public class AmqpSender extends AmqpAbstractResource { try { doSend(message, sendRequest, txId); session.pumpToProtonTransport(sendRequest); - } - catch (Exception e) { + } catch (Exception e) { sendRequest.onFailure(e); session.getConnection().fireClientException(e); } @@ -149,8 +148,7 @@ public class AmqpSender extends AmqpAbstractResource { if (sendTimeout <= 0) { sendRequest.sync(); - } - else { + } else { sendRequest.sync(sendTimeout, TimeUnit.MILLISECONDS); } } @@ -262,8 +260,7 @@ public class AmqpSender extends AmqpAbstractResource { sender.setTarget(target); if (presettle) { sender.setSenderSettleMode(SenderSettleMode.SETTLED); - } - else { + } else { sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); } sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); @@ -279,8 +276,7 @@ public class AmqpSender extends AmqpAbstractResource { org.apache.qpid.proton.amqp.transport.Target t = getEndpoint().getRemoteTarget(); if (t != null) { super.doOpenCompletion(); - } - else { + } else { // No link terminus was created, the peer will now detach/close us. } } @@ -289,8 +285,7 @@ public class AmqpSender extends AmqpAbstractResource { protected void doOpenInspection() { try { getStateInspector().inspectOpenedResource(getSender()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -299,8 +294,7 @@ public class AmqpSender extends AmqpAbstractResource { protected void doClosedInspection() { try { getStateInspector().inspectClosedResource(getSender()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -309,8 +303,7 @@ public class AmqpSender extends AmqpAbstractResource { protected void doDetachedInspection() { try { getStateInspector().inspectDetachedResource(getSender()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -321,8 +314,7 @@ public class AmqpSender extends AmqpAbstractResource { org.apache.qpid.proton.amqp.transport.Target t = getEndpoint().getRemoteTarget(); if (t != null) { return super.getOpenAbortException(); - } - else { + } else { // No link terminus was created, the peer has detach/closed us, create IDE. return new InvalidDestinationException("Link creation was refused"); } @@ -334,8 +326,7 @@ public class AmqpSender extends AmqpAbstractResource { Delivery delivery = null; if (presettle) { delivery = getEndpoint().delivery(EMPTY_BYTE_ARRAY, 0, 0); - } - else { + } else { byte[] tag = tagGenerator.getNextTag(); delivery = getEndpoint().delivery(tag, 0, tag.length); } @@ -345,8 +336,7 @@ public class AmqpSender extends AmqpAbstractResource { Binary amqpTxId = null; if (txId != null) { amqpTxId = txId.getRemoteTxId(); - } - else if (session.isInTransaction()) { + } else if (session.isInTransaction()) { amqpTxId = session.getTransactionId().getRemoteTxId(); } @@ -361,8 +351,7 @@ public class AmqpSender extends AmqpAbstractResource { if (presettle) { delivery.settle(); request.onSuccess(); - } - else { + } else { pending.add(delivery); getEndpoint().advance(); } @@ -375,8 +364,7 @@ public class AmqpSender extends AmqpAbstractResource { try { encodedSize = message.encode(encodeBuffer, 0, encodeBuffer.length); break; - } - catch (java.nio.BufferOverflowException e) { + } catch (java.nio.BufferOverflowException e) { encodeBuffer = new byte[encodeBuffer.length * 2]; } } @@ -390,8 +378,7 @@ public class AmqpSender extends AmqpAbstractResource { if ((encodedSize - sentSoFar) == 0) { break; } - } - else { + } else { LOG.warn("{} failed to send any data from current Message.", this); } } @@ -411,11 +398,9 @@ public class AmqpSender extends AmqpAbstractResource { if (state instanceof TransactionalState) { LOG.trace("State of delivery is Transactional, retrieving outcome: {}", state); outcome = ((TransactionalState) state).getOutcome(); - } - else if (state instanceof Outcome) { + } else if (state instanceof Outcome) { outcome = (Outcome) state; - } - else { + } else { LOG.warn("Message send updated with unsupported state: {}", state); outcome = null; } @@ -428,8 +413,7 @@ public class AmqpSender extends AmqpAbstractResource { if (request != null && !request.isComplete()) { request.onSuccess(); } - } - else if (outcome instanceof Rejected) { + } else if (outcome instanceof Rejected) { LOG.trace("Outcome of delivery was rejected: {}", delivery); ErrorCondition remoteError = ((Rejected) outcome).getError(); if (remoteError == null) { @@ -437,12 +421,10 @@ public class AmqpSender extends AmqpAbstractResource { } deliveryError = AmqpSupport.convertToException(remoteError); - } - else if (outcome instanceof Released) { + } else if (outcome instanceof Released) { LOG.trace("Outcome of delivery was released: {}", delivery); deliveryError = new IOException("Delivery failed: released by receiver"); - } - else if (outcome instanceof Modified) { + } else if (outcome instanceof Modified) { LOG.trace("Outcome of delivery was modified: {}", delivery); deliveryError = new IOException("Delivery failed: failure at remote"); } @@ -450,8 +432,7 @@ public class AmqpSender extends AmqpAbstractResource { if (deliveryError != null) { if (request != null && !request.isComplete()) { request.onFailure(deliveryError); - } - else { + } else { connection.fireClientException(deliveryError); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSession.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSession.java index 755ecf804a..65a69b780a 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSession.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSession.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, @@ -426,8 +426,7 @@ public class AmqpSession extends AmqpAbstractResource { protected void doOpenInspection() { try { getStateInspector().inspectOpenedResource(getSession()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } @@ -436,8 +435,7 @@ public class AmqpSession extends AmqpAbstractResource { protected void doClosedInspection() { try { getStateInspector().inspectClosedResource(getSession()); - } - catch (Throwable error) { + } catch (Throwable error) { getStateInspector().markAsInvalid(error.getMessage()); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSupport.java index c9ee57b8cc..f8958e3ba6 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSupport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpSupport.java @@ -99,33 +99,25 @@ public class AmqpSupport { if (error.equals(AmqpError.UNAUTHORIZED_ACCESS)) { remoteError = new JMSSecurityException(message); - } - else if (error.equals(AmqpError.RESOURCE_LIMIT_EXCEEDED)) { + } else if (error.equals(AmqpError.RESOURCE_LIMIT_EXCEEDED)) { remoteError = new ResourceAllocationException(message); - } - else if (error.equals(AmqpError.NOT_FOUND)) { + } else if (error.equals(AmqpError.NOT_FOUND)) { remoteError = new InvalidDestinationException(message); - } - else if (error.equals(TransactionErrors.TRANSACTION_ROLLBACK)) { + } else if (error.equals(TransactionErrors.TRANSACTION_ROLLBACK)) { remoteError = new TransactionRolledBackException(message); - } - else if (error.equals(ConnectionError.REDIRECT)) { + } else if (error.equals(ConnectionError.REDIRECT)) { remoteError = createRedirectException(error, message, errorCondition); - } - else if (error.equals(AmqpError.INVALID_FIELD)) { + } else if (error.equals(AmqpError.INVALID_FIELD)) { Map info = errorCondition.getInfo(); if (info != null && CONTAINER_ID.equals(info.get(INVALID_FIELD))) { remoteError = new InvalidClientIDException(message); - } - else { + } else { remoteError = new JMSException(message); } - } - else { + } else { remoteError = new JMSException(message); } - } - else { + } else { remoteError = new JMSException("Unknown error from remote peer"); } @@ -170,8 +162,7 @@ public class AmqpSupport { if (info == null) { result = new IOException(message + " : Redirection information not set."); - } - else { + } else { String hostname = (String) info.get(OPEN_HOSTNAME); String networkHost = (String) info.get(NETWORK_HOST); @@ -182,8 +173,7 @@ public class AmqpSupport { int port = 0; try { port = Integer.valueOf(info.get(PORT).toString()); - } - catch (Exception ex) { + } catch (Exception ex) { result = new IOException(message + " : Redirection information not set."); } @@ -192,4 +182,4 @@ public class AmqpSupport { return result; } -} \ No newline at end of file +} diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionContext.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionContext.java index 939f0406e6..a9ef01cb9a 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionContext.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionContext.java @@ -84,8 +84,7 @@ public class AmqpTransactionContext { try { LOG.info("Attempting to declare TX:[{}]", txId); coordinator.declare(txId, request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -100,13 +99,11 @@ public class AmqpTransactionContext { return request.isComplete(); } }); - } - else { + } else { try { LOG.info("Attempting to declare TX:[{}]", txId); coordinator.declare(txId, request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -154,8 +151,7 @@ public class AmqpTransactionContext { LOG.info("Attempting to commit TX:[{}]", transactionId); coordinator.discharge(transactionId, request, true); session.pumpToProtonTransport(request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } @@ -200,8 +196,7 @@ public class AmqpTransactionContext { LOG.info("Attempting to roll back TX:[{}]", transactionId); coordinator.discharge(transactionId, request, false); session.pumpToProtonTransport(request); - } - catch (Exception e) { + } catch (Exception e) { request.onFailure(e); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java index aded162a8f..ae7f36d0c5 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java @@ -89,22 +89,19 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource { Declared declared = (Declared) state; txId.setRemoteTxId(declared.getTxnId()); pendingRequest.onSuccess(); - } - else if (state instanceof Rejected) { + } else if (state instanceof Rejected) { LOG.debug("Last TX request failed: {}", txId.getTxId()); Rejected rejected = (Rejected) state; Exception cause = AmqpSupport.convertToException(rejected.getError()); JMSException failureCause = null; if (txId.isCommit()) { failureCause = new TransactionRolledBackException(cause.getMessage()); - } - else { + } else { failureCause = new JMSException(cause.getMessage()); } pendingRequest.onFailure(failureCause); - } - else { + } else { LOG.debug("Last TX request succeeded: {}", txId.getTxId()); pendingRequest.onSuccess(); } @@ -116,8 +113,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource { } super.processDeliveryUpdates(connection); - } - catch (Exception e) { + } catch (Exception e) { throw IOExceptionSupport.create(e); } } @@ -153,8 +149,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource { if (commit) { failureCause = new TransactionRolledBackException("Transaction inbout: Coordinator remotely closed"); - } - else { + } else { failureCause = new JMSException("Rollback cannot complete: Coordinator remotely closed"); } @@ -220,8 +215,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource { try { encodedSize = message.encode(buffer, 0, buffer.length); break; - } - catch (BufferOverflowException e) { + } catch (BufferOverflowException e) { buffer = new byte[buffer.length * 2]; } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionId.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionId.java index 5dcdfe1c1e..6810ef08ec 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionId.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransactionId.java @@ -88,8 +88,7 @@ public class AmqpTransactionId { if (other.txId != null) { return false; } - } - else if (!txId.equals(other.txId)) { + } else if (!txId.equals(other.txId)) { return false; } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransferTagGenerator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransferTagGenerator.java index 85ee07f0e4..48b9fe51e0 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransferTagGenerator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpTransferTagGenerator.java @@ -41,8 +41,7 @@ public final class AmqpTransferTagGenerator { public AmqpTransferTagGenerator(boolean pool) { if (pool) { this.tagPool = new LinkedHashSet<>(); - } - else { + } else { this.tagPool = null; } } @@ -58,12 +57,10 @@ public final class AmqpTransferTagGenerator { final Iterator iterator = tagPool.iterator(); rc = iterator.next(); iterator.remove(); - } - else { + } else { try { rc = Long.toHexString(nextTagId++).getBytes("UTF-8"); - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { // This should never happen since we control the input. throw new RuntimeException(e); } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/AbstractMechanism.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/AbstractMechanism.java index 011fba745d..4c7d1ed1be 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/AbstractMechanism.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/AbstractMechanism.java @@ -37,8 +37,7 @@ public abstract class AbstractMechanism implements Mechanism { if (getPriority() < other.getPriority()) { return -1; - } - else if (getPriority() > other.getPriority()) { + } else if (getPriority() > other.getPriority()) { return 1; } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java index a7c885879a..8573306d86 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java @@ -71,18 +71,14 @@ public class CramMD5Mechanism extends AbstractMechanism { sentResponse = true; return hash.toString().getBytes(ASCII); - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw new SaslException("Unable to utilise required encoding", e); - } - catch (InvalidKeyException e) { + } catch (InvalidKeyException e) { throw new SaslException("Unable to utilise key", e); - } - catch (NoSuchAlgorithmException e) { + } catch (NoSuchAlgorithmException e) { throw new SaslException("Unable to utilise required algorithm", e); } - } - else { + } else { return EMPTY; } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/Mechanism.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/Mechanism.java index cc2687ff82..e7b2667214 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/Mechanism.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/Mechanism.java @@ -45,7 +45,7 @@ public interface Mechanism extends Comparable { public int getValue() { return value; } - }; + } /** * @return return the relative priority of this SASL mechanism. diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/SaslAuthenticator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/SaslAuthenticator.java index 5c25fae229..4ac3b7f992 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/SaslAuthenticator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/SaslAuthenticator.java @@ -100,14 +100,12 @@ public class SaslAuthenticator { if (response != null && response.length != 0) { sasl.send(response, 0, response.length); } - } - else { + } else { // TODO - Better error message. throw new SecurityException("Could not find a matching SASL mechanism for the remote peer."); } } - } - catch (SaslException se) { + } catch (SaslException se) { // TODO - Better error message. SecurityException jmsse = new SecurityException("Exception while processing SASL init."); jmsse.initCause(se); @@ -129,14 +127,11 @@ public class SaslAuthenticator { Mechanism mechanism = null; if (remoteMechanism.equalsIgnoreCase("PLAIN")) { mechanism = new PlainMechanism(); - } - else if (remoteMechanism.equalsIgnoreCase("ANONYMOUS")) { + } else if (remoteMechanism.equalsIgnoreCase("ANONYMOUS")) { mechanism = new AnonymousMechanism(); - } - else if (remoteMechanism.equalsIgnoreCase("CRAM-MD5")) { + } else if (remoteMechanism.equalsIgnoreCase("CRAM-MD5")) { mechanism = new CramMD5Mechanism(); - } - else { + } else { LOG.debug("Unknown remote mechanism {}, skipping", remoteMechanism); continue; } @@ -166,8 +161,7 @@ public class SaslAuthenticator { byte[] response = mechanism.getChallengeResponse(challenge); sasl.send(response, 0, response.length); } - } - catch (SaslException se) { + } catch (SaslException se) { // TODO - Better error message. SecurityException jmsse = new SecurityException("Exception while processing SASL step."); jmsse.initCause(se); diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTcpTransport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTcpTransport.java index f790433a25..d4b9f5401c 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTcpTransport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTcpTransport.java @@ -120,11 +120,9 @@ public class NettyTcpTransport implements NettyTransport { public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { handleConnected(future.channel()); - } - else if (future.isCancelled()) { + } else if (future.isCancelled()) { connectionFailed(future.channel(), new IOException("Connection attempt was cancelled")); - } - else { + } else { connectionFailed(future.channel(), IOExceptionSupport.create(future.cause())); } } @@ -132,8 +130,7 @@ public class NettyTcpTransport implements NettyTransport { try { connectLatch.await(); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { LOG.debug("Transport connection was interrupted."); Thread.interrupted(); failureCause = IOExceptionSupport.create(ex); @@ -151,8 +148,7 @@ public class NettyTcpTransport implements NettyTransport { } throw failureCause; - } - else { + } else { // Connected, allow any held async error to fire now and close the transport. channel.eventLoop().execute(new Runnable() { @@ -223,8 +219,7 @@ public class NettyTcpTransport implements NettyTransport { if (options == null) { if (isSSL()) { options = NettyTransportSslOptions.INSTANCE; - } - else { + } else { options = NettyTransportOptions.INSTANCE; } } @@ -260,8 +255,7 @@ public class NettyTcpTransport implements NettyTransport { if (port <= 0) { if (isSSL()) { port = getSslOptions().getDefaultSslPort(); - } - else { + } else { port = getTransportOptions().getDefaultTcpPort(); } } @@ -299,8 +293,7 @@ public class NettyTcpTransport implements NettyTransport { if (future.isSuccess()) { LOG.trace("SSL Handshake has completed: {}", channel); connectionEstablished(channel); - } - else { + } else { LOG.trace("SSL Handshake has failed: {}", channel); connectionFailed(channel, IOExceptionSupport.create(future.cause())); } @@ -378,12 +371,10 @@ public class NettyTcpTransport implements NettyTransport { LOG.trace("Firing onTransportError listener"); if (pendingFailure != null) { listener.onTransportError(pendingFailure); - } - else { + } else { listener.onTransportError(cause); } - } - else { + } else { // Hold the first failure for later dispatch if connect succeeds. // This will then trigger disconnect using the first error reported. if (pendingFailure != null) { diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportFactory.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportFactory.java index 566371303d..f6eae46385 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportFactory.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportFactory.java @@ -46,8 +46,7 @@ public final class NettyTransportFactory { if (!remoteURI.getScheme().equalsIgnoreCase("ssl") && !remoteURI.getScheme().equalsIgnoreCase("wss")) { transportOptions = NettyTransportOptions.INSTANCE.clone(); - } - else { + } else { transportOptions = NettyTransportSslOptions.INSTANCE.clone(); } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportSupport.java index 51cedea028..15854e8baa 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportSupport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportSupport.java @@ -81,8 +81,7 @@ public class NettyTransportSupport { context.init(keyMgrs, trustManagers, new SecureRandom()); return context; - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Failed to create SSLContext: {}", e, e); throw e; } @@ -117,8 +116,7 @@ public class NettyTransportSupport { SSLEngine engine = null; if (remote == null) { engine = context.createSSLEngine(); - } - else { + } else { engine = context.createSSLEngine(remote.getHost(), remote.getPort()); } @@ -142,8 +140,7 @@ public class NettyTransportSupport { List configuredProtocols = Arrays.asList(options.getEnabledProtocols()); LOG.trace("Configured protocols from transport options: {}", configuredProtocols); enabledProtocols.addAll(configuredProtocols); - } - else { + } else { List engineProtocols = Arrays.asList(engine.getEnabledProtocols()); LOG.trace("Default protocols from the SSLEngine: {}", engineProtocols); enabledProtocols.addAll(engineProtocols); @@ -168,8 +165,7 @@ public class NettyTransportSupport { List configuredCipherSuites = Arrays.asList(options.getEnabledCipherSuites()); LOG.trace("Configured cipher suites from transport options: {}", configuredCipherSuites); enabledCipherSuites.addAll(configuredCipherSuites); - } - else { + } else { List engineCipherSuites = Arrays.asList(engine.getEnabledCipherSuites()); LOG.trace("Default cipher suites from the SSLEngine: {}", engineCipherSuites); enabledCipherSuites.addAll(engineCipherSuites); @@ -229,8 +225,7 @@ public class NettyTransportSupport { if (alias == null) { return fact.getKeyManagers(); - } - else { + } else { validateAlias(keyStore, alias); return wrapKeyManagers(alias, fact.getKeyManagers()); } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyWSTransport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyWSTransport.java index b28f523f01..8a34a4b38a 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyWSTransport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/NettyWSTransport.java @@ -135,11 +135,9 @@ public class NettyWSTransport implements NettyTransport { public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { handleConnected(future.channel()); - } - else if (future.isCancelled()) { + } else if (future.isCancelled()) { connectionFailed(future.channel(), new IOException("Connection attempt was cancelled")); - } - else { + } else { connectionFailed(future.channel(), IOExceptionSupport.create(future.cause())); } } @@ -149,8 +147,7 @@ public class NettyWSTransport implements NettyTransport { // Now wait for WS protocol level handshake completion handshakeFuture.await(); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { LOG.debug("Transport connection attempt was interrupted."); Thread.interrupted(); failureCause = IOExceptionSupport.create(ex); @@ -168,8 +165,7 @@ public class NettyWSTransport implements NettyTransport { } throw failureCause; - } - else { + } else { // Connected, allow any held async error to fire now and close the transport. channel.eventLoop().execute(new Runnable() { @@ -240,8 +236,7 @@ public class NettyWSTransport implements NettyTransport { if (options == null) { if (isSSL()) { options = NettyTransportSslOptions.INSTANCE; - } - else { + } else { options = NettyTransportOptions.INSTANCE; } } @@ -277,8 +272,7 @@ public class NettyWSTransport implements NettyTransport { if (port <= 0) { if (isSSL()) { port = getSslOptions().getDefaultSslPort(); - } - else { + } else { port = getTransportOptions().getDefaultTcpPort(); } } @@ -316,8 +310,7 @@ public class NettyWSTransport implements NettyTransport { if (future.isSuccess()) { LOG.trace("SSL Handshake has completed: {}", channel); connectionEstablished(channel); - } - else { + } else { LOG.trace("SSL Handshake has failed: {}", channel); connectionFailed(channel, IOExceptionSupport.create(future.cause())); } @@ -411,12 +404,10 @@ public class NettyWSTransport implements NettyTransport { LOG.trace("Firing onTransportError listener"); if (pendingFailure != null) { listener.onTransportError(pendingFailure); - } - else { + } else { listener.onTransportError(cause); } - } - else { + } else { // Hold the first failure for later dispatch if connect succeeds. // This will then trigger disconnect using the first error reported. if (pendingFailure != null) { @@ -454,16 +445,13 @@ public class NettyWSTransport implements NettyTransport { TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; LOG.warn("WebSocket Client received message: " + textFrame.text()); ctx.fireExceptionCaught(new IOException("Received invalid frame over WebSocket.")); - } - else if (frame instanceof BinaryWebSocketFrame) { + } else if (frame instanceof BinaryWebSocketFrame) { BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame; LOG.info("WebSocket Client received data: {} bytes", binaryFrame.content().readableBytes()); listener.onData(binaryFrame.content()); - } - else if (frame instanceof PongWebSocketFrame) { + } else if (frame instanceof PongWebSocketFrame) { LOG.trace("WebSocket Client received pong"); - } - else if (frame instanceof CloseWebSocketFrame) { + } else if (frame instanceof CloseWebSocketFrame) { LOG.trace("WebSocket Client received closing"); ch.close(); } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/PartialPooledByteBufAllocator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/PartialPooledByteBufAllocator.java index c3c428660b..988e5019cc 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/PartialPooledByteBufAllocator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/transport/PartialPooledByteBufAllocator.java @@ -25,7 +25,6 @@ import io.netty.buffer.UnpooledByteBufAllocator; /** * A {@link ByteBufAllocator} which is partial pooled. Which means only direct * {@link ByteBuf}s are pooled. The rest is unpooled. - * */ public class PartialPooledByteBufAllocator implements ByteBufAllocator { diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/ClientFuture.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/ClientFuture.java index 12d38fd235..07c064a4e5 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/ClientFuture.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/ClientFuture.java @@ -75,8 +75,7 @@ public class ClientFuture implements AsyncResult { public void sync(long amount, TimeUnit unit) throws IOException { try { latch.await(amount, unit); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.interrupted(); throw IOExceptionSupport.create(e); } @@ -92,8 +91,7 @@ public class ClientFuture implements AsyncResult { public void sync() throws IOException { try { latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.interrupted(); throw IOExceptionSupport.create(e); } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java index c662b59e76..b5c7478d87 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java @@ -47,8 +47,7 @@ public class IdGenerator { if (sm != null) { sm.checkPropertiesAccess(); } - } - catch (SecurityException se) { + } catch (SecurityException se) { canAccessSystemProps = false; } @@ -62,12 +61,10 @@ public class IdGenerator { ss = new ServerSocket(idGeneratorPort); stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-"; Thread.sleep(100); - } - catch (Exception e) { + } catch (Exception e) { if (LOG.isTraceEnabled()) { LOG.trace("could not generate unique stub by using DNS and binding to local port", e); - } - else { + } else { LOG.warn("could not generate unique stub by using DNS and binding to local port: {} {}", e.getClass().getCanonicalName(), e.getMessage()); } @@ -75,17 +72,14 @@ public class IdGenerator { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } - } - finally { + } finally { if (ss != null) { try { ss.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { if (LOG.isTraceEnabled()) { LOG.trace("Closing the server socket failed", ioe); - } - else { + } else { LOG.warn("Closing the server socket failed" + " due " + ioe.getMessage()); } } @@ -150,8 +144,7 @@ public class IdGenerator { // only include ASCII chars if (ch < 127) { sb.append(ch); - } - else { + } else { changed = true; } } @@ -160,8 +153,7 @@ public class IdGenerator { String newHost = sb.toString(); LOG.info("Sanitized hostname from: {} to: {}", hostName, newHost); return newHost; - } - else { + } else { return hostName; } } @@ -259,8 +251,7 @@ public class IdGenerator { protected static String getLocalHostName() throws UnknownHostException { try { return (InetAddress.getLocalHost()).getHostName(); - } - catch (UnknownHostException uhe) { + } catch (UnknownHostException uhe) { String host = uhe.getMessage(); // host = "hostname: hostname" if (host != null) { int colon = host.indexOf(':'); diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java index 20979a8192..1e18904d44 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java @@ -109,8 +109,7 @@ public class PropertyUtil { for (Entry entry : options.entrySet()) { if (first) { first = false; - } - else { + } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), "UTF-8")); @@ -118,12 +117,10 @@ public class PropertyUtil { rc.append(URLEncoder.encode((String) entry.getValue(), "UTF-8")); } return rc.toString(); - } - else { + } else { return ""; } - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } } @@ -178,8 +175,7 @@ public class PropertyUtil { 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); } } @@ -258,8 +254,7 @@ public class PropertyUtil { Map map = parseParameters(uri); if (!map.isEmpty()) { map.putAll(properties); - } - else { + } else { map = properties; } if (!map.isEmpty()) { @@ -358,11 +353,9 @@ public class PropertyUtil { if (value != null) { if (value instanceof Boolean || value instanceof Number || value instanceof String || value instanceof URI || value instanceof URL) { properties.put(pd.getName(), ("" + value)); - } - else if (value instanceof SSLContext) { + } else if (value instanceof SSLContext) { // ignore this one.. - } - else { + } else { Map inner = getProperties(value); for (Entry entry : inner.entrySet()) { properties.put(pd.getName() + "." + entry.getKey(), entry.getValue()); @@ -428,13 +421,11 @@ public class PropertyUtil { // value directly if (value == null || value.getClass() == setter.getParameterTypes()[0]) { setter.invoke(target, new Object[]{value}); - } - else { + } else { setter.invoke(target, new Object[]{convert(value, setter.getParameterTypes()[0])}); } return true; - } - catch (Throwable ignore) { + } catch (Throwable ignore) { return false; } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/TypeConversionSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/TypeConversionSupport.java index 7d075510e8..50e5c2c4da 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/TypeConversionSupport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/TypeConversionSupport.java @@ -189,23 +189,17 @@ public final class TypeConversionSupport { if (type.isPrimitive()) { if (type == int.class) { rc = Integer.class; - } - else if (type == long.class) { + } else if (type == long.class) { rc = Long.class; - } - else if (type == double.class) { + } else if (type == double.class) { rc = Double.class; - } - else if (type == float.class) { + } else if (type == float.class) { rc = Float.class; - } - else if (type == short.class) { + } else if (type == short.class) { rc = Short.class; - } - else if (type == byte.class) { + } else if (type == byte.class) { rc = Byte.class; - } - else if (type == boolean.class) { + } else if (type == boolean.class) { rc = Boolean.class; } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java index 9f48b41f98..dea8602cbc 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java @@ -44,11 +44,9 @@ public class UnmodifiableDelivery implements Delivery { public Link getLink() { if (delivery.getLink() instanceof Sender) { return new UnmodifiableSender((Sender) delivery.getLink()); - } - else if (delivery.getLink() instanceof Receiver) { + } else if (delivery.getLink() instanceof Receiver) { return new UnmodifiableReceiver((Receiver) delivery.getLink()); - } - else { + } else { throw new IllegalStateException("Delivery has unknown link type"); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableLink.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableLink.java index 18f091d8a5..ac0e83eaf0 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableLink.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableLink.java @@ -166,8 +166,7 @@ public class UnmodifiableLink implements Link { if (next != null) { if (next instanceof Sender) { next = new UnmodifiableSender((Sender) next); - } - else { + } else { next = new UnmodifiableReceiver((Receiver) next); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/JournalImplLatencyBench.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/JournalImplLatencyBench.java index 7f13639470..3304f1529f 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/JournalImplLatencyBench.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/JournalImplLatencyBench.java @@ -51,6 +51,7 @@ public class JournalImplLatencyBench implements JLBHTask { private EncodingSupport encodingSupport; private JLBH jlbh; private long id; + public JournalImplLatencyBench(SequentialFileFactory sequentialFileFactory) { this.sequentialFileFactory = sequentialFileFactory; } @@ -93,8 +94,7 @@ public class JournalImplLatencyBench implements JLBHTask { try { journal.start(); journal.load(new ArrayList(), null, null); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } @@ -105,8 +105,7 @@ public class JournalImplLatencyBench implements JLBHTask { id++; try { journal.appendAddRecord(id, (byte) 0, encodingSupport, false); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } jlbh.sample(System.nanoTime() - startTimeNS); @@ -119,8 +118,7 @@ public class JournalImplLatencyBench implements JLBHTask { for (File journalFile : sequentialFileFactory.getDirectory().listFiles()) { journalFile.deleteOnExit(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -152,4 +150,4 @@ public class JournalImplLatencyBench implements JLBHTask { throw new UnsupportedOperationException(); } } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournal.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournal.java index 91bc6e5904..d2af86772a 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournal.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournal.java @@ -71,11 +71,10 @@ final class GcFreeJournal extends JournalImpl { try { this.journalRecordBytes.limit(alignedLength); sequentialFile.writeDirect(this.journalRecordBytes, sync); - } - finally { + } finally { this.journalRecordBytes.clear(); } //TODO AVOID INDEXING WITH CONCURRENT MAP! } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournalLatencyBench.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournalLatencyBench.java index a859006698..9b72f150c5 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournalLatencyBench.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/GcFreeJournalLatencyBench.java @@ -95,8 +95,7 @@ public class GcFreeJournalLatencyBench implements JLBHTask { try { journal.start(); journal.load(new ArrayList(), null, null); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } @@ -107,8 +106,7 @@ public class GcFreeJournalLatencyBench implements JLBHTask { id++; try { journal.appendAddRecord(id, (byte) 0, encodedRecord, 0, ENCODED_SIZE, false); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } jlbh.sample(System.nanoTime() - startTimeNS); @@ -121,8 +119,7 @@ public class GcFreeJournalLatencyBench implements JLBHTask { for (File journalFile : sequentialFileFactory.getDirectory().listFiles()) { journalFile.deleteOnExit(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -131,4 +128,4 @@ public class GcFreeJournalLatencyBench implements JLBHTask { MAPPED, NIO } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/sequentialfile/SequentialFileLatencyBench.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/sequentialfile/SequentialFileLatencyBench.java index 0a758dbb9e..343d95d10a 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/sequentialfile/SequentialFileLatencyBench.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/sequentialfile/SequentialFileLatencyBench.java @@ -50,6 +50,7 @@ public final class SequentialFileLatencyBench implements JLBHTask { private SequentialFile sequentialFile; private ByteBuffer message; private JLBH jlbh; + public SequentialFileLatencyBench(SequentialFileFactory sequentialFileFactory) { this.sequentialFileFactory = sequentialFileFactory; } @@ -58,8 +59,7 @@ public final class SequentialFileLatencyBench implements JLBHTask { final File journalDir; if (SHM) { journalDir = Files.createDirectory(Paths.get("/dev/shm/seq_files")).toFile(); - } - else { + } else { journalDir = Files.createTempDirectory("seq_files").toFile(); } journalDir.deleteOnExit(); @@ -93,8 +93,7 @@ public final class SequentialFileLatencyBench implements JLBHTask { final File file = this.sequentialFile.getJavaFile(); file.deleteOnExit(); System.out.println("sequentialFile: " + file); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } this.message = this.sequentialFileFactory.allocateDirectBuffer(JOURNAL_RECORD_SIZE).order(ByteOrder.nativeOrder()); @@ -106,8 +105,7 @@ public final class SequentialFileLatencyBench implements JLBHTask { message.position(0); try { sequentialFile.writeDirect(message, false, DummyCallback.getInstance()); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } jlbh.sample(System.nanoTime() - startTimeNS); @@ -118,8 +116,7 @@ public final class SequentialFileLatencyBench implements JLBHTask { sequentialFileFactory.releaseDirectBuffer(message); try { sequentialFile.close(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -128,4 +125,4 @@ public final class SequentialFileLatencyBench implements JLBHTask { MAPPED, NIO } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQMessageHandlerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQMessageHandlerTest.java index a60c251969..af6ed080b7 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQMessageHandlerTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQMessageHandlerTest.java @@ -227,8 +227,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { this.twoPhase = twoPhase; try { session = locator.createSessionFactory().createSession(true, false, false); - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e); } } @@ -243,8 +242,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { if (twoPhase) { currentTX.enlistResource(new DummyXAResource()); } - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } } @@ -270,8 +268,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { afterDeliveryCounts++; try { currentTX.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { //its unsure as to whether the EJB/JCA layer will handle this or throw it to us, // either way we don't do anything else so its fine just to throw. // NB this will only happen with 2 phase commit @@ -305,8 +302,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { try { TransactionReaper.terminate(true); TxControl.disable(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } tm = null; diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java index 333da9cf22..97f5e21492 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + import org.apache.activemq.artemis.api.core.ActiveMQTransactionOutcomeUnknownException; import org.apache.activemq.artemis.api.core.ActiveMQTransactionRolledBackException; import org.apache.activemq.artemis.api.core.ActiveMQUnBlockedException; @@ -46,10 +50,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - @RunWith(BMUnitRunner.class) public class BMFailoverTest extends FailoverTestBase { @@ -72,14 +72,12 @@ public class BMFailoverTest extends FailoverTestBase { if (!stopped) { try { serverToStop.getServer().stop(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } stopped = true; @@ -130,18 +128,15 @@ public class BMFailoverTest extends FailoverTestBase { try { //top level prepare session.end(xid, XAResource.TMSUCCESS); - } - catch (XAException e) { + } catch (XAException e) { try { //top level abort session.end(xid, XAResource.TMFAIL); - } - catch (XAException e1) { + } catch (XAException e1) { try { //rollback session.rollback(xid); - } - catch (XAException e2) { + } catch (XAException e2) { } } } @@ -209,8 +204,7 @@ public class BMFailoverTest extends FailoverTestBase { try { //this may fail but thats ok, it depends on the race and when failover actually happens xaSessionRec.end(xidRec, XAResource.TMSUCCESS); - } - catch (XAException ignore) { + } catch (XAException ignore) { } //we always reset the client on the RA @@ -269,8 +263,7 @@ public class BMFailoverTest extends FailoverTestBase { try { session.commit(); fail("should have thrown an exception"); - } - catch (ActiveMQTransactionOutcomeUnknownException e) { + } catch (ActiveMQTransactionOutcomeUnknownException e) { //pass } sendMessages(session, producer, 10); @@ -309,11 +302,9 @@ public class BMFailoverTest extends FailoverTestBase { try { session.commit(); fail("should have thrown an exception"); - } - catch (ActiveMQTransactionOutcomeUnknownException e) { + } catch (ActiveMQTransactionOutcomeUnknownException e) { //pass - } - catch (ActiveMQTransactionRolledBackException e1) { + } catch (ActiveMQTransactionRolledBackException e1) { //pass } Queue bindable = (Queue) backupServer.getServer().getPostOffice().getBinding(FailoverTestBase.ADDRESS).getBindable(); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java index 792263f537..5e6a497200 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java @@ -69,8 +69,7 @@ public class BridgeServerLocatorConfigurationTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params); @@ -114,8 +113,7 @@ public class BridgeServerLocatorConfigurationTest extends ActiveMQTestBase { long bridgeTTL = getBridgeTTL(serverWithBridge, BRIDGE_NAME); assertEquals(BRIDGE_TTL, bridgeTTL); - } - finally { + } finally { serverWithBridge.stop(); server1.stop(); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java index afef1d28bf..d4bfc00946 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java @@ -80,8 +80,7 @@ public class ClosingConnectionTest extends ActiveMQTestBase { ActiveMQServerControl serverControl = ManagementControlHelper.createActiveMQServerControl(mBeanServer); serverControl.closeConnectionsForUser("guest"); readyToKill = false; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -96,8 +95,7 @@ public class ClosingConnectionTest extends ActiveMQTestBase { * back to the caller. It's a bit of a hack, but I couldn't find any other way to simulate it. */ Thread.sleep(1500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } @@ -107,14 +105,12 @@ public class ClosingConnectionTest extends ActiveMQTestBase { * Test for https://bugzilla.redhat.com/show_bug.cgi?id=1193085 * */ @Test - @BMRules(rules = { - @BMRule( - name = "rule to kill connection", - targetClass = "org.apache.activemq.artemis.core.io.nio.NIOSequentialFile", - targetMethod = "open(int, boolean)", - targetLocation = "AT INVOKE java.nio.channels.FileChannel.size()", - action = "org.apache.activemq.artemis.tests.extras.byteman.ClosingConnectionTest.killConnection();") - }) + @BMRules(rules = {@BMRule( + name = "rule to kill connection", + targetClass = "org.apache.activemq.artemis.core.io.nio.NIOSequentialFile", + targetMethod = "open(int, boolean)", + targetLocation = "AT INVOKE java.nio.channels.FileChannel.size()", + action = "org.apache.activemq.artemis.tests.extras.byteman.ClosingConnectionTest.killConnection();")}) public void testKillConnection() throws Exception { locator.setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true); @@ -140,8 +136,7 @@ public class ClosingConnectionTest extends ActiveMQTestBase { producer.send(message); } fail("Sending message here should result in failure."); - } - catch (Exception e) { + } catch (Exception e) { IntegrationTestLogger.LOGGER.info("Caught exception: " + e.getMessage()); } @@ -162,4 +157,4 @@ public class ClosingConnectionTest extends ActiveMQTestBase { return server; } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredBridgeReconnectTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredBridgeReconnectTest.java index e7ab0ce5a2..0db2426975 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredBridgeReconnectTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredBridgeReconnectTest.java @@ -179,8 +179,7 @@ public class ClusteredBridgeReconnectTest extends ClusterTestBase { try { latch2.countDown(); latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -194,8 +193,7 @@ public class ClusteredBridgeReconnectTest extends ClusterTestBase { try { latch2.countDown(); latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredGroupingTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredGroupingTest.java index 9f4cf7eb41..773f291378 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredGroupingTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClusteredGroupingTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; @@ -33,9 +36,6 @@ import org.jboss.byteman.contrib.bmunit.BMUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - @RunWith(BMUnitRunner.class) public class ClusteredGroupingTest extends ClusterTestBase { @@ -91,12 +91,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { try { sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1")); - } - catch (ActiveMQNonExistentQueueException e) { + } catch (ActiveMQNonExistentQueueException e) { fail("did not handle removal of queue"); } - } - finally { + } finally { latch.countDown(); } } @@ -161,12 +159,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { try { sendWithProperty(1, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1")); - } - catch (ActiveMQNonExistentQueueException e) { + } catch (ActiveMQNonExistentQueueException e) { fail("did not handle removal of queue"); } - } - finally { + } finally { latch.countDown(); } @@ -233,12 +229,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { try { sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1")); - } - catch (ActiveMQNonExistentQueueException e) { + } catch (ActiveMQNonExistentQueueException e) { fail("did not handle removal of queue"); } - } - finally { + } finally { latch.countDown(); } @@ -313,12 +307,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { try { sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1")); - } - catch (ActiveMQNonExistentQueueException e) { + } catch (ActiveMQNonExistentQueueException e) { fail("did not handle removal of queue"); } - } - finally { + } finally { latch.countDown(); } //now restart server @@ -349,8 +341,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { latch2.countDown(); latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -364,8 +355,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { latch2.countDown(); latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ConcurrentDeliveryCancelTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ConcurrentDeliveryCancelTest.java index 15cfc19632..039315ced2 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ConcurrentDeliveryCancelTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ConcurrentDeliveryCancelTest.java @@ -64,8 +64,7 @@ public class ConcurrentDeliveryCancelTest extends JMSTestBase { latchEnter.countDown(); try { latchFlag.await(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -165,8 +164,7 @@ public class ConcurrentDeliveryCancelTest extends JMSTestBase { System.out.println(Thread.currentThread().getName() + " closing consumer"); consumer.close(); System.out.println(Thread.currentThread().getName() + " closed consumer"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -182,8 +180,7 @@ public class ConcurrentDeliveryCancelTest extends JMSTestBase { // a call to RemotingConnection.fail wasn't replicating the issue. // I needed to call Session.close() directly to replicate what was happening in production sess.close(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } System.out.println("Thread " + Thread.currentThread().getName() + " done"); @@ -239,16 +236,14 @@ public class ConcurrentDeliveryCancelTest extends JMSTestBase { if (count == null) { System.out.println("Message " + i + " not received"); failed = true; - } - else if (count.get() > 1) { + } else if (count.get() > 1) { System.out.println("Message " + i + " received " + count.get() + " times"); failed = true; } } Assert.assertFalse("test failed, look at the system.out of the test for more information", failed); - } - finally { + } finally { connection.close(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/FailureXATest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/FailureXATest.java index 63ca340af7..762cee9851 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/FailureXATest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/FailureXATest.java @@ -17,6 +17,16 @@ package org.apache.activemq.artemis.tests.extras.byteman; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.XAConnection; +import javax.jms.XASession; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; @@ -29,16 +39,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.XAConnection; -import javax.jms.XASession; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - @RunWith(BMUnitRunner.class) public class FailureXATest extends ActiveMQTestBase { @@ -63,25 +63,25 @@ public class FailureXATest extends ActiveMQTestBase { @Test @BMRules( - rules = {@BMRule( - name = "Crash after onephase committed", - targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl", - targetMethod = "xaCommit(javax.transaction.xa.Xid, boolean)", - targetLocation = "EXIT", - action = "throw new RuntimeException()")}) + rules = {@BMRule( + name = "Crash after onephase committed", + targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl", + targetMethod = "xaCommit(javax.transaction.xa.Xid, boolean)", + targetLocation = "EXIT", + action = "throw new RuntimeException()")}) public void testCrashServerAfterOnePhaseCommit() throws Exception { doTestCrashServerAfterXACommit(true); } @Test @BMRules( - rules = {@BMRule( - name = "Crash after onephase committed", - targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl", - targetMethod = "xaCommit(javax.transaction.xa.Xid, boolean)", - targetLocation = "EXIT", - //helper = "org.apache.activemq.artemis.tests.extras.byteman.FailureXATest", - action = "throw new RuntimeException()")}) + rules = {@BMRule( + name = "Crash after onephase committed", + targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl", + targetMethod = "xaCommit(javax.transaction.xa.Xid, boolean)", + targetLocation = "EXIT", + //helper = "org.apache.activemq.artemis.tests.extras.byteman.FailureXATest", + action = "throw new RuntimeException()")}) public void testCrashServerAfterTwoPhaseCommit() throws Exception { doTestCrashServerAfterXACommit(false); } @@ -112,19 +112,16 @@ public class FailureXATest extends ActiveMQTestBase { try { xaResource.commit(xid, onePhase); Assert.fail("didn't get expected exception!"); - } - catch (XAException xae) { + } catch (XAException xae) { if (onePhase) { //expected error code is XAER_RMFAIL Assert.assertEquals(XAException.XAER_RMFAIL, xae.errorCode); - } - else { + } else { //expected error code is XA_RETRY Assert.assertEquals(XAException.XA_RETRY, xae.errorCode); } } - } - finally { + } finally { connection.close(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/GroupingTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/GroupingTest.java index 6cc2e855ee..137eb824ed 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/GroupingTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/GroupingTest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; + import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; @@ -27,15 +36,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; - /** * GroupingTest */ @@ -105,8 +105,7 @@ public class GroupingTest extends JMSTestBase { producer.send(message); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } } @@ -137,8 +136,7 @@ public class GroupingTest extends JMSTestBase { assertEquals(tm.getStringProperty("JMSXGroupID"), "foo"); } - } - finally { + } finally { if (sendConnection != null) { sendConnection.close(); } @@ -153,8 +151,7 @@ public class GroupingTest extends JMSTestBase { try { System.out.println("pausing after rollback"); Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } System.out.println("finished pausing after rollback"); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java index d981aa9ba8..749bc49dbc 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java @@ -34,9 +34,9 @@ import org.junit.runner.RunWith; @RunWith(BMUnitRunner.class) @BMRules(rules = {@BMRule(name = "modify map during iteration", - targetClass = "org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository", - targetMethod = "getPossibleMatches(String)", targetLocation = "AT INVOKE java.util.HashMap.put", - action = "org.apache.activemq.artemis.tests.extras.byteman.HierarchicalObjectRepositoryTest.bum()"),}) + targetClass = "org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository", + targetMethod = "getPossibleMatches(String)", targetLocation = "AT INVOKE java.util.HashMap.put", + action = "org.apache.activemq.artemis.tests.extras.byteman.HierarchicalObjectRepositoryTest.bum()"),}) public class HierarchicalObjectRepositoryTest { private static final String A = "a."; @@ -81,8 +81,7 @@ public class HierarchicalObjectRepositoryTest { public void run() { try { latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -131,8 +130,7 @@ public class HierarchicalObjectRepositoryTest { latch.countDown(); try { latch2.await(3, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // no op } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/InterruptedMessageHandlerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/InterruptedMessageHandlerTest.java index 4f44f0d0da..6ebbb50ada 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/InterruptedMessageHandlerTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/InterruptedMessageHandlerTest.java @@ -168,8 +168,7 @@ public class InterruptedMessageHandlerTest extends ActiveMQRATestBase { this.twoPhase = twoPhase; try { session = locator.createSessionFactory().createSession(true, false, false); - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e); } } @@ -184,8 +183,7 @@ public class InterruptedMessageHandlerTest extends ActiveMQRATestBase { if (twoPhase) { currentTX.enlistResource(new DummyXAResource()); } - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } } @@ -200,8 +198,7 @@ public class InterruptedMessageHandlerTest extends ActiveMQRATestBase { afterDeliveryCounts++; try { currentTX.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { // its unsure as to whether the EJB/JCA layer will handle this or throw it to us, // either way we don't do anything else so its fine just to throw. // NB this will only happen with 2 phase commit @@ -235,8 +232,7 @@ public class InterruptedMessageHandlerTest extends ActiveMQRATestBase { try { TransactionReaper.terminate(true); TxControl.disable(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } tm = null; @@ -320,8 +316,7 @@ public class InterruptedMessageHandlerTest extends ActiveMQRATestBase { if (twoPhase) { currentTX.enlistResource(new DummyXAResourceFailEnd()); } - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java index 7848f04a7b..0a5d52dcfe 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.core.client.impl.ClientProducerCredits; import org.apache.activemq.artemis.core.message.impl.MessageInternal; import org.apache.activemq.artemis.core.protocol.core.Packet; @@ -32,9 +35,6 @@ import org.jboss.byteman.contrib.bmunit.BMUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - @RunWith(BMUnitRunner.class) public class JMSBridgeReconnectionTest extends BridgeTestBase { @@ -68,8 +68,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase { try { sendMessages(cf0, sourceQueue, 0, 1, false, false); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -93,15 +92,13 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase { if (sendMessage.getMessage().containsProperty("__AMQ_CID") && count < 0 && !stopped) { try { activeMQServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } stopped = true; try { Thread.sleep(5000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } stopLatch.countDown(); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java index 75ba5dc4c6..fff9cb0a9b 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java @@ -54,14 +54,12 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { private static ActiveMQServer backupServer; private static ActiveMQServer liveServer; - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616?minLargeMessageSize=10000&HA=true&retryInterval=100&reconnectAttempts=-1&producerWindowSize=10000"); ActiveMQConnection connection; Session session; Queue queue; MessageProducer producer; - @Override @Before public void setUp() throws Exception { @@ -91,7 +89,6 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { waitForServerToStart(backupServer); - // Just to make sure the expression worked Assert.assertEquals(10000, factory.getMinLargeMessageSize()); Assert.assertEquals(10000, factory.getProducerWindowSize()); @@ -114,8 +111,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { if (connection != null) { try { connection.close(); - } - catch (Exception e) { + } catch (Exception e) { } } if (backupServer != null) { @@ -131,10 +127,10 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { backupServer = liveServer = null; } - /* - * simple test to induce a potential race condition where the server's acceptors are active, but the server's - * state != STARTED - */ + /* + * simple test to induce a potential race condition where the server's acceptors are active, but the server's + * state != STARTED + */ @Test @BMRules( rules = {@BMRule( @@ -151,8 +147,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { producer.send(message); Assert.fail("expected an exception"); // session.commit(); - } - catch (JMSException expected) { + } catch (JMSException expected) { } session.rollback(); @@ -194,8 +189,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { try { consumer.receive(5000); Assert.fail("Expected a failure here"); - } - catch (JMSException expected) { + } catch (JMSException expected) { } session.rollback(); @@ -220,8 +214,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { try { latch.countDown(); liveServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -230,8 +223,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { // just to make sure it's about to be stopped // avoiding bootstrapping the thread as a delay latch.await(1, TimeUnit.MINUTES); - } - catch (Throwable ignored ) { + } catch (Throwable ignored) { } } } @@ -248,8 +240,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { Logger.get(LargeMessageOverReplicationTest.class).warn("Can't failover server"); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -263,4 +254,4 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { return message; } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java index 4387e23b8e..1ff58cde9f 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java @@ -86,15 +86,13 @@ public class MessageCopyTest { latchAlign.countDown(); try { latchReady.await(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } for (int i = 0; i < RUNS; i++) { try { ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -113,8 +111,7 @@ public class MessageCopyTest { latchAlign.countDown(); try { latchReady.await(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } for (int i = 0; i < RUNS; i++) { @@ -123,8 +120,7 @@ public class MessageCopyTest { ActiveMQBuffer buf = ssm.encode(null); System.out.println("reading at buf = " + buf); simulateRead(buf); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/OrphanedConsumerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/OrphanedConsumerTest.java index a95cbaa948..72a4a2d4d7 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/OrphanedConsumerTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/OrphanedConsumerTest.java @@ -114,8 +114,7 @@ public class OrphanedConsumerTest extends ActiveMQTestBase { targetMethod = "close", targetLocation = "ENTRY", condition = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()", - action = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()") - }) + action = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()")}) public void testOrphanedConsumers() throws Exception { internalTestOrphanedConsumers(false); } @@ -142,8 +141,7 @@ public class OrphanedConsumerTest extends ActiveMQTestBase { targetMethod = "close", targetLocation = "ENTRY", condition = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()", - action = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()") - }) + action = "org.apache.activemq.artemis.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()")}) public void testOrphanedConsumersByManagement() throws Exception { internalTestOrphanedConsumers(true); } @@ -190,8 +188,7 @@ public class OrphanedConsumerTest extends ActiveMQTestBase { // an extra second to avoid races of something closing the session while we are asserting it Thread.sleep(1000); - } - else { + } else { server.getActiveMQServerControl().closeConnectionsForAddress("127.0.0.1"); } @@ -230,4 +227,4 @@ public class OrphanedConsumerTest extends ActiveMQTestBase { session.close(); } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingLeakTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingLeakTest.java index cfd481cb4a..f9744d22ab 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingLeakTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingLeakTest.java @@ -165,8 +165,7 @@ public class PagingLeakTest extends ActiveMQTestBase { lastTime = System.currentTimeMillis(); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingOMETest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingOMETest.java index aa3ef3819e..cdf1c56488 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingOMETest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/PagingOMETest.java @@ -159,8 +159,7 @@ public class PagingOMETest extends ActiveMQTestBase { try { session.commit(); Assert.fail("exception expected"); - } - catch (Exception expected) { + } catch (Exception expected) { } failureActive = false; session.rollback(); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java index c939a46363..866189f88f 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java @@ -47,8 +47,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -/** This test will add more bytes to the large message while still syncing. - * At the time of writing I couldn't replicate any issues, but I'm keeping it here to validate the impl */ +/** + * This test will add more bytes to the large message while still syncing. + * At the time of writing I couldn't replicate any issues, but I'm keeping it here to validate the impl + */ @RunWith(BMUnitRunner.class) public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase { @@ -138,8 +140,7 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase if (connection != null) { try { connection.close(); - } - catch (Exception e) { + } catch (Exception e) { } } if (backupServer != null) { @@ -188,8 +189,7 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase try { producer.send(message); session.commit(); - } - catch (JMSException expected) { + } catch (JMSException expected) { expected.printStackTrace(); } } @@ -217,11 +217,10 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase flagSyncWait.countDown(); - Assert.assertTrue(((SharedNothingBackupActivation)backupServer.getActivation()).waitForBackupSync(10, TimeUnit.SECONDS)); + Assert.assertTrue(((SharedNothingBackupActivation) backupServer.getActivation()).waitForBackupSync(10, TimeUnit.SECONDS)); waitForRemoteBackup(connection.getSessionFactory(), 30); - liveServer.stop(true); Assert.assertTrue(failedOver.await(10, TimeUnit.SECONDS)); @@ -248,8 +247,7 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase try { flagSyncEntered.countDown(); flagSyncWait.await(100, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -263,8 +261,7 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase flagChunkEntered.countDown(); flagChunkWait.await(10, TimeUnit.SECONDS); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -278,4 +275,4 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase return message; } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java index 30fdcec66b..d649bf2986 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java @@ -126,8 +126,7 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase if (connection != null) { try { connection.close(); - } - catch (Exception e) { + } catch (Exception e) { } } if (backupServer != null) { @@ -175,8 +174,7 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase try { producer.send(message); session.commit(); - } - catch (JMSException expected) { + } catch (JMSException expected) { expected.printStackTrace(); } } @@ -202,7 +200,6 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase Assert.assertFalse(t.isAlive()); - liveServer.stop(true); Assert.assertTrue(failedOver.await(10, TimeUnit.SECONDS)); @@ -228,8 +225,7 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase try { flagArrived.countDown(); flagWait.await(10, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -244,4 +240,4 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase return message; } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ReplicationBackupTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ReplicationBackupTest.java index 248204fce0..b1ff7973f7 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ReplicationBackupTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ReplicationBackupTest.java @@ -16,11 +16,13 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.jboss.byteman.contrib.bmunit.BMRule; import org.jboss.byteman.contrib.bmunit.BMRules; @@ -28,8 +30,6 @@ import org.jboss.byteman.contrib.bmunit.BMUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; - @RunWith(BMUnitRunner.class) public class ReplicationBackupTest extends ActiveMQTestBase { @@ -69,8 +69,7 @@ public class ReplicationBackupTest extends ActiveMQTestBase { public void run() { try { liveServer.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -91,9 +90,8 @@ public class ReplicationBackupTest extends ActiveMQTestBase { * but the server's state != STARTED which would cause the backup to fail to announce */ Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } -} \ No newline at end of file +} diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ScaleDownFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ScaleDownFailoverTest.java index 7b672b83d6..20b9aab6c3 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ScaleDownFailoverTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ScaleDownFailoverTest.java @@ -164,8 +164,7 @@ public class ScaleDownFailoverTest extends ClusterTestBase { } } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java index d7d5db6722..29c885a416 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.extras.byteman; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; @@ -31,9 +34,6 @@ import org.jboss.byteman.contrib.bmunit.BMUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - /** * This test validates a deadlock identified by https://bugzilla.redhat.com/show_bug.cgi?id=959616 */ @@ -93,8 +93,7 @@ public class StartStopDeadlockTest extends ActiveMQTestBase { startLatch.await(); System.out.println("Crashing...."); serverLive.stop(true); - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); e.printStackTrace(); } @@ -108,8 +107,7 @@ public class StartStopDeadlockTest extends ActiveMQTestBase { align.countDown(); startLatch.await(); jmsServer.stop(); - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); e.printStackTrace(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StompInternalStateTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StompInternalStateTest.java index aca3059790..c798b5793b 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StompInternalStateTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StompInternalStateTest.java @@ -68,8 +68,7 @@ public class StompInternalStateTest extends ActiveMQTestBase { session.deleteQueue(STOMP_QUEUE_NAME); assertNull(resultTestStompProtocolManagerLeak); - } - finally { + } finally { if (session != null) { session.close(); } @@ -96,8 +95,7 @@ public class StompInternalStateTest extends ActiveMQTestBase { if (!destinations.contains(STOMP_QUEUE_NAME)) { resultTestStompProtocolManagerLeak += "didn't save the queue when binding added " + destinations; } - } - else if (noti.getType() == CoreNotificationType.BINDING_REMOVED) { + } else if (noti.getType() == CoreNotificationType.BINDING_REMOVED) { if (destinations.contains(STOMP_QUEUE_NAME)) { resultTestStompProtocolManagerLeak = "didn't remove the queue when binding removed " + destinations; } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/TimeoutXATest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/TimeoutXATest.java index 76679efa58..ce36a0e989 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/TimeoutXATest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/TimeoutXATest.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, @@ -44,7 +44,6 @@ import org.junit.runner.RunWith; @RunWith(BMUnitRunner.class) public class TimeoutXATest extends ActiveMQTestBase { - protected ActiveMQServer server = null; @Override @@ -79,7 +78,6 @@ public class TimeoutXATest extends ActiveMQTestBase { static CountDownLatch enteredRollbackLatch; static CountDownLatch waitingRollbackLatch; - @Test @BMRules( rules = {@BMRule( @@ -88,14 +86,13 @@ public class TimeoutXATest extends ActiveMQTestBase { targetMethod = "removeTransaction(javax.transaction.xa.Xid)", targetLocation = "ENTRY", helper = "org.apache.activemq.artemis.tests.extras.byteman.TimeoutXATest", - action = "removingTX()"), - @BMRule( - name = "afterRollback TX", - targetClass = "org.apache.activemq.artemis.core.transaction.impl.TransactionImpl", - targetMethod = "afterRollback", - targetLocation = "ENTRY", - helper = "org.apache.activemq.artemis.tests.extras.byteman.TimeoutXATest", - action = "afterRollback()")}) + action = "removingTX()"), @BMRule( + name = "afterRollback TX", + targetClass = "org.apache.activemq.artemis.core.transaction.impl.TransactionImpl", + targetMethod = "afterRollback", + targetLocation = "ENTRY", + helper = "org.apache.activemq.artemis.tests.extras.byteman.TimeoutXATest", + action = "afterRollback()")}) public void testTimeoutOnTX2() throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); XAConnection connection = connectionFactory.createXAConnection(); @@ -132,8 +129,7 @@ public class TimeoutXATest extends ActiveMQTestBase { latchStore.countDown(); server.getStorageManager().storeDuplicateID(SimpleString.toSimpleString("crebis"), new byte[]{1}, server.getStorageManager().generateID()); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -146,8 +142,7 @@ public class TimeoutXATest extends ActiveMQTestBase { public void run() { try { xaSession.getXAResource().rollback(xid); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -156,7 +151,6 @@ public class TimeoutXATest extends ActiveMQTestBase { t.start(); - removingTXEntered1.await(); storingThread.start(); @@ -191,8 +185,7 @@ public class TimeoutXATest extends ActiveMQTestBase { enteredRollbackLatch.countDown(); try { waitingRollbackLatch.await(); - } - catch (Throwable e) { + } catch (Throwable e) { } } @@ -206,17 +199,14 @@ public class TimeoutXATest extends ActiveMQTestBase { removingTXEntered0.countDown(); try { removingTXAwait0.await(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } - } - else if (xent == 1) { + } else if (xent == 1) { removingTXEntered1.countDown(); try { removingTXAwait1.await(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java index 4ed91c069e..e52963e07f 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java @@ -354,15 +354,13 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { ((ActiveMQMessage) msg).setInputStream(ActiveMQTestBase.createFakeLargeStream(1024L * 1024L)); msg.setStringProperty("msg", "message" + i); prod.send(msg); - } - else { + } else { TextMessage tm = sess.createTextMessage("message" + i); prod.send(tm); } } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -410,8 +408,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { for (int i = 0; i < 1024; i++) { Assert.assertEquals(1024, bmsg.readBytes(buffRead)); } - } - else { + } else { msgs.add(((TextMessage) tm).getText()); } @@ -430,16 +427,14 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE) { Assert.assertEquals(numMessages, msgs.size()); } - } - else if (qosMode == QualityOfServiceMode.AT_MOST_ONCE) { + } else if (qosMode == QualityOfServiceMode.AT_MOST_ONCE) { // No *guarantee* that any messages will be received // but you still might get some depending on how/where the crash occurred } BridgeTestBase.log.trace("Check complete"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -475,13 +470,11 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { for (int j = 0; j < 1024; j++) { Assert.assertEquals(1024, bmsg.readBytes(buffRead)); } - } - else { + } else { Assert.assertEquals("message" + (i + start), ((TextMessage) tm).getText()); } } - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/ClusteredBridgeTestBase.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/ClusteredBridgeTestBase.java index fe86bbdd3d..fa66cf288d 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/ClusteredBridgeTestBase.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/ClusteredBridgeTestBase.java @@ -29,6 +29,7 @@ import com.arjuna.ats.arjuna.coordinator.TransactionReaper; import com.arjuna.ats.arjuna.coordinator.TxControl; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; @@ -36,7 +37,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.FailoverEventListener; import org.apache.activemq.artemis.api.core.client.FailoverEventType; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -236,8 +236,7 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase { ClientMessage m = consumer.receive(500); if (checkDup) { assertNull(m); - } - else { + } else { //drain messages while (m != null) { m = consumer.receive(200); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeClusteredTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeClusteredTest.java index f04f5909bf..fc8b166178 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeClusteredTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeClusteredTest.java @@ -130,8 +130,7 @@ public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase { //verify bridge still work sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES); receiveMessages(targetServer, targetQueueName, batchSize); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -182,8 +181,7 @@ public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase { //verify bridge still work sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES); receiveMessages(targetServer, targetQueueName, NUM_MESSAGES, mode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -200,8 +198,7 @@ public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase { boolean checkDup) throws ActiveMQException { try { server.receiveMessages(queueName, num, checkDup); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); throw e; } @@ -210,8 +207,7 @@ public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase { private void receiveMessages(ServerGroup server, String queueName, int num) throws ActiveMQException { try { server.receiveMessages(queueName, num, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); throw e; } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java index a665b57d74..7c1b8783c2 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.extras.jms.bridge; +import javax.transaction.HeuristicMixedException; +import javax.transaction.HeuristicRollbackException; +import javax.transaction.RollbackException; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.xa.XAResource; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -29,14 +37,6 @@ import org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager; import org.junit.Assert; import org.junit.Test; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.RollbackException; -import javax.transaction.Synchronization; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.xa.XAResource; - public class JMSBridgeReconnectionTest extends BridgeTestBase { /** @@ -235,8 +235,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase { while (bridge.isStarted()) { try { sendMessages(cf0, sourceQueue, 0, 1, false, false); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -319,8 +318,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase { if (restart) { assertTrue(tx.rolledback); assertTrue(tx.targetConnected); - } - else { + } else { assertTrue(tx.rolledback); assertFalse(tx.targetConnected); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeTest.java index 17f364c7ef..3e8e13b986 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/JMSBridgeTest.java @@ -376,8 +376,7 @@ public class JMSBridgeTest extends BridgeTestBase { checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false); - } - finally { + } finally { if (bridge != null) { JMSBridgeTest.log.info("Stopping bridge"); bridge.stop(); @@ -416,88 +415,72 @@ public class JMSBridgeTest extends BridgeTestBase { try { bridge = new JMSBridgeImpl(null, cff1, sourceQueueFactory, targetQueueFactory, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, null, sourceQueueFactory, targetQueueFactory, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, null, targetQueueFactory, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, null, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, targetQueueFactory, sourceUsername, sourcePassword, destUsername, destPassword, selector, -2, maxRetries, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, targetQueueFactory, sourceUsername, sourcePassword, destUsername, destPassword, selector, -1, 10, qosMode, batchSize, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, null, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, 0, maxBatchTime, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } try { bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, null, sourceUsername, sourcePassword, destUsername, destPassword, selector, failureRetryInterval, maxRetries, qosMode, batchSize, -2, subName, clientID, false).setBridgeName("test-bridge"); fail("expected exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok - } - finally { + } finally { stopComponent(bridge); } } @@ -546,8 +529,7 @@ public class JMSBridgeTest extends BridgeTestBase { Message m = cons.receiveNoWait(); Assert.assertNull(m); - } - finally { + } finally { if (connSource != null) { connSource.close(); } @@ -592,8 +574,7 @@ public class JMSBridgeTest extends BridgeTestBase { if (i >= NUM_MESSAGES / 2) { tm.setStringProperty("vegetable", "radish"); - } - else { + } else { tm.setStringProperty("vegetable", "cauliflower"); } @@ -620,8 +601,7 @@ public class JMSBridgeTest extends BridgeTestBase { Assert.assertNull(m); - } - finally { + } finally { if (connSource != null) { connSource.close(); } @@ -690,8 +670,7 @@ public class JMSBridgeTest extends BridgeTestBase { Assert.assertNull(m); - } - finally { + } finally { if (connSource != null) { connSource.close(); } @@ -765,8 +744,7 @@ public class JMSBridgeTest extends BridgeTestBase { Assert.assertNull(m); - } - finally { + } finally { if (connSource != null) { connSource.close(); } @@ -818,13 +796,11 @@ public class JMSBridgeTest extends BridgeTestBase { sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage); checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage); - } - finally { + } finally { if (started != null) { try { started.rollback(); - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to rollback", e); } } @@ -832,8 +808,7 @@ public class JMSBridgeTest extends BridgeTestBase { if (toResume != null) { try { mgr.resume(toResume); - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to resume", e); } } @@ -866,8 +841,7 @@ public class JMSBridgeTest extends BridgeTestBase { sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage); checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -897,8 +871,7 @@ public class JMSBridgeTest extends BridgeTestBase { sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true, largeMessage); checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1061,8 +1034,7 @@ public class JMSBridgeTest extends BridgeTestBase { } } - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1228,8 +1200,7 @@ public class JMSBridgeTest extends BridgeTestBase { m = cons.receive(5000); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1303,8 +1274,7 @@ public class JMSBridgeTest extends BridgeTestBase { Assert.assertNull(header); } - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1370,8 +1340,7 @@ public class JMSBridgeTest extends BridgeTestBase { throw sender.ex; } - } - finally { + } finally { if (t != null) { t.join(10000); } @@ -1379,8 +1348,7 @@ public class JMSBridgeTest extends BridgeTestBase { if (connSource != null) { try { connSource.close(); - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to close connection", e); } } @@ -1440,8 +1408,7 @@ public class JMSBridgeTest extends BridgeTestBase { throw sender.ex; } - } - finally { + } finally { if (t != null) { t.join(10000); } @@ -1449,8 +1416,7 @@ public class JMSBridgeTest extends BridgeTestBase { if (connSource != null) { try { connSource.close(); - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to close connection", e); } } @@ -1508,8 +1474,7 @@ public class JMSBridgeTest extends BridgeTestBase { throw sender.ex; } - } - finally { + } finally { if (t != null) { t.join(10000); } @@ -1517,8 +1482,7 @@ public class JMSBridgeTest extends BridgeTestBase { if (connSource != null) { try { connSource.close(); - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to close connection", e); } } @@ -1577,8 +1541,7 @@ public class JMSBridgeTest extends BridgeTestBase { checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1, false); checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false); - } - finally { + } finally { if (bridge != null) { JMSBridgeTest.log.info("Stopping bridge"); bridge.stop(); @@ -1634,8 +1597,7 @@ public class JMSBridgeTest extends BridgeTestBase { checkAllMessageReceivedInOrder(cf0, localTargetQueue, NUM_MESSAGES, 1, false); checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES - 1, false); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1675,8 +1637,7 @@ public class JMSBridgeTest extends BridgeTestBase { // Messages should now be receivable checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1717,8 +1678,7 @@ public class JMSBridgeTest extends BridgeTestBase { // Messages should now be receivable checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1733,8 +1693,7 @@ public class JMSBridgeTest extends BridgeTestBase { try { bridge = new JMSBridgeImpl(cff0, cff0, sourceQueueFactory, localTargetQueueFactory, null, null, null, null, null, 3000, 10, QualityOfServiceMode.ONCE_AND_ONLY_ONCE, 10000, 3000, null, null, false).setBridgeName("test-bridge"); bridge.start(); - } - finally { + } finally { if (bridge != null) { bridge.stop(); } @@ -1782,8 +1741,7 @@ public class JMSBridgeTest extends BridgeTestBase { JMSBridgeTest.log.trace("Sent message " + i); } - } - catch (Exception e) { + } catch (Exception e) { JMSBridgeTest.log.error("Failed to send", e); ex = e; } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java index 5c4e854cd1..bc613f6bd5 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java @@ -187,8 +187,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase } } session.commit(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -205,8 +204,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase while (running.get()) { try { Thread.sleep(RandomUtil.randomInterval(100, 200)); - } - catch (InterruptedException intex) { + } catch (InterruptedException intex) { intex.printStackTrace(); return; } @@ -218,8 +216,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase if (serverSessions.size() != NUMBER_OF_SESSIONS) { System.err.println("the server was supposed to have " + NUMBER_OF_MESSAGES + " RA Sessions but it only contained accordingly to the meta-data"); metaDataFailed.set(true); - } - else if (serverSessions.size() == NUMBER_OF_SESSIONS) { + } else if (serverSessions.size() == NUMBER_OF_SESSIONS) { // it became the same after some reconnect? which would be acceptable metaDataFailed.set(false); } @@ -239,8 +236,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase // where the consumer is closed while things are still happening consumer.close(true); Thread.sleep(100); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -322,8 +318,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase if (atomicInteger == null) { out.println("didn't receive message with i=" + i); failed = true; - } - else if (atomicInteger.get() > 1) { + } else if (atomicInteger.get() > 1) { out.println("message with i=" + i + " received " + atomicInteger.get() + " times"); failed = true; } @@ -375,8 +370,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase serverSessions.clear(); try { Thread.sleep(100); - } - catch (Exception e) { + } catch (Exception e) { break; } } @@ -430,8 +424,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase // buggingList.add(factory); endpointSession = factory.createSession(true, false, false); producer = endpointSession.createProducer("jms.queue.outQueue"); - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e); } } @@ -443,8 +436,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase DummyTMLocator.tm.begin(); currentTX = DummyTMLocator.tm.getTransaction(); currentTX.enlistResource(xaResource); - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } @@ -456,8 +448,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase try { value = message.getIntProperty("i"); - } - catch (Exception e) { + } catch (Exception e) { } @@ -475,13 +466,11 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase Thread.sleep(2000); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); try { currentTX.setRollbackOnly(); - } - catch (Exception ex) { + } catch (Exception ex) { } e.printStackTrace(); // throw new RuntimeException(e); @@ -494,21 +483,16 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase try { if (currentTX.getStatus() == Status.STATUS_MARKED_ROLLBACK) { DummyTMLocator.tm.rollback(); - } - else { + } else { DummyTMLocator.tm.commit(); } - } - catch (HeuristicMixedException e) { + } catch (HeuristicMixedException e) { throw new LocalTransactionException(e); - } - catch (SystemException e) { + } catch (SystemException e) { throw new LocalTransactionException(e); - } - catch (HeuristicRollbackException e) { + } catch (HeuristicRollbackException e) { throw new LocalTransactionException(e); - } - catch (RollbackException e) { + } catch (RollbackException e) { throw new LocalTransactionException(e); } super.afterDelivery(); @@ -523,8 +507,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase try { TransactionReaper.terminate(true); TxControl.disable(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } tm = null; diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/JMSXDeliveryCountTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/JMSXDeliveryCountTest.java index 3c1c0b58c7..1b2d9fd047 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/JMSXDeliveryCountTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/JMSXDeliveryCountTest.java @@ -37,7 +37,6 @@ import javax.transaction.xa.Xid; import com.arjuna.ats.arjuna.coordinator.TransactionReaper; import com.arjuna.ats.arjuna.coordinator.TxControl; import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple; - import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.After; @@ -115,8 +114,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { tm.acknowledge(); conn.close(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -187,8 +185,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { Assert.assertEquals(1, tm.getIntProperty("JMSXDeliveryCount")); tm.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -240,8 +237,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { } tm.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -302,8 +298,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { cons3.close(); sess3.unsubscribe("subxyz"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -382,8 +377,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { Assert.assertTrue(rm.getJMSRedelivered()); consumerSess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -461,8 +455,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { Assert.assertTrue(rm.getJMSRedelivered()); rm.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -605,8 +598,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { tx.delistResource(res, XAResource.TMSUCCESS); tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -614,8 +606,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { if (tx != null) { try { mgr.commit(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } if (xaConn != null) { @@ -625,8 +616,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { if (toResume != null) { try { mgr.resume(toResume); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } } @@ -670,11 +660,9 @@ public class JMSXDeliveryCountTest extends JMSTestBase { if (tm == null) { failed = true; - } - else if (!tm.getText().equals("testing" + i)) { + } else if (!tm.getText().equals("testing" + i)) { failed = true; - } - else if (tm.getIntProperty("JMSXDeliveryCount") != j + 1) { + } else if (tm.getIntProperty("JMSXDeliveryCount") != j + 1) { failed = true; } } @@ -684,8 +672,7 @@ public class JMSXDeliveryCountTest extends JMSTestBase { } lastMessage.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { failed = true; } } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/XATest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/XATest.java index a594b15f39..a7e8cc6877 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/XATest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/xa/XATest.java @@ -89,8 +89,7 @@ public class XATest extends JMSTestBase { // roll it back try { tm.rollback(); - } - catch (Throwable ignore) { + } catch (Throwable ignore) { // The connection will probably be closed so this may well throw an exception } } @@ -160,8 +159,7 @@ public class XATest extends JMSTestBase { m2 = (TextMessage) cons.receive(1000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -217,8 +215,7 @@ public class XATest extends JMSTestBase { m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -269,8 +266,7 @@ public class XATest extends JMSTestBase { tm.commit(); Assert.fail("should not get here"); - } - catch (Exception e) { + } catch (Exception e) { // We should expect this } @@ -280,8 +276,7 @@ public class XATest extends JMSTestBase { MessageConsumer cons = sessReceiver.createConsumer(queue1); Message m2 = cons.receive(100); Assert.assertNull(m2); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -331,8 +326,7 @@ public class XATest extends JMSTestBase { Message m2 = cons.receive(100); Assert.assertNull(m2); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -404,8 +398,7 @@ public class XATest extends JMSTestBase { tx.delistResource(res2, XAResource.TMSUCCESS); tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -477,8 +470,7 @@ public class XATest extends JMSTestBase { tx.delistResource(res2, XAResource.TMSUCCESS); tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -555,8 +547,7 @@ public class XATest extends JMSTestBase { tx.delistResource(res2, XAResource.TMSUCCESS); tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -632,8 +623,7 @@ public class XATest extends JMSTestBase { tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -681,8 +671,7 @@ public class XATest extends JMSTestBase { m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -746,8 +735,7 @@ public class XATest extends JMSTestBase { tx.delistResource(res, XAResource.TMSUCCESS); tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -822,8 +810,7 @@ public class XATest extends JMSTestBase { tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -894,8 +881,7 @@ public class XATest extends JMSTestBase { TextMessage r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -966,8 +952,7 @@ public class XATest extends JMSTestBase { TextMessage r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1065,11 +1050,9 @@ public class XATest extends JMSTestBase { if (r.getText().equals("jellyfish1")) { session1First = true; - } - else if (r.getText().equals("jellyfish3")) { + } else if (r.getText().equals("jellyfish3")) { session1First = false; - } - else { + } else { Assert.fail("Unexpected message"); } @@ -1092,8 +1075,7 @@ public class XATest extends JMSTestBase { Assert.assertEquals("jellyfish4", r.getText()); - } - else { + } else { r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); @@ -1117,8 +1099,7 @@ public class XATest extends JMSTestBase { Assert.assertNull(r); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1219,11 +1200,9 @@ public class XATest extends JMSTestBase { if (r.getText().equals("jellyfish1")) { session1First = true; - } - else if (r.getText().equals("jellyfish3")) { + } else if (r.getText().equals("jellyfish3")) { session1First = false; - } - else { + } else { Assert.fail("Unexpected message"); } @@ -1246,8 +1225,7 @@ public class XATest extends JMSTestBase { Assert.assertEquals("jellyfish4", r.getText()); - } - else { + } else { r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); @@ -1270,8 +1248,7 @@ public class XATest extends JMSTestBase { r = (TextMessage) cons.receive(100); Assert.assertNull(r); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1354,8 +1331,7 @@ public class XATest extends JMSTestBase { try { tm.commit(); Assert.fail("should not get here"); - } - catch (Exception e) { + } catch (Exception e) { // We should expect this } @@ -1392,8 +1368,7 @@ public class XATest extends JMSTestBase { r = (TextMessage) cons.receive(100); Assert.assertNull(r); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1457,8 +1432,7 @@ public class XATest extends JMSTestBase { Assert.assertNotNull(r2); Assert.assertEquals("echidna2", r2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1524,8 +1498,7 @@ public class XATest extends JMSTestBase { Assert.assertNotNull(r2); Assert.assertEquals("echidna2", r2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1585,8 +1558,7 @@ public class XATest extends JMSTestBase { TextMessage r1 = (TextMessage) cons.receive(100); Assert.assertNull(r1); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1644,8 +1616,7 @@ public class XATest extends JMSTestBase { TextMessage r1 = (TextMessage) cons.receive(100); Assert.assertNull(r1); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1724,8 +1695,7 @@ public class XATest extends JMSTestBase { tm.resume(suspended); tm.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1818,8 +1788,7 @@ public class XATest extends JMSTestBase { r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1894,8 +1863,7 @@ public class XATest extends JMSTestBase { Assert.assertNotNull(r3); Assert.assertEquals("kangaroo1", r3.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolManagerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolManagerTest.java index 98a4ce641a..29542c9b93 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolManagerTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolManagerTest.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, @@ -50,6 +50,7 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { ActiveMQServer server; EmbeddedJMS embeddedJMS; + @Override @Before public void setUp() throws Exception { @@ -58,7 +59,7 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { configuration.setPersistenceEnabled(false); configuration.getAcceptorConfigurations().clear(); configuration.addAcceptorConfiguration("legacy", "tcp://localhost:61616?protocols=HORNETQ"). - addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE"); + addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE"); configuration.addConnectorConfiguration("legacy", "tcp://localhost:61616"); JMSConfiguration jmsConfiguration = new JMSConfigurationImpl(); @@ -87,17 +88,16 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { manager.register(connectionFactory, null, null, new ConcurrentHashMap()); manager.register(connectionFactory2, null, null, new ConcurrentHashMap()); - for (XARecoveryConfig resource :manager.getResources()) { + for (XARecoveryConfig resource : manager.getResources()) { try (ServerLocator locator = resource.createServerLocator(); - ClientSessionFactory factory = locator.createSessionFactory(); - ClientSession session = factory.createSession()) { + ClientSessionFactory factory = locator.createSessionFactory(); + ClientSession session = factory.createSession()) { // Nothing } } } - /** This test will use an ArtemisConnectionFactory with clientProtocolManager=*/ @Test public void testLegacy2() throws Exception { @@ -110,7 +110,6 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { Queue queue = (Queue) embeddedJMS.lookup("testQueue"); - ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) embeddedJMS.lookup("legacy"); Connection connection = connectionFactory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -124,7 +123,7 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { connection.start(); MessageConsumer consumer = session.createConsumer(queue); - TextMessage messageRec = (TextMessage)consumer.receive(5000); + TextMessage messageRec = (TextMessage) consumer.receive(5000); Assert.assertNotNull(messageRec); Assert.assertEquals("Test", messageRec.getText()); @@ -134,6 +133,5 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase { } - } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolTest.java index 29c7677467..920b77a87a 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/protocols/hornetq/HornetQProtocolTest.java @@ -62,7 +62,6 @@ public class HornetQProtocolTest extends ActiveMQTestBase { waitForServerToStart(server); } - @Override @After public void tearDown() throws Exception { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java index 5fe8953409..8456765e6f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java @@ -169,8 +169,7 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { if (temporary) { session.createTemporaryQueue(addressName, queueName, null); - } - else { + } else { session.createQueue(addressName, queueName, null, true); } @@ -277,8 +276,7 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.commit(); Assert.fail("Exception expected"); - } - catch (ActiveMQException expected) { + } catch (ActiveMQException expected) { } @@ -601,8 +599,7 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.commit(); - } - catch (Exception e) { + } catch (Exception e) { session.rollback(); } @@ -710,11 +707,9 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.commit(); - } - catch (ActiveMQDuplicateIdException die) { + } catch (ActiveMQDuplicateIdException die) { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1136,8 +1131,7 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.prepare(xid2); fail("Should throw an exception here!"); - } - catch (XAException expected) { + } catch (XAException expected) { assertTrue(expected.getCause().toString().contains("DUPLICATE_ID_REJECTED")); } @@ -1522,11 +1516,9 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.commit(); - } - catch (ActiveMQDuplicateIdException die) { + } catch (ActiveMQDuplicateIdException die) { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1539,11 +1531,9 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.commit(); - } - catch (ActiveMQDuplicateIdException die) { + } catch (ActiveMQDuplicateIdException die) { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1789,8 +1779,7 @@ public class DuplicateDetectionTest extends ActiveMQTestBase { try { session.prepare(xid2); fail("Should throw an exception here!"); - } - catch (XAException expected) { + } catch (XAException expected) { } session.rollback(xid2); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SimpleTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SimpleTest.java index f0db2068c1..ab565c3bda 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SimpleTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SimpleTest.java @@ -17,6 +17,8 @@ package org.apache.activemq.artemis.tests.integration; +import java.util.UUID; + import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; @@ -28,8 +30,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import java.util.UUID; - /** * A simple test-case used for documentation purposes. */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SingleServerSimpleTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SingleServerSimpleTest.java index b71e31de7d..41a130ed74 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SingleServerSimpleTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/SingleServerSimpleTest.java @@ -17,14 +17,14 @@ package org.apache.activemq.artemis.tests.integration; +import java.util.UUID; + import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.tests.util.SingleServerTestBase; import org.junit.Test; -import java.util.UUID; - /** * A simple test-case used for documentation purposes. */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java index 8a9d586d32..585717348d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -35,6 +29,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * There is a bug in JDK1.3, 1.4 whereby writeUTF fails if more than 64K bytes are written @@ -161,16 +158,14 @@ public class String64KLimitTest extends ActiveMQTestBase { ClientMessage tm3 = session.createMessage(false); tm3.getBodyBuffer().writeUTF(s3); Assert.fail("can not write UTF string bigger than 64K"); - } - catch (Exception e) { + } catch (Exception e) { } try { ClientMessage tm4 = session.createMessage(false); tm4.getBodyBuffer().writeUTF(s4); Assert.fail("can not write UTF string bigger than 64K"); - } - catch (Exception e) { + } catch (Exception e) { } producer.send(tm1); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java index 7babcfcd60..91b6718d58 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java @@ -16,6 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.aerogear; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -24,7 +35,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; @@ -40,16 +50,6 @@ import org.mortbay.jetty.Server; import org.mortbay.jetty.handler.AbstractHandler; import org.mortbay.jetty.nio.SelectChannelConnector; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class AeroGearBasicServerTest extends ActiveMQTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpClientTestSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpClientTestSupport.java index d4281b5dc9..f0f52bae66 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpClientTestSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpClientTestSupport.java @@ -35,18 +35,15 @@ import org.junit.Before; */ public class AmqpClientTestSupport extends ActiveMQTestBase { - ActiveMQServer server; LinkedList connections = new LinkedList<>(); - protected AmqpConnection addConnection(AmqpConnection connection) { connections.add(connection); return connection; } - @Before @Override public void setUp() throws Exception { @@ -60,11 +57,10 @@ public class AmqpClientTestSupport extends ActiveMQTestBase { public void tearDown() throws Exception { super.tearDown(); - for (AmqpConnection conn: connections) { + for (AmqpConnection conn : connections) { try { conn.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } } @@ -137,16 +133,13 @@ public class AmqpClientTestSupport extends ActiveMQTestBase { if (isUseSSL()) { if (webSocket) { uri = "wss://127.0.0.1:" + port; - } - else { + } else { uri = "ssl://127.0.0.1:" + port; } - } - else { + } else { if (webSocket) { uri = "ws://127.0.0.1:" + port; - } - else { + } else { uri = "tcp://127.0.0.1:" + port; } } @@ -156,8 +149,7 @@ public class AmqpClientTestSupport extends ActiveMQTestBase { } return new URI(uri); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonMaxFrameSizeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonMaxFrameSizeTest.java index 9f22362476..299732717b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonMaxFrameSizeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonMaxFrameSizeTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.amqp; +import java.net.URI; +import java.util.Map; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.transport.amqp.client.AmqpClient; import org.apache.activemq.transport.amqp.client.AmqpConnection; import org.apache.activemq.transport.amqp.client.AmqpMessage; @@ -26,10 +30,6 @@ import org.apache.qpid.proton.amqp.messaging.Data; import org.apache.qpid.proton.message.impl.MessageImpl; import org.junit.Test; -import java.net.URI; -import java.util.Map; -import java.util.concurrent.TimeUnit; - public class ProtonMaxFrameSizeTest extends ProtonTestBase { private static final int FRAME_SIZE = 512; @@ -47,7 +47,6 @@ public class ProtonMaxFrameSizeTest extends ProtonTestBase { AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password); - AmqpConnection amqpConnection = client.createConnection(); try { @@ -79,8 +78,7 @@ public class ProtonMaxFrameSizeTest extends ProtonTestBase { message.accept(); } - } - finally { + } finally { amqpConnection.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonPubSubTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonPubSubTest.java index c8fc454d13..39197fd1f1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonPubSubTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonPubSubTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.amqp; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.qpid.jms.JmsConnectionFactory; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -36,8 +29,15 @@ import javax.jms.TopicSession; import javax.jms.TopicSubscriber; import java.util.Map; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.qpid.jms.JmsConnectionFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ProtonPubSubTest extends ProtonTestBase { + private final String prefix = "foo.bar."; private final String pubAddress = "pubAddress"; private final String prefixedPubAddress = prefix + "pubAddress"; @@ -77,8 +77,7 @@ public class ProtonPubSubTest extends ProtonTestBase { if (connection != null) { connection.close(); } - } - finally { + } finally { super.tearDown(); } } @@ -131,7 +130,6 @@ public class ProtonPubSubTest extends ProtonTestBase { } } - @Test public void testDurablePubSub() throws Exception { int numMessages = 100; @@ -244,13 +242,11 @@ public class ProtonPubSubTest extends ProtonTestBase { session.unsubscribe("myPubId"); } - private javax.jms.Topic createTopic(String address) throws Exception { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { return session.createTopic(address); - } - finally { + } finally { session.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java index 9ed8aaae39..e90a8b180a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.amqp; -import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.contains; -import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.DELAYED_DELIVERY; -import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.PRODUCT; -import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.VERSION; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -63,6 +58,7 @@ import org.apache.activemq.artemis.core.remoting.CloseListener; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerReceiverContext; import org.apache.activemq.artemis.utils.ByteUtil; import org.apache.activemq.artemis.utils.VersionLoader; import org.apache.activemq.transport.amqp.client.AmqpClient; @@ -81,7 +77,11 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerReceiverContext; + +import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.DELAYED_DELIVERY; +import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.PRODUCT; +import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.VERSION; +import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.contains; @RunWith(Parameterized.class) public class ProtonTest extends ProtonTestBase { @@ -94,7 +94,6 @@ public class ProtonTest extends ProtonTestBase { private static final String password = "guest"; - private static final String brokerName = "my-broker"; private static final long maxSizeBytes = 1 * 1024 * 1024; @@ -121,8 +120,7 @@ public class ProtonTest extends ProtonTestBase { this.protocol = protocol; if (protocol == 0 || protocol == 3) { this.address = coreAddress; - } - else { + } else { this.address = "exampleQueue"; } } @@ -170,8 +168,7 @@ public class ProtonTest extends ProtonTestBase { if (connection != null) { connection.close(); } - } - finally { + } finally { super.tearDown(); } } @@ -194,8 +191,7 @@ public class ProtonTest extends ProtonTestBase { Assert.assertNull(server.getPostOffice().getBinding(new SimpleString("myClientId:myDurSub"))); session.close(); connection.close(); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -222,8 +218,7 @@ public class ProtonTest extends ProtonTestBase { latch.await(5, TimeUnit.SECONDS); bindingsForAddress = server.getPostOffice().getBindingsForAddress(new SimpleString("amqp_testtopic")); Assert.assertEquals(1, bindingsForAddress.getBindings().size()); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -236,8 +231,7 @@ public class ProtonTest extends ProtonTestBase { AmqpConnection amqpConnection = client.connect(); try { assertTrue(brokerName.equals(amqpConnection.getEndpoint().getRemoteContainer())); - } - finally { + } finally { amqpConnection.close(); } } @@ -253,8 +247,7 @@ public class ProtonTest extends ProtonTestBase { assertTrue("apache-activemq-artemis".equals(properties.get(Symbol.valueOf("product")))); assertTrue(VersionLoader.getVersion().getFullVersion().equals(properties.get(Symbol.valueOf("version")))); } - } - finally { + } finally { amqpConnection.close(); } } @@ -293,8 +286,7 @@ public class ProtonTest extends ProtonTestBase { try { assertNotNull(connection); connection.getStateInspector().assertValid(); - } - finally { + } finally { connection.close(); } } @@ -322,8 +314,7 @@ public class ProtonTest extends ProtonTestBase { // Shouldn't get this since we delayed the message. assertNull(receiver.receive(5, TimeUnit.SECONDS)); - } - finally { + } finally { connection.close(); } } @@ -355,8 +346,7 @@ public class ProtonTest extends ProtonTestBase { Long msgDeliveryTime = (Long) received.getMessageAnnotation("x-opt-delivery-time"); assertNotNull(msgDeliveryTime); assertEquals(deliveryTime, msgDeliveryTime.longValue()); - } - finally { + } finally { connection.close(); } } @@ -376,8 +366,7 @@ public class ProtonTest extends ProtonTestBase { AmqpSession session = amqpConnection.createSession(); AmqpSender sender = session.createSender(destinationAddress); assertTrue(sender.getSender().getCredit() == 1); - } - finally { + } finally { amqpConnection.close(); maxCreditAllocation.setInt(null, originalMaxCreditAllocation); } @@ -466,7 +455,6 @@ public class ProtonTest extends ProtonTestBase { Assert.assertEquals(q.getMessageCount(), 0); } - @Test public void testRollbackConsumer() throws Throwable { @@ -542,8 +530,7 @@ public class ProtonTest extends ProtonTestBase { Exception e = null; try { p.send(session.createBytesMessage()); - } - catch (ResourceAllocationException rae) { + } catch (ResourceAllocationException rae) { e = rae; } assertTrue(e instanceof ResourceAllocationException); @@ -579,8 +566,7 @@ public class ProtonTest extends ProtonTestBase { long addressSize = server.getPagingManager().getPageStore(new SimpleString(destinationAddress)).getAddressSize(); assertTrue(addressSize >= maxSizeBytes && addressSize <= maxSizeBytesRejectThreshold); - } - finally { + } finally { amqpConnection.close(); maxCreditAllocation.setInt(null, originalMaxCreditAllocation); } @@ -617,8 +603,7 @@ public class ProtonTest extends ProtonTestBase { Thread.sleep(500); assertTrue(sender.getSender().getCredit() >= 0); - } - finally { + } finally { amqpConnection.close(); } } @@ -636,8 +621,7 @@ public class ProtonTest extends ProtonTestBase { // Wait for a potential flow frame. Thread.sleep(1000); assertEquals(0, sender.getSender().getCredit()); - } - finally { + } finally { amqpConnection.close(); } } @@ -665,11 +649,9 @@ public class ProtonTest extends ProtonTestBase { session.begin(); sender.send(message); session.commit(); - } - catch (Exception e) { + } catch (Exception e) { expectedException = e; - } - finally { + } finally { amqpConnection.close(); } @@ -680,6 +662,7 @@ public class ProtonTest extends ProtonTestBase { /** * Fills an address. Careful when using this method. Only use when rejected messages are switched on. + * * @param address * @return * @throws Exception @@ -692,11 +675,9 @@ public class ProtonTest extends ProtonTestBase { AmqpSession session = amqpConnection.createSession(); AmqpSender sender = session.createSender(address); sendUntilFull(sender); - } - catch (Exception e) { + } catch (Exception e) { exception = e; - } - finally { + } finally { amqpConnection.close(); } @@ -724,8 +705,7 @@ public class ProtonTest extends ProtonTestBase { sentMessages.getAndIncrement(); } timeout.countDown(); - } - catch (IOException e) { + } catch (IOException e) { errors[0] = e; } } @@ -751,8 +731,7 @@ public class ProtonTest extends ProtonTestBase { Exception expectedException = null; try { session.createSender("AnAddressThatDoesNotExist"); - } - catch (Exception e) { + } catch (Exception e) { expectedException = e; } @@ -814,8 +793,7 @@ public class ProtonTest extends ProtonTestBase { assertTrue(((String) value).length() > 0); assertTrue(((String) value).contains(destinationAddress)); response.accept(); - } - finally { + } finally { amqpConnection.close(); } } @@ -926,8 +904,7 @@ public class ProtonTest extends ProtonTestBase { if (success) { break; - } - else { + } else { System.err.println("Had to make it fail!!!"); tearDown(); setUp(); @@ -1116,25 +1093,21 @@ public class ProtonTest extends ProtonTestBase { Message m = consumer.receive(5000); Assert.assertNotNull("Could not receive message count=" + count + " on consumer", m); count--; - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); break; } } - } - catch (Throwable e) { + } catch (Throwable e) { exceptions.add(e); e.printStackTrace(); - } - finally { + } finally { try { // if the createconnecion wasn't commented out if (connectionConsumer != connection) { connectionConsumer.close(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { // NO OP } } @@ -1441,20 +1414,17 @@ public class ProtonTest extends ProtonTestBase { try { testConn1.setClientID("client-id2"); fail("didn't get expected exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { //expected } try { testConn2.setClientID("client-id1"); fail("didn't get expected exception"); - } - catch (InvalidClientIDException e) { + } catch (InvalidClientIDException e) { //expected } - } - finally { + } finally { testConn1.close(); testConn2.close(); } @@ -1464,8 +1434,7 @@ public class ProtonTest extends ProtonTestBase { testConn2 = createConnection(false); testConn1.setClientID("client-id1"); testConn2.setClientID("client-id2"); - } - finally { + } finally { testConn1.close(); testConn2.close(); } @@ -1475,8 +1444,7 @@ public class ProtonTest extends ProtonTestBase { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { return session.createQueue(address); - } - finally { + } finally { session.close(); } } @@ -1490,12 +1458,10 @@ public class ProtonTest extends ProtonTestBase { if (protocol == 3) { factory = new JmsConnectionFactory(amqpConnectionUri); connection = factory.createConnection(); - } - else if (protocol == 0) { + } else if (protocol == 0) { factory = new JmsConnectionFactory(userName, password, amqpConnectionUri); connection = factory.createConnection(); - } - else { + } else { Assert.fail("protocol = " + protocol + " not supported"); return null; // just to compile, the previous statement will throw an exception } @@ -1525,8 +1491,7 @@ public class ProtonTest extends ProtonTestBase { }); connection.setClientID(clientId); connection.start(); - } - else if (protocol == 0) { + } else if (protocol == 0) { factory = new JmsConnectionFactory(userName, password, amqpConnectionUri); connection = factory.createConnection(); connection.setExceptionListener(new ExceptionListener() { @@ -1537,8 +1502,7 @@ public class ProtonTest extends ProtonTestBase { }); connection.setClientID(clientId); connection.start(); - } - else { + } else { Assert.fail("protocol = " + protocol + " not supported"); return null; // just to compile, the previous statement will throw an exception } @@ -1546,7 +1510,6 @@ public class ProtonTest extends ProtonTestBase { return connection; } - private void setAddressFullBlockPolicy() { // For BLOCK tests AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch("#"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestBase.java index d6369ebe51..9dacd6692d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestBase.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.amqp; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -25,9 +28,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.After; import org.junit.Before; -import java.util.HashMap; -import java.util.Map; - public class ProtonTestBase extends ActiveMQTestBase { protected String brokerName = "my-broker"; @@ -69,8 +69,7 @@ public class ProtonTestBase extends ActiveMQTestBase { public void tearDown() throws Exception { try { server.stop(); - } - finally { + } finally { super.tearDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestForHeader.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestForHeader.java index a50af0d970..dffc12eff9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestForHeader.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTestForHeader.java @@ -28,8 +28,8 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.Wait; import org.fusesource.hawtbuf.Buffer; import org.junit.After; import org.junit.Before; @@ -61,8 +61,7 @@ public class ProtonTestForHeader extends ActiveMQTestBase { public void tearDown() throws Exception { try { server.stop(); - } - finally { + } finally { super.tearDown(); } } @@ -91,8 +90,7 @@ public class ProtonTestForHeader extends ActiveMQTestBase { try { connection.send(header); return false; - } - catch (Exception e) { + } catch (Exception e) { return true; } } @@ -124,8 +122,7 @@ public class ProtonTestForHeader extends ActiveMQTestBase { int read = is.read(header); if (read == header.length) { return new AmqpHeader(new Buffer(header)); - } - else { + } else { return null; } } @@ -207,8 +204,7 @@ public class ProtonTestForHeader extends ActiveMQTestBase { char value = (char) buffer.get(i); if (Character.isLetter(value)) { builder.append(value); - } - else { + } else { builder.append(","); builder.append((int) value); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/SendingAndReceivingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/SendingAndReceivingTest.java index 0c9783efea..882efd579e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/SendingAndReceivingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/SendingAndReceivingTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.amqp; -import java.util.Random; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -25,11 +23,11 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Random; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.qpid.jms.JmsConnectionFactory; - import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -52,8 +50,7 @@ public class SendingAndReceivingTest extends ActiveMQTestBase { public void tearDown() throws Exception { try { server.stop(); - } - finally { + } finally { super.tearDown(); } } @@ -78,8 +75,7 @@ public class SendingAndReceivingTest extends ActiveMQTestBase { TextMessage m = (TextMessage) consumer.receive(5000); Assert.assertEquals(body, m.getText()); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -90,7 +86,7 @@ public class SendingAndReceivingTest extends ActiveMQTestBase { final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Random rnd = new Random(); StringBuilder sb = new StringBuilder(messageSize); - for (int j = 0; j < messageSize; j++ ) { + for (int j = 0; j < messageSize; j++) { sb.append(AB.charAt(rnd.nextInt(AB.length()))); } String body = sb.toString(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java index 234a9fb9c5..c2ffd26106 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/broadcast/JGroupsBroadcastTest.java @@ -41,7 +41,6 @@ public class JGroupsBroadcastTest { JChannelManager.getInstance().setLoopbackMessages(true); } - @Rule public ThreadLeakCheckRule threadLeakCheckRule = new ThreadLeakCheckRule(); @@ -86,8 +85,7 @@ public class JGroupsBroadcastTest { try { channelEndpoint2.openClient(); Assert.fail("this should be closed"); - } - catch (Exception e) { + } catch (Exception e) { } newChannel = new JChannel(configurator); @@ -98,22 +96,18 @@ public class JGroupsBroadcastTest { channelEndpoint1.openClient(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; - } - finally { + } finally { try { channel.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { newChannel.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java index 4109db95b7..74cbd289ff 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.cli; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Map; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.cli.commands.ActionContext; import org.apache.activemq.artemis.cli.commands.destination.CreateDestination; @@ -27,10 +31,6 @@ import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Before; import org.junit.Test; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.Map; - public class DestinationCommandTest extends JMSTestBase { //the command @@ -183,15 +183,13 @@ public class DestinationCommandTest extends JMSTestBase { System.out.println("output: " + fullMessage); assertTrue(fullMessage, fullMessage.contains("successfully")); assertTrue(checkBindingExists(command, null)); - } - else { + } else { if (command.getName().equals("jmsQueue1") || command.getName().equals("coreQueue2") || command.getName().equals("jmsTopic1")) { String fullMessage = output.toString(); System.out.println("output: " + fullMessage); assertTrue(fullMessage, fullMessage.contains("successfully")); assertFalse(checkBindingExists(command, null)); - } - else { + } else { String errorMessage = error.toString(); System.out.println("error: " + errorMessage); assertTrue(errorMessage, errorMessage.contains("Failed to")); @@ -205,8 +203,7 @@ public class DestinationCommandTest extends JMSTestBase { if (isJms(command)) { if (isTopic(command)) { bindingKey = "jms.topic." + bindingKey; - } - else { + } else { bindingKey = "jms.queue." + bindingKey; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java index 2e5bb96124..beac414e02 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java @@ -23,9 +23,9 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java index 476f191a9a..0597dd5d98 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java @@ -33,13 +33,13 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQConsumerContext; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.spi.core.remoting.ConsumerContext; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.UUID; import org.junit.Assert; import org.junit.Test; @@ -145,12 +145,10 @@ public class AcknowledgeTest extends ActiveMQTestBase { public void onMessage(final ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { try { session.close(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } } @@ -215,16 +213,14 @@ public class AcknowledgeTest extends ActiveMQTestBase { // pretending to be an unbehaved client doing an invalid ack right after failover ((ClientSessionInternal) sessionConsumer).acknowledge(new FakeConsumerWithID(0), new FakeMessageWithID(12343)); fail("supposed to throw an exception here"); - } - catch (Exception e) { + } catch (Exception e) { } try { // pretending to be an unbehaved client doing an invalid ack right after failover ((ClientSessionInternal) sessionConsumer).acknowledge(new FakeConsumerWithID(3), new FakeMessageWithID(12343)); fail("supposed to throw an exception here"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -264,12 +260,10 @@ public class AcknowledgeTest extends ActiveMQTestBase { if (latch.getCount() == 1) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { try { session.close(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java index 30d9e8617b..5270d9e99a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java @@ -109,14 +109,12 @@ public class ActiveMQCrashTest extends ActiveMQTestBase { public void run() { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } }.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java index dcae248cc4..46e9db7dd9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java @@ -121,8 +121,7 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase { try { producer.send(mess); Assert.fail("Sending a message here should throw a JMSSecurityException"); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e instanceof JMSSecurityException); } @@ -211,7 +210,7 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase { Connection connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); -// javax.jms.Topic topic = ActiveMQJMSClient.createTopic("test"); + // javax.jms.Topic topic = ActiveMQJMSClient.createTopic("test"); ActiveMQTemporaryTopic topic = (ActiveMQTemporaryTopic) session.createTemporaryTopic(); @@ -233,7 +232,7 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase { connection.close(); -// assertNotNull(server.getManagementService().getResource("jms.topic.test")); + // assertNotNull(server.getManagementService().getResource("jms.topic.test")); assertNull(server.locateQueue(topicAddress)); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteJmsDestinationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteJmsDestinationTest.java index 44bb7643da..9d23445fb0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteJmsDestinationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoDeleteJmsDestinationTest.java @@ -25,9 +25,9 @@ import javax.jms.TextMessage; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.core.server.Queue; import org.junit.Assert; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutogroupIdTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutogroupIdTest.java index 487edfb18c..da86e97bd2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutogroupIdTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutogroupIdTest.java @@ -212,8 +212,7 @@ public class AutogroupIdTest extends ActiveMQTestBase { messagesReceived++; try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } latch.countDown(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CommitRollbackTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CommitRollbackTest.java index ec9c041c24..1bb29a391d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CommitRollbackTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CommitRollbackTest.java @@ -28,9 +28,9 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; @@ -176,12 +176,10 @@ public class CommitRollbackTest extends ActiveMQTestBase { public void onMessage(final ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { try { session.close(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } } @@ -251,12 +249,10 @@ public class CommitRollbackTest extends ActiveMQTestBase { public void onMessage(final ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { try { session.close(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java index 14f8826c20..c45f4a90c2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java @@ -26,11 +26,11 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; @@ -136,8 +136,7 @@ public class ConcurrentCreateDeleteProduceTest extends ActiveMQTestBase { System.out.println("Deleting " + queueName); } session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.ex = e; e.printStackTrace(); running = false; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java index efcbf1828d..d942269e13 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.SimpleString; @@ -37,9 +40,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class ConsumerCloseTest extends ActiveMQTestBase { private ClientSessionFactory sf; @@ -116,8 +116,7 @@ public class ConsumerCloseTest extends ActiveMQTestBase { try { received.countDown(); waitingToProceed.await(); - } - catch (Exception e) { + } catch (Exception e) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerRoundRobinTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerRoundRobinTest.java index 8caef8cafb..8350ddcb4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerRoundRobinTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerRoundRobinTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -30,6 +26,8 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; public class ConsumerRoundRobinTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java index 747d9548a2..d6557538ed 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java @@ -93,8 +93,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { received.acknowledge(); } } - } - catch (Throwable e) { + } catch (Throwable e) { Thread.currentThread().interrupt(); e.printStackTrace(); } @@ -135,8 +134,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { fail("The cleanup wasn't able to finish cleaning the session. It's probably stuck, look at the thread dump generated by the test for more information"); } assertEquals(0, server.getConnectionCount()); - } - finally { + } finally { nettyConnection.getNettyChannel().config().setAutoRead(true); tReceive.interrupt(); tReceive.join(); @@ -178,8 +176,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { received.acknowledge(); } } - } - catch (Throwable e) { + } catch (Throwable e) { Thread.currentThread().interrupt(); e.printStackTrace(); } @@ -201,8 +198,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(session, "m" + i); producer.send(message); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -247,8 +243,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { Thread.sleep(10); } assertEquals(0, server.getConnectionCount()); - } - finally { + } finally { nettyConnection.getNettyChannel().config().setAutoRead(true); tReceive.interrupt(); tReceive.join(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java index e9918fc192..1c1f929dab 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java @@ -268,8 +268,7 @@ public class ConsumerTest extends ActiveMQTestBase { public void onMessage(final ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } } @@ -360,11 +359,9 @@ public class ConsumerTest extends ActiveMQTestBase { try { consumer.receiveImmediate(); Assert.fail("Should throw exception"); - } - catch (ActiveMQIllegalStateException ise) { + } catch (ActiveMQIllegalStateException ise) { //ok - } - catch (ActiveMQException me) { + } catch (ActiveMQException me) { Assert.fail("Wrong exception code"); } @@ -430,12 +427,10 @@ public class ConsumerTest extends ActiveMQTestBase { errors.incrementAndGet(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { latchReceive.countDown(); } } @@ -470,8 +465,7 @@ public class ConsumerTest extends ActiveMQTestBase { sessionSend.close(); factory.close(); locatorSend.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); @@ -540,8 +534,7 @@ public class ConsumerTest extends ActiveMQTestBase { if (count % 2 == 0 && !redelivered) { session.rollback(); - } - else { + } else { session.commit(); } } @@ -611,8 +604,7 @@ public class ConsumerTest extends ActiveMQTestBase { if (count % 2 == 0 && !redelivered) { session.rollback(); - } - else { + } else { session.commit(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerWindowSizeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerWindowSizeTest.java index 5009461bbd..b5ce930fe5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerWindowSizeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerWindowSizeTest.java @@ -32,16 +32,16 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal; import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.Bindings; import org.apache.activemq.artemis.core.postoffice.QueueBinding; -import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -336,8 +336,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -525,8 +524,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { Assert.assertEquals(0, getMessageCount(server, ADDRESS.toString())); - } - finally { + } finally { try { if (session != null) { session.close(); @@ -534,8 +532,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (sessionB != null) { sessionB.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -639,8 +636,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { Assert.assertEquals(0, getMessageCount(server, ADDRESS.toString())); - } - finally { + } finally { try { if (session != null) { session.close(); @@ -648,8 +644,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (sessionB != null) { sessionB.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -806,8 +801,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { session2 = null; Assert.assertEquals(0, getMessageCount(server, ADDRESS.toString())); - } - finally { + } finally { try { if (session1 != null) { session1.close(); @@ -815,8 +809,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (session2 != null) { session2.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -872,14 +865,12 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { session1 = null; Assert.assertEquals(0, getMessageCount(server, ADDRESS.toString())); - } - finally { + } finally { try { if (session1 != null) { session1.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -934,8 +925,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (isLargeMessage) { // something to ensure we are using large messages locator.setMinLargeMessageSize(100); - } - else { + } else { // To make sure large messages won't kick in, we set anything large locator.setMinLargeMessageSize(Integer.MAX_VALUE); } @@ -986,14 +976,12 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { session.commit(); } - } - finally { + } finally { try { if (session != null) { session.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -1071,8 +1059,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { latchRead.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); // Hudson / JUnit report failed = true; } @@ -1123,8 +1110,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { Assert.assertFalse("MessageHandler received a failure", handler.failed); - } - finally { + } finally { try { if (session != null) { session.close(); @@ -1132,8 +1118,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (sessionB != null) { sessionB.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -1214,8 +1199,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { failed = true; } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); // Hudson / JUnit report failed = true; } @@ -1272,8 +1256,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { Assert.assertFalse("MessageHandler received a failure", handler.failed); - } - finally { + } finally { try { if (session != null) { session.close(); @@ -1281,8 +1264,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (sessionB != null) { sessionB.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } @@ -1389,8 +1371,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { " foundB = " + foundB, foundB); - } - finally { + } finally { try { if (sessionA != null) { sessionA.close(); @@ -1398,8 +1379,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase { if (sessionB != null) { sessionB.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java index a907ad2176..3a6c404642 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java @@ -57,9 +57,9 @@ public class CoreClientTest extends ActiveMQTestBase { public void testCoreClientWithInjectedThreadPools() throws Exception { ExecutorService threadPool = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); - ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(10); + ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(10); - ServerLocator locator = createNonHALocator(false); + ServerLocator locator = createNonHALocator(false); boolean setThreadPools = locator.setThreadPools(threadPool, scheduledThreadPool); assertTrue(setThreadPools); @@ -83,8 +83,7 @@ public class CoreClientTest extends ActiveMQTestBase { ActiveMQClient.clearThreadPools(); ServerLocator locator = createNonHALocator(false); testCoreClient(true, locator); - } - finally { + } finally { // restoring original value otherwise future tests would be screwed up ActiveMQClient.setGlobalThreadPoolProperties(originalGlobal, originalScheduled); ActiveMQClient.clearThreadPools(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CreateQueueIdempotentTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CreateQueueIdempotentTest.java index 90ed01ab93..2b57f06605 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CreateQueueIdempotentTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CreateQueueIdempotentTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -29,8 +31,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.atomic.AtomicInteger; - public class CreateQueueIdempotentTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -58,11 +58,9 @@ public class CreateQueueIdempotentTest extends ActiveMQTestBase { try { session.createQueue(QUEUE, QUEUE, null, true); fail("Expected exception, queue already exists"); - } - catch (ActiveMQQueueExistsException qee) { + } catch (ActiveMQQueueExistsException qee) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -131,22 +129,18 @@ public class CreateQueueIdempotentTest extends ActiveMQTestBase { final SimpleString QUEUE = new SimpleString(queueName); session.createQueue(QUEUE, QUEUE, null, true); queuesCreated.incrementAndGet(); - } - catch (ActiveMQQueueExistsException qne) { + } catch (ActiveMQQueueExistsException qne) { failedAttempts.incrementAndGet(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (locator != null) { locator.close(); } if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java index 8edd6271cf..0daf48284e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java @@ -93,7 +93,7 @@ public class DeadLetterAddressTest extends ActiveMQTestBase { // only run this on *nix systems which will have the com.sun.management.UnixOperatingSystemMXBean (needed to check open file count) Assume.assumeTrue(os instanceof UnixOperatingSystemMXBean); - long fdBaseline = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount(); + long fdBaseline = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount(); final int SIZE = 2 * 1024; SimpleString dla = new SimpleString("DLA"); SimpleString qName = new SimpleString("q1"); @@ -228,8 +228,7 @@ public class DeadLetterAddressTest extends ActiveMQTestBase { latch.countDown(); try { clientSession.rollback(true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } throw new RuntimeException(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeliveryOrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeliveryOrderTest.java index 8b04ba418f..f93c27174f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeliveryOrderTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeliveryOrderTest.java @@ -29,8 +29,8 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -163,8 +163,7 @@ public class DeliveryOrderTest extends ActiveMQTestBase { int i = message.getBodyBuffer().readInt(); try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } if (i <= lastMessage) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DurableQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DurableQueueTest.java index ac0e67427e..85b3dd5f52 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DurableQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DurableQueueTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -31,8 +24,12 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class DurableQueueTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java index 38d4515326..0e393db94a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java @@ -26,12 +26,12 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; /** @@ -103,8 +103,7 @@ public class ExpiryLargeMessageTest extends ActiveMQTestBase { if (i % 2 == 0) { message.putBooleanProperty("tst-large", false); message.getBodyBuffer().writeBytes(bufferSample); - } - else { + } else { message.putBooleanProperty("tst-large", true); message.setBodyInputStream(createFakeLargeStream(messageSize)); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FailureDeadlockTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FailureDeadlockTest.java index d74186f887..4c6b646ad5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FailureDeadlockTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FailureDeadlockTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import javax.jms.Connection; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.Session; + import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -34,11 +39,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Session; - public class FailureDeadlockTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -85,8 +85,7 @@ public class FailureDeadlockTest extends ActiveMQTestBase { public void onException(final JMSException exception) { try { conn2.close(); - } - catch (Exception e) { + } catch (Exception e) { FailureDeadlockTest.log.error("Failed to close connection2", e); } } @@ -144,8 +143,7 @@ public class FailureDeadlockTest extends ActiveMQTestBase { try { conn1.createSession(false, Session.AUTO_ACKNOWLEDGE); Assert.fail("should throw exception"); - } - catch (JMSException e) { + } catch (JMSException e) { //pass } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FlowControlOnIgnoreLargeMessageBodyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FlowControlOnIgnoreLargeMessageBodyTest.java index c872d281d8..64cb0181fa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FlowControlOnIgnoreLargeMessageBodyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FlowControlOnIgnoreLargeMessageBodyTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - -import java.util.concurrent.CountDownLatch; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -31,9 +25,12 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSubscriber; +import java.util.concurrent.CountDownLatch; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Before; +import org.junit.Test; public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { @@ -133,22 +130,18 @@ public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { } } System.out.println("Ending producer for " + topic + " - " + getName() + " messages " + sentMessages); - } - catch (Exception e) { + } catch (Exception e) { error = true; e.printStackTrace(); - } - finally { + } finally { try { session.commit(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } try { connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -234,8 +227,7 @@ public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { if (msg == null) { System.out.println("Cannot get message in specified timeout: " + topic + " - " + getName()); error = true; - } - else { + } else { counter++; if (msg.getIntProperty(FlowControlOnIgnoreLargeMessageBodyTest.ATTR_MSG_COUNTER) != counter) { error = true; @@ -250,25 +242,21 @@ public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { receivedMessages = counter; } session.commit(); - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Exception in consumer " + getName() + " : " + e.getMessage()); e.printStackTrace(); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Cannot close session " + e.getMessage()); } } if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Cannot close connection " + e.getMessage()); } } @@ -314,8 +302,7 @@ public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { String errorMessage = null; if (producer.getSentMessages() != FlowControlOnIgnoreLargeMessageBodyTest.TOTAL_MESSAGES_COUNT) { errorMessage = "Producer did not send defined count of messages"; - } - else { + } else { for (LoadConsumer consumer : consumers) { if (consumer.getReceivedMessages() != FlowControlOnIgnoreLargeMessageBodyTest.TOTAL_MESSAGES_COUNT) { errorMessage = "Consumer did not send defined count of messages"; @@ -327,15 +314,13 @@ public class FlowControlOnIgnoreLargeMessageBodyTest extends JMSTestBase { if (errorMessage != null) { System.err.println(" ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR "); System.err.println(errorMessage); - } - else { + } else { System.out.println(" OK "); } assertFalse(error); assertNull(errorMessage); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java index 4ddabec63e..83d28a12d5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java @@ -164,8 +164,7 @@ public class HangConsumerTest extends ActiveMQTestBase { sessionProducer.close(); sessionConsumer.close(); - } - finally { + } finally { releaseConsumers(); } } @@ -301,8 +300,7 @@ public class HangConsumerTest extends ActiveMQTestBase { public void run() { try { server.destroyQueue(QUEUE); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -314,8 +312,7 @@ public class HangConsumerTest extends ActiveMQTestBase { try { server.createQueue(QUEUE, QUEUE, null, true, false); - } - catch (Exception expected) { + } catch (Exception expected) { } blocked.release(); @@ -411,8 +408,7 @@ public class HangConsumerTest extends ActiveMQTestBase { msg.acknowledge(); session.commit(); - } - finally { + } finally { hangInt.open(); } @@ -457,12 +453,10 @@ public class HangConsumerTest extends ActiveMQTestBase { if (i < 4) server.start(); } - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -524,16 +518,14 @@ public class HangConsumerTest extends ActiveMQTestBase { inCall.countDown(); try { callbackSemaphore.acquire(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { inCall.countUp(); return -1; } try { return targetCallback.sendMessage(ref, message, consumer, deliveryCount); - } - finally { + } finally { callbackSemaphore.release(); inCall.countUp(); } @@ -627,8 +619,7 @@ public class HangConsumerTest extends ActiveMQTestBase { semaphore.acquire(); semaphore.release(); reusableLatch.countUp(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java index 27baa74de1..8f089c3e26 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -34,11 +39,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - public class HeuristicXATest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -124,8 +124,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (isCommit) { jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid)); - } - else { + } else { jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid)); } @@ -133,8 +132,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (isCommit) { Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length); Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length); - } - else { + } else { Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length); Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length); } @@ -207,8 +205,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (isCommit) { jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid)); - } - else { + } else { jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid)); } @@ -242,8 +239,7 @@ public class HeuristicXATest extends ActiveMQTestBase { String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions(); Assert.assertEquals(1, listHeuristicCommittedTransactions.length); System.out.println(listHeuristicCommittedTransactions[0]); - } - else { + } else { String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions(); Assert.assertEquals(1, listHeuristicRolledBackTransactions.length); System.out.println(listHeuristicRolledBackTransactions[0]); @@ -299,8 +295,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (heuristicCommit) { jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid)); - } - else { + } else { jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid)); } @@ -335,8 +330,7 @@ public class HeuristicXATest extends ActiveMQTestBase { String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions(); Assert.assertEquals(1, listHeuristicCommittedTransactions.length); System.out.println(listHeuristicCommittedTransactions[0]); - } - else { + } else { String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions(); Assert.assertEquals(1, listHeuristicRolledBackTransactions.length); System.out.println(listHeuristicRolledBackTransactions[0]); @@ -398,8 +392,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (heuristicCommit) { jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid)); - } - else { + } else { jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid)); } @@ -412,8 +405,7 @@ public class HeuristicXATest extends ActiveMQTestBase { if (heuristicCommit) { Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length); - } - else { + } else { Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length); } @@ -428,8 +420,7 @@ public class HeuristicXATest extends ActiveMQTestBase { jmxServer = ManagementControlHelper.createActiveMQServerControl(mbeanServer); if (heuristicCommit) { Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length); - } - else { + } else { Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java index 8a2f362477..f8ac8666d7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java @@ -153,8 +153,7 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase { received.getBodyBuffer().readByte(); Assert.fail("Should throw exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { // OK } } @@ -200,8 +199,7 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase { protected ServerLocator createFactory() throws Exception { if (isNetty()) { return createNettyNonHALocator(); - } - else { + } else { return createInVMNonHALocator(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java index e2c3ae5278..a2316dfd7a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java @@ -148,16 +148,13 @@ public class IncompatibleVersionTest extends ActiveMQTestBase { assertNotNull(packet); // 1 connection on the server assertEquals(1, server.getConnectionCount()); - } - else { + } else { try { channel1.sendBlocking(request, PacketImpl.CREATESESSION_RESP); fail(); - } - catch (ActiveMQIncompatibleClientServerException icsv) { + } catch (ActiveMQIncompatibleClientServerException icsv) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } long start = System.currentTimeMillis(); @@ -200,13 +197,11 @@ public class IncompatibleVersionTest extends ActiveMQTestBase { if (client.waitFor() == 0) { result = true; } - } - finally { + } finally { if (serverProcess != null) { try { serverProcess.destroy(); - } - catch (Throwable t) { + } catch (Throwable t) { /* ignore */ } } @@ -239,8 +234,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase { ClientSession session = sf.createSession(false, true, true); log.info("### client: connected. server incrementingVersion = " + session.getVersion()); session.close(); - } - finally { + } finally { closeSessionFactory(sf); closeServerLocator(locator); } @@ -256,12 +250,10 @@ public class IncompatibleVersionTest extends ActiveMQTestBase { if (args[0].equals("server")) { ServerStarter ss = new ServerStarter(); ss.perform(args[1]); - } - else if (args[0].equals("client")) { + } else if (args[0].equals("client")) { ClientStarter cs = new ClientStarter(); cs.perform(); - } - else { + } else { throw new Exception("args[0] must be \"server\" or \"client\""); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java index f7b1c41f38..d78c0fbb72 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java @@ -185,8 +185,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { } msg.checkCompletion(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); expectedErrors.incrementAndGet(); } @@ -238,12 +237,10 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { unexpectedErrors.incrementAndGet(); return; } - } - catch (JMSException e) { + } catch (JMSException e) { log.debug("This exception was ok as it was expected", e); expectedErrors.incrementAndGet(); - } - catch (Throwable e) { + } catch (Throwable e) { log.warn("Captured unexpected exception", e); unexpectedErrors.incrementAndGet(); } @@ -380,8 +377,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { } if (h == 4) { session.commit(); - } - else { + } else { session.rollback(); } @@ -474,8 +470,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { if (start == 1) { session.commit(); - } - else { + } else { session.rollback(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java index 11b557cc89..86c0539a66 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.paging.PagingStore; -import org.apache.activemq.artemis.core.settings.impl.AddressSettings; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Before; -import org.junit.Test; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.Message; @@ -32,6 +24,14 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.paging.PagingStore; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Before; +import org.junit.Test; + /** * This will perform cleanup tests on paging while using JMS topics */ @@ -129,8 +129,7 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { assertFalse(pagingStore.isPaging()); } - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -208,8 +207,7 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { } assertEquals(1, pagingStore.getNumberOfPages()); //I expected number of the page is 1, but It was not. - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -247,4 +245,4 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { System.out.println(" Address Size = " + pagingStore.getAddressSize()); System.out.println(" Is Paging = " + pagingStore.isPaging()); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java index b7ea680e11..e394e9430f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java @@ -16,6 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; @@ -32,16 +42,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - /** * -- https://issues.jboss.org/browse/HORNETQ-746 * Stress test using netty with NIO and many JMS clients concurrently, to try @@ -169,16 +169,13 @@ public class JmsNettyNioStressTest extends ActiveMQTestBase { totalCount.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -212,16 +209,13 @@ public class JmsNettyNioStressTest extends ActiveMQTestBase { totalCount.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -248,16 +242,13 @@ public class JmsNettyNioStressTest extends ActiveMQTestBase { totalCount.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -294,4 +285,4 @@ public class JmsNettyNioStressTest extends ActiveMQTestBase { // Inner classes ------------------------------------------------- -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java index e340d38059..88bfd7a7ce 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java @@ -28,14 +28,14 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.junit.Assert; import org.junit.Test; @@ -100,8 +100,7 @@ public class JournalCrashTest extends ActiveMQTestBase { // System.out.flush(); Runtime.getRuntime().halt(100); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(System.out); System.exit(1); } @@ -112,8 +111,7 @@ public class JournalCrashTest extends ActiveMQTestBase { try { session.createQueue(QUEUE, QUEUE, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } ClientProducer prod = session.createProducer(QUEUE); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java index 6cf150a05e..70c1952b10 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java @@ -18,17 +18,17 @@ package org.apache.activemq.artemis.tests.integration.client; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.StoreConfiguration; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; @@ -225,8 +225,7 @@ public class LargeMessageAvoidLargeMessagesTest extends LargeMessageTest { ClientMessage clientFile = session.createMessage(true); if (i % 2 == 0) { clientFile.setBodyInputStream(regularInput.clone()); - } - else { + } else { clientFile.setBodyInputStream(largeInput.clone()); } @@ -250,8 +249,7 @@ public class LargeMessageAvoidLargeMessagesTest extends LargeMessageTest { byte b = msg1.getBodyBuffer().readByte(); Assert.assertEquals("incorrect char ", regularInput.getChar(i), b); } - } - else { + } else { for (int i = 0; i < largeInput.getSize(); i++) { byte b = msg1.getBodyBuffer().readByte(); Assert.assertEquals("incorrect char ", largeInput.getChar(i), b); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageCompressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageCompressTest.java index 70a9cb4fc7..c8745e167c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageCompressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageCompressTest.java @@ -25,12 +25,12 @@ import java.io.OutputStream; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.StoreConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -262,8 +262,7 @@ public class LargeMessageCompressTest extends LargeMessageTest { if (count++ < messageSize) { return ' '; - } - else { + } else { return -1; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java index cd9978f847..3577a876e2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java @@ -99,7 +99,6 @@ public class LargeMessageTest extends LargeMessageTestBase { ActiveMQServer server = createServer(true, isNetty(), storeType); - AddressSettings settings = new AddressSettings(); if (redeliveryDelay) { settings.setRedeliveryDelay(100); @@ -152,8 +151,7 @@ public class LargeMessageTest extends LargeMessageTestBase { // System.out.println("Rollback"); message.acknowledge(); session.rollback(); - } - else { + } else { message.acknowledge(); session.commit(); } @@ -161,8 +159,7 @@ public class LargeMessageTest extends LargeMessageTestBase { if (counter == 40) { latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { latch.countDown(); e.printStackTrace(); errors.incrementAndGet(); @@ -216,8 +213,7 @@ public class LargeMessageTest extends LargeMessageTestBase { try { msg1.getBodyBuffer().readByte(); Assert.fail("Exception was expected"); - } - catch (final Exception ignored) { + } catch (final Exception ignored) { // empty on purpose } @@ -852,12 +848,10 @@ public class LargeMessageTest extends LargeMessageTestBase { session.close(); validateNoFilesOnLargeDir(); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -897,8 +891,7 @@ public class LargeMessageTest extends LargeMessageTestBase { if (isSimulateBridge) { clientFile.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, someDuplicateInfo.getBytes()); - } - else { + } else { clientFile.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, someDuplicateInfo.getBytes()); } @@ -925,12 +918,10 @@ public class LargeMessageTest extends LargeMessageTestBase { validateNoFilesOnLargeDir(); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -1001,12 +992,10 @@ public class LargeMessageTest extends LargeMessageTestBase { session.close(); validateNoFilesOnLargeDir(); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -1073,12 +1062,10 @@ public class LargeMessageTest extends LargeMessageTestBase { session.close(); validateNoFilesOnLargeDir(); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -1101,7 +1088,7 @@ public class LargeMessageTest extends LargeMessageTestBase { @Test public void testFilePersistenceOneMessageStreaming() throws Exception { - testChunks(false, false, false, true, true, false, false, false, false, 1, largeMessageSize, LargeMessageTest.RECEIVE_WAIT_TIME, 0); + testChunks(false, false, false, true, true, false, false, false, false, 1, largeMessageSize, LargeMessageTest.RECEIVE_WAIT_TIME, 0); } @Test @@ -1111,7 +1098,7 @@ public class LargeMessageTest extends LargeMessageTestBase { @Test public void testFilePersistenceOneHugeMessageConsumer() throws Exception { - testChunks(false, false, false, true, true, false, false, false, true, 1, largeMessageSize, 120000, 0, 10 * 1024 * 1024, 1024 * 1024); + testChunks(false, false, false, true, true, false, false, false, true, 1, largeMessageSize, 120000, 0, 10 * 1024 * 1024, 1024 * 1024); } @Test @@ -1519,8 +1506,7 @@ public class LargeMessageTest extends LargeMessageTestBase { session = sf.createSession(isXA, false, false); session.rollback(xid); - } - else { + } else { session.rollback(); } @@ -1579,8 +1565,7 @@ public class LargeMessageTest extends LargeMessageTestBase { session.rollback(xid); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.rollback(); } @@ -1595,8 +1580,7 @@ public class LargeMessageTest extends LargeMessageTestBase { session.commit(xid, true); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.commit(); } @@ -1617,19 +1601,16 @@ public class LargeMessageTest extends LargeMessageTestBase { session.rollback(xid); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.end(xid, XAResource.TMSUCCESS); session.commit(xid, true); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); } - } - else { + } else { if (i == 0) { session.rollback(); - } - else { + } else { session.commit(); } } @@ -1702,8 +1683,7 @@ public class LargeMessageTest extends LargeMessageTestBase { } if (trans == 0) { session.rollback(); - } - else { + } else { session.commit(); } } @@ -1711,18 +1691,15 @@ public class LargeMessageTest extends LargeMessageTestBase { Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()))); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -1787,8 +1764,7 @@ public class LargeMessageTest extends LargeMessageTestBase { } if (trans == 0) { session.rollback(); - } - else { + } else { session.commit(); } @@ -1798,18 +1774,15 @@ public class LargeMessageTest extends LargeMessageTestBase { Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()))); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -2094,22 +2067,18 @@ public class LargeMessageTest extends LargeMessageTestBase { Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()))); - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); throw t; - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -2167,18 +2136,15 @@ public class LargeMessageTest extends LargeMessageTestBase { Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()))); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -2248,18 +2214,15 @@ public class LargeMessageTest extends LargeMessageTestBase { Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()))); - } - finally { + } finally { try { session.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java index f54f509c65..631507029d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java @@ -17,9 +17,8 @@ package org.apache.activemq.artemis.tests.integration.client; import org.apache.activemq.artemis.jlibaio.LibaioContext; -import org.junit.Test; - import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Test; /** * This tests is placed in duplication here to validate that the libaio module is properly loaded on this diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageBufferTest.java index 2b6b26ec91..62713a36ed 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageBufferTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageBufferTest.java @@ -58,7 +58,7 @@ public class MessageBufferTest extends ActiveMQTestBase { session.createQueue(addressName, queueName); ClientProducer producer = session.createProducer(addressName); - ClientMessageImpl message = (ClientMessageImpl)session.createMessage(true); + ClientMessageImpl message = (ClientMessageImpl) session.createMessage(true); message.getBodyBuffer().writeString(data); for (int i = 0; i < 100; i++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConcurrencyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConcurrencyTest.java index c277e0d9a1..6d67fca44f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConcurrencyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConcurrencyTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -31,11 +36,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Before; import org.junit.Test; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - public class MessageConcurrencyTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -215,8 +215,7 @@ public class MessageConcurrencyTest extends ActiveMQTestBase { producer.send(msg); } - } - catch (Exception e) { + } catch (Exception e) { log.error("Failed to send message", e); failed = true; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConsumerRollbackTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConsumerRollbackTest.java index b4a3843b89..99c16ff6b2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConsumerRollbackTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageConsumerRollbackTest.java @@ -28,10 +28,10 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; @@ -221,18 +221,15 @@ public class MessageConsumerRollbackTest extends ActiveMQTestBase { if (counter.incrementAndGet() % 200 == 0) { System.out.println("rollback " + message); session.rollback(); - } - else { + } else { commitLatch.countDown(); session.commit(); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); try { session.rollback(); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageCounterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageCounterTest.java index a847b78d86..1e094c3b32 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageCounterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageCounterTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -31,6 +25,9 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class MessageCounterTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java index f6e455c971..5a557a36e1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java @@ -69,11 +69,9 @@ public class MessageDurabilityTest extends ActiveMQTestBase { session.start(); try { session.createConsumer(queue); - } - catch (ActiveMQNonExistentQueueException neqe) { + } catch (ActiveMQNonExistentQueueException neqe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageExpirationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageExpirationTest.java index 9fd6b24045..b60c293b85 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageExpirationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageExpirationTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -35,6 +29,9 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class MessageExpirationTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java index 282014f2f0..0f7e9f67ab 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -32,10 +36,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class MessageGroupingConnectionFactoryTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -135,8 +135,7 @@ public class MessageGroupingConnectionFactoryTest extends ActiveMQTestBase { if (acknowledge) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java index 03fcd03daf..3d916b67e4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; @@ -37,12 +43,6 @@ import org.junit.Assume; import org.junit.Before; import org.junit.Test; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class MessageGroupingTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -132,8 +132,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { Assert.assertNotEquals("You shouldn't have all messages bound to a single consumer", 30, count); Assert.assertNotEquals("But you shouldn't have also a single consumer bound to none", 0, count); } - } - finally { + } finally { consumer1.close(); consumer2.close(); consumer3.close(); @@ -183,8 +182,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -220,8 +218,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -262,8 +259,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -317,8 +313,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -384,8 +379,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -439,8 +433,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -505,8 +498,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { ClientMessage message = createTextMessage(clientSession, "m" + i); if (i % 2 == 0 || i == 0) { message.putStringProperty(Message.HDR_GROUP_ID, groupId); - } - else { + } else { message.putStringProperty(Message.HDR_GROUP_ID, groupId2); } clientProducer.send(message); @@ -566,8 +558,7 @@ public class MessageGroupingTest extends ActiveMQTestBase { if (acknowledge) { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageHandlerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageHandlerTest.java index cdc0c44397..d3543212b2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageHandlerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageHandlerTest.java @@ -16,15 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,6 +30,9 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class MessageHandlerTest extends ActiveMQTestBase { @@ -94,8 +91,7 @@ public class MessageHandlerTest extends ActiveMQTestBase { Thread.sleep(10); message.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -179,8 +175,7 @@ public class MessageHandlerTest extends ActiveMQTestBase { consumer.setMessageHandler(null); } - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -267,8 +262,7 @@ public class MessageHandlerTest extends ActiveMQTestBase { consumer.setMessageHandler(null); } - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -347,8 +341,7 @@ public class MessageHandlerTest extends ActiveMQTestBase { consumer.setMessageHandler(null); } - } - catch (Exception e) { + } catch (Exception e) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageRateTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageRateTest.java index c581f1ab65..b42f9923f8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageRateTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageRateTest.java @@ -177,8 +177,7 @@ public class MessageRateTest extends ActiveMQTestBase { try { message.acknowledge(); messages.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); // Hudson report failures.incrementAndGet(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleProducersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleProducersTest.java index a98ff74811..a750312e2a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleProducersTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleProducersTest.java @@ -94,9 +94,8 @@ public class MultipleProducersTest extends JMSTestBase { while (true) { sendMessage(queueOne, session); } - } - catch (Throwable t) { -// t.printStackTrace(); + } catch (Throwable t) { + // t.printStackTrace(); // expected } @@ -115,8 +114,7 @@ public class MultipleProducersTest extends JMSTestBase { try { sendMessage(queueOne, session); Assert.fail("Exception expected"); - } - catch (Exception t) { + } catch (Exception t) { } // send 5 message to queueTwo @@ -163,8 +161,7 @@ public class MultipleProducersTest extends JMSTestBase { mp.setTimeToLive(Message.DEFAULT_TIME_TO_LIVE); mp.send(session.createTextMessage("This is message for " + queue.getQueueName())); - } - finally { + } finally { mp.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java index b342dea76b..d74f16b9dd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java @@ -16,14 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Assert; -import org.junit.Test; - import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -33,6 +29,9 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; /** * Multiple Threads producing Messages, with Multiple Consumers with different queues, each queue with a different filter @@ -83,17 +82,14 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { public void run() { try { sendMessages(numberOfMessages / 2); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { try { prodSession.close(); locator.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -165,12 +161,10 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { Assert.assertNull(consumer.receiveImmediate()); consumerSession.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { close(); } @@ -183,8 +177,7 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { try { consumerSession.close(); locator.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } } @@ -217,8 +210,7 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { if (isPaging) { server = createServer(true, createDefaultConfig(isNetty), PAGE_SIZE, PAGE_MAX, new HashMap()); - } - else { + } else { server = createServer(true, isNetty); } @@ -271,8 +263,7 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { waitForNotPaging(server.locateQueue(new SimpleString("Q1"))); - } - finally { + } finally { server.stop(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java index 54d7ca7381..af60428c09 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,12 +42,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - public class NIOvsOIOTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -203,8 +203,7 @@ public class NIOvsOIOTest extends ActiveMQTestBase { for (int i = 0; i < numMessages; i++) { try { producer.send(msg); - } - catch (Exception e) { + } catch (Exception e) { log.error("Caught exception", e); } @@ -272,8 +271,7 @@ public class NIOvsOIOTest extends ActiveMQTestBase { public void onMessage(ClientMessage msg) { try { msg.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { log.error("Caught exception", e); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/OrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/OrderTest.java index c87dbb069e..cf3f880572 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/OrderTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/OrderTest.java @@ -25,9 +25,9 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java index eab43cf5df..9b9362951f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -40,13 +47,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - public class ProducerFlowControlTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -245,8 +245,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { Thread.sleep(consumerDelay); } - } - catch (Exception e) { + } catch (Exception e) { ProducerFlowControlTest.log.error("Failed to handle message", e); exception = e; @@ -271,8 +270,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { for (int i = 0; i < numProducers; i++) { if (anon) { producers[i] = session.createProducer(); - } - else { + } else { producers[i] = session.createProducer(address); } } @@ -287,8 +285,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { for (int j = 0; j < numProducers; j++) { if (anon) { producers[j].send(address, message); - } - else { + } else { producers[j].send(message); } @@ -350,8 +347,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { closed.set(true); session.close(); - } - catch (Exception e) { + } catch (Exception e) { } } }); @@ -363,8 +359,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { for (int i = 0; i < 10; i++) { producer.send(message); } - } - catch (ActiveMQObjectClosedException expected) { + } catch (ActiveMQObjectClosedException expected) { } Assert.assertTrue(closed.get()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java index 69285a42b3..c409d5fb3b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java @@ -112,8 +112,7 @@ public class ProducerTest extends ActiveMQTestBase { msg.getBodyBuffer().writeBytes(new byte[1024]); producer.send(QUEUE, msg); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/QueueBrowserTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/QueueBrowserTest.java index 2aba9256f3..beabef9061 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/QueueBrowserTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/QueueBrowserTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -32,6 +25,10 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class QueueBrowserTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java index c025174701..42b3549751 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java @@ -16,14 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,6 +30,9 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ReceiveImmediateTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveTest.java index 95e7435db6..dfe8f5ad99 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveTest.java @@ -27,8 +27,8 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -94,11 +94,9 @@ public class ReceiveTest extends ActiveMQTestBase { try { cc.receive(); Assert.fail("should throw exception"); - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -120,11 +118,9 @@ public class ReceiveTest extends ActiveMQTestBase { try { cc.receive(); Assert.fail("should throw exception"); - } - catch (ActiveMQIllegalStateException ise) { + } catch (ActiveMQIllegalStateException ise) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RedeliveryConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RedeliveryConsumerTest.java index f2e64b79c2..cfe6fa91a7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RedeliveryConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RedeliveryConsumerTest.java @@ -28,11 +28,11 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; @@ -159,8 +159,7 @@ public class RedeliveryConsumerTest extends ActiveMQTestBase { session = factory.createSession(false, false, false); session.start(); consumer = session.createConsumer(ADDRESS); - } - else { + } else { session.rollback(); } } @@ -323,8 +322,7 @@ public class RedeliveryConsumerTest extends ActiveMQTestBase { ClientSession session = addClientSession(factory.createSession(false, false, false)); try { session.createQueue(ADDRESS, ADDRESS, true); - } - catch (ActiveMQException expected) { + } catch (ActiveMQException expected) { // in case of restart } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java index 43119cc07a..68e178465a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java @@ -271,8 +271,7 @@ public class RequestorTest extends ActiveMQTestBase { ClientProducer replyProducer = session.createProducer(replyTo); replyProducer.send(reply); request.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java index 8e4314cfa0..cc6d95d7e8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java @@ -23,8 +23,8 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -165,11 +165,9 @@ public class RoutingTest extends ActiveMQTestBase { ClientMessage clientMessage = sendSession.createMessage(false); if (i % 3 == 0) { clientMessage.putStringProperty(new SimpleString("foo"), new SimpleString("bar")); - } - else if (i % 3 == 1) { + } else if (i % 3 == 1) { clientMessage.putIntProperty(new SimpleString("x"), 1); - } - else { + } else { clientMessage.putBooleanProperty(new SimpleString("b"), false); } p.send(clientMessage); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java index d613f8b812..aff0475ca7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java @@ -119,8 +119,7 @@ public class SelfExpandingBufferTest extends ActiveMQTestBase { msg2.getBodyBuffer().readBytes(receivedBytes); ActiveMQTestBase.assertEqualsByteArrays(bytes, receivedBytes); - } - finally { + } finally { session.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ServerLocatorConnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ServerLocatorConnectTest.java index 257592e6cd..0304174304 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ServerLocatorConnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ServerLocatorConnectTest.java @@ -118,11 +118,9 @@ public class ServerLocatorConnectTest extends ActiveMQTestBase { ClientSessionFactoryInternal csf = null; try { csf = locator.connect(); - } - catch (ActiveMQNotConnectedException nce) { + } catch (ActiveMQNotConnectedException nce) { //ok - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQException); fail("Invalid Exception type:" + ((ActiveMQException) e).getType()); } @@ -165,8 +163,7 @@ public class ServerLocatorConnectTest extends ActiveMQTestBase { public void run() { try { csf = locator.connect(); - } - catch (Exception e) { + } catch (Exception e) { this.e = e; } latch.countDown(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java index 559cc0ab63..5d32fc1274 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java @@ -16,7 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import static org.apache.activemq.artemis.tests.util.RandomUtil.randomXid; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; @@ -34,8 +35,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; +import static org.apache.activemq.artemis.tests.util.RandomUtil.randomXid; public class SessionCloseTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionClosedOnRemotingConnectionFailureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionClosedOnRemotingConnectionFailureTest.java index 8c80988a84..9b0f36a8d8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionClosedOnRemotingConnectionFailureTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionClosedOnRemotingConnectionFailureTest.java @@ -73,11 +73,9 @@ public class SessionClosedOnRemotingConnectionFailureTest extends ActiveMQTestBa prod.send(session.createMessage(false)); Assert.fail("Should throw exception"); - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -85,11 +83,9 @@ public class SessionClosedOnRemotingConnectionFailureTest extends ActiveMQTestBa cons.receive(); Assert.fail("Should throw exception"); - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateAndDeleteQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateAndDeleteQueueTest.java index 5f5d2dedce..4d6dde3c3e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateAndDeleteQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateAndDeleteQueueTest.java @@ -127,11 +127,9 @@ public class SessionCreateAndDeleteQueueTest extends ActiveMQTestBase { try { session.deleteQueue(queueName); Assert.fail("should throw exception"); - } - catch (ActiveMQNonExistentQueueException neqe) { + } catch (ActiveMQNonExistentQueueException neqe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateConsumerTest.java index 4d0697379c..8d40d4c68e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateConsumerTest.java @@ -63,11 +63,9 @@ public class SessionCreateConsumerTest extends ActiveMQTestBase { try { clientSession.createConsumer(queueName); Assert.fail("should throw exception"); - } - catch (ActiveMQNonExistentQueueException neqe) { + } catch (ActiveMQNonExistentQueueException neqe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -85,11 +83,9 @@ public class SessionCreateConsumerTest extends ActiveMQTestBase { try { clientSession.createConsumer(queueName, "this is not valid filter"); Assert.fail("should throw exception"); - } - catch (ActiveMQInvalidFilterExpressionException ifee) { + } catch (ActiveMQInvalidFilterExpressionException ifee) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateProducerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateProducerTest.java index a8f7e05431..8ca40b83bc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateProducerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCreateProducerTest.java @@ -21,9 +21,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -72,11 +72,9 @@ public class SessionCreateProducerTest extends ActiveMQTestBase { try { clientSession.createProducer(); Assert.fail("should throw exception"); - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionFactoryTest.java index 60708ae18f..b7f6b7b8cf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionFactoryTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.Arrays; + import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -33,8 +35,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.Arrays; - public class SessionFactoryTest extends ActiveMQTestBase { private final DiscoveryGroupConfiguration groupConfiguration = new DiscoveryGroupConfiguration().setBroadcastEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(getUDPDiscoveryAddress()).setGroupPort(getUDPDiscoveryPort())); @@ -169,148 +169,127 @@ public class SessionFactoryTest extends ActiveMQTestBase { try { cf.getServerLocator().setClientFailureCheckPeriod(clientFailureCheckPeriod); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setConnectionTTL(connectionTTL); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setCallTimeout(callTimeout); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setMinLargeMessageSize(minLargeMessageSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setConsumerWindowSize(consumerWindowSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setConsumerMaxRate(consumerMaxRate); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setConfirmationWindowSize(confirmationWindowSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setProducerMaxRate(producerMaxRate); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setBlockOnAcknowledge(blockOnAcknowledge); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setBlockOnDurableSend(blockOnDurableSend); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setBlockOnNonDurableSend(blockOnNonDurableSend); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setAutoGroup(autoGroup); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setPreAcknowledge(preAcknowledge); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setAckBatchSize(ackBatchSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setUseGlobalPools(useGlobalPools); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setThreadPoolMaxSize(threadPoolMaxSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setRetryInterval(retryInterval); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setRetryIntervalMultiplier(retryIntervalMultiplier); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.getServerLocator().setReconnectAttempts(reconnectAttempts); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } @@ -365,8 +344,7 @@ public class SessionFactoryTest extends ActiveMQTestBase { final int reconnectAttempts) { if (staticConnectors == null) { Assert.assertTrue("no static connectors", Arrays.equals(new String[]{}, locator.getStaticTransportConfigurations())); - } - else { + } else { assertEqualsTransportConfigurations(staticConnectors, locator.getStaticTransportConfigurations()); } Assert.assertEquals(locator.getDiscoveryGroupConfiguration(), discoveryGroupConfiguration); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionSendAcknowledgementHandlerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionSendAcknowledgementHandlerTest.java index 689446ea33..95ef668fd7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionSendAcknowledgementHandlerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionSendAcknowledgementHandlerTest.java @@ -66,8 +66,7 @@ public class SessionSendAcknowledgementHandlerTest extends ActiveMQTestBase { public void sendAcknowledged(Message message) { } }); - } - catch (Throwable expected) { + } catch (Throwable expected) { failed = true; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionStopStartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionStopStartTest.java index 5b1de42ab2..afc7a1ce0f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionStopStartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionStopStartTest.java @@ -16,15 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.junit.Before; - -import org.junit.Test; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,6 +30,9 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class SessionStopStartTest extends ActiveMQTestBase { @@ -193,8 +190,7 @@ public class SessionStopStartTest extends ActiveMQTestBase { } latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -274,8 +270,7 @@ public class SessionStopStartTest extends ActiveMQTestBase { consumer.setMessageHandler(null); } - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -288,8 +283,7 @@ public class SessionStopStartTest extends ActiveMQTestBase { try { session.stop(); - } - catch (Exception e) { + } catch (Exception e) { SessionStopStartTest.log.warn(e.getMessage(), e); throw e; } @@ -378,8 +372,7 @@ public class SessionStopStartTest extends ActiveMQTestBase { started = false; } - } - catch (Exception e) { + } catch (Exception e) { } } } @@ -473,8 +466,7 @@ public class SessionStopStartTest extends ActiveMQTestBase { started = false; } - } - catch (Exception e) { + } catch (Exception e) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionTest.java index f85fe84109..2f72d8b9a5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionTest.java @@ -30,13 +30,13 @@ import org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.SessionFailureListener; -import org.apache.activemq.artemis.tests.util.CountDownSessionFailureListener; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.CountDownSessionFailureListener; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -106,8 +106,7 @@ public class SessionTest extends ActiveMQTestBase { clientSession.close(); server.stop(); Assert.assertFalse(listener.called); - } - finally { + } finally { ((ClientSessionFactoryInternal) cf).causeExit(); cf.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SlowConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SlowConsumerTest.java index 788a810811..a2d60d98c0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SlowConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SlowConsumerTest.java @@ -112,8 +112,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { try { consumer.receiveImmediate(); fail(); - } - catch (ActiveMQObjectClosedException e) { + } catch (ActiveMQObjectClosedException e) { assertEquals(e.getType(), ActiveMQExceptionType.OBJECT_CLOSED); } } @@ -144,10 +143,9 @@ public class SlowConsumerTest extends ActiveMQTestBase { assertTrue(connections.isEmpty()); if (sf instanceof ClientSessionFactoryImpl) { - int reconnectAttemps = ((ClientSessionFactoryImpl)sf).getReconnectAttempts(); + int reconnectAttemps = ((ClientSessionFactoryImpl) sf).getReconnectAttempts(); assertEquals(0, reconnectAttemps); - } - else { + } else { fail("ClientSessionFactory is not the instance of ClientSessionFactoryImpl"); } } @@ -190,8 +188,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { assertEquals(Integer.valueOf(1), message.getIntProperty(ManagementHelper.HDR_CONSUMER_COUNT)); if (isNetty) { assertTrue(message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString().startsWith("/127.0.0.1")); - } - else { + } else { assertEquals(SimpleString.toSimpleString("invm:0"), message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); } assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME)); @@ -199,8 +196,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME)); try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } notifLatch.countDown(); @@ -266,8 +262,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { try { producer.send(m); messagesProduced.incrementAndGet(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); return; } @@ -281,8 +276,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { producer.send(m); messagesProduced.incrementAndGet(); Thread.sleep(1000); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return; } @@ -346,8 +340,7 @@ public class SlowConsumerTest extends ActiveMQTestBase { try { consumer.receiveImmediate(); fail(); - } - catch (ActiveMQObjectClosedException e) { + } catch (ActiveMQObjectClosedException e) { assertEquals(e.getType(), ActiveMQExceptionType.OBJECT_CLOSED); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java index a25805cd15..86d32bd8ba 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; @@ -48,11 +53,6 @@ import org.apache.activemq.artemis.tests.util.SingleServerTestBase; import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Test; -import java.util.Arrays; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class TemporaryQueueTest extends SingleServerTestBase { // Constants ----------------------------------------------------- @@ -190,11 +190,9 @@ public class TemporaryQueueTest extends SingleServerTestBase { try { session.createConsumer(queue); fail("temp queue must not exist after the remoting connection is closed"); - } - catch (ActiveMQNonExistentQueueException neqe) { + } catch (ActiveMQNonExistentQueueException neqe) { //ol - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -378,8 +376,7 @@ public class TemporaryQueueTest extends SingleServerTestBase { log.warn("Unexpected color " + message.getStringProperty("color") + " when we were expecting " + color); errors.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.getMessage(), e); errors.incrementAndGet(); } @@ -437,8 +434,7 @@ public class TemporaryQueueTest extends SingleServerTestBase { assertEquals(0, errors.get()); - } - finally { + } finally { localSession.close(); clientsConnecton.close(); } @@ -553,8 +549,7 @@ public class TemporaryQueueTest extends SingleServerTestBase { prod.send(msg); msgs.incrementAndGet(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -575,8 +570,7 @@ public class TemporaryQueueTest extends SingleServerTestBase { while (t.isAlive() && errors.get() == 0 && (!prod.getProducerCredits().isBlocked() || blockedTime < 60)) { if (prod.getProducerCredits().isBlocked()) { blockedTime++; - } - else { + } else { blockedTime = 0; } Thread.sleep(100); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TransientQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TransientQueueTest.java index 8b45ef18bc..e9acf3cef5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TransientQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TransientQueueTest.java @@ -150,8 +150,7 @@ public class TransientQueueTest extends SingleServerTestBase { try { // There's already a queue with that name, we are supposed to throw an exception session2.createSharedQueue(address2, queue, false); - } - catch (ActiveMQInvalidTransientQueueUseException e) { + } catch (ActiveMQInvalidTransientQueueUseException e) { exHappened = true; } @@ -162,8 +161,7 @@ public class TransientQueueTest extends SingleServerTestBase { try { // There's already a queue with that name, we are supposed to throw an exception session2.createSharedQueue(address, queue, SimpleString.toSimpleString("a=1"), false); - } - catch (ActiveMQInvalidTransientQueueUseException e) { + } catch (ActiveMQInvalidTransientQueueUseException e) { exHappened = true; } @@ -181,8 +179,7 @@ public class TransientQueueTest extends SingleServerTestBase { try { // There's already a queue with that name, we are supposed to throw an exception session2.createSharedQueue(address, queue, SimpleString.toSimpleString("q=2"), false); - } - catch (ActiveMQInvalidTransientQueueUseException e) { + } catch (ActiveMQInvalidTransientQueueUseException e) { exHappened = true; } @@ -192,8 +189,7 @@ public class TransientQueueTest extends SingleServerTestBase { try { // There's already a queue with that name, we are supposed to throw an exception session2.createSharedQueue(address, queue, false); - } - catch (ActiveMQInvalidTransientQueueUseException e) { + } catch (ActiveMQInvalidTransientQueueUseException e) { exHappened = true; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java index 7863043a1d..956b8bd3af 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.clientcrash; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; -import org.junit.Before; - -import org.junit.Test; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -32,6 +26,10 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; +import org.junit.Before; +import org.junit.Test; /** * A test that makes sure that an ActiveMQ Artemis server cleans up the associated diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java index 42ea2c5fa1..0be37b9aa4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java @@ -16,13 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.clientcrash; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; - -import org.junit.Assert; - import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; public abstract class ClientTestBase extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient.java index b006790dc5..6f5d1c67f9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient.java @@ -19,15 +19,15 @@ package org.apache.activemq.artemis.tests.integration.clientcrash; import java.util.Arrays; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; /** * Code to be run in an external VM, via main() @@ -59,8 +59,7 @@ public class CrashClient { // exit without closing the session properly System.exit(9); - } - catch (Throwable t) { + } catch (Throwable t) { CrashClient.log.error(t.getMessage(), t); System.exit(1); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient2.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient2.java index f83a941912..bd5a0d4132 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient2.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/CrashClient2.java @@ -19,12 +19,12 @@ package org.apache.activemq.artemis.tests.integration.clientcrash; import java.util.Arrays; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; @@ -73,8 +73,7 @@ public class CrashClient2 { // exit without closing the session properly System.exit(9); - } - catch (Throwable t) { + } catch (Throwable t) { log.error(t.getMessage(), t); System.exit(1); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptorB.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptorB.java index 998e3b4e80..81ef047f30 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptorB.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptorB.java @@ -20,9 +20,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; public class DummyInterceptorB implements Interceptor { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/GracefulClient.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/GracefulClient.java index d57cf22f2b..bec01f2d4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/GracefulClient.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/GracefulClient.java @@ -17,12 +17,12 @@ package org.apache.activemq.artemis.tests.integration.clientcrash; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; @@ -64,8 +64,7 @@ public class GracefulClient { // this should silence any non-daemon thread and allow for graceful exit session.close(); System.exit(0); - } - catch (Throwable t) { + } catch (Throwable t) { GracefulClient.log.error(t.getMessage(), t); System.exit(1); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java index fa497804b1..f9079452fa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/PendingDeliveriesTest.java @@ -37,7 +37,6 @@ import org.junit.Test; public class PendingDeliveriesTest extends ClientTestBase { - @Before public void createQueue() throws Exception { server.createQueue(SimpleString.toSimpleString("jms.queue.queue1"), SimpleString.toSimpleString("jms.queue.queue1"), null, true, false); @@ -60,12 +59,10 @@ public class PendingDeliveriesTest extends ClientTestBase { System.exit(-1); } - String uri = arg[0]; String destinationName = arg[1]; boolean cleanShutdown = Boolean.valueOf(arg[2]); - ConnectionFactory factory; factory = createCF(uri); @@ -93,21 +90,18 @@ public class PendingDeliveriesTest extends ClientTestBase { System.exit(0); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } - } private static ConnectionFactory createCF(String uri) { ConnectionFactory factory; if (uri.startsWith("amqp")) { factory = new JmsConnectionFactory(uri); - } - else { + } else { factory = new ActiveMQConnectionFactory(uri); } return factory; @@ -134,20 +128,18 @@ public class PendingDeliveriesTest extends ClientTestBase { for (int i = 0; i < 100; i++) { Assert.assertNotNull(consumer.receive(1000)); } - } - finally { + } finally { connection.stop(); connection.close(); } if (cf instanceof ActiveMQConnectionFactory) { - ((ActiveMQConnectionFactory)cf).close(); + ((ActiveMQConnectionFactory) cf).close(); } } - @Test public void testWithtReconnect() throws Exception { startClient(CORE_URI_WITH_RECONNECT, "queue1", true, false); @@ -168,15 +160,13 @@ public class PendingDeliveriesTest extends ClientTestBase { } Assert.assertTrue(i < 100); - } - finally { + } finally { connection.stop(); connection.close(); } } - @Test public void testCleanShutdownNoLogger() throws Exception { AssertionLoggerHandler.startCapture(); @@ -192,13 +182,15 @@ public class PendingDeliveriesTest extends ClientTestBase { Assert.assertTrue(AssertionLoggerHandler.findText(1000, "clearing up resources")); } - @Test public void testCleanShutdown() throws Exception { } - private void startClient(String uriToUse, String destinationName, boolean log, boolean cleanShutdown) throws Exception { + private void startClient(String uriToUse, + String destinationName, + boolean log, + boolean cleanShutdown) throws Exception { Process process = SpawnedVMSupport.spawnVM(PendingDeliveriesTest.class.getName(), log, uriToUse, destinationName, Boolean.toString(cleanShutdown)); Assert.assertEquals(0, process.waitFor()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java index 0d52d05763..91857ef095 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java @@ -71,8 +71,7 @@ public class ClusterControllerTest extends ClusterTestBase { try { clusterControl.authorize(); fail("should throw ActiveMQClusterSecurityException"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue("should throw ActiveMQClusterSecurityException", e instanceof ActiveMQClusterSecurityException); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerAction.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerAction.java index ee0bee600c..8ade9eed4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerAction.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerAction.java @@ -121,8 +121,7 @@ public class NodeManagerAction { nodeManager.start(); try { nodeManagerAction.performWork(nodeManager); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); System.exit(9); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java index 4cba6bc6e4..450c1a99e7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java @@ -138,8 +138,7 @@ public class NodeManagerTest extends ActiveMQTestBase { for (Thread thread : threads) { try { thread.join(5000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // } if (thread.isAlive()) { @@ -171,8 +170,7 @@ public class NodeManagerTest extends ActiveMQTestBase { public void run() { try { action.performWork(manager); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java index dc7a62e96e..34849321d7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java @@ -20,10 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.apache.activemq.artemis.utils.UUID; import org.junit.Assert; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java index 03a1b6d477..e8da0588d4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.bridge; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; @@ -45,11 +50,6 @@ import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class BridgeReconnectTest extends BridgeTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeStartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeStartTest.java index 99ece872a3..29cb8e6492 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeStartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeStartTest.java @@ -25,20 +25,20 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.cluster.Bridge; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -79,8 +79,7 @@ public class BridgeStartTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params); @@ -201,8 +200,7 @@ public class BridgeStartTest extends ActiveMQTestBase { sf0.close(); sf1.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } @@ -226,8 +224,7 @@ public class BridgeStartTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params); @@ -392,8 +389,7 @@ public class BridgeStartTest extends ActiveMQTestBase { sf0.close(); locator.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } @@ -412,8 +408,7 @@ public class BridgeStartTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, false, server1Params); @@ -523,8 +518,7 @@ public class BridgeStartTest extends ActiveMQTestBase { sf0.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } @@ -544,8 +538,7 @@ public class BridgeStartTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, false, server1Params); @@ -702,8 +695,7 @@ public class BridgeStartTest extends ActiveMQTestBase { session0.close(); sf0.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java index b8d746cec8..e976664b4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java @@ -50,11 +50,11 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.artemis.core.postoffice.DuplicateIDCache; @@ -118,8 +118,7 @@ public class BridgeTest extends ActiveMQTestBase { private String getConnector() { if (isNetty()) { return NETTY_CONNECTOR_FACTORY; - } - else { + } else { return INVM_CONNECTOR_FACTORY; } } @@ -250,7 +249,6 @@ public class BridgeTest extends ActiveMQTestBase { System.out.println(timeTaken + "ms"); } - public void internaltestSimpleBridge(final boolean largeMessage, final boolean useFiles) throws Exception { Map server0Params = new HashMap<>(); server0 = createClusteredServerWithParams(isNetty(), 0, useFiles, server0Params); @@ -393,8 +391,7 @@ public class BridgeTest extends ActiveMQTestBase { IntegrationTestLogger.LOGGER.info("IGNORED: " + packet); latch.countDown(); return false; - } - else { + } else { IntegrationTestLogger.LOGGER.info(packet); return true; } @@ -521,8 +518,7 @@ public class BridgeTest extends ActiveMQTestBase { private void addTargetParameters(final Map server1Params) { if (isNetty()) { server1Params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1); } } @@ -767,8 +763,7 @@ public class BridgeTest extends ActiveMQTestBase { try { session1.createQueue(forwardAddress, queueName1); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -899,8 +894,7 @@ public class BridgeTest extends ActiveMQTestBase { try { session1.createQueue(forwardAddress, queueName1); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -1145,8 +1139,7 @@ public class BridgeTest extends ActiveMQTestBase { sf.close(); locator.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -1188,8 +1181,7 @@ public class BridgeTest extends ActiveMQTestBase { if (i % 100 == 0) { message.setPriority((byte) (RandomUtil.randomPositiveInt() % 9)); - } - else { + } else { message.setPriority((byte) 5); } @@ -1198,18 +1190,15 @@ public class BridgeTest extends ActiveMQTestBase { producer.send(message); assertTrue(semop.tryAcquire(1, 10, TimeUnit.SECONDS)); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(System.out); errors.incrementAndGet(); - } - finally { + } finally { try { session.close(); sf.close(); locator.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { errors.incrementAndGet(); } } @@ -1233,19 +1222,16 @@ public class BridgeTest extends ActiveMQTestBase { assertEquals(0, errors.get()); } - } - finally { + } finally { try { server0.stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } try { server1.stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -1401,8 +1387,7 @@ public class BridgeTest extends ActiveMQTestBase { if (msgCount == null) { System.err.println("Msg " + i + " wasn't received"); failed = true; - } - else if (msgCount.get() > 1) { + } else if (msgCount.get() > 1) { System.err.println("msg " + i + " was received " + msgCount.get() + " times"); failed = true; } @@ -1419,21 +1404,18 @@ public class BridgeTest extends ActiveMQTestBase { sf1.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } try { server0.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server1.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1474,8 +1456,7 @@ public class BridgeTest extends ActiveMQTestBase { System.out.println("Stopping server"); latch.countDown(); serverToStop.stop(false); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1485,8 +1466,7 @@ public class BridgeTest extends ActiveMQTestBase { latch.await(); return true; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1606,21 +1586,18 @@ public class BridgeTest extends ActiveMQTestBase { sf1.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } try { server0.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server1.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1663,17 +1640,7 @@ public class BridgeTest extends ActiveMQTestBase { int minLargeMessageSize = 1024 * 1024; - BridgeConfiguration bridgeConfiguration = new BridgeConfiguration() - .setName("bridge1") - .setQueueName(queueName0) - .setForwardingAddress(forwardAddress) - .setRetryInterval(1000) - .setReconnectAttemptsOnSameNode(-1) - .setUseDuplicateDetection(false) - .setConfirmationWindowSize(1024) - .setStaticConnectors(staticConnectors) - .setMinLargeMessageSize(minLargeMessageSize) - .setProducerWindowSize(minLargeMessageSize / 2); + BridgeConfiguration bridgeConfiguration = new BridgeConfiguration().setName("bridge1").setQueueName(queueName0).setForwardingAddress(forwardAddress).setRetryInterval(1000).setReconnectAttemptsOnSameNode(-1).setUseDuplicateDetection(false).setConfirmationWindowSize(1024).setStaticConnectors(staticConnectors).setMinLargeMessageSize(minLargeMessageSize).setProducerWindowSize(minLargeMessageSize / 2); List bridgeConfigs = new ArrayList<>(); bridgeConfigs.add(bridgeConfiguration); @@ -1684,9 +1651,7 @@ public class BridgeTest extends ActiveMQTestBase { queueConfigs0.add(queueConfig0); server0.getConfiguration().setQueueConfigurations(queueConfigs0); - CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration() - .setAddress(forwardAddress) - .setName(queueName1); + CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName1); List queueConfigs1 = new ArrayList<>(); queueConfigs1.add(queueConfig1); server1.getConfiguration().setQueueConfigurations(queueConfigs1); @@ -1763,21 +1728,18 @@ public class BridgeTest extends ActiveMQTestBase { sf1.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } try { server0.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { server1.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1971,8 +1933,7 @@ public class BridgeTest extends ActiveMQTestBase { if (count == null) { count = new AtomicInteger(1); messageRefCounts.put(ref.refEncoding.queueID, count); - } - else { + } else { count.incrementAndGet(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java index a05bcbe6d7..d87c0e358a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java @@ -20,7 +20,6 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; @@ -28,6 +27,7 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnector; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.NodeManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.InVMNodeManagerServer; import org.junit.After; @@ -57,8 +57,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { params.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + id); tc = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params); - } - else { + } else { params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, id); tc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params); } @@ -69,8 +68,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { ActiveMQServer server; if (nodeManager == null) { server = ActiveMQServers.newActiveMQServer(serviceConf, true); - } - else { + } else { server = new InVMNodeManagerServer(serviceConf, nodeManager); } @@ -88,8 +86,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { params.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + id); tc = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params); - } - else { + } else { params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, id); tc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params); } @@ -101,8 +98,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase { ActiveMQServer server; if (nodeManager == null) { server = ActiveMQServers.newActiveMQServer(serviceConf, true); - } - else { + } else { server = new InVMNodeManagerServer(serviceConf, nodeManager); } return addServer(server); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java index b09d355dad..bf67e0798a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeWithDiscoveryGroupStartTest.java @@ -28,12 +28,12 @@ import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; @@ -76,8 +76,7 @@ public class BridgeWithDiscoveryGroupStartTest extends ActiveMQTestBase { Map server1Params = new HashMap<>(); if (isNetty()) { server1Params.put("port", TransportConstants.DEFAULT_PORT + 1); - } - else { + } else { server1Params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, 1); } ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params); @@ -209,8 +208,7 @@ public class BridgeWithDiscoveryGroupStartTest extends ActiveMQTestBase { sf0.close(); sf1.close(); - } - finally { + } finally { if (locator != null) { locator.close(); } @@ -227,8 +225,7 @@ public class BridgeWithDiscoveryGroupStartTest extends ActiveMQTestBase { private String getConnector() { if (isNetty()) { return NettyConnectorFactory.class.getName(); - } - else { + } else { return InVMConnectorFactory.class.getName(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java index 517274f653..26bcb43880 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java @@ -16,17 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Before; - -import org.junit.Test; - import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.core.message.impl.MessageImpl; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; +import org.junit.Before; +import org.junit.Test; public class ClusterHeadersRemovedTest extends ClusterTestBase { @@ -74,8 +72,7 @@ public class ClusterHeadersRemovedTest extends ClusterTestBase { producer.send(message); } - } - finally { + } finally { session0.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java index a861b23bec..538779ffe7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java @@ -216,16 +216,14 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (consumer != null) { try { consumer.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } @@ -317,17 +315,14 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { liveServer = server.getIdentity(); if (member.getLive() != null) { liveServer += "(notified)"; - } - else { + } else { liveServer += "(not notified)"; } - } - else { + } else { backupServer = server.getIdentity(); if (member.getBackup() != null) { liveServer += "(notified)"; - } - else { + } else { liveServer += "(not notified)"; } } @@ -336,12 +331,10 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { topologyDiagram.append("\t").append("|\n").append("\t->").append(liveServer).append("/").append(backupServer).append("\n"); } - } - else { + } else { topologyDiagram.append("-> no cluster connections\n"); } - } - else { + } else { topologyDiagram.append("-> stopped\n"); } } @@ -452,8 +445,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { out.println(debugBindings(activeMQServer, activeMQServer.getConfiguration().getManagementNotificationAddress().toString())); } } - } - catch (Throwable dontCare) { + } catch (Throwable dontCare) { } logAndSystemOut(writer.toString()); @@ -490,8 +482,6 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { } - - protected void createQueue(final int node, final String address, final String queueName, @@ -588,8 +578,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { session.start(); consumers[consumerID] = new ConsumerHolder(consumerID, consumer, session, node); - } - catch (Exception e) { + } catch (Exception e) { // Proxy the failure and print a dump into System.out, so it is captured by Jenkins reports e.printStackTrace(); System.out.println(ActiveMQTestBase.threadDump(" - fired by ClusterTestBase::addConsumer")); @@ -708,8 +697,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { } session.commit(); - } - finally { + } finally { session.close(); } } @@ -753,8 +741,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { producer.send(message); } - } - finally { + } finally { session.close(); } } @@ -857,8 +844,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (groupIdsReceived.get(id) == null) { groupIdsReceived.put(id, i); - } - else if (groupIdsReceived.get(id) != i) { + } else if (groupIdsReceived.get(id) != i) { Assert.fail("consumer " + groupIdsReceived.get(id) + " already bound to groupid " + id + @@ -978,8 +964,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { ClusterManager clusterManager = server.getClusterManager(); if (clusterManager == null) { out += "N/A"; - } - else { + } else { for (ClusterConnection cc : clusterManager.getClusterConnections()) { out += cc.describe() + "\n"; out += cc.getTopology().describe(); @@ -1021,8 +1006,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { log.info("check receive Consumer " + consumerID + " received message " + message.getObjectProperty(ClusterTestBase.COUNT_PROP)); - } - else { + } else { log.info("check receive Consumer " + consumerID + " null message"); } } while (message != null); @@ -1334,7 +1318,11 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { setupSessionFactory(node, netty, ha, null, null); } - protected void setupSessionFactory(final int node, final boolean netty, boolean ha, final String user, final String password) throws Exception { + protected void setupSessionFactory(final int node, + final boolean netty, + boolean ha, + final String user, + final String password) throws Exception { if (sfs[node] != null) { throw new IllegalArgumentException("Already a factory at " + node); } @@ -1345,15 +1333,13 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (netty) { serverTotc = new TransportConfiguration(ActiveMQTestBase.NETTY_CONNECTOR_FACTORY, params); - } - else { + } else { serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params); } if (ha) { locators[node] = ActiveMQClient.createServerLocatorWithHA(serverTotc); - } - else { + } else { locators[node] = ActiveMQClient.createServerLocatorWithoutHA(serverTotc); } @@ -1379,8 +1365,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (netty) { serverTotc = new TransportConfiguration(ActiveMQTestBase.NETTY_CONNECTOR_FACTORY, params); - } - else { + } else { serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params); } @@ -1448,8 +1433,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { HAPolicyConfiguration haPolicyConfiguration = null; if (liveOnly) { haPolicyConfiguration = new LiveOnlyPolicyConfiguration(); - } - else { + } else { if (sharedStorage) haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration(); else @@ -1463,16 +1447,13 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (fileStorage) { if (sharedStorage) { server = createInVMFailoverServer(true, configuration, nodeManagers[node], node); - } - else { + } else { server = createServer(configuration); } - } - else { + } else { if (sharedStorage) { server = createInVMFailoverServer(false, configuration, nodeManagers[node], node); - } - else { + } else { server = createServer(false, configuration); } } @@ -1517,8 +1498,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (sharedStorage) { server = createInVMFailoverServer(true, configuration, nodeManagers[liveNode], liveNode); - } - else { + } else { boolean enablePersistency = fileStorage ? true : configuration.isPersistenceEnabled(); server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency)); } @@ -1555,17 +1535,14 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { if (fileStorage) { if (sharedStorage) { server = createInVMFailoverServer(true, configuration, nodeManagers[node], node); - } - else { + } else { server = addServer(ActiveMQServers.newActiveMQServer(configuration)); server.setIdentity("Server " + node); } - } - else { + } else { if (sharedStorage) { server = createInVMFailoverServer(false, configuration, nodeManagers[node], node); - } - else { + } else { server = addServer(ActiveMQServers.newActiveMQServer(configuration, false)); server.setIdentity("Server " + node); } @@ -1602,8 +1579,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { ActiveMQServer server; if (sharedStorage) { server = createInVMFailoverServer(fileStorage, configuration, nodeManagers[liveNode], liveNode); - } - else { + } else { boolean enablePersistency = fileStorage ? configuration.isPersistenceEnabled() : false; server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency)); } @@ -1692,10 +1668,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { config.getClusterConfigurations().add(clusterConf); } - - protected void setupClusterConnection(final String name, - final String uri, - int server) throws Exception { + protected void setupClusterConnection(final String name, final String uri, int server) throws Exception { ActiveMQServer serverFrom = servers[server]; if (serverFrom == null) { @@ -1706,7 +1679,6 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { serverFrom.getConfiguration().addClusterConfiguration(configuration); - } protected void setupClusterConnection(final String name, @@ -1873,8 +1845,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { log.info("stopping server " + node); servers[node].stop(); log.info("server " + node + " stopped"); - } - catch (Exception e) { + } catch (Exception e) { exception = e; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterWithBackupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterWithBackupTest.java index c806e3b957..0a65415691 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterWithBackupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterWithBackupTest.java @@ -19,7 +19,6 @@ package org.apache.activemq.artemis.tests.integration.cluster.distribution; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.junit.Before; - import org.junit.Test; public class ClusterWithBackupTest extends ClusterTestBase { @@ -70,8 +69,7 @@ public class ClusterWithBackupTest extends ClusterTestBase { verifyReceiveRoundRobinInSomeOrder(100, 0, 1, 2); verifyNotReceive(0, 0, 1, 2); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); log.error(e.getMessage(), e); throw e; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java index ecf5aae3c3..7bc6312754 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; @@ -42,15 +51,6 @@ import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class ClusteredGroupingTest extends ClusterTestBase { @Test @@ -581,19 +581,16 @@ public class ClusteredGroupingTest extends ClusterTestBase { if (count % 3 == 0) { factory = sf2; targetServer = 2; - } - else if (count % 2 == 0) { + } else if (count % 2 == 0) { factory = sf1; targetServer = 1; - } - else { + } else { factory = sf0; } IntegrationTestLogger.LOGGER.debug("Creating producer session factory to node " + targetServer); session = addClientSession(factory.createSession(false, true, true)); producer = addClientProducer(session.createProducer(ADDRESS)); - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); IntegrationTestLogger.LOGGER.warn("Producer thread couldn't establish connection", e); return; @@ -610,13 +607,11 @@ public class ClusteredGroupingTest extends ClusterTestBase { producer.send(message); totalMessageProduced.incrementAndGet(); messageCount++; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { IntegrationTestLogger.LOGGER.warn("Producer thread threw exception while sending messages to " + targetServer + ": " + e.getMessage()); // in case of a failure we change the group to make possible errors more likely group = group + "afterFail"; - } - catch (Exception e) { + } catch (Exception e) { IntegrationTestLogger.LOGGER.warn("Producer thread threw unexpected exception while sending messages to " + targetServer + ": " + e.getMessage()); group = group + "afterFail"; break; @@ -636,15 +631,13 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); // ignore } System.out.println("Cycling server"); cycleServer(1); - } - finally { + } finally { okToConsume.countDown(); } } @@ -664,8 +657,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { IntegrationTestLogger.LOGGER.info("Waiting to start consumer thread..."); okToConsume.await(20, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); return; } @@ -680,12 +672,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { if (consumerCounter.get() % 3 == 0) { factory = sf2; targetServer = 2; - } - else if (consumerCounter.get() % 2 == 0) { + } else if (consumerCounter.get() % 2 == 0) { factory = sf1; targetServer = 1; - } - else { + } else { factory = sf0; } IntegrationTestLogger.LOGGER.info("Creating consumer session factory to node " + targetServer); @@ -694,8 +684,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { session.start(); consumerCounter.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { IntegrationTestLogger.LOGGER.info("Consumer thread couldn't establish connection", e); errors.incrementAndGet(); return; @@ -710,12 +699,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { } m.acknowledge(); IntegrationTestLogger.LOGGER.trace("Consumed message " + m.getStringProperty(Message.HDR_DUPLICATE_DETECTION_ID) + " from server " + targetServer + ". Total consumed: " + totalMessagesConsumed.incrementAndGet()); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { errors.incrementAndGet(); IntegrationTestLogger.LOGGER.warn("Consumer thread threw exception while receiving messages from server " + targetServer + ".: " + e.getMessage()); - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); IntegrationTestLogger.LOGGER.warn("Consumer thread threw unexpected exception while receiving messages from server " + targetServer + ".: " + e.getMessage()); return; @@ -741,8 +728,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { try { stopServers(node); startServers(node); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1039,8 +1025,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { // it should get the Retries on the latch assertTrue(latch.await(10, TimeUnit.SECONDS)); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } @@ -1230,11 +1215,9 @@ public class ClusteredGroupingTest extends ClusterTestBase { int consumer = 0; if (consumers[0].consumer.receive(5000) != null) { consumer = 0; - } - else if (consumers[2].consumer.receive(5000) != null) { + } else if (consumers[2].consumer.receive(5000) != null) { consumer = 2; - } - else { + } else { fail("Message was not received."); } @@ -1682,18 +1665,15 @@ public class ClusteredGroupingTest extends ClusterTestBase { if (wait) { try { latch.await(5, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } - } - else { + } else { latch.countDown(); } try { sendInRange(node, "queues.testaddress", msgStart, msgEnd, false, Message.HDR_GROUP_ID, id); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java index 2b00104e9f..de5fe338d9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java @@ -28,15 +28,15 @@ import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.core.message.impl.MessageImpl; import org.apache.activemq.artemis.core.server.Bindable; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.core.server.cluster.impl.Redistributor; import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration; import org.apache.activemq.artemis.core.server.impl.QueueImpl; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OneWayChainClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OneWayChainClusterTest.java index 71d96967ee..e82f465c60 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OneWayChainClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OneWayChainClusterTest.java @@ -16,18 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Before; - -import org.junit.Test; +import java.util.Map; +import java.util.Set; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; import org.apache.activemq.artemis.core.server.cluster.MessageFlowRecord; import org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; - -import java.util.Map; -import java.util.Set; +import org.junit.Before; +import org.junit.Test; public class OneWayChainClusterTest extends ClusterTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java index 8424de5735..f722d6702e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java @@ -18,13 +18,10 @@ package org.apache.activemq.artemis.tests.integration.cluster.distribution; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class OnewayTwoNodeClusterTest extends ClusterTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java index ade1a427d1..e110cde23a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java @@ -136,8 +136,7 @@ public class SymmetricClusterTest extends ClusterTestBase { verifyNotReceive(0, 1, 2, 3, 4); - } - catch (Throwable e) { + } catch (Throwable e) { System.out.println(ActiveMQTestBase.threadDump("SymmetricClusterTest::testStopAllStartAll")); throw e; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java index 543e31f88d..6e4792f48b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java @@ -117,8 +117,7 @@ public class SymmetricClusterWithBackupTest extends SymmetricClusterTest { verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4); verifyNotReceive(0, 1, 2, 3, 4); - } - catch (Throwable e) { + } catch (Throwable e) { System.out.println(ActiveMQTestBase.threadDump("SymmetricClusterWithBackupTest::testStopAllStartAll")); throw e; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TemporaryQueueClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TemporaryQueueClusterTest.java index a698df2885..3f4c113947 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TemporaryQueueClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TemporaryQueueClusterTest.java @@ -16,16 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class TemporaryQueueClusterTest extends ClusterTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java index 8a0ae8b25d..36f22eb819 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java @@ -125,8 +125,7 @@ public class TwoWayTwoNodeClusterTest extends ClusterTestBase { waitForTopology(servers[0], 2, -1, 2000); waitForTopology(servers[1], 2, -1, 2000); } - } - finally { + } finally { Thread.currentThread().setName(name); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java index 111d2c3731..7dc5162e3f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java @@ -64,8 +64,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { public void run() { try { doTestNonTransactional(this); - } - catch (Throwable e) { + } catch (Throwable e) { AsynchronousFailoverTest.log.error("Test failed", e); addException(e); } @@ -85,12 +84,10 @@ public class AsynchronousFailoverTest extends FailoverTestBase { running = true; try { doTestTransactional(this); - } - finally { + } finally { running = false; } - } - catch (Throwable e) { + } catch (Throwable e) { AsynchronousFailoverTest.log.error("Test failed", e); addException(e); } @@ -197,8 +194,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { Assert.assertEquals(0, sf.numSessions()); locator.close(); - } - finally { + } finally { locator.close(); Assert.assertEquals(0, sf.numConnections()); @@ -211,8 +207,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { setUp(); } } - } - finally { + } finally { } } @@ -248,16 +243,14 @@ public class AsynchronousFailoverTest extends FailoverTestBase { producer.send(message); retry = false; - } - catch (ActiveMQUnBlockedException ube) { + } catch (ActiveMQUnBlockedException ube) { AsynchronousFailoverTest.log.info("exception when sending message with counter " + i); ube.printStackTrace(); retry = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } while (retry); @@ -271,14 +264,12 @@ public class AsynchronousFailoverTest extends FailoverTestBase { consumer = session.createConsumer(FailoverTestBase.ADDRESS); retry = false; - } - catch (ActiveMQUnBlockedException ube) { + } catch (ActiveMQUnBlockedException ube) { AsynchronousFailoverTest.log.info("exception when creating consumer"); retry = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } while (retry); @@ -302,8 +293,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { if (count != lastCount + 1) { if (counterGap) { Assert.fail("got another counter gap at " + count + ": " + counts); - } - else { + } else { if (lastCount != -1) { AsynchronousFailoverTest.log.info("got first counter gap at " + count); counterGap = true; @@ -372,27 +362,22 @@ public class AsynchronousFailoverTest extends FailoverTestBase { session.commit(); retry = false; - } - catch (ActiveMQDuplicateIdException die) { + } catch (ActiveMQDuplicateIdException die) { logAndSystemOut("#test duplicate id rejected on sending"); break; - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { log.info("#test transaction rollback retrying on sending"); // OK retry = true; - } - catch (ActiveMQUnBlockedException ube) { + } catch (ActiveMQUnBlockedException ube) { log.info("#test transaction rollback retrying on sending"); // OK retry = true; - } - catch (ActiveMQTransactionOutcomeUnknownException toue) { + } catch (ActiveMQTransactionOutcomeUnknownException toue) { log.info("#test transaction rollback retrying on sending"); // OK retry = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { log.info("#test Exception " + e, e); throw e; } @@ -440,13 +425,11 @@ public class AsynchronousFailoverTest extends FailoverTestBase { log.info("#test commit"); try { session.commit(); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { //we know the tx has been rolled back so we just consume again retry = true; continue; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // This could eventually happen // We will get rid of this when we implement 2 phase commit on failover log.warn("exception during commit, it will be ignored for now" + e.getMessage(), e); @@ -455,12 +438,10 @@ public class AsynchronousFailoverTest extends FailoverTestBase { try { if (blocked) { assertTrue("msgs.size is expected to be 0 or " + numMessages + " but it was " + msgs.size(), msgs.size() == 0 || msgs.size() == numMessages); - } - else { + } else { assertTrue("msgs.size is expected to be " + numMessages + " but it was " + msgs.size(), msgs.size() == numMessages); } - } - catch (Throwable e) { + } catch (Throwable e) { log.info(threadDump("Thread dump, messagesReceived = " + msgs.size())); logAndSystemOut(e.getMessage() + " messages received"); for (Integer msg : msgs) { @@ -476,37 +457,32 @@ public class AsynchronousFailoverTest extends FailoverTestBase { retry = false; blocked = false; - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { logAndSystemOut("Transaction rolled back with " + msgs.size(), trbe); // TODO: https://jira.jboss.org/jira/browse/HORNETQ-369 // ATM RolledBack exception is being called with the transaction is committed. // the test will fail if you remove this next line blocked = true; retry = true; - } - catch (ActiveMQTransactionOutcomeUnknownException tou) { + } catch (ActiveMQTransactionOutcomeUnknownException tou) { logAndSystemOut("Transaction rolled back with " + msgs.size(), tou); // TODO: https://jira.jboss.org/jira/browse/HORNETQ-369 // ATM RolledBack exception is being called with the transaction is committed. // the test will fail if you remove this next line blocked = true; retry = true; - } - catch (ActiveMQUnBlockedException ube) { + } catch (ActiveMQUnBlockedException ube) { logAndSystemOut("Unblocked with " + msgs.size(), ube); // TODO: https://jira.jboss.org/jira/browse/HORNETQ-369 // This part of the test is never being called. blocked = true; retry = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { logAndSystemOut(e.getMessage(), e); throw e; } } while (retry); - } - finally { + } finally { if (session != null) { session.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java index e762a2f772..15c4257818 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; @@ -38,14 +46,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - @RunWith(value = Parameterized.class) public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { @@ -113,8 +113,7 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory()); Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory()); Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory()); - } - else { + } else { Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory()); Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory()); Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory()); @@ -124,12 +123,10 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory()); Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory()); } - } - finally { + } finally { try { server0.stop(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } server1.stop(); @@ -187,8 +184,7 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory()); Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory()); Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory()); - } - else { + } else { Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory()); Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory()); Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory()); @@ -198,12 +194,10 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory()); Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory()); } - } - finally { + } finally { try { server0.stop(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } server1.stop(); @@ -264,8 +258,7 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { Assert.assertEquals(server1.getNodeID(), backupServer0.getNodeID()); Assert.assertEquals(server2.getNodeID(), backupServer3.getNodeID()); Assert.assertEquals(server3.getNodeID(), backupServer2.getNodeID()); - } - finally { + } finally { server0.stop(); server1.stop(); server2.stop(); @@ -317,8 +310,7 @@ public class AutomaticColocatedQuorumVoteTest extends ActiveMQTestBase { if (scaleDown) { sssc.setScaleDownConfiguration(new ScaleDownConfiguration()); } - } - else { + } else { ReplicatedPolicyConfiguration rpc = new ReplicatedPolicyConfiguration(); ReplicaPolicyConfiguration rpc2 = new ReplicaPolicyConfiguration(); haPolicy.setLiveConfig(rpc); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java index f488f3e74c..9f444a49bf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java @@ -16,21 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.junit.Before; - -import org.junit.Test; - import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; +import org.junit.Before; +import org.junit.Test; public class BackupAuthenticationTest extends FailoverTestBase { @@ -85,8 +83,7 @@ public class BackupAuthenticationTest extends FailoverTestBase { public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { if (packet.getType() == PacketImpl.BACKUP_REGISTRATION) { latch.countDown(); - } - else if (packet.getType() == PacketImpl.CLUSTER_CONNECT) { + } else if (packet.getType() == PacketImpl.CLUSTER_CONNECT) { latch.countDown(); } return true; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncJournalTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncJournalTest.java index b80df4ee07..20ddae37c6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncJournalTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncJournalTest.java @@ -194,8 +194,7 @@ public class BackupSyncJournalTest extends FailoverTestBase { receiveMsgsInRange(0, n_msgs); assertNoMoreMessages(); - } - catch (AssertionError error) { + } catch (AssertionError error) { printJournal(liveServer); printJournal(backupServer); // test failed @@ -210,8 +209,7 @@ public class BackupSyncJournalTest extends FailoverTestBase { DescribeJournal.describeBindingsJournal(config.getBindingsLocation()); System.out.println("\n\n MESSAGES JOURNAL\n\n"); DescribeJournal.describeMessagesJournal(config.getJournalLocation()); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } @@ -255,8 +253,7 @@ public class BackupSyncJournalTest extends FailoverTestBase { UUID uuid = new UUID(UUID.TYPE_TIME_BASED, bytes); SimpleString storedNodeId = new SimpleString(uuid.toString()); assertEquals("nodeId must match", backupServer.getServer().getNodeID(), storedNodeId); - } - finally { + } finally { raFile.close(); } } @@ -294,8 +291,7 @@ public class BackupSyncJournalTest extends FailoverTestBase { liveServer.start(); assertTrue("must have become a backup", liveServer.getServer().getHAPolicy().isBackup()); Assert.assertEquals(0, liveMoveManager.getNumberOfFolders()); - } - finally { + } finally { liveServer.getServer().unlockActivation(); } waitForServerToStart(liveServer.getServer()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java index 2e5ec8a3be..f90af32657 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.io.File; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -27,14 +35,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; -import java.io.File; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - public class BackupSyncLargeMessageTest extends BackupSyncJournalTest { @Override @@ -128,12 +128,10 @@ public class BackupSyncLargeMessageTest extends BackupSyncJournalTest { producer.send(message); sendMessages(session, producer, 20); session.commit(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); caughtException.set(true); - } - finally { + } finally { latch2.countDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncPagingTest.java index c69b67f8bb..7b985cc5c2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncPagingTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.junit.Before; - -import org.junit.Test; - import java.util.HashMap; import java.util.Map; @@ -28,6 +24,8 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.junit.Before; +import org.junit.Test; public class BackupSyncPagingTest extends BackupSyncJournalTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java index a71adeb407..3f4f4e7f8f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java @@ -19,10 +19,10 @@ package org.apache.activemq.artemis.tests.integration.cluster.failover; import java.util.HashSet; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer; import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; import org.junit.Before; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java index 9a4f3a9385..49daf27232 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java @@ -29,8 +29,7 @@ public class DelayInterceptor implements Interceptor { if (packet.getType() == PacketImpl.SESS_SEND) { // Lose the send return false; - } - else { + } else { return true; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor2.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor2.java index c7ce876320..fb7582d4a9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor2.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor2.java @@ -41,8 +41,7 @@ public class DelayInterceptor2 implements Interceptor { latch.countDown(); return false; - } - else { + } else { return true; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor3.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor3.java index 38be634ad9..c50dd4e396 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor3.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor3.java @@ -29,8 +29,7 @@ public class DelayInterceptor3 implements Interceptor { if (packet.getType() == PacketImpl.SESS_COMMIT) { // lose the commit return false; - } - else { + } else { return true; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailBackManualTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailBackManualTest.java index 1dc00e37af..72bac9012a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailBackManualTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailBackManualTest.java @@ -185,8 +185,7 @@ public class FailBackManualTest extends FailoverTestBase { public void run() { try { server.start(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java index dca12ee51b..29acb6dc99 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java @@ -270,8 +270,7 @@ public class FailoverListenerTest extends FailoverTestBase { log.info("Failover event just happen : " + eventType.toString()); if (eventType == FailoverEventType.FAILURE_DETECTED) { failureLatch.countDown(); - } - else if (eventType == FailoverEventType.FAILOVER_COMPLETED || eventType == FailoverEventType.FAILOVER_FAILED) { + } else if (eventType == FailoverEventType.FAILOVER_COMPLETED || eventType == FailoverEventType.FAILOVER_FAILED) { failureDoneLatch.countDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverOnFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverOnFlowControlTest.java index 2fcd6e128e..b5fdbe0c3c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverOnFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverOnFlowControlTest.java @@ -16,12 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.junit.Test; - import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,6 +34,7 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnection; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; +import org.junit.Test; public class FailoverOnFlowControlTest extends FailoverTestBase { @@ -61,11 +60,9 @@ public class FailoverOnFlowControlTest extends FailoverTestBase { try { InVMConnection.setFlushEnabled(false); crash(false, sessionList.get(0)); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { InVMConnection.setFlushEnabled(true); } return false; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java index 9e4a650f71..982e214255 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java @@ -137,14 +137,12 @@ public class FailoverTest extends FailoverTestBase { latchFailed.await(10, TimeUnit.SECONDS); } } - } - catch (Exception e) { + } catch (Exception e) { // this is our retry try { if (!producer.isClosed()) producer.send(message); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } } @@ -210,8 +208,7 @@ public class FailoverTest extends FailoverTestBase { log.debug("acking message = id = " + message.getMessageID() + ", counter = " + message.getIntProperty("counter")); message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); return; } @@ -276,8 +273,7 @@ public class FailoverTest extends FailoverTestBase { ", counter = " + message.getIntProperty("counter")); message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); continue; } @@ -293,8 +289,7 @@ public class FailoverTest extends FailoverTestBase { break; } } - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("failing due to exception " + e); } @@ -308,11 +303,9 @@ public class FailoverTest extends FailoverTestBase { log.info("Returning null message on consuming"); } return msg; - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { throw new RuntimeException(oce); - } - catch (ActiveMQException ignored) { + } catch (ActiveMQException ignored) { // retry ignored.printStackTrace(); } @@ -362,8 +355,7 @@ public class FailoverTest extends FailoverTestBase { try { session.commit(xid, false); - } - catch (XAException e) { + } catch (XAException e) { //there is still an edge condition that we must deal with session.commit(xid, false); } @@ -409,13 +401,11 @@ public class FailoverTest extends FailoverTestBase { try { session.rollback(xid); - } - catch (XAException e) { + } catch (XAException e) { try { //there is still an edge condition that we must deal with session.rollback(xid); - } - catch (Exception ignored) { + } catch (Exception ignored) { log.trace(ignored.getMessage(), ignored); } } @@ -674,8 +664,7 @@ public class FailoverTest extends FailoverTestBase { FileMoveManager moveManager = new FileMoveManager(backupServer.getServer().getConfiguration().getJournalLocation(), 0); Assert.assertEquals(1, moveManager.getNumberOfFolders()); } - } - else { + } else { backupServer.stop(); beforeRestart(backupServer); backupServer.start(); @@ -740,11 +729,9 @@ public class FailoverTest extends FailoverTestBase { try { session.commit(); Assert.fail("session must have rolled back on failover"); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } @@ -823,11 +810,9 @@ public class FailoverTest extends FailoverTestBase { session.commit(); Assert.fail("Should throw exception"); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } @@ -864,11 +849,9 @@ public class FailoverTest extends FailoverTestBase { session.commit(); Assert.fail("Should throw exception"); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } @@ -926,17 +909,14 @@ public class FailoverTest extends FailoverTestBase { session.commit(); session.close(); - } - finally { + } finally { try { liveServer.getServer().stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { backupServer.getServer().stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -1008,11 +988,9 @@ public class FailoverTest extends FailoverTestBase { session2.commit(); Assert.fail("Should throw exception"); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } } @@ -1085,8 +1063,7 @@ public class FailoverTest extends FailoverTestBase { session.end(xid, XAResource.TMSUCCESS); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode); } @@ -1124,8 +1101,7 @@ public class FailoverTest extends FailoverTestBase { session.end(xid, XAResource.TMSUCCESS); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { // Assert.assertEquals(XAException.XAER_NOTA, e.errorCode); } @@ -1162,8 +1138,7 @@ public class FailoverTest extends FailoverTestBase { session.prepare(xid); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode); // XXXX session.rollback(); } @@ -1205,8 +1180,7 @@ public class FailoverTest extends FailoverTestBase { session.commit(xid, false); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_NOTA, e.errorCode); } @@ -1290,8 +1264,7 @@ public class FailoverTest extends FailoverTestBase { session2.end(xid, XAResource.TMSUCCESS); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode); } } @@ -1329,8 +1302,7 @@ public class FailoverTest extends FailoverTestBase { session2.end(xid, XAResource.TMSUCCESS); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { } // Since the end was not accepted, the messages should be redelivered @@ -1369,8 +1341,7 @@ public class FailoverTest extends FailoverTestBase { session2.prepare(xid); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode); } } @@ -1409,8 +1380,7 @@ public class FailoverTest extends FailoverTestBase { session2.commit(xid, false); Assert.fail("Should throw exception"); - } - catch (XAException e) { + } catch (XAException e) { // it should be rolled back Assert.assertEquals(XAException.XAER_NOTA, e.errorCode); } @@ -1437,8 +1407,7 @@ public class FailoverTest extends FailoverTestBase { try { createClientSessionFactory(); break; - } - catch (Exception e) { + } catch (Exception e) { // retrying Thread.sleep(100); } @@ -1574,8 +1543,7 @@ public class FailoverTest extends FailoverTestBase { if (repeatMessage != null) { message = repeatMessage; repeatMessage = null; - } - else { + } else { message = consumer.receive(1000); } @@ -1669,8 +1637,7 @@ public class FailoverTest extends FailoverTestBase { if (temporary) { session.createTemporaryQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null); - } - else { + } else { session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, durable); } @@ -1712,8 +1679,7 @@ public class FailoverTest extends FailoverTestBase { try { producer.send(message); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { this.e = e1; } } @@ -1779,8 +1745,7 @@ public class FailoverTest extends FailoverTestBase { sf.getServerLocator().addIncomingInterceptor(interceptor); session.commit(); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { // Ok - now we retry the commit after removing the interceptor sf.getServerLocator().removeIncomingInterceptor(interceptor); @@ -1789,12 +1754,10 @@ public class FailoverTest extends FailoverTestBase { session.commit(); failed = false; - } - catch (ActiveMQException e2) { + } catch (ActiveMQException e2) { throw new RuntimeException(e2); } - } - catch (ActiveMQTransactionOutcomeUnknownException toue) { + } catch (ActiveMQTransactionOutcomeUnknownException toue) { // Ok - now we retry the commit after removing the interceptor sf.getServerLocator().removeIncomingInterceptor(interceptor); @@ -1803,12 +1766,10 @@ public class FailoverTest extends FailoverTestBase { session.commit(); failed = false; - } - catch (ActiveMQException e2) { + } catch (ActiveMQException e2) { throw new RuntimeException(e2); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { //ignore } } @@ -1859,11 +1820,9 @@ public class FailoverTest extends FailoverTestBase { try { session2.commit(); Assert.fail("expecting DUPLICATE_ID_REJECTED exception"); - } - catch (ActiveMQDuplicateIdException dide) { + } catch (ActiveMQDuplicateIdException dide) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } @@ -1901,8 +1860,7 @@ public class FailoverTest extends FailoverTestBase { liveServer.addInterceptor(interceptor); session.commit(); - } - catch (ActiveMQTransactionRolledBackException trbe) { + } catch (ActiveMQTransactionRolledBackException trbe) { // Ok - now we retry the commit after removing the interceptor liveServer.removeInterceptor(interceptor); @@ -1911,11 +1869,9 @@ public class FailoverTest extends FailoverTestBase { session.commit(); failed = false; + } catch (ActiveMQException e2) { } - catch (ActiveMQException e2) { - } - } - catch (ActiveMQTransactionOutcomeUnknownException toue) { + } catch (ActiveMQTransactionOutcomeUnknownException toue) { // Ok - now we retry the commit after removing the interceptor liveServer.removeInterceptor(interceptor); @@ -1924,11 +1880,9 @@ public class FailoverTest extends FailoverTestBase { session.commit(); failed = false; + } catch (ActiveMQException e2) { } - catch (ActiveMQException e2) { - } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { //ignore } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java index aa87b28236..fc0cad3687 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java @@ -133,8 +133,7 @@ public abstract class FailoverTestBase extends ActiveMQTestBase { protected static void setLargeMessageBody(final int i, final ClientMessage message) { try { message.setBodyInputStream(ActiveMQTestBase.createFakeLargeStream(LARGE_MESSAGE_SIZE)); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -230,15 +229,13 @@ public abstract class FailoverTestBase extends ActiveMQTestBase { try { ServerSocket serverSocket = new ServerSocket(61616); serverSocket.close(); - } - catch (IOException e) { + } catch (IOException e) { throw e; } try { ServerSocket serverSocket = new ServerSocket(61617); serverSocket.close(); - } - catch (IOException e) { + } catch (IOException e) { throw e; } } @@ -267,8 +264,7 @@ public abstract class FailoverTestBase extends ActiveMQTestBase { final ActiveMQServerImpl actualServer = (ActiveMQServerImpl) backupServer.getServer(); if (actualServer.getHAPolicy().isSharedStore()) { waitForServerToStart(actualServer); - } - else { + } else { waitForRemoteBackup(sessionFactory, seconds, true, actualServer); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java index 66c48b5fa0..1ca2497ad5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientProducer; @@ -32,10 +36,6 @@ import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.junit.Assert; import org.junit.Test; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class LiveToLiveFailoverTest extends FailoverTest { private InVMNodeManager nodeManager0; @@ -88,8 +88,7 @@ public class LiveToLiveFailoverTest extends FailoverTest { } try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { fail(e.getMessage()); } } @@ -157,8 +156,7 @@ public class LiveToLiveFailoverTest extends FailoverTest { if (liveServer.getServer().isStarted()) { sf = (ClientSessionFactoryInternal) createSessionFactory(locator); sf = (ClientSessionFactoryInternal) locator.createSessionFactory(liveServer.getServer().getNodeID().toString()); - } - else { + } else { sf = (ClientSessionFactoryInternal) createSessionFactory(locator); } } @@ -261,8 +259,7 @@ public class LiveToLiveFailoverTest extends FailoverTest { try { createClientSessionFactory(); break; - } - catch (Exception e) { + } catch (Exception e) { // retrying Thread.sleep(100); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java index 5b32c84496..b8f50f2306 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java @@ -28,13 +28,13 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; public abstract class MultipleBackupsFailoverTestBase extends ActiveMQTestBase { @@ -55,14 +55,12 @@ public abstract class MultipleBackupsFailoverTestBase extends ActiveMQTestBase { TestableServer backupServer = servers.get(node); if (newLive == -1 && backupServer.isActive()) { newLive = node; - } - else if (newLive != -1) { + } else if (newLive != -1) { if (waitForNewBackup) { if (node != newLive && servers.get(node).isStarted()) { return newLive; } - } - else { + } else { return newLive; } } @@ -70,8 +68,7 @@ public abstract class MultipleBackupsFailoverTestBase extends ActiveMQTestBase { try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // ignore } if (System.currentTimeMillis() > (time + toWait)) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java index edc8b118ee..d0208183cd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -32,9 +35,6 @@ import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessAct import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - /** */ public class MultipleLivesMultipleBackupsFailoverTest extends MultipleBackupsFailoverTestBase { @@ -99,8 +99,7 @@ public class MultipleLivesMultipleBackupsFailoverTest extends MultipleBackupsFai servers.get(1).stop(); Thread.sleep(500); servers.get(2).stop(); - } - else { + } else { Thread.sleep(500); servers.get(2).stop(); Thread.sleep(500); @@ -112,8 +111,7 @@ public class MultipleLivesMultipleBackupsFailoverTest extends MultipleBackupsFai servers.get(5).stop(); Thread.sleep(500); servers.get(4).stop(); - } - else { + } else { Thread.sleep(500); servers.get(4).stop(); Thread.sleep(500); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java index 39261729dd..cc1ebf6c44 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; @@ -38,9 +41,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.junit.Before; -import java.util.ArrayList; -import java.util.List; - public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -82,8 +82,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { if (isSharedStore()) { haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration(); - } - else { + } else { haPolicyConfiguration = new ReplicatedPolicyConfiguration(); if (getNodeGroupName() != null) { ((ReplicatedPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i); @@ -97,8 +96,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { configuration.setJournalDirectory(getJournalDir(i, false)); configuration.setPagingDirectory(getPageDir(i, false)); configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, false)); - } - else { + } else { //todo } @@ -127,8 +125,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { if (isSharedStore()) { haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration(); - } - else { + } else { haPolicyConfiguration = new ReplicaPolicyConfiguration(); if (getNodeGroupName() != null) { ((ReplicaPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i); @@ -142,8 +139,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { configuration.setJournalDirectory(getJournalDir(i, true)); configuration.setPagingDirectory(getPageDir(i, true)); configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, true)); - } - else { + } else { //todo } @@ -177,8 +173,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { TransportConfiguration transportConfiguration; if (isNetty()) { transportConfiguration = TransportConfigurationUtils.getNettyAcceptor(live, node, (live ? "live-" : "backup-") + node); - } - else { + } else { transportConfiguration = TransportConfigurationUtils.getInVMAcceptor(live, node, (live ? "live-" : "backup-") + node); } return transportConfiguration; @@ -188,8 +183,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { TransportConfiguration transportConfiguration; if (isNetty()) { transportConfiguration = TransportConfigurationUtils.getNettyConnector(live, node, (live ? "live-" : "backup-") + node); - } - else { + } else { transportConfiguration = TransportConfigurationUtils.getInVMConnector(live, node, (live ? "live-" : "backup-") + node); } return transportConfiguration; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java index 2c1ccfdb90..f3801a1c1c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java @@ -16,21 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.junit.Test; - import java.util.HashMap; import java.util.Map; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; +import org.junit.Assert; +import org.junit.Test; public class NettyFailoverTest extends FailoverTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java index 4be48e9427..36deb2ddea 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java @@ -39,8 +39,7 @@ public class NettyReplicatedFailoverTest extends NettyFailoverTest { for (ClientSession session : sessions) { waitForRemoteBackup(session.getSessionFactory(), 5, true, backupServer.getServer()); } - } - else { + } else { waitForRemoteBackup(null, 5, true, backupServer.getServer()); } super.crash(waitFailure, sessions); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/PagingFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/PagingFailoverTest.java index 45d48377cf..6467016fdb 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/PagingFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/PagingFailoverTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.HashMap; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -35,8 +37,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; - /** * A PagingFailoverTest *
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java index aeb3009608..633ececffa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java @@ -16,17 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import java.util.Arrays; +import java.util.Collection; + import org.apache.activemq.artemis.core.server.cluster.qourum.BooleanVote; import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteServerConnect; import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; - @RunWith(Parameterized.class) public class QuorumVoteServerConnectTest extends ActiveMQTestBase { @@ -77,8 +77,7 @@ public class QuorumVoteServerConnectTest extends ActiveMQTestBase { } if (size == 1) { assertTrue(quorum.getDecision()); - } - else { + } else { assertFalse(quorum.getDecision()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java index d707865fb4..acbca91b0f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -32,9 +35,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class ReplicatedDistributionTest extends ClusterTestBase { private static final SimpleString ADDRESS = new SimpleString("test.SomeAddress"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedFailoverTest.java index 8dcf90592b..e72bb0caa7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedFailoverTest.java @@ -110,20 +110,17 @@ public class ReplicatedFailoverTest extends FailoverTest { assertTrue(backupServer.getServer().isStarted()); - } - finally { + } finally { if (sf != null) { sf.close(); } try { liveServer.getServer().stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } try { backupServer.getServer().stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -139,8 +136,7 @@ public class ReplicatedFailoverTest extends FailoverTest { ((ReplicatedPolicyConfiguration) liveConfig.getHAPolicyConfiguration()).setCheckForLiveServer(true); ((ReplicaPolicyConfiguration) backupConfig.getHAPolicyConfiguration()).setMaxSavedReplicatedJournalsSize(2).setAllowFailBack(true); ((ReplicaPolicyConfiguration) backupConfig.getHAPolicyConfiguration()).setRestartBackup(false); - } - else { + } else { super.setupHAPolicyConfiguration(); } } @@ -151,8 +147,7 @@ public class ReplicatedFailoverTest extends FailoverTest { for (ClientSession session : sessions) { waitForRemoteBackup(session.getSessionFactory(), 5, true, backupServer.getServer()); } - } - else { + } else { waitForRemoteBackup(null, 5, true, backupServer.getServer()); } super.crash(waitFailure, sessions); @@ -164,8 +159,7 @@ public class ReplicatedFailoverTest extends FailoverTest { for (ClientSession session : sessions) { waitForRemoteBackup(session.getSessionFactory(), 5, true, backupServer.getServer()); } - } - else { + } else { waitForRemoteBackup(null, 5, true, backupServer.getServer()); } super.crash(sessions); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedLargeMessageFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedLargeMessageFailoverTest.java index 771455ac80..7479257bd2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedLargeMessageFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedLargeMessageFailoverTest.java @@ -32,8 +32,7 @@ public class ReplicatedLargeMessageFailoverTest extends LargeMessageFailoverTest for (ClientSession session : sessions) { waitForRemoteBackup(((ClientSessionInternal) session).getSessionFactory(), 5, true, backupServer.getServer()); } - } - else { + } else { waitForRemoteBackup(null, 5, true, backupServer.getServer()); } super.crash(waitFailure, sessions); @@ -45,8 +44,7 @@ public class ReplicatedLargeMessageFailoverTest extends LargeMessageFailoverTest for (ClientSession session : sessions) { waitForRemoteBackup(((ClientSessionInternal) session).getSessionFactory(), 5, true, backupServer.getServer()); } - } - else { + } else { waitForRemoteBackup(null, 5, true, backupServer.getServer()); } super.crash(sessions); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java index c1f3942746..62dd384179 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java @@ -25,8 +25,8 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration; +import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; import org.junit.Test; public class ReplicatedMultipleServerFailoverExtraBackupsTest extends ReplicatedMultipleServerFailoverTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverTest.java index 2f3a669350..392af317a2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverTest.java @@ -110,14 +110,12 @@ public class ReplicatedMultipleServerFailoverTest extends MultipleServerFailover } } - } - finally { + } finally { for (ServerLocator locator : locators) { if (locator != null) { try { locator.close(); - } - catch (Exception e) { + } catch (Exception e) { //ignore } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java index 254c679a30..d0d9f0f6d1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java @@ -16,14 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.junit.Test; - import java.util.HashMap; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.junit.Test; public class ReplicatedPagedFailoverTest extends ReplicatedFailoverTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedWithDelayFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedWithDelayFailoverTest.java index 072f995f11..97c7d49c4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedWithDelayFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedWithDelayFailoverTest.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.tests.integration.cluster.util.BackupSyncDelay; import org.junit.Before; -import org.apache.activemq.artemis.api.core.client.ClientSession; - /** * See {@link BackupSyncDelay} for the rationale about these 'WithDelay' tests. */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java index 069eb32ae5..3cf06d2375 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; @@ -32,9 +35,6 @@ import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessAct import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - /** */ public class SingleLiveMultipleBackupsFailoverTest extends MultipleBackupsFailoverTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/remote/FailoverWithSharedStoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/remote/FailoverWithSharedStoreTest.java index b9d22959bc..46b3c3389a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/remote/FailoverWithSharedStoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/remote/FailoverWithSharedStoreTest.java @@ -33,11 +33,9 @@ public class FailoverWithSharedStoreTest extends ClusterTestBase { try { createSessionFactory(locator); fail(); - } - catch (ActiveMQNotConnectedException nce) { + } catch (ActiveMQNotConnectedException nce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java index a2b3ea9b82..83e516cb3f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -35,13 +42,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Test; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReattachSupportTestBase { private final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -1236,8 +1236,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt public synchronized void onMessage(final ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException me) { + } catch (ActiveMQException me) { log.error("Failed to process", me); } @@ -1281,4 +1280,4 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt } } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java index 1037e048ed..027e2b4e21 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; @@ -30,11 +35,6 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - public abstract class MultiThreadReattachSupportTestBase extends ActiveMQTestBase { private final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -102,8 +102,7 @@ public abstract class MultiThreadReattachSupportTestBase extends ActiveMQTestBas public void run() { try { test.run(sf, threadNum); - } - catch (Throwable t) { + } catch (Throwable t) { throwable = t; log.error("Failed to run test", t); @@ -216,8 +215,7 @@ public abstract class MultiThreadReattachSupportTestBase extends ActiveMQTestBas if (failOnCreateConnection) { InVMConnector.numberOfFailures = 1; InVMConnector.failOnCreateConnection = true; - } - else { + } else { conn.fail(new ActiveMQNotConnectedException("blah")); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/OrderReattachTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/OrderReattachTest.java index f0aac93771..f174f3ed75 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/OrderReattachTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/OrderReattachTest.java @@ -16,17 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; -import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.junit.Test; - import java.util.HashSet; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; -import org.junit.Assert; - +import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -41,6 +37,8 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; public class OrderReattachTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -88,8 +86,7 @@ public class OrderReattachTest extends ActiveMQTestBase { Boolean poll = false; try { poll = failureQueue.poll(60, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); break; } @@ -101,13 +98,11 @@ public class OrderReattachTest extends ActiveMQTestBase { // True means... fail session if (poll) { conn.fail(new ActiveMQNotConnectedException("poop")); - } - else { + } else { // false means... finish thread break; } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -120,25 +115,21 @@ public class OrderReattachTest extends ActiveMQTestBase { try { doSend2(1, sf, failureQueue); - } - finally { + } finally { try { session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } try { locator.close(); - } - catch (Exception e) { + } catch (Exception e) { // } try { sf.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -269,4 +260,4 @@ public class OrderReattachTest extends ActiveMQTestBase { s.close(); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java index 4c4873880c..4d44334d5a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java @@ -279,8 +279,7 @@ public class RandomReattachTest extends ActiveMQTestBase { try { message.acknowledge(); - } - catch (ActiveMQException me) { + } catch (ActiveMQException me) { RandomReattachTest.log.error("Failed to process", me); } @@ -492,8 +491,7 @@ public class RandomReattachTest extends ActiveMQTestBase { try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage(), e); } @@ -1313,8 +1311,7 @@ public class RandomReattachTest extends ActiveMQTestBase { public void onMessage(ClientMessage message) { try { onMessageAssert(message); - } - catch (AssertionError e) { + } catch (AssertionError e) { e.printStackTrace(); // System.out -> junit reports errors.add(e); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java index 134377533d..64596d1e52 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; @@ -43,11 +48,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - public class ReattachTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -224,8 +224,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(retryInterval * 3); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; @@ -330,8 +329,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(asyncFailDelay); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } conn2.fail(new ActiveMQNotConnectedException("Did not receive pong from server")); @@ -411,8 +409,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(retryInterval * (reconnectAttempts + 1)); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; @@ -429,11 +426,9 @@ public class ReattachTest extends ActiveMQTestBase { session.start(); Assert.fail("Should throw exception"); - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -487,8 +482,7 @@ public class ReattachTest extends ActiveMQTestBase { session.close(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); failure = e; } @@ -508,8 +502,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { connFailure.fail(new ActiveMQNotConnectedException()); - } - catch (Exception e) { + } catch (Exception e) { ReattachTest.log.warn("Error on the timer " + e); } } @@ -534,8 +527,7 @@ public class ReattachTest extends ActiveMQTestBase { sf.close(); - } - finally { + } finally { timer.cancel(); if (session != null) { @@ -575,8 +567,7 @@ public class ReattachTest extends ActiveMQTestBase { ClientSession session = sf.createSession(false, true, true); session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); failure = e; } @@ -596,8 +587,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(retryInterval * 3); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; @@ -656,8 +646,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(retryInterval * 3); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; @@ -793,8 +782,7 @@ public class ReattachTest extends ActiveMQTestBase { public void run() { try { Thread.sleep(retryInterval / 2); - } - catch (InterruptedException ignore) { + } catch (InterruptedException ignore) { } InVMConnector.failOnCreateConnection = false; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java index 02f852dd1c..3a0d92af13 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.restart; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Test; - import java.util.Collection; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.postoffice.Binding; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; +import org.junit.Test; public class ClusterRestartTest extends ClusterTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java index e45679ad8d..ffef57648a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.topology; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl; @@ -28,11 +33,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class IsolatedTopologyTest extends ActiveMQTestBase { @Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/NonHATopologyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/NonHATopologyTest.java index c039b11a77..a8e9f2b70f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/NonHATopologyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/NonHATopologyTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.topology; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Test; - import java.util.ArrayList; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -31,7 +28,9 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Test; /** * I have added this test to help validate if the connectors from Recovery will be @@ -85,23 +84,19 @@ public class NonHATopologyTest extends ActiveMQTestBase { TopologyMemberImpl member = topology.getMembers().iterator().next(); if (isNetty) { assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName()); - } - else { + } else { assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName()); } - } - finally { + } finally { try { locator.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } try { server.stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } server = null; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java index 3662fb8a4a..14869b21b1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.topology; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; @@ -39,12 +45,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - import static java.util.concurrent.TimeUnit.SECONDS; public abstract class TopologyClusterTestBase extends ClusterTestBase { @@ -151,12 +151,10 @@ public abstract class TopologyClusterTestBase extends ClusterTestBase { session.createQueue(rand, rand); session.deleteQueue(rand); return session; - } - catch (ActiveMQObjectClosedException oce) { + } catch (ActiveMQObjectClosedException oce) { ClientSessionFactory sf = createSessionFactory(locator); return sf.createSession(); - } - catch (ActiveMQUnBlockedException obe) { + } catch (ActiveMQUnBlockedException obe) { ClientSessionFactory sf = createSessionFactory(locator); return sf.createSession(); } @@ -338,8 +336,7 @@ public abstract class TopologyClusterTestBase extends ClusterTestBase { try { session = checkSessionOrReconnect(session, locator); Assert.fail(); - } - catch (ActiveMQException expected) { + } catch (ActiveMQException expected) { Assert.assertEquals(ActiveMQExceptionType.NOT_CONNECTED, expected.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/BackupSyncDelay.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/BackupSyncDelay.java index c379fcd79f..7247ede4f5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/BackupSyncDelay.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/BackupSyncDelay.java @@ -100,8 +100,7 @@ public class BackupSyncDelay implements Interceptor { repChannel.setHandler(handler); handler.setChannel(repChannel); live.getRemotingService().removeIncomingInterceptor(this); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -143,8 +142,7 @@ public class BackupSyncDelay implements Interceptor { try { handler.handlePacket(onHold); delivered = true; - } - finally { + } finally { handler.setChannel(channel); channel.setHandler(handler); onHold = null; @@ -177,8 +175,7 @@ public class BackupSyncDelay implements Interceptor { return; } } - } - else if (typeToIntercept == packet.getType()) { + } else if (typeToIntercept == packet.getType()) { channel.send(new ReplicationResponseMessage()); return; } @@ -349,4 +346,4 @@ public class BackupSyncDelay implements Interceptor { } } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/MultiServerTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/MultiServerTestBase.java index 8ca823ce02..8ceff8829a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/MultiServerTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/MultiServerTestBase.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.util; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration; -import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration; -import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; -import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; -import org.junit.Before; - import java.util.ArrayList; import java.util.List; @@ -33,10 +25,17 @@ import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration; +import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration; +import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; +import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.NodeManager; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.core.server.impl.InVMNodeManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Before; public class MultiServerTestBase extends ActiveMQTestBase { @@ -71,8 +70,7 @@ public class MultiServerTestBase extends ActiveMQTestBase { if (ha) { ServerLocator locator = ActiveMQClient.createServerLocatorWithHA(targetConfig); return addServerLocator(locator); - } - else { + } else { ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(targetConfig); return addServerLocator(locator); } @@ -187,8 +185,7 @@ public class MultiServerTestBase extends ActiveMQTestBase { if (sharedStorage) { server = createInVMFailoverServer(realFiles, configuration, nodeManager, node); - } - else { + } else { server = createServer(realFiles, configuration); } @@ -229,8 +226,7 @@ public class MultiServerTestBase extends ActiveMQTestBase { if (useSharedStorage()) { server = createInVMFailoverServer(true, configuration, nodeManager, liveNode); - } - else { + } else { server = addServer(ActiveMQServers.newActiveMQServer(configuration, useRealFiles())); } server.setIdentity(this.getClass().getSimpleName() + "/Backup(" + node + " of live " + liveNode + ")"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java index 162dda426f..ededc189e7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java @@ -16,16 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.util; -import org.apache.activemq.artemis.api.core.Interceptor; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.tests.util.CountDownSessionFailureListener; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.cluster.ClusterManager; -import org.junit.Assert; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.apache.activemq.artemis.api.core.Interceptor; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.cluster.ClusterManager; +import org.apache.activemq.artemis.tests.util.CountDownSessionFailureListener; +import org.junit.Assert; + public class SameProcessActiveMQServer implements TestableServer { private final ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java index 624c89ca7e..7af172ead6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java @@ -16,6 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.crossprotocol; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.Session; +import java.io.ByteArrayInputStream; +import java.io.ObjectInputStream; +import java.util.ArrayList; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQXAConnectionFactory; import org.apache.activemq.artemis.api.core.SimpleString; @@ -30,18 +41,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.Session; -import java.io.ByteArrayInputStream; -import java.io.ObjectInputStream; -import java.util.ArrayList; - - public class AMQPToOpenwireTest extends ActiveMQTestBase { public static final String OWHOST = "localhost"; @@ -107,11 +106,9 @@ public class AMQPToOpenwireTest extends ActiveMQTestBase { list = (ArrayList) ois.readObject(); assertEquals(list.get(0), "aString"); connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/OpenWireToAMQPTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/OpenWireToAMQPTest.java index 627620304d..b1ae9c9565 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/OpenWireToAMQPTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/OpenWireToAMQPTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.crossprotocol; +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.Session; +import java.util.ArrayList; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQXAConnectionFactory; import org.apache.activemq.artemis.api.core.SimpleString; @@ -28,15 +36,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.Session; -import java.util.ArrayList; - - public class OpenWireToAMQPTest extends ActiveMQTestBase { public static final String OWHOST = "localhost"; @@ -96,11 +95,9 @@ public class OpenWireToAMQPTest extends ActiveMQTestBase { list = (ArrayList) receive.getObject(); assertEquals(list.get(0), "aString"); connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (connection != null) { connection.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java index 44bb31a613..bfef53cb01 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java @@ -27,16 +27,16 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; -import org.apache.activemq.artemis.core.server.ActivateCallback; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.cluster.DiscoveryEntry; import org.apache.activemq.artemis.core.cluster.DiscoveryGroup; import org.apache.activemq.artemis.core.cluster.DiscoveryListener; +import org.apache.activemq.artemis.core.server.ActivateCallback; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup; import org.apache.activemq.artemis.core.server.cluster.impl.BroadcastGroupImpl; import org.apache.activemq.artemis.core.server.management.NotificationService; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryStayAliveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryStayAliveTest.java index 4a8e23dcc0..07c45b2871 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryStayAliveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryStayAliveTest.java @@ -68,8 +68,7 @@ public class DiscoveryStayAliveTest extends DiscoveryBaseTest { public void run() { try { dg.internalRunning(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -98,8 +97,7 @@ public class DiscoveryStayAliveTest extends DiscoveryBaseTest { Thread.sleep(100); assertTrue(t.isAlive()); assertEquals(0, errors.get()); - } - finally { + } finally { if (bg != null) { bg.stop(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java index a1faedca0c..8efcdcdfc5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java @@ -32,13 +32,13 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.jgroups.JChannelManager; import org.apache.activemq.artemis.api.core.management.CoreNotificationType; -import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; import org.apache.activemq.artemis.core.cluster.DiscoveryEntry; import org.apache.activemq.artemis.core.cluster.DiscoveryGroup; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup; import org.apache.activemq.artemis.core.server.cluster.impl.BroadcastGroupImpl; import org.apache.activemq.artemis.core.server.management.Notification; +import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.After; @@ -190,8 +190,7 @@ public class DiscoveryTest extends DiscoveryBaseTest { assertEquals(5, data1[4]); receivers[num - 1].close(false); - } - finally { + } finally { broadcaster.close(true); } } @@ -215,7 +214,6 @@ public class DiscoveryTest extends DiscoveryBaseTest { receivers[i].openClient(); } - try { final byte[] data = new byte[]{1, 2, 3, 4, 5}; @@ -255,8 +253,7 @@ public class DiscoveryTest extends DiscoveryBaseTest { assertEquals(5, received[4]); } - } - finally { + } finally { for (int i = 0; i < num; i++) { receivers[i].close(false); } @@ -367,16 +364,14 @@ public class DiscoveryTest extends DiscoveryBaseTest { for (int i = 0; i < randomBytes.length; i++) { assertEquals(randomBytes[i], btreceived[i]); } - } - finally { + } finally { try { if (broadcaster != null) broadcaster.close(true); if (client != null) client.close(false); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java index 10c887e011..0d94734272 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.divert; +import java.util.Collection; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -40,9 +43,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; -import java.util.Collection; -import java.util.concurrent.TimeUnit; - public class DivertTest extends ActiveMQTestBase { private static final int TIMEOUT = 3000; @@ -214,11 +214,9 @@ public class DivertTest extends ActiveMQTestBase { if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue1")) { countOriginal1++; - } - else if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue2")) { + } else if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue2")) { countOriginal2++; - } - else { + } else { System.out.println("message not part of any expired queue" + message); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java index 4200b7dd3b..a78e041e26 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java @@ -101,10 +101,8 @@ public class ReplicationWithDivertTest extends ActiveMQTestBase { backupConfig.addQueueConfiguration(new CoreQueueConfiguration().setAddress(SOURCE_QUEUE).setName(SOURCE_QUEUE)); backupConfig.addQueueConfiguration(new CoreQueueConfiguration().setAddress(TARGET_QUEUE).setName(TARGET_QUEUE)); - DivertConfiguration divertConfiguration = new DivertConfiguration().setName("Test").setAddress(SOURCE_QUEUE).setForwardingAddress(TARGET_QUEUE).setRoutingName("Test"); - liveConfig = createDefaultInVMConfig(); liveConfig.addQueueConfiguration(new CoreQueueConfiguration().setAddress(SOURCE_QUEUE).setName(SOURCE_QUEUE).setDurable(true)); liveConfig.addQueueConfiguration(new CoreQueueConfiguration().setAddress(TARGET_QUEUE).setName(TARGET_QUEUE).setDurable(true)); @@ -150,8 +148,7 @@ public class ReplicationWithDivertTest extends ActiveMQTestBase { if (connection != null) { try { connection.close(); - } - catch (Exception e) { + } catch (Exception e) { } } if (backupServer != null) { @@ -191,8 +188,7 @@ public class ReplicationWithDivertTest extends ActiveMQTestBase { producer.send(message); session.commit(); } - } - catch (JMSException expected) { + } catch (JMSException expected) { expected.printStackTrace(); } } @@ -256,4 +252,4 @@ public class ReplicationWithDivertTest extends ActiveMQTestBase { return message; } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java index 9c86d69c0b..06056316c4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java @@ -36,8 +36,7 @@ public class ValidateAIOTest extends ActiveMQTestBase { ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true)); try { server.start(); - } - finally { + } finally { server.stop(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java index 119be8740e..7393498a2a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java @@ -16,30 +16,27 @@ */ package org.apache.activemq.artemis.tests.integration.http; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; - -import org.junit.Test; - import java.util.HashMap; import java.util.Random; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class CoreClientOverHttpTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Incoming.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Incoming.java index 6cf1ef3999..4098842506 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Incoming.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Incoming.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, diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java index cffbed523d..5cc97f28c3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java @@ -110,8 +110,7 @@ public class InterceptorTest extends ActiveMQTestBase { createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); System.out.println("userName = " + userName); - } - else if (packet.getType() == PacketImpl.SESS_SEND) { + } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); @@ -141,8 +140,7 @@ public class InterceptorTest extends ActiveMQTestBase { createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); System.out.println("userName = " + userName); - } - else if (packet.getType() == PacketImpl.SESS_SEND) { + } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); @@ -785,8 +783,7 @@ public class InterceptorTest extends ActiveMQTestBase { try { producer.send(message); Assert.fail(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // expected exception Assert.assertTrue(e.getType().getCode() == ActiveMQExceptionType.INTERCEPTOR_REJECTED_PACKET.getCode()); } @@ -1054,7 +1051,6 @@ public class InterceptorTest extends ActiveMQTestBase { session.close(); } - @Test public void testInterceptorOnURI() throws Exception { locator.close(); @@ -1083,7 +1079,6 @@ public class InterceptorTest extends ActiveMQTestBase { producer.send(session.createTextMessage("HelloMessage")); - connection.start(); MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE.toString())); @@ -1101,6 +1096,5 @@ public class InterceptorTest extends ActiveMQTestBase { factory.close(); - } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Outgoing.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Outgoing.java index 7bd85dfdc7..5736762b85 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Outgoing.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/Outgoing.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, diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java index c9ffb3814a..d600ac14fa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jdbc/store/journal/JDBCJournalTest.java @@ -62,8 +62,7 @@ public class JDBCJournalTest extends ActiveMQTestBase { journal.destroy(); try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } scheduledExecutorService.shutdown(); scheduledExecutorService = null; @@ -78,8 +77,7 @@ public class JDBCJournalTest extends ActiveMQTestBase { executorService = Executors.newSingleThreadExecutor(); jdbcUrl = "jdbc:derby:target/data;create=true"; SQLProvider.Factory factory = new DerbySQLProvider.Factory(); - journal = new JDBCJournalImpl(jdbcUrl, DRIVER_CLASS, factory.create(JOURNAL_TABLE_NAME), - scheduledExecutorService, executorService); + journal = new JDBCJournalImpl(jdbcUrl, DRIVER_CLASS, factory.create(JOURNAL_TABLE_NAME), scheduledExecutorService, executorService); journal.start(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java index a40cb07be7..9b8edb87a3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java @@ -16,24 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.integration.jms.serializables.TestClass1; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; -import org.junit.Before; - -import org.junit.Test; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.MessageConsumer; @@ -44,20 +26,34 @@ import javax.jms.QueueBrowser; import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; - -import org.junit.Assert; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.integration.jms.serializables.TestClass1; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * ActiveMQConnectionFactoryTest @@ -86,8 +82,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Assert.fail("Should throw exception"); - } - catch (JMSException e) { + } catch (JMSException e) { // Ok } if (conn != null) { @@ -340,15 +335,18 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { //but String always trusted obj = receiveObjectMessage(blackList, whiteList, qname, new String("hello"), false, false); assertTrue("java.lang.String always trusted " + obj, "hello".equals(obj)); - } - finally { + } finally { System.clearProperty(ObjectInputStreamWithClassLoader.BLACKLIST_PROPERTY); System.clearProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY); } } - private Object receiveObjectMessage(String blackList, String whiteList, String qname, - Serializable obj, boolean useJndi, boolean useBrowser) throws Exception { + private Object receiveObjectMessage(String blackList, + String whiteList, + String qname, + Serializable obj, + boolean useJndi, + boolean useBrowser) throws Exception { sendObjectMessage(qname, obj); StringBuilder query = new StringBuilder(""); @@ -362,8 +360,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { query.append("deserializationWhiteList="); query.append(whiteList); } - } - else { + } else { if (whiteList != null) { query.append("?deserializationWhiteList="); query.append(whiteList); @@ -378,8 +375,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { props.put("connectionFactory.VmConnectionFactory", "vm://0" + query); Context ctx = new InitialContext(props); factory = (ActiveMQConnectionFactory) ctx.lookup("VmConnectionFactory"); - } - else { + } else { factory = new ActiveMQConnectionFactory("vm://0" + query); } Connection connection = null; @@ -396,24 +392,20 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { MessageConsumer consumer = session.createConsumer(queue); consumer.receive(5000); result = objMessage.getObject(); - } - else { + } else { MessageConsumer consumer = session.createConsumer(queue); ObjectMessage objMessage = (ObjectMessage) consumer.receive(5000); assertNotNull(objMessage); result = objMessage.getObject(); } return result; - } - catch (Exception e) { + } catch (Exception e) { return e; - } - finally { + } finally { if (connection != null) { try { connection.close(); - } - catch (JMSException e) { + } catch (JMSException e) { return e; } } @@ -430,8 +422,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { ObjectMessage objMessage = session.createObjectMessage(); objMessage.setObject(obj); producer.send(objMessage); - } - finally { + } finally { connection.close(); } } @@ -465,162 +456,139 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { try { cf.setClientID(clientID); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setClientFailureCheckPeriod(clientFailureCheckPeriod); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setConnectionTTL(connectionTTL); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setCallTimeout(callTimeout); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setMinLargeMessageSize(minLargeMessageSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setConsumerWindowSize(consumerWindowSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setConsumerMaxRate(consumerMaxRate); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setConfirmationWindowSize(confirmationWindowSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setProducerMaxRate(producerMaxRate); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setBlockOnAcknowledge(blockOnAcknowledge); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setBlockOnDurableSend(blockOnDurableSend); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setBlockOnNonDurableSend(blockOnNonDurableSend); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setAutoGroup(autoGroup); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setPreAcknowledge(preAcknowledge); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setDupsOKBatchSize(dupsOKBatchSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setTransactionBatchSize(transactionBatchSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setUseGlobalPools(useGlobalPools); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setThreadPoolMaxSize(threadPoolMaxSize); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setRetryInterval(retryInterval); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setRetryIntervalMultiplier(retryIntervalMultiplier); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { cf.setReconnectAttempts(reconnectAttempts); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } @@ -683,8 +651,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase { TransportConfiguration[] cfStaticConnectors = cf.getStaticConnectors(); if (staticConnectors == null) { Assert.assertNull(staticConnectors); - } - else { + } else { Assert.assertEquals(staticConnectors.length, cfStaticConnectors.length); for (int i = 0; i < staticConnectors.length; i++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java index 9ef5f6dd34..79ed68032e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java @@ -16,6 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.jms; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.DeliveryMode; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -32,17 +43,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import java.util.ArrayList; -import java.util.List; - /** * A FloodServerTest */ @@ -192,8 +192,7 @@ public class FloodServerTest extends ActiveMQTestBase { } connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -239,8 +238,7 @@ public class FloodServerTest extends ActiveMQTestBase { } connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JMSSecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JMSSecurityTest.java index 9795dce43b..d3eca0fbab 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JMSSecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JMSSecurityTest.java @@ -47,8 +47,7 @@ public class JMSSecurityTest extends JMSTestBase { try { JMSContext ctx = cf.createContext("Idont", "exist"); ctx.close(); - } - catch (JMSSecurityRuntimeException e) { + } catch (JMSSecurityRuntimeException e) { // expected } JMSContext ctx = cf.createContext("IDo", "Exist"); @@ -63,8 +62,7 @@ public class JMSSecurityTest extends JMSTestBase { QueueConnection queueC = ((QueueConnectionFactory) cf).createQueueConnection("IDont", "Exist"); fail("supposed to throw exception"); queueC.close(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { // expected } JMSContext ctx = cf.createContext("IDo", "Exist"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JmsProducerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JmsProducerTest.java index 2aba1c46d6..5b8376ebf9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JmsProducerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/JmsProducerTest.java @@ -77,8 +77,7 @@ public class JmsProducerTest extends JMSTestBase { try { producer.setProperty("name1", new ArrayList(2)); fail("didn't get expected MessageFormatRuntimeException"); - } - catch (MessageFormatRuntimeException e) { + } catch (MessageFormatRuntimeException e) { //expected. } } @@ -152,8 +151,7 @@ public class JmsProducerTest extends JMSTestBase { byte value0 = 0; try { value0 = Byte.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -162,12 +160,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0); - } - else { + } else { fail("non existent byte property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -183,8 +179,7 @@ public class JmsProducerTest extends JMSTestBase { boolean value0 = false; try { value0 = Boolean.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -193,12 +188,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertEquals("value0: " + value0 + " value1: " + value1, value1, value0); - } - else { + } else { fail("non existent boolean property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -214,8 +207,7 @@ public class JmsProducerTest extends JMSTestBase { double value0 = 0; try { value0 = Double.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -224,12 +216,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0); - } - else { + } else { fail("non existent double property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -245,8 +235,7 @@ public class JmsProducerTest extends JMSTestBase { float value0 = 0; try { value0 = Float.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -255,12 +244,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0); - } - else { + } else { fail("non existent double property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -276,8 +263,7 @@ public class JmsProducerTest extends JMSTestBase { int value0 = 0; try { value0 = Integer.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -286,12 +272,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0); - } - else { + } else { fail("non existent double property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -307,8 +291,7 @@ public class JmsProducerTest extends JMSTestBase { long value0 = 0; try { value0 = Integer.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -317,12 +300,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertEquals("value0: " + value0 + " value1: " + value1, value1, value0); - } - else { + } else { fail("non existent double property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { @@ -338,8 +319,7 @@ public class JmsProducerTest extends JMSTestBase { short value0 = 0; try { value0 = Short.valueOf(null); - } - catch (Throwable t) { + } catch (Throwable t) { expected = t; } @@ -348,12 +328,10 @@ public class JmsProducerTest extends JMSTestBase { if (expected == null) { assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0); - } - else { + } else { fail("non existent double property expects exception, but got value: " + value1); } - } - catch (Throwable t) { + } catch (Throwable t) { if (expected == null) throw t; if (!t.getClass().equals(expected.getClass())) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManualReconnectionToSingleServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManualReconnectionToSingleServerTest.java index aff6e01f94..9ed0d5b021 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManualReconnectionToSingleServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManualReconnectionToSingleServerTest.java @@ -16,6 +16,22 @@ */ package org.apache.activemq.artemis.tests.integration.jms; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.naming.Context; +import java.util.ArrayList; +import java.util.Date; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -33,22 +49,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.naming.Context; -import java.util.ArrayList; -import java.util.Date; -import java.util.concurrent.CountDownLatch; - import static java.util.concurrent.TimeUnit.SECONDS; public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase { @@ -179,8 +179,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase { connection.close(); connection = null; ManualReconnectionToSingleServerTest.log.info("connection closed"); - } - catch (Exception e) { + } catch (Exception e) { ManualReconnectionToSingleServerTest.log.info("** got exception"); e.printStackTrace(); } @@ -201,8 +200,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase { queue = (Queue) initialContext.lookup(QUEUE_NAME); cf = (ConnectionFactory) initialContext.lookup("/cf"); break; - } - catch (Exception e) { + } catch (Exception e) { if (retries++ > retryLimit) throw e; // retry until server is up @@ -215,13 +213,11 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase { consumer = session.createConsumer(queue); consumer.setMessageListener(listener); connection.start(); - } - catch (Exception e) { + } catch (Exception e) { if (connection != null) { try { connection.close(); - } - catch (JMSException e1) { + } catch (JMSException e1) { e1.printStackTrace(); } } @@ -238,8 +234,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase { try { msg.getIntProperty("counter"); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); } if (count == NUM) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java index 7c49053ba2..81cb3bf81b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java @@ -76,7 +76,6 @@ public class RedeployTest extends ActiveMQTestBase { Assert.assertEquals("jms.queue.NewQueue", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getDeadLetterAddress().toString()); Assert.assertEquals("jms.queue.NewQueue", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getExpiryAddress().toString()); - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(); try (Connection connection = factory.createConnection()) { Session session = connection.createSession(); @@ -88,8 +87,7 @@ public class RedeployTest extends ActiveMQTestBase { Assert.assertNotNull("Divert wasn't redeployed accordingly", consumer.receive(5000)); } - } - finally { + } finally { embeddedJMS.stop(); } } @@ -101,8 +99,7 @@ public class RedeployTest extends ActiveMQTestBase { Queue queue = session.createQueue("NewQueue"); MessageConsumer consumer = session.createConsumer(queue); return true; - } - catch (JMSException e) { + } catch (JMSException e) { return false; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java index ede3419b70..7865e130af 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java @@ -40,7 +40,6 @@ import org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFa import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; @@ -48,6 +47,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ConnectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ConnectionTest.java index 79ccd2829a..77707269c0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ConnectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ConnectionTest.java @@ -51,19 +51,18 @@ public class ConnectionTest extends JMSTestBase { connectionFactory = serialClone(connectionFactory); testThroughNewConnectionFactory(connectionFactory); - connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616?&blockOnNonDurableSend=true&" + - "retryIntervalMultiplier=1.0&maxRetryInterval=2000&producerMaxRate=-1&" + - "blockOnDurableSend=true&connectionTTL=60000&compressLargeMessage=false&reconnectAttempts=0&" + - "cacheLargeMessagesClient=false&scheduledThreadPoolMaxSize=5&useGlobalPools=true&" + - "callFailoverTimeout=-1&initialConnectAttempts=1&clientFailureCheckPeriod=30000&" + - "blockOnAcknowledge=true&consumerWindowSize=1048576&minLargeMessageSize=102400&" + - "autoGroup=false&threadPoolMaxSize=-1&confirmationWindowSize=-1&" + - "transactionBatchSize=1048576&callTimeout=30000&preAcknowledge=false&" + - "connectionLoadBalancingPolicyClassName=org.apache.activemq.artemis.api.core.client.loadbalance." + - "RoundRobinConnectionLoadBalancingPolicy&dupsOKBatchSize=1048576&initialMessagePacketSize=1500&" + - "consumerMaxRate=-1&retryInterval=2000&failoverOnInitialConnection=false&producerWindowSize=65536&" + - "port=61616&host=localhost#"); + "retryIntervalMultiplier=1.0&maxRetryInterval=2000&producerMaxRate=-1&" + + "blockOnDurableSend=true&connectionTTL=60000&compressLargeMessage=false&reconnectAttempts=0&" + + "cacheLargeMessagesClient=false&scheduledThreadPoolMaxSize=5&useGlobalPools=true&" + + "callFailoverTimeout=-1&initialConnectAttempts=1&clientFailureCheckPeriod=30000&" + + "blockOnAcknowledge=true&consumerWindowSize=1048576&minLargeMessageSize=102400&" + + "autoGroup=false&threadPoolMaxSize=-1&confirmationWindowSize=-1&" + + "transactionBatchSize=1048576&callTimeout=30000&preAcknowledge=false&" + + "connectionLoadBalancingPolicyClassName=org.apache.activemq.artemis.api.core.client.loadbalance." + + "RoundRobinConnectionLoadBalancingPolicy&dupsOKBatchSize=1048576&initialMessagePacketSize=1500&" + + "consumerMaxRate=-1&retryInterval=2000&failoverOnInitialConnection=false&producerWindowSize=65536&" + + "port=61616&host=localhost#"); testThroughNewConnectionFactory(connectionFactory); @@ -98,8 +97,7 @@ public class ConnectionTest extends JMSTestBase { try { conn2.setClientID(id); Assert.fail("should not happen."); - } - catch (InvalidClientIDException expected) { + } catch (InvalidClientIDException expected) { // expected } } @@ -160,8 +158,7 @@ public class ConnectionTest extends JMSTestBase { aConn = cf.createConnection(); newCF = getCFThruSerialization(cf); testCreateConnection(newCF); - } - finally { + } finally { if (aConn != null) { aConn.close(); } @@ -193,8 +190,7 @@ public class ConnectionTest extends JMSTestBase { session1.close(); Session session2 = newConn.createSession(true, Session.SESSION_TRANSACTED); session2.close(); - } - finally { + } finally { if (newConn != null) { newConn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java index 5572f213ac..6fadd51c32 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java @@ -22,9 +22,9 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.Topic; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.junit.Test; public class CreateQueueTest extends JMSTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ExpiryMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ExpiryMessageTest.java index 6a64ddfe02..03e3d07d17 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ExpiryMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ExpiryMessageTest.java @@ -23,8 +23,8 @@ import javax.jms.TextMessage; import javax.jms.Topic; import org.apache.activemq.artemis.api.jms.management.TopicControl; -import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupIDTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupIDTest.java index a02dec0dc1..b4d19e0938 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupIDTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupIDTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.junit.Test; - import javax.jms.ConnectionFactory; import javax.jms.Message; @@ -25,6 +23,7 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.junit.Test; public class GroupIDTest extends GroupingTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupingTest.java index 295db6a879..41c325de6b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/GroupingTest.java @@ -16,17 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; -import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSConsumer; @@ -41,6 +30,17 @@ import javax.jms.Session; import javax.jms.TextMessage; import java.util.UUID; +import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + /** * GroupingTest */ @@ -96,8 +96,7 @@ public class GroupingTest extends JMSTestBase { if (jmsxgroupID != null) { assertEquals(jmsxgroupID, prop); - } - else { + } else { jmsxgroupID = prop; } } @@ -254,8 +253,7 @@ public class GroupingTest extends JMSTestBase { if (jmsxgroupID != null) { assertEquals(jmsxgroupID, prop); - } - else { + } else { jmsxgroupID = prop; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageProducerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageProducerTest.java index 425e72729c..2b40b53a4b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageProducerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageProducerTest.java @@ -48,12 +48,10 @@ public class MessageProducerTest extends JMSTestBase { try { producer.send(m); Assert.fail("must not be reached"); - } - catch (UnsupportedOperationException cause) { + } catch (UnsupportedOperationException cause) { // expected } - } - finally { + } finally { session.close(); } } @@ -69,19 +67,16 @@ public class MessageProducerTest extends JMSTestBase { try { producer.send(queue2, m); Assert.fail("must not be reached"); - } - catch (UnsupportedOperationException cause) { + } catch (UnsupportedOperationException cause) { // expected } try { producer.send(queue, m); Assert.fail("tck7 requires an UnsupportedOperationException " + "even if the destination is the same as the default one"); - } - catch (UnsupportedOperationException cause) { + } catch (UnsupportedOperationException cause) { // expected } - } - finally { + } finally { session.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageTest.java index 92525a94da..29063f201d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/MessageTest.java @@ -87,8 +87,7 @@ public class MessageTest extends JMSTestBase { received.readObject(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -96,8 +95,7 @@ public class MessageTest extends JMSTestBase { received.readBoolean(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -105,8 +103,7 @@ public class MessageTest extends JMSTestBase { received.readByte(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -114,8 +111,7 @@ public class MessageTest extends JMSTestBase { received.readChar(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -123,8 +119,7 @@ public class MessageTest extends JMSTestBase { received.readDouble(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -132,8 +127,7 @@ public class MessageTest extends JMSTestBase { received.readFloat(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -141,8 +135,7 @@ public class MessageTest extends JMSTestBase { received.readInt(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -150,8 +143,7 @@ public class MessageTest extends JMSTestBase { received.readLong(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -159,8 +151,7 @@ public class MessageTest extends JMSTestBase { received.readShort(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } @@ -168,12 +159,10 @@ public class MessageTest extends JMSTestBase { received.readString(); fail("Should throw exception"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { //Ok } - } - finally { + } finally { conn.close(); } } @@ -234,40 +223,34 @@ public class MessageTest extends JMSTestBase { try { MessageTest.log.info(message.getIntProperty(MessageTest.propName1)); Assert.fail("Should throw exception"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // Ok } try { MessageTest.log.info(message.getShortProperty(MessageTest.propName1)); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // Ok } try { MessageTest.log.info(message.getByteProperty(MessageTest.propName1)); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // Ok } Assert.assertEquals(false, message.getBooleanProperty(MessageTest.propName1)); try { MessageTest.log.info(message.getLongProperty(MessageTest.propName1)); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // Ok } try { MessageTest.log.info(message.getFloatProperty(MessageTest.propName1)); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { // Ok } try { MessageTest.log.info(message.getDoubleProperty(MessageTest.propName1)); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { // Ok } } @@ -308,8 +291,7 @@ public class MessageTest extends JMSTestBase { assertNotNull(consGeral.receive(5000)); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NewQueueRequestorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NewQueueRequestorTest.java index 84a7940474..25377de8dd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NewQueueRequestorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NewQueueRequestorTest.java @@ -64,8 +64,7 @@ public class NewQueueRequestorTest extends JMSTestBase { assertEquals("This is the response", m2.getText()); requestor.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } @@ -96,8 +95,7 @@ public class NewQueueRequestorTest extends JMSTestBase { Destination queue = m.getJMSReplyTo(); Message m2 = sess.createTextMessage("This is the response"); sender.send(queue, m2); - } - catch (JMSException e) { + } catch (JMSException e) { log.error(e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NoLocalSubscriberTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NoLocalSubscriberTest.java index 6cd63e33bd..860b9ad003 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NoLocalSubscriberTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/NoLocalSubscriberTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Message; @@ -29,8 +26,10 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.jms.TopicSubscriber; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Test; public class NoLocalSubscriberTest extends JMSTestBase { // Constants ----------------------------------------------------- @@ -106,8 +105,7 @@ public class NoLocalSubscriberTest extends JMSTestBase { received = noLocalConsumer.receive(5000); assertNotNull("nolocal consumer did not get message", received); assertEquals(text, ((TextMessage) received).getText()); - } - finally { + } finally { if (defaultConn != null) { defaultConn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/PreACKJMSTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/PreACKJMSTest.java index e702c959e1..cc96f08311 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/PreACKJMSTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/PreACKJMSTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Before; -import org.junit.Test; - import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; @@ -31,6 +24,13 @@ import javax.jms.TextMessage; import java.util.ArrayList; import java.util.List; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Before; +import org.junit.Test; + public class PreACKJMSTest extends JMSTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java index aad5d5337e..bbb81f8282 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java @@ -16,16 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import javax.jms.BytesMessage; import javax.jms.MapMessage; import javax.jms.Message; @@ -39,6 +29,16 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + /** * Receive Messages and resend them, like the bridge would do */ @@ -157,8 +157,7 @@ public class ReSendMessageTest extends JMSTestBase { for (int i = 0; i < copiedBytes.getBodyLength(); i++) { Assert.assertEquals(ActiveMQTestBase.getSamplebyte(i), copiedBytes.readByte()); } - } - else if (copiedMessage instanceof MapMessage) { + } else if (copiedMessage instanceof MapMessage) { MapMessage copiedMap = (MapMessage) copiedMessage; MapMessage originalMap = (MapMessage) originalMessage; if (originalMap.getString("str") != null) { @@ -173,12 +172,10 @@ public class ReSendMessageTest extends JMSTestBase { if (originalMap.getObject("object") != null) { Assert.assertEquals(originalMap.getObject("object"), copiedMap.getObject("object")); } - } - else if (copiedMessage instanceof ObjectMessage) { + } else if (copiedMessage instanceof ObjectMessage) { Assert.assertNotSame(((ObjectMessage) originalMessage).getObject(), ((ObjectMessage) copiedMessage).getObject()); Assert.assertEquals(((ObjectMessage) originalMessage).getObject(), ((ObjectMessage) copiedMessage).getObject()); - } - else if (copiedMessage instanceof TextMessage) { + } else if (copiedMessage instanceof TextMessage) { Assert.assertEquals(((TextMessage) originalMessage).getText(), ((TextMessage) copiedMessage).getText()); } } @@ -215,8 +212,7 @@ public class ReSendMessageTest extends JMSTestBase { if (other.txt != null) { return false; } - } - else if (!txt.equals(other.txt)) { + } else if (!txt.equals(other.txt)) { return false; } return true; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReceiveNoWaitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReceiveNoWaitTest.java index 4e5eb1ce39..a426948632 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReceiveNoWaitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReceiveNoWaitTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Before; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.MessageConsumer; @@ -28,6 +24,10 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Before; +import org.junit.Test; + /** * A ReceiveNoWaitTest */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/RemoteConnectionStressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/RemoteConnectionStressTest.java index c457d7341b..a7775e4d52 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/RemoteConnectionStressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/RemoteConnectionStressTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; +import javax.jms.Connection; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -29,14 +37,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; - /** * test Written to replicate https://issues.jboss.org/browse/HORNETQ-1312 */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionClosedOnRemotingConnectionFailureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionClosedOnRemotingConnectionFailureTest.java index 4f664f117a..244a101f88 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionClosedOnRemotingConnectionFailureTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionClosedOnRemotingConnectionFailureTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -29,9 +23,10 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; -import org.junit.Assert; - +import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -40,6 +35,8 @@ import org.apache.activemq.artemis.jms.client.ActiveMQSession; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Assert; +import org.junit.Test; /** * A SessionClosedOnRemotingConnectionFailureTest @@ -95,8 +92,7 @@ public class SessionClosedOnRemotingConnectionFailureTest extends JMSTestBase { prod.send(session.createMessage()); Assert.fail("Should throw exception"); - } - catch (JMSException e) { + } catch (JMSException e) { // assertEquals(ActiveMQException.OBJECT_CLOSED, e.getCode()); } @@ -104,20 +100,17 @@ public class SessionClosedOnRemotingConnectionFailureTest extends JMSTestBase { cons.receive(); Assert.fail("Should throw exception"); - } - catch (JMSException e) { + } catch (JMSException e) { // assertEquals(ActiveMQException.OBJECT_CLOSED, e.getCode()); } session.close(); conn.close(); - } - finally { + } finally { try { conn.close(); - } - catch (Throwable igonred) { + } catch (Throwable igonred) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionTest.java index 8fdce00e05..895fa88797 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionTest.java @@ -22,8 +22,8 @@ import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.Topic; -import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Test; public class SessionTest extends JMSTestBase { @@ -47,43 +47,37 @@ public class SessionTest extends JMSTestBase { QueueSession qSess = qConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); try { qSess.createDurableConsumer(topic, "mySub1"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { qSess.createDurableConsumer(topic, "mySub1", "TEST = 'test'", false); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { qSess.createSharedConsumer(topic, "mySub1"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { qSess.createSharedConsumer(topic, "mySub1", "TEST = 'test'"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { qSess.createSharedDurableConsumer(topic, "mySub1"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { qSess.createSharedDurableConsumer(topic, "mySub1", "TEST = 'test'"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } @@ -91,34 +85,29 @@ public class SessionTest extends JMSTestBase { try { defaultSess.createDurableSubscriber(topic, "mySub1"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { defaultSess.createDurableSubscriber(topic, "mySub1", "TEST = 'test'", true); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { defaultSess.createDurableConsumer(topic, "mySub1"); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } try { defaultSess.createDurableConsumer(topic, "mySub1", "TEST = 'test'", true); - } - catch (javax.jms.IllegalStateException ex) { + } catch (javax.jms.IllegalStateException ex) { //ok expected. } - } - finally { + } finally { if (defaultConn != null) { defaultConn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/StoreConfigTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/StoreConfigTest.java index 131cb0e621..9641641a8d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/StoreConfigTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/StoreConfigTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -29,10 +24,13 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.naming.NamingException; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl; import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Test; public class StoreConfigTest extends JMSTestBase { @@ -60,8 +58,7 @@ public class StoreConfigTest extends JMSTestBase { try { jmsServer.addConnectionFactoryToBindingRegistry("np", "/someCF"); fail("Failure expected and the API let duplicates"); - } - catch (NamingException expected) { + } catch (NamingException expected) { // expected } @@ -85,8 +82,7 @@ public class StoreConfigTest extends JMSTestBase { try { jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI"); fail("Failure expected and the API let duplicates"); - } - catch (NamingException expected) { + } catch (NamingException expected) { // expected } openCon("/someCF"); @@ -300,8 +296,7 @@ public class StoreConfigTest extends JMSTestBase { Object obj = null; try { obj = namingContext.lookup(name); - } - catch (Exception expected) { + } catch (Exception expected) { } assertNull(obj); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TextMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TextMessageTest.java index faa38955fe..e8b92a162f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TextMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TextMessageTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.jms.client; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.List; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -25,13 +32,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.List; - public class TextMessageTest extends JMSTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TopicCleanupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TopicCleanupTest.java index 3d27f12184..280596aadc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TopicCleanupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TopicCleanupTest.java @@ -94,12 +94,10 @@ public class TopicCleanupTest extends JMSTestBase { jmsServer.start(); - } - finally { + } finally { try { conn.close(); - } - catch (Throwable igonred) { + } catch (Throwable igonred) { } } @@ -141,16 +139,14 @@ public class TopicCleanupTest extends JMSTestBase { } assertFalse(foundStrayRoutingBinding); - } - finally { + } finally { jmsServer.stop(); jmsServer.start(); try { conn.close(); - } - catch (Throwable igonred) { + } catch (Throwable igonred) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/AutoCreateQueueClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/AutoCreateQueueClusterTest.java index 255189095a..cda5494c22 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/AutoCreateQueueClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/AutoCreateQueueClusterTest.java @@ -73,8 +73,7 @@ public class AutoCreateQueueClusterTest extends JMSClusteredTestBase { assertEquals("m1", received.getText()); cons2.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java index 38b8ad6250..927d347bca 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/BindingsClusterTest.java @@ -16,6 +16,18 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -33,18 +45,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - @RunWith(value = Parameterized.class) public class BindingsClusterTest extends JMSClusteredTestBase { @@ -162,8 +162,7 @@ public class BindingsClusterTest extends JMSClusteredTestBase { assertEquals("m3", received.getText()); cons2.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } @@ -283,8 +282,7 @@ public class BindingsClusterTest extends JMSClusteredTestBase { assertEquals("m5", received.getText()); cons2.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } @@ -392,8 +390,7 @@ public class BindingsClusterTest extends JMSClusteredTestBase { assertEquals("m7", received.getText()); cons2.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java index 5cb23b3ef2..5f90a6e6f6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java @@ -16,6 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -47,19 +60,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * A JMSFailoverTest *
@@ -327,8 +327,7 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase { while (timeout > System.currentTimeMillis() && eventTypeList.size() < elements) { try { Thread.sleep(1); - } - catch (Throwable e) { + } catch (Throwable e) { fail(e.getMessage()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverTest.java index a878ae779b..802d84b906 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverTest.java @@ -16,6 +16,22 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.SimpleString; @@ -52,22 +68,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - /** * A JMSFailoverTest *
@@ -135,8 +135,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { JMSUtil.crash(liveServer, coreSession); assertNotNull(ctx2.lookup("/queue/queue1")); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -164,8 +163,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { JMSUtil.crash(liveServer, coreSession); assertNotNull(ctx2.lookup("/topic/t1")); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -366,8 +364,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { // a large timeout just to help in case of debugging try { waitToKill.await(120, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -375,8 +372,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { System.out.println("Killing server..."); JMSUtil.crash(liveServer, coreSession); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -420,8 +416,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { message = (TextMessage) consumer.receive(5000); assertNotNull(message); break; - } - catch (JMSException e) { + } catch (JMSException e) { new Exception("Exception on receive message", e).printStackTrace(); } } while (retryNrs < 10); @@ -430,8 +425,7 @@ public class JMSFailoverTest extends ActiveMQTestBase { try { sess.commit(); - } - catch (Exception e) { + } catch (Exception e) { new Exception("Exception during commit", e); sess.rollback(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java index cba768ac49..639c23c084 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java @@ -16,6 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -36,19 +49,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - public class JMSReconnectTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -182,8 +182,7 @@ public class JMSReconnectTest extends ActiveMQTestBase { coreSession.createQueue(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX + "mytopic", "blahblah", null, false); dest = ActiveMQJMSClient.createTopic("mytopic"); - } - else { + } else { dest = sess.createTemporaryQueue(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/LargeMessageOverBridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/LargeMessageOverBridgeTest.java index e2adebbc3a..14d730c272 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/LargeMessageOverBridgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/LargeMessageOverBridgeTest.java @@ -16,6 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.MapMessage; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -28,17 +39,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.MapMessage; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.Arrays; -import java.util.Collection; - @RunWith(value = Parameterized.class) public class LargeMessageOverBridgeTest extends JMSClusteredTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java index 6ff3748603..75583eca17 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java @@ -29,14 +29,15 @@ import org.junit.Test; public class MultipleThreadsOpeningTest extends JMSClusteredTestBase { - /** created for https://issues.apache.org/jira/browse/ARTEMIS-385 */ + /** + * created for https://issues.apache.org/jira/browse/ARTEMIS-385 + */ @Test public void testRepetitions() throws Exception { // This test was eventually failing with way over more iterations. // you might increase it for debugging final int ITERATIONS = 50; - for (int i = 0; i < ITERATIONS; i++) { System.out.println("#test " + i); internalMultipleOpen(200, 1); @@ -80,8 +81,7 @@ public class MultipleThreadsOpeningTest extends JMSClusteredTestBase { sess.close(); conn.close(); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors++; } @@ -104,8 +104,7 @@ public class MultipleThreadsOpeningTest extends JMSClusteredTestBase { assertFalse(t.isAlive()); assertEquals("There are Errors on the test thread", 0, t.errors); } - } - finally { + } finally { for (ThreadOpen t : threads) { if (t.isAlive()) { t.interrupt(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TemporaryQueueClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TemporaryQueueClusterTest.java index 6f2c68a4aa..8c7a408904 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TemporaryQueueClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TemporaryQueueClusterTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; -import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -26,6 +23,9 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase; +import org.junit.Test; + public class TemporaryQueueClusterTest extends JMSClusteredTestBase { // Constants ----------------------------------------------------- @@ -75,8 +75,7 @@ public class TemporaryQueueClusterTest extends JMSClusteredTestBase { assertNotNull(msgReceived); assertEquals(msgReceived.getText(), msg.getText()); - } - finally { + } finally { conn1.close(); conn2.close(); } @@ -130,8 +129,7 @@ public class TemporaryQueueClusterTest extends JMSClusteredTestBase { System.out.println(received.getText()); } } - } - finally { + } finally { conn1.close(); conn2.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TopicClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TopicClusterTest.java index 3d52e4c020..73bd7ca049 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TopicClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/TopicClusterTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.cluster; -import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.MessageConsumer; @@ -27,6 +24,9 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase; +import org.junit.Test; + public class TopicClusterTest extends JMSClusteredTestBase { // Constants ----------------------------------------------------- @@ -82,8 +82,7 @@ public class TopicClusterTest extends JMSClusteredTestBase { assertEquals("someMessage", received.getText()); cons2.close(); - } - finally { + } finally { conn1.close(); conn2.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java index f2e11f9396..0dd966b7d0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionFactoryOnGCest.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -53,8 +52,7 @@ public class CloseConnectionFactoryOnGCest extends JMSTestBase { conn = null; } forceGC(); - } - finally { + } finally { ServerLocatorImpl.finalizeCallback = null; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java index b6ef8c8103..427fbfbfaa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; +import javax.jms.Connection; +import javax.jms.Session; +import java.lang.ref.WeakReference; +import java.util.Iterator; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -28,13 +35,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.Session; -import java.lang.ref.WeakReference; -import java.util.Iterator; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * A CloseConnectionOnGCTest */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseDestroyedConnectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseDestroyedConnectionTest.java index bb1fa4a113..8f3c5d3192 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseDestroyedConnectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseDestroyedConnectionTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Queue; +import javax.jms.Session; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException; @@ -33,11 +38,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.Session; - public class CloseDestroyedConnectionTest extends JMSTestBase { private ActiveMQConnectionFactory cf; @@ -73,8 +73,7 @@ public class CloseDestroyedConnectionTest extends JMSTestBase { try { cs.createConsumer(address); fail("the address from the TemporaryTopic still exists!"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { assertEquals("expecting 'queue does not exist'", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConcurrentSessionCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConcurrentSessionCloseTest.java index 4317b137db..82e63e8dbf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConcurrentSessionCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConcurrentSessionCloseTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; +import javax.jms.Connection; +import javax.jms.Session; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -24,10 +28,6 @@ import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.Session; -import java.util.concurrent.atomic.AtomicBoolean; - /** * A ConcurrentSessionCloseTest */ @@ -67,8 +67,7 @@ public class ConcurrentSessionCloseTest extends JMSTestBase { Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed.set(true); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactorySerializationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactorySerializationTest.java index 58b797d1d1..931ae074d3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactorySerializationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactorySerializationTest.java @@ -38,12 +38,12 @@ import org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFa import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.commons.beanutils.BeanUtilsBean; import org.junit.Assert; import org.junit.Before; @@ -240,18 +240,15 @@ public class ConnectionFactorySerializationTest extends JMSTestBase { String value = RandomUtil.randomString(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == int.class) { + } else if (descriptor.getPropertyType() == int.class) { int value = RandomUtil.randomPositiveInt(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == long.class) { + } else if (descriptor.getPropertyType() == long.class) { long value = RandomUtil.randomPositiveLong(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); - } - else if (descriptor.getPropertyType() == double.class) { + } else if (descriptor.getPropertyType() == double.class) { double value = RandomUtil.randomDouble(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); @@ -295,8 +292,7 @@ public class ConnectionFactorySerializationTest extends JMSTestBase { InetAddress addr; try { addr = InetAddress.getLocalHost(); - } - catch (ArrayIndexOutOfBoundsException e) { //this is workaround for mac osx bug see AS7-3223 and JGRP-1404 + } catch (ArrayIndexOutOfBoundsException e) { //this is workaround for mac osx bug see AS7-3223 and JGRP-1404 addr = InetAddress.getByName(null); } return addr; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactoryWithJGroupsSerializationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactoryWithJGroupsSerializationTest.java index 1be398da2c..dc2828b786 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactoryWithJGroupsSerializationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ConnectionFactoryWithJGroupsSerializationTest.java @@ -77,8 +77,7 @@ public class ConnectionFactoryWithJGroupsSerializationTest extends JMSTestBase { jmsServer.createConnectionFactory("ConnectionFactory2", false, JMSFactoryType.CF, dcConfig2.getName(), "/ConnectionFactory2"); testQueue = createQueue("testQueueFor1389"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; } @@ -99,8 +98,7 @@ public class ConnectionFactoryWithJGroupsSerializationTest extends JMSTestBase { try { serialize(jmsCf1); - } - catch (java.io.NotSerializableException e) { + } catch (java.io.NotSerializableException e) { //this is expected } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java index 4d9b79f3b3..feaa7a3421 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; +import javax.jms.Connection; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -34,13 +41,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Session; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * ExceptionListenerTest */ diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/InvalidConnectorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/InvalidConnectorTest.java index d1b4588b0a..7348e2a16b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/InvalidConnectorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/InvalidConnectorTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -24,12 +30,6 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Test; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class InvalidConnectorTest extends JMSTestBase { @Test @@ -56,4 +56,4 @@ public class InvalidConnectorTest extends JMSTestBase { assertNotSame(tc.getParams().get(TransportConstants.HOST_PROP_NAME), "0.0.0.0"); assertEquals(tc.getParams().get(TransportConstants.HOST_PROP_NAME), InetAddress.getLocalHost().getHostName()); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java index ae4d041002..7c5cde6098 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java @@ -16,21 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.consumer; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.core.server.Queue; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.utils.ReusableLatch; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import javax.jms.Connection; import javax.jms.JMSConsumer; import javax.jms.JMSContext; @@ -46,6 +31,21 @@ import javax.jms.TextMessage; import java.util.Enumeration; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.apache.activemq.artemis.utils.ReusableLatch; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + public class ConsumerTest extends JMSTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -221,11 +221,9 @@ public class ConsumerTest extends JMSTestBase { } count++; - } - catch (Exception e) { + } catch (Exception e) { errors.incrementAndGet(); - } - finally { + } finally { latch.countDown(); } } @@ -491,8 +489,7 @@ public class ConsumerTest extends JMSTestBase { try { consumer.receiveNoWait(); Assert.fail("Should throw exception"); - } - catch (JMSException e) { + } catch (JMSException e) { // Ok } } @@ -550,8 +547,7 @@ public class ConsumerTest extends JMSTestBase { boolean exception = false; try { conn3.setClientID("C2"); - } - catch (Exception e) { + } catch (Exception e) { exception = true; } @@ -585,8 +581,7 @@ public class ConsumerTest extends JMSTestBase { boolean exceptionHappened = false; try { MessageConsumer cons2Error = session.createSharedConsumer(topic2, "cons1"); - } - catch (JMSException e) { + } catch (JMSException e) { exceptionHappened = true; } @@ -607,8 +602,7 @@ public class ConsumerTest extends JMSTestBase { exceptionHappened = false; try { session.unsubscribe("cons1"); - } - catch (JMSException e) { + } catch (JMSException e) { exceptionHappened = true; } @@ -679,8 +673,7 @@ public class ConsumerTest extends JMSTestBase { try { session.unsubscribe("c1"); - } - catch (JMSException e) { + } catch (JMSException e) { exceptionHappened = true; } @@ -733,8 +726,7 @@ public class ConsumerTest extends JMSTestBase { try { conn.unsubscribe("c1"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); exceptionHappened = true; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/divert/DivertAndACKClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/divert/DivertAndACKClientTest.java index fc7190503b..b702072f99 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/divert/DivertAndACKClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/divert/DivertAndACKClientTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.jms.divert; +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import java.util.List; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -25,14 +33,6 @@ import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Assert; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.util.List; - /** * A DivertAndACKClientTest * diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java index 88de391b8c..826a4c6bde 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java @@ -64,8 +64,7 @@ public class BodyTest extends JMSTestBase { try { msg.getBody(String.class); fail("Exception expected"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/InvalidDestinationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/InvalidDestinationTest.java index 40f73007d0..a4ed52ee54 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/InvalidDestinationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/InvalidDestinationTest.java @@ -62,21 +62,17 @@ public class InvalidDestinationTest extends JMSTestBase { try { producer.send(invalidDestination, expTextMessage); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { producer.send(invalidDestination, message); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } @@ -85,131 +81,105 @@ public class InvalidDestinationTest extends JMSTestBase { om.setObject(sb); try { producer.send(invalidDestination, om); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { producer.send(invalidDestination, bytesMsgSend); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { producer.send(invalidDestination, mapMsgSend); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createConsumer(invalidDestination); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createConsumer(invalidDestination, "lastMessage = TRUE"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createConsumer(invalidDestination, "lastMessage = TRUE", false); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createDurableConsumer(invalidTopic, "InvalidDestinationRuntimeException"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createDurableConsumer(invalidTopic, "InvalidDestinationRuntimeException", "lastMessage = TRUE", false); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createSharedDurableConsumer(invalidTopic, "InvalidDestinationRuntimeException"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createSharedDurableConsumer(invalidTopic, "InvalidDestinationRuntimeException", "lastMessage = TRUE"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.unsubscribe("InvalidSubscriptionName"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createSharedConsumer(invalidTopic, "InvalidDestinationRuntimeException"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } try { context.createSharedConsumer(invalidTopic, "InvalidDestinationRuntimeException", "lastMessage = TRUE"); - } - catch (InvalidDestinationRuntimeException e) { + } catch (InvalidDestinationRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationRuntimeException, received " + e); } } @@ -226,86 +196,69 @@ public class InvalidDestinationTest extends JMSTestBase { try { session.createDurableSubscriber(invalidTopic, "InvalidDestinationException"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createDurableSubscriber(invalidTopic, "InvalidDestinationException", "lastMessage = TRUE", false); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } System.out.println("Testing Session.createDurableConsumer(Topic, String) for InvalidDestinationException"); try { session.createDurableConsumer(invalidTopic, "InvalidDestinationException"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createDurableConsumer(invalidTopic, "InvalidDestinationException", "lastMessage = TRUE", false); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createSharedConsumer(invalidTopic, "InvalidDestinationException"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createSharedConsumer(invalidTopic, "InvalidDestinationException", "lastMessage = TRUE"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createSharedDurableConsumer(invalidTopic, "InvalidDestinationException"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } try { session.createSharedDurableConsumer(invalidTopic, "InvalidDestinationException", "lastMessage = TRUE"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("Expected InvalidDestinationException, received " + e); } - } - finally { + } finally { conn.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsContextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsContextTest.java index e3d7b6d04e..7f6ff379fe 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsContextTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsContextTest.java @@ -250,8 +250,7 @@ public class JmsContextTest extends JMSTestBase { try { producer.send(queue1, (Message) null); Assert.fail("null msg"); - } - catch (MessageFormatRuntimeException expected) { + } catch (MessageFormatRuntimeException expected) { // no-op } } @@ -263,8 +262,7 @@ public class JmsContextTest extends JMSTestBase { try { producer.send((Destination) null, msg); Assert.fail("null Destination"); - } - catch (InvalidDestinationRuntimeException expected) { + } catch (InvalidDestinationRuntimeException expected) { // no-op } } @@ -302,8 +300,7 @@ public class JmsContextTest extends JMSTestBase { try { context.setClientID("id"); Assert.fail("expected exception"); - } - catch (IllegalStateRuntimeException e) { + } catch (IllegalStateRuntimeException e) { // no op } } @@ -339,11 +336,10 @@ public class JmsContextTest extends JMSTestBase { try { msg.acknowledge(); Assert.assertEquals("connection should be open on pass 0. It is " + pass, 0, idx); - } - // HORNETQ-1209 "JMS 2.0" XXX JMSContext javadoc says we must expect a - // IllegalStateRuntimeException here. But Message.ack...() says it must throws the - // non-runtime variant. - catch (javax.jms.IllegalStateException expected) { + } catch (javax.jms.IllegalStateException expected) { + // HORNETQ-1209 "JMS 2.0" XXX JMSContext javadoc says we must expect a + // IllegalStateRuntimeException here. But Message.ack...() says it must throws the + // non-runtime variant. Assert.assertEquals("we only close the connection on pass " + pass, pass, idx); } } @@ -370,8 +366,7 @@ public class JmsContextTest extends JMSTestBase { try { c2.createMessage(); Assert.fail("session should be closed..."); - } - catch (JMSRuntimeException expected) { + } catch (JMSRuntimeException expected) { // expected } Message m1 = context.createMessage(); @@ -534,8 +529,7 @@ public class JmsContextTest extends JMSTestBase { assertTrue(latch.await(5, TimeUnit.SECONDS)); assertEquals(listener.message.readByte(), (byte) 1); assertEquals(listener.message.readInt(), 22); - } - finally { + } finally { context.close(); } } @@ -610,8 +604,7 @@ public class JmsContextTest extends JMSTestBase { private void stopContext() { try { context.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { error = t; } } @@ -619,8 +612,7 @@ public class JmsContextTest extends JMSTestBase { private void closeContext() { try { context.close(); - } - catch (Throwable t) { + } catch (Throwable t) { error = t; } } @@ -642,8 +634,7 @@ public class JmsContextTest extends JMSTestBase { public void onCompletion(Message message) { try { context.stop(); - } - catch (Exception e) { + } catch (Exception e) { this.ex = e; } latch.countDown(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsProducerCompletionListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsProducerCompletionListenerTest.java index debcb03004..d3951f26bf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsProducerCompletionListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/JmsProducerCompletionListenerTest.java @@ -32,8 +32,8 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration; +import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -99,11 +99,9 @@ public class JmsProducerCompletionListenerTest extends JMSTestBase { MessageProducer prod = session.createProducer(queue); prod.send(session.createMessage(), null); Assert.fail("Didn't get expected exception!"); - } - catch (IllegalArgumentException expected) { + } catch (IllegalArgumentException expected) { //ok - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -162,8 +160,7 @@ public class JmsProducerCompletionListenerTest extends JMSTestBase { default: throw new IllegalArgumentException("call code " + call); } - } - catch (Exception error1) { + } catch (Exception error1) { this.error = error1; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/NonExistentQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/NonExistentQueueTest.java index 1115305b50..70d26377b3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/NonExistentQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/NonExistentQueueTest.java @@ -32,9 +32,9 @@ import java.util.Random; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -66,8 +66,7 @@ public class NonExistentQueueTest extends JMSTestBase { MessageProducer messageProducer = session.createProducer(null); messageProducer.send(destination, session.createMessage()); Assert.fail("Succeeded in sending message to a non-existent destination using JMS 1 API!"); - } - catch (JMSException e) { // Expected } + } catch (JMSException e) { // Expected } } @@ -78,8 +77,7 @@ public class NonExistentQueueTest extends JMSTestBase { try { jmsProducer.send(destination, context.createMessage()); Assert.fail("Succeeded in sending message to a non-existent destination using JMS 2 API!"); - } - catch (JMSRuntimeException e) { // Expected } + } catch (JMSRuntimeException e) { // Expected } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/SharedConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/SharedConsumerTest.java index ad58314ec1..8460a5ac6d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/SharedConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/SharedConsumerTest.java @@ -65,8 +65,7 @@ public class SharedConsumerTest extends JMSTestBase { System.out.println("msg = " + msg); } - } - finally { + } finally { context.close(); } } @@ -81,8 +80,7 @@ public class SharedConsumerTest extends JMSTestBase { con2.close(); context.unsubscribe("mySharedCon"); con1 = context.createSharedDurableConsumer(topic2, "mySharedCon"); - } - finally { + } finally { context.close(); } } @@ -100,8 +98,7 @@ public class SharedConsumerTest extends JMSTestBase { binding = server.getPostOffice().getBinding(new SimpleString("nonDurable.mySharedCon")); assertNull(binding); con1 = context.createSharedConsumer(topic2, "mySharedCon"); - } - finally { + } finally { context.close(); } } @@ -114,15 +111,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel2'"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -135,15 +129,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel2'"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -156,15 +147,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedConsumer(topic1, "mySharedCon"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -177,15 +165,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedDurableConsumer(topic2, "mySharedCon"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -198,15 +183,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedDurableConsumer(topic1, "mySharedCon", "sel = 'sel2'"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -219,15 +201,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedDurableConsumer(topic1, "mySharedCon", "sel = 'sel2'"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } @@ -240,15 +219,12 @@ public class SharedConsumerTest extends JMSTestBase { try { context.createSharedDurableConsumer(topic1, "mySharedCon"); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException jmse) { + } catch (JMSRuntimeException jmse) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("threw wrong exception expected JMSRuntimeException got " + e); } - } - finally { + } finally { context.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java index 36f3bd5ca3..ebef7e6829 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.largemessage; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.utils.UUIDGenerator; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.MessageConsumer; @@ -37,6 +30,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.apache.activemq.artemis.utils.UUIDGenerator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + public class JMSLargeMessageTest extends JMSTestBase { // Constants ----------------------------------------------------- @@ -154,8 +154,7 @@ public class JMSLargeMessageTest extends JMSTestBase { try { msg.setObjectProperty("JMS_AMQ_InputStream", ActiveMQTestBase.createFakeLargeStream(10)); Assert.fail("Exception was expected"); - } - catch (JMSException e) { + } catch (JMSException e) { } msg.setText("hello"); @@ -185,8 +184,7 @@ public class JMSLargeMessageTest extends JMSTestBase { }); Assert.fail("Exception was expected"); - } - catch (JMSException e) { + } catch (JMSException e) { } Assert.assertEquals("hello", rm.getText()); @@ -246,8 +244,7 @@ public class JMSLargeMessageTest extends JMSTestBase { try { rm.setObjectProperty("JMS_AMQ_InputStream", ActiveMQTestBase.createFakeLargeStream(100)); Assert.fail("Exception expected!"); - } - catch (MessageNotWriteableException expected) { + } catch (MessageNotWriteableException expected) { } rm.setObjectProperty("JMS_AMQ_SaveStream", out); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/serializables/TestClass1.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/serializables/TestClass1.java index ec73aa5ba9..a27401ba6a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/serializables/TestClass1.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/serializables/TestClass1.java @@ -19,4 +19,5 @@ package org.apache.activemq.artemis.tests.integration.jms.serializables; import java.io.Serializable; public class TestClass1 implements Serializable { + } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerDeployerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerDeployerTest.java index b2645c475c..4f73910d8d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerDeployerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerDeployerTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.Context; + import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; @@ -32,10 +36,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Queue; -import javax.jms.Topic; -import javax.naming.Context; - public class JMSServerDeployerTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -122,4 +122,4 @@ public class JMSServerDeployerTest extends ActiveMQTestBase { // Inner classes ------------------------------------------------- -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java index c18b4310ab..1e20fb0354 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java @@ -99,8 +99,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase { TextMessage tm = sess.createTextMessage("message" + j); producer.send(tm); - } - finally { + } finally { conn.close(); jbcf.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java index d9912b60ee..165e6bfed2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.config; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.Context; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; @@ -36,14 +44,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Queue; -import javax.jms.Topic; -import javax.naming.Context; -import java.util.ArrayList; -import java.util.List; - public class JMSConfigurationTest extends ActiveMQTestBase { @Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSServerConfigParserTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSServerConfigParserTest.java index 31719362cc..953d70b83f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSServerConfigParserTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSServerConfigParserTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.config; -import org.apache.activemq.artemis.core.config.FileDeploymentManager; -import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; -import org.junit.Test; - import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration; import org.apache.activemq.artemis.jms.server.config.TopicConfiguration; +import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Test; public class JMSServerConfigParserTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java index 7436ce1f9c..b5af25bbd2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java @@ -16,29 +16,28 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.management.Notification; import java.util.ArrayList; import java.util.List; -import javax.management.Notification; - -import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; -import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase; -import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl; import org.apache.activemq.artemis.api.jms.management.JMSServerControl; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.artemis.jms.server.management.JMSNotificationType; +import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; +import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase; +import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * A Connection Factory Control Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSMessagingProxy.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSMessagingProxy.java index 6042f2e9d2..1e33e9194a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSMessagingProxy.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSMessagingProxy.java @@ -66,23 +66,24 @@ public class JMSMessagingProxy { JMSManagementHelper.putAttribute(m, resourceName, attributeName); Message reply = requestor.request(m); return JMSManagementHelper.getResult(reply, desiredType); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } + public Object invokeOperation(final String operationName, final Object... args) throws Exception { return invokeOperation(null, operationName, args); } - public Object invokeOperation(final Class desiredType, final String operationName, final Object... args) throws Exception { + public Object invokeOperation(final Class desiredType, + final String operationName, + final Object... args) throws Exception { Message m = session.createMessage(); JMSManagementHelper.putOperationInvocation(m, resourceName, operationName, args); Message reply = requestor.request(m); if (JMSManagementHelper.hasOperationSucceeded(reply)) { return JMSManagementHelper.getResult(reply, desiredType); - } - else { + } else { throw new Exception((String) JMSManagementHelper.getResult(reply)); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java index e312a2acdd..203bd87048 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java @@ -24,6 +24,7 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import javax.json.JsonArray; import javax.management.Notification; import javax.management.openmbean.CompositeData; import javax.naming.Context; @@ -35,6 +36,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -43,7 +45,6 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -72,7 +73,6 @@ import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.json.JsonArray; /** * A QueueControlTest @@ -485,8 +485,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.removeMessage(unknownMessageID); Assert.fail("should throw an exception is the message ID is unknown"); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -589,8 +588,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.changeMessagePriority(messageIDs[0], invalidPriority); Assert.fail("must throw an exception if the new priority is not a valid value"); - } - catch (Exception e) { + } catch (Exception e) { } Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName()); @@ -612,8 +610,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.changeMessagePriority(unknownMessageID, 7); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -698,8 +695,7 @@ public class JMSQueueControlTest extends ManagementTestBase { boolean exception = false; try { serverManager.createQueue(false, someOtherQueue, null, true, someOtherQueue, "/duplicate"); - } - catch (Exception e) { + } catch (Exception e) { exception = true; } @@ -749,8 +745,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.expireMessage(unknownMessageID); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -889,8 +884,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.sendMessageToDeadLetterAddress(unknownMessageID); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -980,8 +974,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.moveMessages(null, unknownQueue); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -1024,14 +1017,13 @@ public class JMSQueueControlTest extends ManagementTestBase { connection.close(); } - protected ActiveMQQueue createDLQ(final String deadLetterQueueName) throws Exception { serverManager.createQueue(false, deadLetterQueueName, null, true, deadLetterQueueName); return (ActiveMQQueue) ActiveMQJMSClient.createQueue(deadLetterQueueName); } protected ActiveMQQueue createTestQueueWithDLQ(final String queueName, final ActiveMQQueue dlq) throws Exception { - serverManager.createQueue(false,queueName,null,true,queueName); + serverManager.createQueue(false, queueName, null, true, queueName); ActiveMQQueue testQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue(queueName); AddressSettings addressSettings = new AddressSettings(); addressSettings.setDeadLetterAddress(new SimpleString(dlq.getAddress())); @@ -1052,21 +1044,22 @@ public class JMSQueueControlTest extends ManagementTestBase { /** * Test retrying all messages put on DLQ - i.e. they should appear on the original queue. + * * @throws Exception */ @Test public void testRetryMessages() throws Exception { ActiveMQQueue dlq = createDLQ(RandomUtil.randomString()); - ActiveMQQueue testQueue = createTestQueueWithDLQ(RandomUtil.randomString(),dlq); + ActiveMQQueue testQueue = createTestQueueWithDLQ(RandomUtil.randomString(), dlq); final int numMessagesToTest = 10; JMSUtil.sendMessages(testQueue, numMessagesToTest); Connection connection = createConnection(); connection.start(); - Session session = connection.createSession(true,Session.AUTO_ACKNOWLEDGE); + Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(testQueue); - for (int i = 0;i < numMessagesToTest;i++) { + for (int i = 0; i < numMessagesToTest; i++) { Message msg = consumer.receive(500L); } session.rollback(); // All messages should now be on DLQ @@ -1074,20 +1067,21 @@ public class JMSQueueControlTest extends ManagementTestBase { JMSQueueControl testQueueControl = createManagementControl(testQueue); JMSQueueControl dlqQueueControl = createManagementControl(dlq); Assert.assertEquals(0, getMessageCount(testQueueControl)); - Assert.assertEquals(numMessagesToTest,getMessageCount(dlqQueueControl)); + Assert.assertEquals(numMessagesToTest, getMessageCount(dlqQueueControl)); - Assert.assertEquals(10,getMessageCount(dlqQueueControl)); + Assert.assertEquals(10, getMessageCount(dlqQueueControl)); dlqQueueControl.retryMessages(); Assert.assertEquals(numMessagesToTest, getMessageCount(testQueueControl)); - Assert.assertEquals(0,getMessageCount(dlqQueueControl)); + Assert.assertEquals(0, getMessageCount(dlqQueueControl)); connection.close(); } /** * Test retrying all messages put on DLQ - i.e. they should appear on the original queue. + * * @throws Exception */ @Test @@ -1101,11 +1095,9 @@ public class JMSQueueControlTest extends ManagementTestBase { MessageConsumer cons1 = sessionConsume.createDurableSubscriber(testTopic, "sub1"); MessageConsumer cons2 = sessionConsume.createDurableSubscriber(testTopic, "sub2"); - final int numMessagesToTest = 10; JMSUtil.sendMessages(testTopic, numMessagesToTest); - connectionConsume.start(); for (int i = 0; i < numMessagesToTest; i++) { Assert.assertNotNull(cons1.receive(500)); @@ -1139,17 +1131,18 @@ public class JMSQueueControlTest extends ManagementTestBase { /** * Test retrying a specific message on DLQ. * Expected to be sent back to original queue. + * * @throws Exception */ @Test public void testRetryMessage() throws Exception { ActiveMQQueue dlq = createDLQ(RandomUtil.randomString()); - ActiveMQQueue testQueue = createTestQueueWithDLQ(RandomUtil.randomString(),dlq); - String messageID = JMSUtil.sendMessages(testQueue,1)[0]; + ActiveMQQueue testQueue = createTestQueueWithDLQ(RandomUtil.randomString(), dlq); + String messageID = JMSUtil.sendMessages(testQueue, 1)[0]; Connection connection = createConnection(); connection.start(); - Session session = connection.createSession(true,Session.AUTO_ACKNOWLEDGE); + Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(testQueue); consumer.receive(500L); session.rollback(); // All messages should now be on DLQ @@ -1157,12 +1150,12 @@ public class JMSQueueControlTest extends ManagementTestBase { JMSQueueControl testQueueControl = createManagementControl(testQueue); JMSQueueControl dlqQueueControl = createManagementControl(dlq); Assert.assertEquals(0, getMessageCount(testQueueControl)); - Assert.assertEquals(1,getMessageCount(dlqQueueControl)); + Assert.assertEquals(1, getMessageCount(dlqQueueControl)); dlqQueueControl.retryMessage(messageID); Assert.assertEquals(1, getMessageCount(testQueueControl)); - Assert.assertEquals(0,getMessageCount(dlqQueueControl)); + Assert.assertEquals(0, getMessageCount(dlqQueueControl)); } @@ -1420,8 +1413,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.moveMessage(unknownMessageID, otherQueueName); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } serverManager.destroyQueue(otherQueueName); @@ -1527,8 +1519,7 @@ public class JMSQueueControlTest extends ManagementTestBase { try { queueControl.moveMessage(messageIDs[0], unknownQueue); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } JMSUtil.consumeMessages(1, queue); @@ -1545,8 +1536,7 @@ public class JMSQueueControlTest extends ManagementTestBase { Assert.assertTrue(queueControl.isPaused()); queueControl.resume(); Assert.assertFalse(queueControl.isPaused()); - } - catch (Exception e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java index a7af35f260..f6c4bdee20 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.QueueConnection; +import javax.jms.QueueSession; +import javax.jms.Session; +import javax.management.openmbean.CompositeData; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.Parameter; import org.apache.activemq.artemis.api.core.management.ResourceNames; @@ -29,12 +35,6 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import javax.jms.QueueConnection; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.management.openmbean.CompositeData; -import java.util.Map; - /** * A JMSQueueControlUsingJMSTest */ @@ -83,8 +83,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest { public void flushExecutor() { try { proxy.invokeOperation("flushExecutor"); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -205,7 +204,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest { } public boolean retryMessage(@Parameter(name = "messageID", desc = "A message ID") long messageID) throws Exception { - return (Boolean) proxy.invokeOperation("retryMessage",messageID); + return (Boolean) proxy.invokeOperation("retryMessage", messageID); } @Override @@ -215,7 +214,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest { @Override public boolean retryMessage(final String messageID) throws Exception { - return (Boolean) proxy.invokeOperation("retryMessage",messageID); + return (Boolean) proxy.invokeOperation("retryMessage", messageID); } @Override @@ -321,7 +320,10 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest { } @Override - public String sendTextMessage(Map headers, String body, String user, String password) throws Exception { + public String sendTextMessage(Map headers, + String body, + String user, + String password) throws Exception { return (String) proxy.invokeOperation("sendTextMessage", headers, body, user, password); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControl2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControl2Test.java index 5950887bb7..87e8921ebd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControl2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControl2Test.java @@ -16,6 +16,22 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -45,22 +61,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.Session; -import javax.jms.TemporaryTopic; -import javax.jms.TextMessage; -import javax.jms.Topic; -import java.util.Arrays; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class JMSServerControl2Test extends ManagementTestBase { private static final long CONNECTION_TTL = 1000; @@ -275,8 +275,7 @@ public class JMSServerControl2Test extends ManagementTestBase { consumer.close(); connection.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.destroyQueue(queueName); serverManager.stop(); @@ -342,8 +341,7 @@ public class JMSServerControl2Test extends ManagementTestBase { consumer.close(); connection.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.destroyTopic(topicName); serverManager.stop(); @@ -428,12 +426,10 @@ public class JMSServerControl2Test extends ManagementTestBase { consumer.close(); connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw e; - } - finally { + } finally { try { if (connection != null) { connection.close(); @@ -443,8 +439,7 @@ public class JMSServerControl2Test extends ManagementTestBase { serverManager.destroyQueue(queueName); serverManager.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -505,8 +500,7 @@ public class JMSServerControl2Test extends ManagementTestBase { assertEquals("user", jmsConnectionInfos[0].getUsername()); assertEquals("my-client-id", jmsConnectionInfos[0].getClientID()); - } - finally { + } finally { if (activation != null) activation.stop(); @@ -523,8 +517,7 @@ public class JMSServerControl2Test extends ManagementTestBase { //serverManager.destroyQueue(queueName); serverManager.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -587,8 +580,7 @@ public class JMSServerControl2Test extends ManagementTestBase { assertEquals("user", jmsConnectionInfos[0].getUsername()); assertEquals("my-client-id", jmsConnectionInfos[0].getClientID()); - } - finally { + } finally { if (activation != null) activation.stop(); @@ -605,8 +597,7 @@ public class JMSServerControl2Test extends ManagementTestBase { //serverManager.destroyQueue(queueName); serverManager.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -650,8 +641,7 @@ public class JMSServerControl2Test extends ManagementTestBase { connection2.close(); waitForConnectionIDs(0, control); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -728,8 +718,7 @@ public class JMSServerControl2Test extends ManagementTestBase { assertNotNull(jsonStr); infos = JMSConnectionInfo.from(jsonStr); assertEquals(0, infos.length); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -782,8 +771,7 @@ public class JMSServerControl2Test extends ManagementTestBase { waitForConnectionIDs(0, control); Assert.assertEquals(0, control.listConnectionIDs().length); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -818,8 +806,7 @@ public class JMSServerControl2Test extends ManagementTestBase { remoteAddresses = control.listRemoteAddresses(); Assert.assertEquals("got " + Arrays.asList(remoteAddresses), 0, remoteAddresses.length); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -867,8 +854,7 @@ public class JMSServerControl2Test extends ManagementTestBase { Assert.assertEquals(0, server.getConnectionCount()); connection.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -916,8 +902,7 @@ public class JMSServerControl2Test extends ManagementTestBase { connection.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -988,8 +973,7 @@ public class JMSServerControl2Test extends ManagementTestBase { connection.close(); connection2.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -1079,8 +1063,7 @@ public class JMSServerControl2Test extends ManagementTestBase { connection.close(); connection2.close(); connection3.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -1151,8 +1134,7 @@ public class JMSServerControl2Test extends ManagementTestBase { connection.close(); connection2.close(); - } - finally { + } finally { if (serverManager != null) { serverManager.stop(); } @@ -1165,4 +1147,4 @@ public class JMSServerControl2Test extends ManagementTestBase { // Inner classes ------------------------------------------------- -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java index 33466239a5..e60011dca5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.Queue; +import javax.jms.QueueRequestor; +import javax.jms.QueueSession; +import javax.jms.Session; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -39,13 +46,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueRequestor; -import javax.jms.QueueSession; -import javax.jms.Session; - public class JMSServerControlRestartTest extends ManagementTestBase { protected InVMNamingContext context; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java index 41bfc70803..bfdd824fdc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java @@ -16,13 +16,36 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import javax.jms.XAConnection; +import javax.jms.XAConnectionFactory; +import javax.jms.XASession; +import javax.json.JsonArray; +import javax.naming.NamingException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.management.AddressControl; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.core.management.ResourceNames; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -53,29 +76,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.XAConnection; -import javax.jms.XAConnectionFactory; -import javax.jms.XASession; -import javax.json.JsonArray; -import javax.naming.NamingException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public class JMSServerControlTest extends ManagementTestBase { // Attributes ---------------------------------------------------- @@ -317,12 +317,10 @@ public class JMSServerControlTest extends ManagementTestBase { try { cons.receive(5000); Assert.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { Assert.assertTrue(e.getCause() instanceof ActiveMQObjectClosedException); } - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -356,8 +354,7 @@ public class JMSServerControlTest extends ManagementTestBase { try { control.destroyQueue(queueName, false); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e.getMessage().startsWith("AMQ119025")); } @@ -369,8 +366,7 @@ public class JMSServerControlTest extends ManagementTestBase { Assert.assertFalse(cons.isClosed()); Assert.assertNotNull(cons.receive(5000)); - } - finally { + } finally { connection.close(); } } @@ -402,8 +398,7 @@ public class JMSServerControlTest extends ManagementTestBase { try { control.destroyTopic(topicName, false); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e.getMessage().startsWith("AMQ119025")); } @@ -412,8 +407,7 @@ public class JMSServerControlTest extends ManagementTestBase { Assert.assertFalse(cons.isClosed()); Assert.assertNotNull(cons.receive(5000)); - } - finally { + } finally { connection.close(); } } @@ -453,12 +447,10 @@ public class JMSServerControlTest extends ManagementTestBase { try { cons.receive(5000); Assert.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { Assert.assertTrue(e.getCause() instanceof ActiveMQObjectClosedException); } - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -504,12 +496,10 @@ public class JMSServerControlTest extends ManagementTestBase { try { cons.receive(5000); Assert.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { Assert.assertTrue(e.getCause() instanceof ActiveMQObjectClosedException); } - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -815,8 +805,7 @@ public class JMSServerControlTest extends ManagementTestBase { try { cf = (ActiveMQQueueConnectionFactory) context.lookup("tst"); Assert.fail("Failure expected"); - } - catch (NamingException e) { + } catch (NamingException e) { } } @@ -926,8 +915,7 @@ public class JMSServerControlTest extends ManagementTestBase { try { connection2.setClientID("someID"); - } - catch (JMSException e) { + } catch (JMSException e) { failed = true; } @@ -942,8 +930,7 @@ public class JMSServerControlTest extends ManagementTestBase { try { connection3.setClientID("someID"); - } - catch (JMSException e) { + } catch (JMSException e) { failed = true; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java index 992b20ba32..7edf3893d2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.QueueConnection; +import javax.jms.QueueSession; +import javax.jms.Session; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.management.ResourceNames; @@ -30,10 +34,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.QueueConnection; -import javax.jms.QueueSession; -import javax.jms.Session; - public class JMSServerControlUsingJMSTest extends JMSServerControlTest { // Constants ----------------------------------------------------- @@ -316,6 +316,7 @@ public class JMSServerControlUsingJMSTest extends JMSServerControlTest { public String listNetworkTopology() throws Exception { return null; } + @Override public String listPreparedTransactionDetailsAsHTML() throws Exception { return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsHTML"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java index 8bbcc1630b..a96d876253 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -32,14 +29,12 @@ import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.management.Notification; import javax.management.NotificationListener; - import java.util.Collection; import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.integration.cluster.failover.FailoverTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Assert; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -56,6 +51,9 @@ import org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImp import org.apache.activemq.artemis.jms.client.ActiveMQConnection; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.tests.integration.cluster.failover.FailoverTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; public class JMSUtil { @@ -158,8 +156,8 @@ public class JMSUtil { } public static BytesMessage sendByteMessage(final Session session, - final Destination destination, - final byte[] bytes) throws JMSException { + final Destination destination, + final byte[] bytes) throws JMSException { MessageProducer producer = session.createProducer(destination); BytesMessage message = session.createBytesMessage(); message.writeBytes(bytes); @@ -190,8 +188,8 @@ public class JMSUtil { } public static Message sendMessageWithReplyTo(final Session session, - final Destination destination, - final String replyTo) throws JMSException { + final Destination destination, + final String replyTo) throws JMSException { MessageProducer producer = session.createProducer(destination); Message message = session.createMessage(); message.setJMSReplyTo(ActiveMQJMSClient.createQueue(replyTo)); @@ -214,8 +212,7 @@ public class JMSUtil { } m = consumer.receiveNoWait(); Assert.assertNull("received one more message than expected (" + expected + ")", m); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -228,8 +225,7 @@ public class JMSUtil { Thread.sleep(100); if (server.isStarted()) { break; - } - else if (System.currentTimeMillis() > timetowait) { + } else if (System.currentTimeMillis() > timetowait) { throw new IllegalStateException("server didn't start"); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlClusterTest.java index 03c47a1bae..2d6e556d38 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlClusterTest.java @@ -16,15 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.Connection; +import javax.jms.Session; +import javax.jms.Topic; + import org.apache.activemq.artemis.api.jms.management.TopicControl; import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.Session; -import javax.jms.Topic; - public class TopicControlClusterTest extends JMSClusteredTestBase { @Test @@ -54,8 +54,7 @@ public class TopicControlClusterTest extends JMSClusteredTestBase { assertEquals(2, topicControl1.getSubscriptionCount()); assertEquals(1, topicControl2.getSubscriptionCount()); - } - finally { + } finally { conn1.close(); conn2.close(); } @@ -63,4 +62,4 @@ public class TopicControlClusterTest extends JMSClusteredTestBase { jmsServer1.destroyTopic("t1"); jmsServer2.destroyTopic("t1"); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java index 25fd608b65..225b7bd72e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java @@ -16,8 +16,24 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.TopicSubscriber; +import javax.json.JsonArray; +import javax.management.Notification; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.JsonUtil; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.management.JMSServerControl; @@ -42,22 +58,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSContext; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.TopicSubscriber; -import javax.json.JsonArray; -import javax.management.Notification; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - public class TopicControlTest extends ManagementTestBase { // Constants ----------------------------------------------------- @@ -297,8 +297,7 @@ public class TopicControlTest extends ManagementTestBase { try { topicControl.countMessagesForSubscription(clientID, unknownSubscription, null); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -311,8 +310,7 @@ public class TopicControlTest extends ManagementTestBase { try { topicControl.countMessagesForSubscription(unknownClientID, subscriptionName, null); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -344,8 +342,7 @@ public class TopicControlTest extends ManagementTestBase { try { topicControl.dropDurableSubscription(clientID, "this subscription does not exist"); Assert.fail("should throw an exception"); - } - catch (Exception e) { + } catch (Exception e) { } @@ -461,8 +458,7 @@ public class TopicControlTest extends ManagementTestBase { try { topicControl.listMessagesForSubscription(ActiveMQDestination.createQueueNameForDurableSubscription(true, unknownClientID, subscriptionName)); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -475,8 +471,7 @@ public class TopicControlTest extends ManagementTestBase { try { topicControl.listMessagesForSubscription(ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, unknownSubscription)); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java index e38135f2de..9d9edab940 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.jms.server.management; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.QueueConnection; +import javax.jms.QueueSession; +import javax.jms.Session; +import javax.jms.TopicSubscriber; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.ResourceNames; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; @@ -37,14 +45,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.QueueConnection; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.jms.TopicSubscriber; - import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; public class TopicControlUsingJMSTest extends ManagementTestBase { @@ -170,9 +170,9 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { waitForAttributeEqualsValue("messageCount", 3L, 3000, Long.class); Assert.assertEquals(2, proxy.invokeOperation(Integer.class, "countMessagesForSubscription", clientID, subscriptionName, key + " =" + - matchingValue)); + matchingValue)); Assert.assertEquals(1, proxy.invokeOperation(Integer.class, "countMessagesForSubscription", clientID, subscriptionName, key + " =" + - unmatchingValue)); + unmatchingValue)); connection.close(); } @@ -184,8 +184,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { try { proxy.invokeOperation("countMessagesForSubscription", clientID, unknownSubscription, null); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -196,8 +195,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { try { proxy.invokeOperation("countMessagesForSubscription", unknownClientID, subscriptionName, null); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -227,8 +225,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { try { proxy.invokeOperation("dropDurableSubscription", clientID, "this subscription does not exist"); Assert.fail("should throw an exception"); - } - catch (Exception e) { + } catch (Exception e) { } @@ -298,8 +295,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { try { proxy.invokeOperation("listMessagesForSubscription", ActiveMQDestination.createQueueNameForDurableSubscription(true, unknownClientID, subscriptionName)); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -310,8 +306,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { try { proxy.invokeOperation("listMessagesForSubscription", ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, unknownSubscription)); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -420,7 +415,10 @@ public class TopicControlUsingJMSTest extends ManagementTestBase { waitForAttributeEqualsValue(attribute, expected, timeout, null); } - private void waitForAttributeEqualsValue(String attribute, Object expected, long timeout, Class desiredType) throws Exception { + private void waitForAttributeEqualsValue(String attribute, + Object expected, + long timeout, + Class desiredType) throws Exception { long timeToWait = System.currentTimeMillis() + timeout; Object actual = null; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOSequentialFileFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOSequentialFileFactoryTest.java index 87d1aeffcf..fd19727373 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOSequentialFileFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOSequentialFileFactoryTest.java @@ -19,10 +19,10 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; import java.nio.ByteBuffer; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.SequentialFileFactoryTestBase; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.SequentialFileFactoryTestBase; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java index c467ddb836..faf197c5cc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java @@ -18,9 +18,9 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; public class NIOBufferedJournalCompactTest extends NIOJournalCompactTest { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java index 471de8138c..4521d976e1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java @@ -16,9 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.journal; -import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; +import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java index 096e45d9ce..ee1ac1118f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java @@ -31,18 +31,18 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; -import org.apache.activemq.artemis.core.journal.RecordInfo; +import org.apache.activemq.artemis.core.io.IOCallback; 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; +import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; +import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.AbstractJournalUpdateTask; import org.apache.activemq.artemis.core.journal.impl.JournalCompactor; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.journal.impl.JournalFileImpl; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; @@ -495,8 +495,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { final Pair pair) throws Exception { if (createControlFile) { return super.createControlFile(files, newFiles, pair); - } - else { + } else { throw new IllegalStateException("Simulating a crash during compact creation"); } } @@ -522,8 +521,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { System.out.println("Waiting on Compact"); try { ActiveMQTestBase.waitForLatch(latchWait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Done"); @@ -575,8 +573,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { for (int i = 0; i < NIOJournalCompactTest.NUMBER_OF_RECORDS; i++) { if (!(i % 10 == 0)) { delete(i); - } - else { + } else { liveIDs.add((long) i); } } @@ -589,8 +586,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { public void run() { try { journal.testCompact(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -626,8 +622,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { for (Long liveID : liveIDs) { if (count++ % 2 == 0) { update(liveID); - } - else { + } else { // A Total new transaction (that was created after the compact started) to update a record that is being // compacted updateTx(transactionID, liveID); @@ -642,8 +637,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { if (count++ % 2 == 0) { System.out.println("Deleting no trans " + liveID); delete(liveID); - } - else { + } else { System.out.println("Deleting TX " + liveID); // A Total new transaction (that was created after the compact started) to delete a record that is being // compacted @@ -672,8 +666,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { if (deleteTransactRecords) { delete(tx.getB()); } - } - else { + } else { rollback(tx.getA()); } } @@ -706,8 +699,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { if (deleteTransactRecords) { delete(tx.getB()); } - } - else { + } else { rollback(tx.getA()); } } @@ -1686,8 +1678,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { for (long messageID : values) { storage.deleteMessage(messageID); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -1698,8 +1689,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { }); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -1716,8 +1706,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase { ((JournalImpl) storage.getMessageJournal()).testCompact(); ((JournalImpl) storage.getMessageJournal()).checkReclaimStatus(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java index 40fb0f379d..0da03eb02a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java @@ -18,11 +18,11 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestUnit; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; public class NIOJournalImplTest extends JournalImplTestUnit { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIONoBufferJournalImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIONoBufferJournalImplTest.java index 584c1b3fec..559725df78 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIONoBufferJournalImplTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIONoBufferJournalImplTest.java @@ -18,9 +18,9 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestUnit; public class NIONoBufferJournalImplTest extends JournalImplTestUnit { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOSequentialFileFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOSequentialFileFactoryTest.java index 42f8dd3cf1..cca5240fea 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOSequentialFileFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOSequentialFileFactoryTest.java @@ -73,8 +73,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase Thread.currentThread().interrupt(); SequentialFile file = factory.createSequentialFile("file.txt"); file.open(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -92,8 +91,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase file.write(fakeEncoding, true); Thread.currentThread().interrupt(); file.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -112,8 +110,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase file.write(fakeEncoding, true); file.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -132,8 +129,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase file.fill(1024); file.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -154,8 +150,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase file.writeDirect(buffer, true); file.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -177,8 +172,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase file.read(readBytes); file.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java index 895a8f3d56..1972863b12 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java @@ -124,16 +124,14 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase { Process process = SpawnedVMSupport.spawnVM(ValidateTransactionHealthTest.class.getCanonicalName(), type, journalDir, Long.toString(numberOfRecords), Integer.toString(transactionSize), Integer.toString(numberOfThreads)); process.waitFor(); Assert.assertEquals(ValidateTransactionHealthTest.OK, process.exitValue()); - } - else { + } else { JournalImpl journal = ValidateTransactionHealthTest.appendData(type, journalDir, numberOfRecords, transactionSize, numberOfThreads); journal.stop(); } } reload(type, journalDir, numberOfRecords, numberOfThreads); - } - finally { + } finally { File file = new File(journalDir); deleteDirectory(file); } @@ -250,8 +248,7 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase { // The test is making sure that committed data can be reloaded fine... // i.e. commits are sync on disk as stated on the transaction. // The journal shouldn't leave any state impeding reloading the server - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(System.out); System.exit(-1); } @@ -325,11 +322,9 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase { public static SequentialFileFactory getFactory(final String factoryType, final String directory) { if (factoryType.equals("aio")) { return new AIOSequentialFileFactory(new File(directory), ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO, 10, false); - } - else if (factoryType.equals("nio2")) { + } else if (factoryType.equals("nio2")) { return new NIOSequentialFileFactory(new File(directory), true, 1); - } - else { + } else { return new NIOSequentialFileFactory(new File(directory), false, 1); } } @@ -380,8 +375,7 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase { transactionCounter = 0; transactionId = nextID.incrementAndGet(); } - } - else { + } else { journal.appendAddRecord(id, (byte) 99, buffer.array(), false); } } @@ -393,8 +387,7 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase { if (transactionSize == 0) { journal.debugWait(); } - } - catch (Exception e) { + } catch (Exception e) { this.e = e; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java index 64d706547b..d1193c6d37 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.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, @@ -16,6 +16,25 @@ */ package org.apache.activemq.artemis.tests.integration.karaf; +import javax.inject.Inject; +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.security.auth.Subject; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; + import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; import org.apache.karaf.shell.api.console.Session; @@ -39,25 +58,6 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; import org.osgi.util.tracker.ServiceTracker; -import javax.inject.Inject; -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.security.auth.Subject; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintStream; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; - import static org.ops4j.pax.exam.CoreOptions.maven; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; @@ -99,17 +99,11 @@ public class ArtemisFeatureTest extends Assert { ArrayList f = new ArrayList<>(); f.addAll(Arrays.asList(features)); - Option[] options = - new Option[]{ - karafDistributionConfiguration().frameworkUrl( - maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject()) - .unpackDirectory(new File("target/paxexam/unpack/")), + Option[] options = new Option[]{karafDistributionConfiguration().frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject()).unpackDirectory(new File("target/paxexam/unpack/")), - KarafDistributionOption.keepRuntimeFolder(), - logLevel(LogLevelOption.LogLevel.INFO), - editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"), - //debugConfiguration("5005", true), - features(getArtemisMQKarafFeatureUrl(), f.toArray(new String[f.size()]))}; + KarafDistributionOption.keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.INFO), editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"), + //debugConfiguration("5005", true), + features(getArtemisMQKarafFeatureUrl(), f.toArray(new String[f.size()]))}; return options; } @@ -117,7 +111,7 @@ public class ArtemisFeatureTest extends Assert { public static UrlReference getArtemisMQKarafFeatureUrl() { String type = "xml/features"; UrlReference urlReference = mavenBundle().groupId("org.apache.activemq"). - artifactId("artemis-features").versionAsInProject().type(type); + artifactId("artemis-features").versionAsInProject().type(type); LOG.info("FeatureURL: " + urlReference.getURL()); return urlReference; } @@ -154,8 +148,7 @@ public class ArtemisFeatureTest extends Assert { MessageConsumer consumer = sess.createConsumer(queue); Message msg = consumer.receive(5000); assertNotNull(msg); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -169,41 +162,38 @@ public class ArtemisFeatureTest extends Assert { final Session commandSession = sessionFactory.create(System.in, printStream, printStream); commandSession.put("APPLICATION", System.getProperty("karaf.name", "root")); commandSession.put("USER", USER); - FutureTask commandFuture = new FutureTask<>( - new Callable() { - @Override - public String call() { + FutureTask commandFuture = new FutureTask<>(new Callable() { + @Override + public String call() { - Subject subject = new Subject(); - subject.getPrincipals().add(new UserPrincipal("admin")); - subject.getPrincipals().add(new RolePrincipal("admin")); - subject.getPrincipals().add(new RolePrincipal("manager")); - subject.getPrincipals().add(new RolePrincipal("viewer")); - return Subject.doAs(subject, new PrivilegedAction() { - @Override - public String run() { - try { - if (!silent) { - System.out.println(command); - System.out.flush(); - } - commandSession.execute(command); - } - catch (Exception e) { - e.printStackTrace(System.err); - } - printStream.flush(); - return byteArrayOutputStream.toString(); + Subject subject = new Subject(); + subject.getPrincipals().add(new UserPrincipal("admin")); + subject.getPrincipals().add(new RolePrincipal("admin")); + subject.getPrincipals().add(new RolePrincipal("manager")); + subject.getPrincipals().add(new RolePrincipal("viewer")); + return Subject.doAs(subject, new PrivilegedAction() { + @Override + public String run() { + try { + if (!silent) { + System.out.println(command); + System.out.flush(); } - }); + commandSession.execute(command); + } catch (Exception e) { + e.printStackTrace(System.err); + } + printStream.flush(); + return byteArrayOutputStream.toString(); } }); + } + }); try { executor.submit(commandFuture); response = commandFuture.get(timeout, TimeUnit.MILLISECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(System.err); response = "SHELL COMMAND TIMED OUT: "; } @@ -220,13 +210,11 @@ public class ArtemisFeatureTest extends Assert { while (true) { try { return callable.call(); - } - catch (Throwable t) { + } catch (Throwable t) { if (System.currentTimeMillis() < max) { TimeUnit.SECONDS.sleep(1); continue; - } - else { + } else { throw t; } } @@ -250,8 +238,7 @@ public class ArtemisFeatureTest extends Assert { try { st.open(); return st.waitForService(timeout); - } - finally { + } finally { st.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java index 290661e0f2..1b27380cc8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java @@ -16,6 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.largemessage; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Collection; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; @@ -40,19 +53,6 @@ import org.junit.Assert; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.Collection; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - @RunWith(Parameterized.class) public abstract class LargeMessageTestBase extends ActiveMQTestBase { @@ -129,8 +129,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { Configuration configuration; if (storeType == StoreConfiguration.StoreType.DATABASE) { configuration = createDefaultJDBCConfig(true); - } - else { + } else { configuration = createDefaultConfig(false); } @@ -191,8 +190,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { producer = session.createProducer(ADDRESS); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.rollback(); } @@ -225,8 +223,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { session.commit(xid, false); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.commit(); } @@ -293,8 +290,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { if (b[0] == ActiveMQTestBase.getSamplebyte(bytesRead.get())) { bytesRead.addAndGet(b.length); LargeMessageTestBase.log.debug("Read position " + bytesRead.get() + " on consumer"); - } - else { + } else { LargeMessageTestBase.log.warn("Received invalid packet at position " + bytesRead.get()); } } @@ -303,16 +299,14 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { public void write(final int b) throws IOException { if (b == ActiveMQTestBase.getSamplebyte(bytesRead.get())) { bytesRead.incrementAndGet(); - } - else { + } else { LargeMessageTestBase.log.warn("byte not as expected!"); } } }); Assert.assertEquals(numberOfBytes, bytesRead.get()); - } - else { + } else { ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.resetReaderIndex(); @@ -327,17 +321,14 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { try { buffer.readByte(); Assert.fail("Supposed to throw an exception"); - } - catch (Exception e) { + } catch (Exception e) { } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); LargeMessageTestBase.log.warn("Got an error", e); errors.incrementAndGet(); - } - finally { + } finally { latchDone.countDown(); msgCounter++; } @@ -350,8 +341,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { Assert.assertTrue(latchDone.await(waitOnConsumer, TimeUnit.MILLISECONDS)); Assert.assertEquals(0, errors.get()); - } - else { + } else { session.start(); @@ -390,8 +380,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { if (b.length > 0) { if (b[0] == ActiveMQTestBase.getSamplebyte(bytesRead.get())) { bytesRead.addAndGet(b.length); - } - else { + } else { LargeMessageTestBase.log.warn("Received invalid packet at position " + bytesRead.get()); } } @@ -404,16 +393,14 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { } if (b == (byte) 'a') { bytesRead.incrementAndGet(); - } - else { + } else { LargeMessageTestBase.log.warn("byte not as expected!"); } } }); Assert.assertEquals(numberOfBytes, bytesRead.get()); - } - else { + } else { ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.resetReaderIndex(); @@ -436,19 +423,16 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { session.rollback(xid); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.rollback(); } - } - else { + } else { if (isXA) { session.end(xid, XAResource.TMSUCCESS); session.commit(xid, true); xid = newXID(); session.start(xid, XAResource.TMNOFLAGS); - } - else { + } else { session.commit(); } } @@ -461,17 +445,14 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { validateNoFilesOnLargeDir(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); throw e; - } - finally { + } finally { locator.close(); try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } } @@ -501,8 +482,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { if (numberOfBytes > 1024 * 1024 || i % 2 == 0) { LargeMessageTestBase.log.debug("Sending message (stream)" + i); message.setBodyInputStream(ActiveMQTestBase.createFakeLargeStream(numberOfBytes)); - } - else { + } else { LargeMessageTestBase.log.debug("Sending message (array)" + i); byte[] bytes = new byte[(int) numberOfBytes]; for (int j = 0; j < bytes.length; j++) { @@ -517,8 +497,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, time + delayDelivery); producer.send(message); - } - else { + } else { producer.send(message); } } @@ -635,17 +614,14 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { // ok it can be sent as regular stream.resetAdjust(0); break; - } - else if ((!regular) && (totalCompressed > stream.getMinLarge())) { + } else if ((!regular) && (totalCompressed > stream.getMinLarge())) { // now it cannot be sent as regular stream.resetAdjust(0); break; - } - else { + } else { stream.resetAdjust(regular ? -absoluteStep : absoluteStep); } - } - finally { + } finally { compressor.close(); } } @@ -673,8 +649,7 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase { if (random) { Random r = new Random(); return 'A' + r.nextInt(26); - } - else { + } else { return 'A' + index % 26; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java index 5e7d16eee1..be050b580d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java @@ -97,8 +97,7 @@ public class ServerLargeMessageTest extends ActiveMQTestBase { session.commit(); - } - finally { + } finally { sf.close(); locator.close(); server.stop(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java index 14142345f8..dc1c4ea6a5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java @@ -16,15 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; -import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Test; - import java.util.HashMap; -import org.junit.Assert; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -34,8 +28,13 @@ import org.apache.activemq.artemis.api.core.management.AcceptorControl; import org.apache.activemq.artemis.api.core.management.CoreNotificationType; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.management.Notification; +import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class AcceptorControlTest extends ManagementTestBase { // Static -------------------------------------------------------- @@ -88,8 +87,7 @@ public class AcceptorControlTest extends ManagementTestBase { try { sf.createSession(false, true, true); Assert.fail("acceptor must not accept connections when stopped accepting"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } acceptorControl.start(); @@ -109,8 +107,7 @@ public class AcceptorControlTest extends ManagementTestBase { try { sf.createSession(false, true, true); Assert.fail("acceptor must not accept connections when stopped accepting"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java index a1bd0b3815..5907f3f462 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java @@ -60,8 +60,7 @@ public class AcceptorControlUsingCoreTest extends AcceptorControlTest { public void reload() { try { proxy.invokeOperation("reload"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java index 8ec533001f..df3cf5789a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java @@ -353,15 +353,13 @@ public class ActiveMQServerControlTest extends ManagementTestBase { try { serverControl.setMessageCounterMaxDayCount(-1); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } try { serverControl.setMessageCounterMaxDayCount(0); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } Assert.assertEquals(newCount, serverControl.getMessageCounterMaxDayCount()); @@ -381,22 +379,19 @@ public class ActiveMQServerControlTest extends ManagementTestBase { try { serverControl.setMessageCounterSamplePeriod(-1); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } try { serverControl.setMessageCounterSamplePeriod(0); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } try { serverControl.setMessageCounterSamplePeriod(MessageCounterManagerImpl.MIN_SAMPLE_PERIOD - 1); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } Assert.assertEquals(newSample, serverControl.getMessageCounterSamplePeriod()); @@ -430,8 +425,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { if (roleInfos[0].getName().equals("foo")) { fooRole = roleInfos[0]; barRole = roleInfos[1]; - } - else { + } else { fooRole = roleInfos[1]; barRole = roleInfos[0]; } @@ -490,8 +484,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { boolean ex = false; try { serverControl.addAddressSettings(addressMatch, DLA, expiryAddress, expiryDelay, lastValueQueue, deliveryAttempts, 100, 1000, pageMaxCacheSize, redeliveryDelay, redeliveryMultiplier, maxRedeliveryDelay, redistributionDelay, sendToDLAOnNoRoute, addressFullMessagePolicy, slowConsumerThreshold, slowConsumerCheckPeriod, slowConsumerPolicy, autoCreateJmsQueues, autoDeleteJmsQueues, autoCreateJmsTopics, autoDeleteJmsTopics); - } - catch (Exception expected) { + } catch (Exception expected) { ex = true; } @@ -552,8 +545,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { ex = false; try { serverControl.addAddressSettings(addressMatch, DLA, expiryAddress, expiryDelay, lastValueQueue, deliveryAttempts, -2, 1000, pageMaxCacheSize, redeliveryDelay, redeliveryMultiplier, maxRedeliveryDelay, redistributionDelay, sendToDLAOnNoRoute, addressFullMessagePolicy, slowConsumerThreshold, slowConsumerCheckPeriod, slowConsumerPolicy, autoCreateJmsQueues, autoDeleteJmsQueues, autoCreateJmsTopics, autoDeleteJmsTopics); - } - catch (Exception e) { + } catch (Exception e) { ex = true; } @@ -903,8 +895,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { ActiveMQServerControl serverControl = createManagementControl(); try { serverControl.forceFailover(); - } - catch (Exception e) { + } catch (Exception e) { if (!usingCore()) { fail(e.getMessage()); } @@ -1165,8 +1156,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { if (array.getJsonObject(0).getJsonNumber("creationTime").longValue() < array.getJsonObject(1).getJsonNumber("creationTime").longValue()) { first = array.getJsonObject(0); second = array.getJsonObject(1); - } - else { + } else { first = array.getJsonObject(1); second = array.getJsonObject(0); } @@ -1175,7 +1165,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(first.getString("connectionID").length() > 0); Assert.assertEquals(factory.getConnection().getID().toString(), first.getString("connectionID")); Assert.assertTrue(first.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session).getName(), first.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session).getName(), first.getString("sessionID")); Assert.assertTrue(first.getString("queueName").length() > 0); Assert.assertEquals(queueName.toString(), first.getString("queueName")); Assert.assertEquals(false, first.getBoolean("browseOnly")); @@ -1186,7 +1176,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(second.getString("connectionID").length() > 0); Assert.assertEquals(factory.getConnection().getID().toString(), second.getString("connectionID")); Assert.assertTrue(second.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session).getName(), second.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session).getName(), second.getString("sessionID")); Assert.assertTrue(second.getString("queueName").length() > 0); Assert.assertEquals(queueName.toString(), second.getString("queueName")); Assert.assertEquals(true, second.getBoolean("browseOnly")); @@ -1253,7 +1243,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(first.getString("connectionID").length() > 0); Assert.assertEquals(factory.getConnection().getID().toString(), first.getString("connectionID")); Assert.assertTrue(first.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session).getName(), first.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session).getName(), first.getString("sessionID")); Assert.assertTrue(first.getString("queueName").length() > 0); Assert.assertEquals(queueName.toString(), first.getString("queueName")); Assert.assertEquals(false, first.getBoolean("browseOnly")); @@ -1264,7 +1254,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(second.getString("connectionID").length() > 0); Assert.assertEquals(factory2.getConnection().getID().toString(), second.getString("connectionID")); Assert.assertTrue(second.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session2).getName(), second.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session2).getName(), second.getString("sessionID")); Assert.assertTrue(second.getString("queueName").length() > 0); Assert.assertEquals(queueName.toString(), second.getString("queueName")); Assert.assertEquals(false, second.getBoolean("browseOnly")); @@ -1294,21 +1284,20 @@ public class ActiveMQServerControlTest extends ManagementTestBase { if (array.getJsonObject(0).getJsonNumber("creationTime").longValue() < array.getJsonObject(1).getJsonNumber("creationTime").longValue()) { first = array.getJsonObject(0); second = array.getJsonObject(1); - } - else { + } else { first = array.getJsonObject(1); second = array.getJsonObject(0); } Assert.assertTrue(first.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session1).getName(), first.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session1).getName(), first.getString("sessionID")); Assert.assertTrue(first.getString("principal").length() > 0); Assert.assertEquals("guest", first.getString("principal")); Assert.assertTrue(first.getJsonNumber("creationTime").longValue() > 0); Assert.assertEquals(0, first.getJsonNumber("consumerCount").longValue()); Assert.assertTrue(second.getString("sessionID").length() > 0); - Assert.assertEquals(((ClientSessionImpl)session2).getName(), second.getString("sessionID")); + Assert.assertEquals(((ClientSessionImpl) session2).getName(), second.getString("sessionID")); Assert.assertTrue(second.getString("principal").length() > 0); Assert.assertEquals("myUser", second.getString("principal")); Assert.assertTrue(second.getJsonNumber("creationTime").longValue() > 0); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index 0d81e93d95..69949b6b3f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -663,7 +663,6 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes proxy.invokeOperation("createBridge", name, queueName, forwardingAddress, filterString, transformerClassName, retryInterval, retryIntervalMultiplier, initialConnectAttempts, reconnectAttempts, useDuplicateDetection, confirmationWindowSize, producerWindowSize, clientFailureCheckPeriod, connectorNames, useDiscovery, ha, user, password); } - @Override public void createBridge(String name, String queueName, diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java index d34468b697..299d6ecf9b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import java.util.HashSet; +import java.util.Set; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -36,9 +39,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.HashSet; -import java.util.Set; - import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; public class AddressControlTest extends ManagementTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java index dfb754b56d..f943bf842e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import java.util.HashSet; +import java.util.Set; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; @@ -31,9 +34,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.HashSet; -import java.util.Set; - import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; public class AddressControlUsingCoreTest extends ManagementTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BridgeControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BridgeControlTest.java index 4f899cc7d0..df63043501 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BridgeControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BridgeControlTest.java @@ -16,20 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Before; -import org.junit.Test; - +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.BridgeControl; @@ -44,6 +37,11 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.management.Notification; +import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class BridgeControlTest extends ManagementTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java index ce8873f572..bf447c740d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java @@ -16,11 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import javax.json.JsonArray; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl; -import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; @@ -29,10 +33,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.json.JsonArray; -import java.util.ArrayList; -import java.util.List; - public class BroadcastGroupControlTest extends ManagementTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java index bcce1f798a..445fae5109 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java @@ -16,24 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -45,6 +34,13 @@ import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ClusterConnectionControl2Test extends ManagementTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java index f2b85eca05..f414c15583 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java @@ -16,23 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.JsonUtil; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.junit.Before; -import org.junit.After; -import org.junit.Test; - +import javax.json.JsonArray; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.json.JsonArray; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; @@ -47,9 +40,14 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.core.server.management.Notification; import org.apache.activemq.artemis.tests.integration.SimpleNotificationService; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ClusterConnectionControlTest extends ManagementTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java index 69b3ae8c57..3f4e8a18ae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/CoreMessagingProxy.java @@ -66,8 +66,7 @@ public class CoreMessagingProxy { Object result = ManagementHelper.getResult(reply, desiredType); return result; - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -76,7 +75,9 @@ public class CoreMessagingProxy { return invokeOperation(null, operationName, args); } - public Object invokeOperation(final Class desiredType, final String operationName, final Object... args) throws Exception { + public Object invokeOperation(final Class desiredType, + final String operationName, + final Object... args) throws Exception { try (ClientSessionFactory sessionFactory = locator.createSessionFactory(); ClientSession session = getSession(sessionFactory); ClientRequestor requestor = getClientRequestor(session)) { @@ -86,12 +87,10 @@ public class CoreMessagingProxy { if (reply != null) { if (ManagementHelper.hasOperationSucceeded(reply)) { return ManagementHelper.getResult(reply, desiredType); - } - else { + } else { throw new Exception((String) ManagementHelper.getResult(reply)); } - } - else { + } else { return null; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JMXDomainTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JMXDomainTest.java index 39789381bd..fefdb7dfc0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JMXDomainTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JMXDomainTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; @@ -26,9 +29,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - public class JMXDomainTest extends ManagementTestBase { ActiveMQServer server_0 = null; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementActivationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementActivationTest.java index 480f5367b6..05007761ae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementActivationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementActivationTest.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import javax.jms.ConnectionFactory; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.NameNotFoundException; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration; @@ -27,13 +34,6 @@ import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.junit.Before; import org.junit.Test; -import javax.jms.ConnectionFactory; -import javax.jms.Queue; -import javax.jms.Topic; -import javax.naming.NameNotFoundException; -import java.util.ArrayList; -import java.util.List; - /** * Validates if a JMS management operations will wait until the server is activated. If the server is not active * then JMS management operations (e.g. create connection factory, create queue, etc.) should be stored in a cache @@ -78,8 +78,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { context.lookup("/myConnectionFactory"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { exception = true; } @@ -93,14 +92,12 @@ public class ManagementActivationTest extends FailoverTestBase { while (timeout > System.currentTimeMillis()) { try { factory = (ConnectionFactory) context.lookup("/myConnectionFactory"); - } - catch (Exception ignored) { + } catch (Exception ignored) { // ignored.printStackTrace(); } if (factory == null) { Thread.sleep(100); - } - else { + } else { break; } } @@ -115,8 +112,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { context.lookup("/myQueue"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { exception = true; } @@ -130,14 +126,12 @@ public class ManagementActivationTest extends FailoverTestBase { while (timeout > System.currentTimeMillis()) { try { queue = (Queue) context.lookup("/myQueue"); - } - catch (Exception ignored) { + } catch (Exception ignored) { // ignored.printStackTrace(); } if (queue == null) { Thread.sleep(100); - } - else { + } else { break; } } @@ -152,8 +146,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { context.lookup("/myTopic"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { exception = true; } @@ -167,14 +160,12 @@ public class ManagementActivationTest extends FailoverTestBase { while (timeout > System.currentTimeMillis()) { try { topic = (Topic) context.lookup("/myTopic"); - } - catch (Exception ignored) { + } catch (Exception ignored) { // ignored.printStackTrace(); } if (topic == null) { Thread.sleep(100); - } - else { + } else { break; } } @@ -196,8 +187,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { backupJmsServer.destroyConnectionFactory("fakeConnectionFactory"); - } - catch (Exception e) { + } catch (Exception e) { exception = true; } @@ -219,8 +209,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { backupJmsServer.removeQueueFromBindingRegistry("fakeQueue"); - } - catch (Exception e) { + } catch (Exception e) { exception = true; } @@ -238,8 +227,7 @@ public class ManagementActivationTest extends FailoverTestBase { boolean exception = false; try { backupJmsServer.removeTopicFromBindingRegistry("fakeTopic"); - } - catch (Exception e) { + } catch (Exception e) { exception = true; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementControlHelper.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementControlHelper.java index 10a9d55a70..a41c9082ca 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementControlHelper.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementControlHelper.java @@ -24,12 +24,12 @@ import javax.management.ObjectName; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.management.AcceptorControl; +import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.BridgeControl; import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl; import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl; import org.apache.activemq.artemis.api.core.management.DivertControl; -import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java index 8cc0f99d1f..0719b38d88 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java @@ -22,9 +22,9 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.management.ManagementHelper; +import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.utils.RandomUtil; -import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; import org.junit.Assert; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java index 2d963aca5b..ce95046a59 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.ManagementHelper; @@ -37,6 +30,11 @@ import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl; import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager; +import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class ManagementServiceImplTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementTestBase.java index a3bc00b30d..8b79e7cc37 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementTestBase.java @@ -16,22 +16,20 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.management.QueueControl; -import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; -import org.junit.Before; -import org.junit.After; - import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.management.QueueControl; +import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; public abstract class ManagementTestBase extends ActiveMQTestBase { @@ -58,8 +56,7 @@ public abstract class ManagementTestBase extends ActiveMQTestBase { session.commit(); m = consumer.receiveImmediate(); Assert.assertNull("received one more message than expected (" + expected + ")", m); - } - finally { + } finally { if (consumer != null) { consumer.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java index 793e82d449..7e10297ac8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import javax.json.JsonArray; +import java.nio.ByteBuffer; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.SimpleString; @@ -36,9 +39,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.json.JsonArray; -import java.nio.ByteBuffer; - /** * This class contains tests for core management * functionalities that are affected by a server @@ -121,8 +121,7 @@ public class ManagementWithPagingServerTest extends ManagementTestBase { ClientMessage message = session1.createMessage(true); if (i % 2 == 0) { message.putLongProperty(key, matchingValue); - } - else { + } else { message.putLongProperty(key, unmatchingValue); } producer.send(message); @@ -241,13 +240,11 @@ public class ManagementWithPagingServerTest extends ManagementTestBase { producer.send(message); try { Thread.sleep(delay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - catch (Exception e) { + } catch (Exception e) { error = e; } } @@ -282,13 +279,11 @@ public class ManagementWithPagingServerTest extends ManagementTestBase { session2.commit(); try { Thread.sleep(delay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - catch (Exception e) { + } catch (Exception e) { error = e; } } @@ -316,13 +311,11 @@ public class ManagementWithPagingServerTest extends ManagementTestBase { queueControl.listMessagesAsJSON(null); try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - catch (Exception e) { + } catch (Exception e) { error = e; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithStompTest.java index 97ef1716b0..035d4ca722 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithStompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithStompTest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.management; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -37,15 +46,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - public class ManagementWithStompTest extends ManagementTestBase { // Constants ----------------------------------------------------- @@ -205,8 +205,7 @@ public class ManagementWithStompTest extends ManagementTestBase { c = is.read(); if (c < 0) { throw new IOException("socket closed."); - } - else if (c == 0) { + } else if (c == 0) { c = is.read(); if (c != '\n') { byte[] ba = inputBuffer.toByteArray(); @@ -216,8 +215,7 @@ public class ManagementWithStompTest extends ManagementTestBase { byte[] ba = inputBuffer.toByteArray(); inputBuffer.reset(); return new String(ba, StandardCharsets.UTF_8); - } - else { + } else { inputBuffer.write(c); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java index 95a08a1e9c..fa84c163b1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java @@ -421,15 +421,13 @@ public class QueueControlTest extends ManagementTestBase { public void onMessage(ClientMessage message) { try { message.acknowledge(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { e1.printStackTrace(); } latch1.countDown(); try { latch2.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } latch3.countDown(); @@ -458,8 +456,7 @@ public class QueueControlTest extends ManagementTestBase { latch3.await(10, TimeUnit.SECONDS); transSession.commit(); - } - finally { + } finally { consumer.close(); transSession.deleteQueue(queue); transSession.close(); @@ -935,8 +932,7 @@ public class QueueControlTest extends ManagementTestBase { try { queueControl.moveMessages(null, unknownQueue.toString()); Assert.fail("operation must fail if the other queue does not exist"); - } - catch (Exception e) { + } catch (Exception e) { } Assert.assertEquals(1, getMessageCount(queueControl)); @@ -1066,8 +1062,7 @@ public class QueueControlTest extends ManagementTestBase { try { queueControl.moveMessage(messageID, unknownQueue.toString()); Assert.fail("operation must fail if the other queue does not exist"); - } - catch (Exception e) { + } catch (Exception e) { } Assert.assertEquals(1, getMessageCount(queueControl)); @@ -1599,8 +1594,7 @@ public class QueueControlTest extends ManagementTestBase { try { queueControl.changeMessagePriority(messageID, invalidPriority); Assert.fail("operation fails when priority value is < 0 or > 9"); - } - catch (Exception e) { + } catch (Exception e) { } ClientConsumer consumer = session.createConsumer(queue); @@ -1925,8 +1919,7 @@ public class QueueControlTest extends ManagementTestBase { Assert.assertTrue(queueControl.isPaused()); queueControl.resume(); Assert.assertFalse(queueControl.isPaused()); - } - catch (Exception e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -2156,7 +2149,6 @@ public class QueueControlTest extends ManagementTestBase { Assert.assertEquals(new String(body), ""); } - // Package protected --------------------------------------------- // Protected ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java index 4cb5a1defa..e8e04f20e4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java @@ -36,8 +36,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest { public void flushExecutor() { try { proxy.invokeOperation("flushExecutor"); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -314,7 +313,13 @@ public class QueueControlUsingCoreTest extends QueueControlTest { } @Override - public String sendMessage(Map headers, int type, String body, String userID, boolean durable, String user, String password) throws Exception { + public String sendMessage(Map headers, + int type, + String body, + String userID, + boolean durable, + String user, + String password) throws Exception { return (String) proxy.invokeOperation("sendMessage", headers, type, body, userID, durable, user, password); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java index 5b6b315410..c4e27af19f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java @@ -66,8 +66,7 @@ public abstract class SecurityManagementTestBase extends ActiveMQTestBase { ClientSession session = null; if (user == null) { session = sf.createSession(false, true, true); - } - else { + } else { session = sf.createSession(user, password, false, true, true, false, 1); } @@ -81,20 +80,17 @@ public abstract class SecurityManagementTestBase extends ActiveMQTestBase { if (expectSuccess) { Assert.assertNotNull(reply); Assert.assertTrue((Boolean) ManagementHelper.getResult(reply)); - } - else { + } else { Assert.assertNull(reply); } requestor.close(); - } - catch (Exception e) { + } catch (Exception e) { if (expectSuccess) { Assert.fail("got unexpected exception " + e.getClass() + ": " + e.getMessage()); e.printStackTrace(); } - } - finally { + } finally { sf.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java index 3e8dca4543..8e3091b563 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java @@ -75,8 +75,7 @@ public class SecurityNotificationTest extends ActiveMQTestBase { try { sf.createSession(unknownUser, RandomUtil.randomString(), false, true, true, false, 1); Assert.fail("authentication must fail and a notification of security violation must be sent"); - } - catch (Exception e) { + } catch (Exception e) { } ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); @@ -105,8 +104,7 @@ public class SecurityNotificationTest extends ActiveMQTestBase { try { guestSession.createQueue(address, queue, true); Assert.fail("session creation must fail and a notification of security violation must be sent"); - } - catch (Exception e) { + } catch (Exception e) { } ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/FuseMQTTClientProvider.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/FuseMQTTClientProvider.java index f0515ba9f2..23037fa9d0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/FuseMQTTClientProvider.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/FuseMQTTClientProvider.java @@ -16,9 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.mqtt.imported; -import java.util.concurrent.TimeUnit; - import javax.net.ssl.SSLContext; +import java.util.concurrent.TimeUnit; import org.fusesource.mqtt.client.BlockingConnection; import org.fusesource.mqtt.client.MQTT; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTClientProvider.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTClientProvider.java index 284d5f0b3a..6dddefcd1f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTClientProvider.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTClientProvider.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, diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java index 1b0964baf0..7ea7a1e5d6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java @@ -93,8 +93,7 @@ public class MQTTTest extends MQTTTestSupport { byte[] payload = subscriptionProvider.receive(10000); assertNotNull("Should get a message", payload); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); break; } @@ -137,8 +136,7 @@ public class MQTTTest extends MQTTTestSupport { byte[] payload = subscriptionProvider.receive(10000); assertNotNull("Should get a message", payload); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); break; } @@ -650,8 +648,7 @@ public class MQTTTest extends MQTTTestSupport { PUBLISH publish = new PUBLISH(); try { publish.decode(frame); - } - catch (ProtocolException e) { + } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } publishList.add(publish); @@ -736,8 +733,7 @@ public class MQTTTest extends MQTTTestSupport { PUBLISH publish = new PUBLISH(); try { publish.decode(frame); - } - catch (ProtocolException e) { + } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } publishList.add(publish); @@ -807,8 +803,7 @@ public class MQTTTest extends MQTTTestSupport { try { publish.decode(frame); LOG.info("PUBLISH " + publish); - } - catch (ProtocolException e) { + } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } if (publishMap.get(publish.messageId()) != null) { @@ -887,8 +882,7 @@ public class MQTTTest extends MQTTTestSupport { try { publish.decode(frame); LOG.info("PUBLISH " + publish); - } - catch (ProtocolException e) { + } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } if (publishMap.get(publish.messageId()) != null) { @@ -1222,8 +1216,7 @@ public class MQTTTest extends MQTTTestSupport { try { connection3.connect(); fail("Duplicate client connected"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -1593,4 +1586,4 @@ public class MQTTTest extends MQTTTestSupport { connection.disconnect(); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java index 010949c190..27ebde06c8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.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, @@ -136,9 +136,7 @@ public class MQTTTestSupport extends ActiveMQTestBase { } private ActiveMQServer createServerForMQTT() throws Exception { - Configuration defaultConfig = createDefaultConfig(true) - .setIncomingInterceptorClassNames(singletonList(MQTTIncomingInterceptor.class.getName())) - .setOutgoingInterceptorClassNames(singletonList(MQTTOutoingInterceptor.class.getName())); + Configuration defaultConfig = createDefaultConfig(true).setIncomingInterceptorClassNames(singletonList(MQTTIncomingInterceptor.class.getName())).setOutgoingInterceptorClassNames(singletonList(MQTTOutoingInterceptor.class.getName())); return createServer(true, defaultConfig); } @@ -196,8 +194,7 @@ public class MQTTTestSupport extends ActiveMQTestBase { protected void initializeConnection(MQTTClientProvider provider) throws Exception { if (!isUseSSL()) { provider.connect("tcp://localhost:" + port); - } - else { + } else { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom()); provider.setSslContext(ctx); @@ -245,8 +242,7 @@ public class MQTTTestSupport extends ActiveMQTestBase { try { task.run(); return; - } - catch (Throwable e) { + } catch (Throwable e) { long remaining = deadline - System.currentTimeMillis(); if (remaining <= 0) { if (e instanceof RuntimeException) { @@ -275,8 +271,7 @@ public class MQTTTestSupport extends ActiveMQTestBase { protected MQTT createMQTTConnection(String clientId, boolean clean) throws Exception { if (isUseSSL()) { return createMQTTSslConnection(clientId, clean); - } - else { + } else { return createMQTTTcpConnection(clientId, clean); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/PahoMQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/PahoMQTTTest.java index bd912ffe6f..a5d39b392d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/PahoMQTTTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/PahoMQTTTest.java @@ -81,12 +81,10 @@ public class PahoMQTTTest extends MQTTTestSupport { } client.disconnect(); client.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); asyncError.set(e); - } - finally { + } finally { disconnectDoneLatch.countDown(); } } @@ -151,4 +149,4 @@ public class PahoMQTTTest extends MQTTTestSupport { return new MqttClient("tcp://localhost:" + getPort(), clientId, new MemoryPersistence()); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/ResourceLoadingSslContext.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/ResourceLoadingSslContext.java index 91eef82064..1e6ac5cf90 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/ResourceLoadingSslContext.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/ResourceLoadingSslContext.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, @@ -68,8 +68,7 @@ public class ResourceLoadingSslContext extends SslContext { private void postConstruct() { try { afterPropertiesSet(); - } - catch (Exception ex) { + } catch (Exception ex) { throw new RuntimeException(ex); } } @@ -121,8 +120,7 @@ public class ResourceLoadingSslContext extends SslContext { InputStream is = resourceFromString(trustStore).getInputStream(); try { ks.load(is, trustStorePassword == null ? null : trustStorePassword.toCharArray()); - } - finally { + } finally { is.close(); } return ks; @@ -137,8 +135,7 @@ public class ResourceLoadingSslContext extends SslContext { InputStream is = resourceFromString(keyStore).getInputStream(); try { ks.load(is, keyStorePassword == null ? null : keyStorePassword.toCharArray()); - } - finally { + } finally { is.close(); } return ks; @@ -229,11 +226,9 @@ public class ResourceLoadingSslContext extends SslContext { File file = new File(uri); if (file.exists()) { resource = new FileSystemResource(uri); - } - else if (ResourceUtils.isUrl(uri)) { + } else if (ResourceUtils.isUrl(uri)) { resource = new UrlResource(uri); - } - else { + } else { resource = new ClassPathResource(uri); } return resource; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/Wait.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/Wait.java index 976b4d3a1f..fec6bc4e7c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/Wait.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/util/Wait.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, diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java index 09fd9b7c00..37de64f6fe 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java @@ -29,9 +29,9 @@ import java.util.Map; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.ActiveMQXAConnectionFactory; import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.ActiveMQXAConnectionFactory; import org.apache.activemq.command.ActiveMQDestination; import org.junit.After; import org.junit.Before; @@ -47,7 +47,6 @@ public class BasicOpenWireTest extends OpenWireTestBase { protected ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlString); protected ActiveMQXAConnectionFactory xaFactory = new ActiveMQXAConnectionFactory(urlString); - protected ActiveMQConnection connection; protected String topicName = "amqTestTopic1"; protected String queueName = "amqTestQueue1"; @@ -97,23 +96,19 @@ public class BasicOpenWireTest extends OpenWireTestBase { SimpleString coreQ = iterQueues.next(); try { this.server.destroyQueue(coreQ, null, false, true); - } - catch (ActiveMQNonExistentQueueException idontcare) { + } catch (ActiveMQNonExistentQueueException idontcare) { // i don't care if this failed. it means it didn't find the queue - } - catch (Throwable e) { + } catch (Throwable e) { // just print, what else can we do? e.printStackTrace(); } System.out.println("Destroyed queue: " + coreQ); } testQueues.clear(); - } - catch (Throwable e) { + } catch (Throwable e) { System.out.println("Exception !! " + e); e.printStackTrace(); - } - finally { + } finally { super.tearDown(); System.out.println("Super done."); } @@ -220,8 +215,7 @@ public class BasicOpenWireTest extends OpenWireTestBase { protected void safeClose(Session s) { try { s.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicSecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicSecurityTest.java index 14cfee096b..753505373e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicSecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicSecurityTest.java @@ -54,8 +54,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { newConn.close(); newConn = null; - } - finally { + } finally { if (newConn != null) { newConn.close(); } @@ -65,11 +64,9 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { newConn = factory.createConnection("openwireSender", "WrongPasswD"); newConn.start(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected - } - finally { + } finally { if (newConn != null) { newConn.close(); } @@ -79,11 +76,9 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { newConn = factory.createConnection("wronguser", "SeNdEr"); newConn.start(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected - } - finally { + } finally { if (newConn != null) { newConn.close(); } @@ -93,11 +88,9 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { newConn = factory.createConnection("wronguser", "wrongpass"); newConn.start(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected - } - finally { + } finally { if (newConn != null) { newConn.close(); } @@ -107,11 +100,9 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { newConn = factory.createConnection(); newConn.start(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected - } - finally { + } finally { if (newConn != null) { newConn.close(); } @@ -119,7 +110,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { } @Test - public void testSendnReceiveAuthorization() throws Exception { + public void testSendnReceiveAuthorization() throws Exception { Connection sendingConn = null; Connection receivingConn = null; @@ -144,8 +135,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { producer.send(message); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected producer.close(); } @@ -157,8 +147,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { consumer = sendingSession.createConsumer(dest); Assert.fail("exception expected"); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { e.printStackTrace(); //expected } @@ -168,8 +157,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { assertNotNull(received); assertEquals("Hello World", received.getText()); - } - finally { + } finally { if (sendingConn != null) { sendingConn.close(); } @@ -198,8 +186,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { try { session1.createTemporaryQueue(); fail("user shouldn't be able to create temp queue"); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { //expected } @@ -207,8 +194,7 @@ public class BasicSecurityTest extends BasicOpenWireTest { TemporaryQueue q = session2.createTemporaryQueue(); assertNotNull(q); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java index 8cafc070eb..7ded062009 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireTestBase.java @@ -95,7 +95,7 @@ public class OpenWireTestBase extends ActiveMQTestBase { Role destRole = new Role("manager", false, false, false, false, true, true, false, false); - Set roles = new HashSet<>(); + Set roles = new HashSet<>(); roles.add(senderRole); roles.add(receiverRole); roles.add(guestRole); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireUtilTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireUtilTest.java index 69d978471d..4f2696dd48 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireUtilTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireUtilTest.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.openwire; -import static org.junit.Assert.assertEquals; - import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class OpenWireUtilTest { @Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java index ca3ea2380d..9a2b8be8fd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java @@ -170,8 +170,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { connection.close(); System.err.println("Done!!!"); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -427,8 +426,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { try { session.createProducer(queue); - } - catch (JMSException expected) { + } catch (JMSException expected) { } session.close(); } @@ -495,8 +493,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { try { MessageConsumer consumer = session.createConsumer(queue); fail("supposed to throw an exception here"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -529,8 +526,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { messageProducer.send(session.createTextMessage("Test2")); assertNotNull(consumer.receive(5000)); - } - finally { + } finally { if (exConn != null) { exConn.close(); } @@ -571,8 +567,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); assertEquals("This is a text message", messageReceived.getText()); - } - finally { + } finally { if (exConn != null) { exConn.close(); } @@ -614,8 +609,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); assertEquals("This is a text message", messageReceived.getText()); - } - finally { + } finally { if (exConn != null) { exConn.close(); } @@ -818,8 +812,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { connection.close(); System.err.println("Done!!!"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -877,8 +870,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { } consumer.waitFor(nMsg * delay * 2); - } - finally { + } finally { sendConnection.close(); receiveConnection.close(); } @@ -1021,8 +1013,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { TextMessage txt = (TextMessage) consumer.receiveNoWait(); if (txt == null) { break; - } - else { + } else { duplicatedMessages = true; System.out.println("received in duplicate:" + txt.getText()); } @@ -1138,8 +1129,7 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { try { //waiting for last ack to finish Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } assertEquals(0L, binding.getQueue().getMessageCount()); } @@ -1154,10 +1144,10 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { private MessageConsumer consumer; AsyncConsumer(String queueName, - Connection receiveConnection, - final int ackMode, - final long delay, - final int expectedMsgs) throws JMSException { + Connection receiveConnection, + final int ackMode, + final long delay, + final int expectedMsgs) throws JMSException { this.queueName = queueName; this.nMsgs = expectedMsgs; Session session = receiveConnection.createSession(false, ackMode); @@ -1174,16 +1164,14 @@ public class SimpleOpenWireTest extends BasicOpenWireTest { //delay try { TimeUnit.SECONDS.sleep(delay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } if (ackMode == Session.CLIENT_ACKNOWLEDGE) { try { message.acknowledge(); - } - catch (JMSException e) { + } catch (JMSException e) { System.err.println("Failed to acknowledge " + message); e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/VerySimpleOenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/VerySimpleOenwireTest.java index 8d315d38a5..7a720dc5d2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/VerySimpleOenwireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/VerySimpleOenwireTest.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, @@ -66,8 +66,7 @@ public class VerySimpleOenwireTest extends OpenWireTestBase { TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); assertEquals("This is a text message", messageReceived.getText()); - } - finally { + } finally { if (exConn != null) { exConn.close(); } @@ -114,5 +113,4 @@ public class VerySimpleOenwireTest extends OpenWireTestBase { } - } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer10Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer10Test.java index ff1c52a13b..b54efd4a0f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer10Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer10Test.java @@ -16,17 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java index c4be09317d..870338f272 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java @@ -16,17 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -95,8 +94,7 @@ public class JMSConsumer11Test extends BasicOpenWireTest { try { connection2.close(); - } - catch (Throwable e) { + } catch (Throwable e) { System.err.println("exception e: " + e); e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer12Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer12Test.java index bdea0ebcc8..9ddfb75545 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer12Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer12Test.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer13Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer13Test.java index c19ea6ebe7..cf4dbc018e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer13Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer13Test.java @@ -16,17 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer1Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer1Test.java index f7347e1630..f8ffa25c58 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer1Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer1Test.java @@ -16,20 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; +import javax.jms.DeliveryMode; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Session; import java.util.Arrays; import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.DeliveryMode; -import javax.jms.Message; -import javax.jms.MessageListener; -import javax.jms.Session; - import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java index 5b0c038575..ba1ae85545 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Session; import java.lang.Thread.UncaughtExceptionHandler; import java.util.Collections; import java.util.HashMap; @@ -26,15 +30,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; - import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; /** @@ -87,8 +86,7 @@ public class JMSConsumer2Test extends BasicOpenWireTest { // ack every 200 message.acknowledge(); } - } - catch (Exception e) { + } catch (Exception e) { exceptions.put(Thread.currentThread(), e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer3Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer3Test.java index 21298992da..47c380a82b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer3Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer3Test.java @@ -16,16 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer4Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer4Test.java index 45d96b2979..b116def4ce 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer4Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer4Test.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -26,9 +23,11 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.util.Arrays; +import java.util.Collection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer5Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer5Test.java index b66d82423b..3fb9e95d5a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer5Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer5Test.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.BytesMessage; import javax.jms.DeliveryMode; import javax.jms.Message; @@ -29,9 +23,14 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer7Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer7Test.java index d0147976d9..c15e5a1b9c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer7Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer7Test.java @@ -16,22 +16,21 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -90,8 +89,7 @@ public class JMSConsumer7Test extends BasicOpenWireTest { } System.out.println("acking tm: " + tm.getText()); tm.acknowledge(); - } - catch (Throwable e) { + } catch (Throwable e) { System.out.println("ack failed!!"); e.printStackTrace(); } @@ -128,8 +126,7 @@ public class JMSConsumer7Test extends BasicOpenWireTest { if (counter.get() == 4) { done2.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { System.err.println("Unexpected exception: " + e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer8Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer8Test.java index f4505f1d7f..0d410a6caf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer8Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer8Test.java @@ -16,22 +16,21 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -90,8 +89,7 @@ public class JMSConsumer8Test extends BasicOpenWireTest { connection.close(); got2Done.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -123,8 +121,7 @@ public class JMSConsumer8Test extends BasicOpenWireTest { if (counter.get() == 4) { done2.countDown(); } - } - catch (Throwable e) { + } catch (Throwable e) { System.err.println("Unexpected exception " + e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer9Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer9Test.java index f6da123804..b73b2cf06f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer9Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer9Test.java @@ -16,20 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; +import javax.jms.DeliveryMode; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Session; import java.util.Arrays; import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.DeliveryMode; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; - -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSIndividualAckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSIndividualAckTest.java index 4a735be7b9..7366c9d1d1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSIndividualAckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSIndividualAckTest.java @@ -25,8 +25,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; /** diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSMessageTest.java index 0d44282b1d..602bfba631 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSMessageTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Vector; - import javax.jms.BytesMessage; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -34,9 +28,14 @@ import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Vector; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -170,8 +169,7 @@ public class JMSMessageTest extends BasicOpenWireTest { try { message.readByte(); fail("Expected exception not thrown."); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } } @@ -205,8 +203,7 @@ public class JMSMessageTest extends BasicOpenWireTest { try { message.readByte(); fail("Should have received NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } assertEquals("This is a test to see how it works.", message.readString()); @@ -216,8 +213,7 @@ public class JMSMessageTest extends BasicOpenWireTest { try { message.readByte(); fail("Should have received MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } } assertNull(consumer.receiveNoWait()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecase1Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecase1Test.java index b4b0811fba..a5e060aac8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecase1Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecase1Test.java @@ -16,18 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.Arrays; +import java.util.Collection; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecaseTest.java index 05685f6b11..ba955b0ff7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecaseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSUsecaseTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; - import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageProducer; @@ -27,9 +23,12 @@ import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Collection; +import java.util.Enumeration; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsAutoAckListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsAutoAckListenerTest.java index 644bc5e807..b69e3de367 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsAutoAckListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsAutoAckListenerTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConnectionStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConnectionStartStopTest.java index c538aef52c..2eb9754e06 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConnectionStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConnectionStartStopTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Random; -import java.util.Vector; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -31,6 +24,12 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.After; @@ -129,11 +128,9 @@ public class JmsConnectionStartStopTest extends BasicOpenWireTest { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); counter.incrementAndGet(); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); - } - catch (Throwable t) { + } catch (Throwable t) { } } }; @@ -145,11 +142,9 @@ public class JmsConnectionStartStopTest extends BasicOpenWireTest { TimeUnit.MILLISECONDS.sleep(rand.nextInt(10)); stoppedConnection.start(); stoppedConnection.stop(); - } - catch (Exception e) { + } catch (Exception e) { exceptions.add(e); - } - catch (Throwable t) { + } catch (Throwable t) { } } }; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConsumerResetActiveListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConsumerResetActiveListenerTest.java index 04a331e793..d487b512aa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConsumerResetActiveListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsConsumerResetActiveListenerTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Vector; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; @@ -30,6 +25,10 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Vector; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; @@ -62,12 +61,10 @@ public class JmsConsumerResetActiveListenerTest extends BasicOpenWireTest { try { consumer.setMessageListener(this); results.add(message); - } - catch (JMSException e) { + } catch (JMSException e) { results.add(e); } - } - else { + } else { results.add(message); } latch.countDown(); @@ -115,12 +112,10 @@ public class JmsConsumerResetActiveListenerTest extends BasicOpenWireTest { MessageConsumer anotherConsumer = session.createConsumer(dest); anotherConsumer.setMessageListener(this); results.add(message); - } - catch (JMSException e) { + } catch (JMSException e) { results.add(e); } - } - else { + } else { results.add(message); } latch.countDown(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsCreateConsumerInOnMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsCreateConsumerInOnMessageTest.java index 0aaded967b..825f3238ad 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsCreateConsumerInOnMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsCreateConsumerInOnMessageTest.java @@ -23,8 +23,8 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Test; /** @@ -82,8 +82,7 @@ public class JmsCreateConsumerInOnMessageTest extends BasicOpenWireTest implemen consumerSession.createProducer(topic); lock.notify(); } - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); assertTrue(false); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsQueueBrowserTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsQueueBrowserTest.java index 382e1f9b59..d34c9633d1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsQueueBrowserTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsQueueBrowserTest.java @@ -16,18 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Enumeration; - import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Enumeration; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; /** diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsResourceProvider.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsResourceProvider.java index 47bdb23f7e..056891aed9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsResourceProvider.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsResourceProvider.java @@ -107,8 +107,7 @@ public class JmsResourceProvider { public Destination createDestination(Session session, JmsTransactionTestSupport support) throws JMSException { if (isTopic) { return support.createDestination(session, ActiveMQDestination.TOPIC_TYPE); - } - else { + } else { return support.createDestination(session, ActiveMQDestination.QUEUE_TYPE); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsSendReceiveTestSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsSendReceiveTestSupport.java index e5cf65915f..1e9a2d9e98 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsSendReceiveTestSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsSendReceiveTestSupport.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; @@ -32,6 +25,12 @@ import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Before; @@ -147,8 +146,7 @@ public abstract class JmsSendReceiveTestSupport extends BasicOpenWireTest implem while (messages.size() < data.length && waitTime >= 0) { try { lock.wait(200); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRedeliverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRedeliverTest.java index b5286e390a..aa3a170303 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRedeliverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRedeliverTest.java @@ -25,8 +25,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Before; import org.junit.Test; @@ -72,8 +72,7 @@ public class JmsTopicRedeliverTest extends BasicOpenWireTest { if (topic) { consumerDestination = this.createDestination(session, ActiveMQDestination.TOPIC_TYPE); producerDestination = this.createDestination(session, ActiveMQDestination.TOPIC_TYPE); - } - else { + } else { consumerDestination = this.createDestination(session, ActiveMQDestination.QUEUE_TYPE); producerDestination = this.createDestination(session, ActiveMQDestination.QUEUE_TYPE); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRequestReplyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRequestReplyTest.java index ad2e85b731..9e8cdb7468 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRequestReplyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicRequestReplyTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.List; -import java.util.Vector; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -30,9 +27,11 @@ import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.TemporaryTopic; import javax.jms.TextMessage; +import java.util.List; +import java.util.Vector; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -100,8 +99,7 @@ public class JmsTopicRequestReplyTest extends BasicOpenWireTest implements Messa System.out.println("Received reply."); System.out.println(replyMessage.toString()); assertEquals("Wrong message content", "Hello: Olivier", replyMessage.getText()); - } - else { + } else { fail("Should have received a reply by now"); } replyConsumer.close(); @@ -143,15 +141,13 @@ public class JmsTopicRequestReplyTest extends BasicOpenWireTest implements Messa if (dynamicallyCreateProducer) { replyProducer = serverSession.createProducer(replyDestination); replyProducer.send(replyMessage); - } - else { + } else { replyProducer.send(replyDestination, replyMessage); } System.out.println("Sent reply to " + replyDestination); System.out.println(replyMessage.toString()); - } - catch (JMSException e) { + } catch (JMSException e) { onException(e); } } @@ -164,12 +160,10 @@ public class JmsTopicRequestReplyTest extends BasicOpenWireTest implements Messa Message message = requestConsumer.receive(5000); if (message != null) { onMessage(message); - } - else { + } else { System.err.println("No message received"); } - } - catch (JMSException e) { + } catch (JMSException e) { onException(e); } } @@ -192,8 +186,7 @@ public class JmsTopicRequestReplyTest extends BasicOpenWireTest implements Messa final MessageConsumer requestConsumer = serverSession.createConsumer(requestDestination); if (useAsyncConsume) { requestConsumer.setMessageListener(this); - } - else { + } else { Thread thread = new Thread(new Runnable() { @Override public void run() { @@ -239,8 +232,7 @@ public class JmsTopicRequestReplyTest extends BasicOpenWireTest implements Messa protected void deleteTemporaryDestination(Destination dest) throws JMSException { if (topic) { ((TemporaryTopic) dest).delete(); - } - else { + } else { System.out.println("Deleting: " + dest); ((TemporaryQueue) dest).delete(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSelectorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSelectorTest.java index 1d42383422..231ddc81b7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSelectorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSelectorTest.java @@ -26,8 +26,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; -import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.Before; import org.junit.Test; @@ -63,8 +63,7 @@ public class JmsTopicSelectorTest extends BasicOpenWireTest { if (topic) { consumerDestination = this.createDestination(session, ActiveMQDestination.TOPIC_TYPE); producerDestination = this.createDestination(session, ActiveMQDestination.TOPIC_TYPE); - } - else { + } else { consumerDestination = this.createDestination(session, ActiveMQDestination.QUEUE_TYPE); producerDestination = this.createDestination(session, ActiveMQDestination.QUEUE_TYPE); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java index 16d2ebe863..e9926931ae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java @@ -53,8 +53,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { if (topic) { consumerDestination = createDestination(session, ActiveMQDestination.TOPIC_TYPE, getConsumerSubject()); producerDestination = createDestination(session, ActiveMQDestination.TOPIC_TYPE, getProducerSubject()); - } - else { + } else { consumerDestination = createDestination(session, ActiveMQDestination.QUEUE_TYPE, getConsumerSubject()); producerDestination = createDestination(session, ActiveMQDestination.QUEUE_TYPE, getConsumerSubject()); } @@ -87,8 +86,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { protected Session createConsumerSession() throws JMSException { if (useSeparateSession) { return connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - else { + } else { return session; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveWithTwoConnectionsTest.java index 467eab62e1..809594dc64 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveWithTwoConnectionsTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveWithTwoConnectionsTest.java @@ -54,8 +54,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes if (topic) { consumerDestination = createDestination(session, ActiveMQDestination.TOPIC_TYPE); producerDestination = createDestination(session, ActiveMQDestination.TOPIC_TYPE); - } - else { + } else { consumerDestination = createDestination(session, ActiveMQDestination.QUEUE_TYPE); producerDestination = createDestination(session, ActiveMQDestination.QUEUE_TYPE); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTransactionTestSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTransactionTestSupport.java index e2cd32d01e..978c88d433 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTransactionTestSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTransactionTestSupport.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.ArrayList; -import java.util.List; - import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; @@ -28,6 +25,8 @@ import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQPrefetchPolicy; @@ -570,8 +569,7 @@ public abstract class JmsTransactionTestSupport extends BasicOpenWireTest implem try { message.setStringProperty("foo", "def"); fail("Cannot change properties of the object!"); - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("Caught expected exception: " + e); e.printStackTrace(); } @@ -645,19 +643,16 @@ public abstract class JmsTransactionTestSupport extends BasicOpenWireTest implem try { rollbackTx(); resendPhase = true; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } - } - else { + } else { ackMessages.add(message); if (ackMessages.size() == MESSAGE_COUNT) { try { commitTx(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/MessageListenerRedeliveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/MessageListenerRedeliveryTest.java index e5ada0229c..09dc56590e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/MessageListenerRedeliveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/MessageListenerRedeliveryTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -32,14 +27,18 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQMessageConsumer; import org.apache.activemq.RedeliveryPolicy; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -104,14 +103,12 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { if (counter <= 4) { System.out.println("Message Rollback."); session.rollback(); - } - else { + } else { System.out.println("Message Commit."); message.acknowledge(); session.commit(); } - } - catch (JMSException e) { + } catch (JMSException e) { System.out.println("Error when rolling back transaction"); } } @@ -140,8 +137,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // first try.. should get 2 since there is no delay on the @@ -150,16 +146,14 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // 2nd redeliver (redelivery after 1 sec) assertEquals(3, listener.counter); try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // 3rd redeliver (redelivery after 2 seconds) - it should give up after // that @@ -171,16 +165,14 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // it should be committed, so no redelivery assertEquals(5, listener.counter); try { Thread.sleep(1500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // no redelivery, counter should still be 4 assertEquals(5, listener.counter); @@ -211,8 +203,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // first try @@ -220,8 +211,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // second try (redelivery after 1 sec) @@ -229,8 +219,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } // third try (redelivery after 2 seconds) - it should give up after that @@ -242,8 +231,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // ignore } // it should be committed, so no redelivery @@ -251,8 +239,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { try { Thread.sleep(1500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // ignore } // no redelivery, counter should still be 4 @@ -287,8 +274,7 @@ public class MessageListenerRedeliveryTest extends BasicOpenWireTest { System.out.println("Message Received: " + message); try { received.add(((TextMessage) message).getText()); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); fail(e.toString()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlSendFailTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlSendFailTest.java index 4d3a6f801e..227221ea9e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlSendFailTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlSendFailTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import javax.jms.ConnectionFactory; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -28,6 +24,9 @@ import javax.jms.MessageProducer; import javax.jms.ResourceAllocationException; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; @@ -101,8 +100,7 @@ public class ProducerFlowControlSendFailTest extends ProducerFlowControlTest { // will be limited by the network buffers Thread.sleep(200); } - } - catch (Exception e) { + } catch (Exception e) { // with async send, there will be no exceptions e.printStackTrace(); } @@ -145,8 +143,7 @@ public class ProducerFlowControlSendFailTest extends ProducerFlowControlTest { while (keepGoing.get()) { try { producer.send(session.createTextMessage("Test message")); - } - catch (JMSException arg0) { + } catch (JMSException arg0) { if (arg0 instanceof ResourceAllocationException) { gotResourceException.set(true); exceptionCount.incrementAndGet(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java index c468773e79..4f3d38d86e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java @@ -103,8 +103,7 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { done.set(false); try { producer.send(session.createTextMessage("Test message " + ++i)); - } - catch (JMSException e) { + } catch (JMSException e) { break; } } @@ -151,8 +150,7 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { done.set(false); try { producer.send(session.createTextMessage("Test message " + ++i)); - } - catch (JMSException e) { + } catch (JMSException e) { } } } @@ -270,10 +268,8 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { done.set(false); producer.send(session.createTextMessage("Hello World")); } - } - catch (JMSException e) { - } - finally { + } catch (JMSException e) { + } finally { safeClose(session); } } @@ -309,11 +305,9 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); producer.send(session.createTextMessage(message)); done.countDown(); - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); - } - finally { + } finally { safeClose(session); } } @@ -345,8 +339,7 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { try { flowControlConnection.getTransport().stop(); flowControlConnection.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { // sometimes the disposed up can make the test to fail // even worse I have seen this breaking every single test after this // if not caught here @@ -357,8 +350,7 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { asyncThread.join(); asyncThread = null; } - } - finally { + } finally { super.tearDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ReconnectWithSameClientIDTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ReconnectWithSameClientIDTest.java index 671fd8d3fd..ecefece384 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ReconnectWithSameClientIDTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ReconnectWithSameClientIDTest.java @@ -47,11 +47,9 @@ public class ReconnectWithSameClientIDTest extends BasicOpenWireTest { try { useConnection(connection2); fail("Should have thrown InvalidClientIDException on attempt" + i); - } - catch (InvalidClientIDException e) { + } catch (InvalidClientIDException e) { System.err.println("Caught expected: " + e); - } - finally { + } finally { connection2.close(); } } @@ -61,8 +59,7 @@ public class ReconnectWithSameClientIDTest extends BasicOpenWireTest { sameIdConnection.close(); sameIdConnection = (ActiveMQConnection) factory.createConnection(); useConnection(connection); - } - finally { + } finally { if (sameIdConnection != null) { sameIdConnection.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java index 5f14906748..030d5223d5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java @@ -22,11 +22,11 @@ import javax.jms.Session; import javax.jms.TextMessage; import org.apache.activemq.RedeliveryPolicy; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; /** diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/TransactionContextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/TransactionContextTest.java index a96fb7922c..5d274a3e8f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/TransactionContextTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/TransactionContextTest.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; +import javax.jms.TransactionRolledBackException; import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.TransactionRolledBackException; - import org.apache.activemq.TransactionContext; -import org.apache.activemq.transaction.Synchronization; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.transaction.Synchronization; import org.junit.Before; import org.junit.Test; @@ -86,8 +85,7 @@ public class TransactionContextTest extends BasicOpenWireTest { try { underTest.commit(); fail("exepcted rollback exception"); - } - catch (TransactionRolledBackException expected) { + } catch (TransactionRolledBackException expected) { } assertEquals("beforeEnd A called once", 1, beforeEndCountA.get()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java index b0a1237652..5f2c621830 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.interop; -import org.apache.activemq.ActiveMQMessageProducer; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; -import org.apache.activemq.command.ActiveMQDestination; -import org.junit.Before; -import org.junit.Test; - -import java.nio.charset.StandardCharsets; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.MapMessage; @@ -34,10 +26,18 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TextMessage; +import java.nio.charset.StandardCharsets; + +import org.apache.activemq.ActiveMQMessageProducer; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; +import org.junit.Before; +import org.junit.Test; public class CompressedInteropTest extends BasicOpenWireTest { private static final String TEXT; + static { StringBuilder builder = new StringBuilder(); @@ -103,7 +103,7 @@ public class CompressedInteropTest extends BasicOpenWireTest { boolean booleanVal = streamMessage.readBoolean(); assertTrue(booleanVal); byte byteVal = streamMessage.readByte(); - assertEquals((byte)10, byteVal); + assertEquals((byte) 10, byteVal); byte[] originVal = TEXT.getBytes(); byte[] bytesVal = new byte[originVal.length]; streamMessage.readBytes(bytesVal); @@ -176,7 +176,7 @@ public class CompressedInteropTest extends BasicOpenWireTest { boolean booleanVal = mapMessage.getBoolean("boolean-type"); assertTrue(booleanVal); byte byteVal = mapMessage.getByte("byte-type"); - assertEquals((byte)10, byteVal); + assertEquals((byte) 10, byteVal); byte[] bytesVal = mapMessage.getBytes("bytes-type"); byte[] originVal = TEXT.getBytes(); assertEquals(originVal.length, bytesVal.length); @@ -242,8 +242,7 @@ public class CompressedInteropTest extends BasicOpenWireTest { MessageConsumer coreConsumer = session.createConsumer(queue); message = coreConsumer.receive(5000); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/GeneralInteropTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/GeneralInteropTest.java index f82f112431..91f8188f1a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/GeneralInteropTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/GeneralInteropTest.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.interop; -import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.ActiveMQMessageProducer; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; -import org.apache.activemq.command.ActiveMQDestination; -import org.junit.Before; -import org.junit.Test; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.MapMessage; @@ -37,6 +29,14 @@ import javax.jms.TextMessage; import java.io.Serializable; import java.nio.charset.StandardCharsets; +import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.ActiveMQMessageProducer; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQDestination; +import org.junit.Before; +import org.junit.Test; + /** * This test covers interactions between core clients and * openwire clients, i.e. core producers sending messages @@ -197,8 +197,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { TextMessage msg = session.createTextMessage(text + i); producer.send(msg); } - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -223,8 +222,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(message); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -251,8 +249,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(bytesMessage); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -271,8 +268,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(objectMessage); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -301,8 +297,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(msg); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -331,8 +326,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(mapMessage); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -350,8 +344,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.send(msg); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -467,8 +460,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { assertEquals(979, genericMessage.getIntProperty("intProperty")); assertEquals((short) 1099, genericMessage.getShortProperty("shortProperty")); assertEquals("HelloMessage", genericMessage.getStringProperty("stringProperty")); - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } @@ -497,8 +489,7 @@ public class GeneralInteropTest extends BasicOpenWireTest { assertEquals(txtMessage.getJMSDestination(), queue); assertEquals(text + i, txtMessage.getText()); } - } - finally { + } finally { if (jmsConn != null) { jmsConn.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java index f6003c5b39..1e88d300be 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java @@ -77,7 +77,6 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { server.start(); - internalTest(MAX_MESSAGES, MY_ADDRESS, MY_QUEUE, server); } @@ -113,12 +112,10 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { try { future.get(3, TimeUnit.SECONDS); sendCount++; - } - catch (TimeoutException ex) { + } catch (TimeoutException ex) { // message sending has been blocked break; - } - finally { + } finally { future.cancel(true); // may or may not desire this } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/GlobalPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/GlobalPagingTest.java index d734a1e7d9..c94f54ab30 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/GlobalPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/GlobalPagingTest.java @@ -47,10 +47,10 @@ public class GlobalPagingTest extends PagingTest { @Override protected ActiveMQServer createServer(final boolean realFiles, - final Configuration configuration, - final long pageSize, - final long maxAddressSize, - final Map settings) { + final Configuration configuration, + final long pageSize, + final long maxAddressSize, + final Map settings) { ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, realFiles)); if (settings != null) { @@ -67,8 +67,6 @@ public class GlobalPagingTest extends PagingTest { return server; } - - @Test public void testPagingOverFullDisk() throws Exception { clearDataRecreateServerDirs(); @@ -80,7 +78,7 @@ public class GlobalPagingTest extends PagingTest { server.start(); - ActiveMQServerImpl serverImpl = (ActiveMQServerImpl)server; + ActiveMQServerImpl serverImpl = (ActiveMQServerImpl) server; serverImpl.getMonitor().stop(); // stop the scheduled executor, we will do it manually only serverImpl.getMonitor().tick(); @@ -106,7 +104,6 @@ public class GlobalPagingTest extends PagingTest { bb.put(getSamplebyte(j)); } - Queue queue = server.locateQueue(ADDRESS); queue.getPageSubscription().getPagingStore().forceAnotherPage(); @@ -121,8 +118,7 @@ public class GlobalPagingTest extends PagingTest { public void run() { try { sendFewMessages(numberOfMessages, session, producer, body); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -138,7 +134,6 @@ public class GlobalPagingTest extends PagingTest { t.join(5000); Assert.assertFalse(t.isAlive()); - session.start(); assertEquals(numberOfMessages * 2, getMessageCount(queue)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java index 769f436188..ab183c293f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java @@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; @@ -47,6 +46,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfi import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Assert; @@ -130,11 +130,9 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase { break; msgReceived.incrementAndGet(); } - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); - } - finally { + } finally { runnersLatch.countDown(); } } @@ -154,11 +152,9 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase { producer.send(session.createTextMessage(this.hashCode() + " counter " + i)); msgSent.incrementAndGet(); } - } - catch (Exception cause) { + } catch (Exception cause) { throw new RuntimeException(cause); - } - finally { + } finally { runnersLatch.countDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java index ae04a9f55b..0707297664 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.paging; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -30,9 +33,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class PageCountSyncOnNonTXTest extends ActiveMQTestBase { public static final String WORD_START = "&*STARTED&*"; @@ -123,13 +123,11 @@ public class PageCountSyncOnNonTXTest extends ActiveMQTestBase { session.commit(); } } - } - catch (Exception expected) { + } catch (Exception expected) { expected.printStackTrace(); } - } - finally { + } finally { locator.close(); } assertEquals("Process didn't end as expected", 1, process.waitFor()); @@ -169,13 +167,11 @@ public class PageCountSyncOnNonTXTest extends ActiveMQTestBase { session.close(); - } - finally { + } finally { locator.close(); } - } - finally { + } finally { server.stop(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncServer.java index 982dfe0faa..3711965280 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncServer.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncServer.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.paging; -import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; /** * This is a sub process of the test {@link PageCountSyncOnNonTXTest} @@ -30,7 +30,10 @@ public class PageCountSyncServer extends SpawnedServerSupport { return SpawnedVMSupport.spawnVM(PageCountSyncServer.class.getName(), testDir, "" + timeToRun); } - public static Process spawnVMWithLogMacher(final String wordMatch, final Runnable runnable, final String testDir, final long timeToRun) throws Exception { + public static Process spawnVMWithLogMacher(final String wordMatch, + final Runnable runnable, + final String testDir, + final long timeToRun) throws Exception { return SpawnedVMSupport.spawnVMWithLogMacher(wordMatch, runnable, PageCountSyncServer.class.getName(), null, true, testDir, "" + timeToRun); } @@ -49,8 +52,7 @@ public class PageCountSyncServer extends SpawnedServerSupport { System.out.println("Going down now!!!"); System.exit(1); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); System.exit(-1); } @@ -66,8 +68,7 @@ public class PageCountSyncServer extends SpawnedServerSupport { if (args.length == 2) { ss.perform(args[0], Long.parseLong(args[1])); - } - else { + } else { System.err.println("you were expected to pass getTestDir as an argument on SpawnVMSupport"); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingCounterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingCounterTest.java index 9fe1b68864..2d27fd0461 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingCounterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingCounterTest.java @@ -22,7 +22,6 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.paging.cursor.PageSubscription; import org.apache.activemq.artemis.core.paging.cursor.PageSubscriptionCounter; import org.apache.activemq.artemis.core.paging.cursor.impl.PageSubscriptionCounterImpl; @@ -33,6 +32,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; @@ -75,8 +75,7 @@ public class PagingCounterTest extends ActiveMQTestBase { storage.waitOnOperations(); assertEquals(1, counter.getValue()); - } - finally { + } finally { sf.close(); session.close(); } @@ -131,8 +130,7 @@ public class PagingCounterTest extends ActiveMQTestBase { assertEquals(2100, counter.getValue()); - } - finally { + } finally { sf.close(); session.close(); } @@ -189,8 +187,7 @@ public class PagingCounterTest extends ActiveMQTestBase { assertEquals(0, counter.getValue()); - } - finally { + } finally { sf.close(); session.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingOrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingOrderTest.java index 54c658f8e9..fa43ae7b8e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingOrderTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingOrderTest.java @@ -16,6 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.paging; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -44,17 +55,6 @@ import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.concurrent.atomic.AtomicInteger; - /** * A PagingOrderTest. PagingTest has a lot of tests already. I decided to create a newer one more * specialized on Ordering and counters @@ -217,8 +217,7 @@ public class PagingOrderTest extends ActiveMQTestBase { assertNull(cons.receiveImmediate()); sess.close(); sl.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -345,8 +344,7 @@ public class PagingOrderTest extends ActiveMQTestBase { } sess.close(); sl.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java index e1b10c61ca..4a26d97ffa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java @@ -23,11 +23,11 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java index f913dca5c1..ca8a9a1d1b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSendTest.java @@ -34,13 +34,13 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.LinkedListIterator; import org.junit.Assert; import org.junit.Before; @@ -177,8 +177,7 @@ public class PagingSendTest extends ActiveMQTestBase { sessionProducer.commit(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSyncTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSyncTest.java index bb9463449a..d4bc86a829 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSyncTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingSyncTest.java @@ -26,10 +26,10 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; /** diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java index 82ce14f1cd..6f0bdc1a00 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java @@ -178,8 +178,7 @@ public class PagingTest extends ActiveMQTestBase { if (ad > -1) { session.commit(); - } - else { + } else { session.rollback(); for (int i = 0; i < 100; i++) { ClientMessage message2 = consumer.receive(10000); @@ -834,8 +833,7 @@ public class PagingTest extends ActiveMQTestBase { if (ref.refEncoding.queueID == deletedQueueID) { deletedQueueReferences.add(new Long(info.id)); } - } - else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { + } else if (info.getUserRecordType() == JournalRecordIds.ACKNOWLEDGE_REF) { AckDescribe ref = (AckDescribe) DescribeJournal.newObjectEncoding(info); if (ref.refEncoding.queueID == deletedQueueID) { @@ -1479,12 +1477,10 @@ public class PagingTest extends ActiveMQTestBase { } session.commit(); session.close(); - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1615,13 +1611,11 @@ public class PagingTest extends ActiveMQTestBase { } session.close(); - } - finally { + } finally { locator.close(); try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -1813,8 +1807,7 @@ public class PagingTest extends ActiveMQTestBase { getMessageCount(queue); Thread.sleep(10); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { log.info("Thread interrupted"); } } @@ -1835,8 +1828,7 @@ public class PagingTest extends ActiveMQTestBase { session.createQueue(PagingTest.ADDRESS + "-1", PagingTest.ADDRESS + "-1", null, true); session.createQueue(PagingTest.ADDRESS + "-2", PagingTest.ADDRESS + "-2", null, true); - } - else { + } else { session.createQueue(PagingTest.ADDRESS.toString(), PagingTest.ADDRESS + "-1", null, true); session.createQueue(PagingTest.ADDRESS.toString(), PagingTest.ADDRESS + "-2", null, true); @@ -1933,8 +1925,7 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); - } - catch (AssertionError e) { + } catch (AssertionError e) { PagingTest.log.info("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); PagingTest.log.info("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); throw e; @@ -1946,8 +1937,7 @@ public class PagingTest extends ActiveMQTestBase { consumer.close(); session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -1978,8 +1968,7 @@ public class PagingTest extends ActiveMQTestBase { assertEquals(0, server.getPagingManager().getTransactions().size()); - } - finally { + } finally { running.set(false); if (tcount1 != null) { @@ -1994,8 +1983,7 @@ public class PagingTest extends ActiveMQTestBase { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } @@ -2098,8 +2086,7 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); - } - catch (AssertionError e) { + } catch (AssertionError e) { PagingTest.log.info("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); PagingTest.log.info("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); throw e; @@ -2111,8 +2098,7 @@ public class PagingTest extends ActiveMQTestBase { consumer.close(); session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -2226,8 +2212,7 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); - } - catch (AssertionError e) { + } catch (AssertionError e) { PagingTest.log.info("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); PagingTest.log.info("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); throw e; @@ -2518,8 +2503,7 @@ public class PagingTest extends ActiveMQTestBase { producerNonTransacted.send(msgSend); } assertTrue(server.getPagingManager().getPageStore(PagingTest.ADDRESS).isPaging()); - } - else { + } else { ClientConsumer consumer = sessionNonTX.createConsumer(PagingTest.ADDRESS); for (int j = 0; j < 20; j++) { ClientMessage msgReceived = consumer.receive(10000); @@ -2610,18 +2594,15 @@ public class PagingTest extends ActiveMQTestBase { sessionProducer.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); // >> junit report errors.incrementAndGet(); - } - finally { + } finally { try { if (sessionProducer != null) { sessionProducer.close(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -2712,18 +2693,15 @@ public class PagingTest extends ActiveMQTestBase { log.info("Producer gone"); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); // >> junit report errors.incrementAndGet(); - } - finally { + } finally { try { if (sessionProducer != null) { sessionProducer.close(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -2851,8 +2829,7 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); - } - catch (AssertionError e) { + } catch (AssertionError e) { PagingTest.log.info("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); PagingTest.log.info("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); throw e; @@ -2914,7 +2891,6 @@ public class PagingTest extends ActiveMQTestBase { session.close(); } - @Test public void testRollbackOnSendThenSendMore() throws Exception { clearDataRecreateServerDirs(); @@ -2971,7 +2947,6 @@ public class PagingTest extends ActiveMQTestBase { ClientSession consumerSession = sf.createSession(false, false); - queue.getPageSubscription().getPagingStore().disableCleanup(); queue.getPageSubscription().getPagingStore().getCursorProvider().cleanup(); @@ -2993,11 +2968,9 @@ public class PagingTest extends ActiveMQTestBase { consumerSession.close(); - session.close(); sf.close(); - server.stop(); } @@ -3023,12 +2996,10 @@ public class PagingTest extends ActiveMQTestBase { public void cleanup() { if (mainCleanup.get()) { super.cleanup(); - } - else { + } else { try { pagingStore.unlock(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -3039,7 +3010,10 @@ public class PagingTest extends ActiveMQTestBase { protected PagingStoreFactoryNIO getPagingStoreFactory() { return new PagingStoreFactoryNIO(this.getStorageManager(), this.getConfiguration().getPagingLocation(), this.getConfiguration().getJournalBufferTimeout_NIO(), this.getScheduledPool(), this.getExecutorFactory(), this.getConfiguration().isJournalSyncNonTransactional(), null) { @Override - public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, Executor executor) { + public PageCursorProvider newCursorProvider(PagingStore store, + StorageManager storageManager, + AddressSettings addressSettings, + Executor executor) { return new InterruptedCursorProvider(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); } }; @@ -3049,7 +3023,7 @@ public class PagingTest extends ActiveMQTestBase { addServer(server); - AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes( PagingTest.PAGE_SIZE).setMaxSizeBytes(PagingTest.PAGE_MAX).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); + AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(PagingTest.PAGE_SIZE).setMaxSizeBytes(PagingTest.PAGE_MAX).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); server.getAddressSettingsRepository().addMatch("#", defaultSetting); @@ -3132,14 +3106,12 @@ public class PagingTest extends ActiveMQTestBase { } } - mainCleanup.set(true); queue = server.locateQueue(ADDRESS); queue.getPageSubscription().cleanupEntries(false); queue.getPageSubscription().getPagingStore().getCursorProvider().cleanup(); - ClientConsumer consumer = session.createConsumer(ADDRESS); session.start(); @@ -3154,8 +3126,6 @@ public class PagingTest extends ActiveMQTestBase { // Thread.sleep(5000); - - } @Test @@ -3484,8 +3454,7 @@ public class PagingTest extends ActiveMQTestBase { public void onMessage(ClientMessage message1) { try { Thread.sleep(1); - } - catch (Exception e) { + } catch (Exception e) { } @@ -3497,8 +3466,7 @@ public class PagingTest extends ActiveMQTestBase { try { message1.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -3633,12 +3601,10 @@ public class PagingTest extends ActiveMQTestBase { server.stop(); - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } OperationContextImpl.clearContext(); @@ -3915,16 +3881,13 @@ public class PagingTest extends ActiveMQTestBase { } } sessionConsumer.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { try { sessionConsumer.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -4137,12 +4100,10 @@ public class PagingTest extends ActiveMQTestBase { sf.close(); locator.close(); - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -4214,12 +4175,10 @@ public class PagingTest extends ActiveMQTestBase { sf.close(); locator.close(); - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -4318,12 +4277,10 @@ public class PagingTest extends ActiveMQTestBase { sf.close(); locator.close(); - } - finally { + } finally { try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -4428,8 +4385,7 @@ public class PagingTest extends ActiveMQTestBase { log.info(threadDump("dump")); fail("Couldn't finish large message receiving"); } - } - catch (Throwable e) { + } catch (Throwable e) { log.info("output bytes = " + bytesOutput); log.info(threadDump("dump")); fail("Couldn't finish large message receiving for id=" + message.getStringProperty("id") + @@ -4531,15 +4487,13 @@ public class PagingTest extends ActiveMQTestBase { assertFalse(pgStoreAddress.isPaging()); session.commit(); - } - finally { + } finally { session.close(); sf.close(); locator.close(); try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -4590,8 +4544,7 @@ public class PagingTest extends ActiveMQTestBase { if (i % 2 == 0) { message.setBodyInputStream(createFakeLargeStream(messageSize)); - } - else { + } else { byte[] bytes = new byte[messageSize]; for (int s = 0; s < bytes.length; s++) { bytes[s] = getSamplebyte(s); @@ -4666,13 +4619,11 @@ public class PagingTest extends ActiveMQTestBase { assertFalse(pgStoreAddress.isPaging()); session.close(); - } - finally { + } finally { locator.close(); try { server.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -4756,14 +4707,12 @@ public class PagingTest extends ActiveMQTestBase { // this send will succeed on the server producer.send(message); } - } - catch (Exception e) { + } catch (Exception e) { exception = true; } assertTrue("Expected to throw an exception", exception); - } - finally { + } finally { AssertionLoggerHandler.stopCapture(); } } @@ -4811,8 +4760,7 @@ public class PagingTest extends ActiveMQTestBase { for (int i = 0; i < 50; i++) { if (i > 2) { validateExceptionOnSending(producer, message); - } - else { + } else { producer.send(message); } } @@ -4834,8 +4782,7 @@ public class PagingTest extends ActiveMQTestBase { // this send will succeed on the server producer.send(message); } - } - catch (Exception e) { + } catch (Exception e) { exception = true; } @@ -4932,8 +4879,7 @@ public class PagingTest extends ActiveMQTestBase { try { // after the address is full this send should fail (since the address full policy is FAIL) producer.send(message); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { expected = e; } @@ -5181,8 +5127,7 @@ public class PagingTest extends ActiveMQTestBase { session.close(); locator.close(); - } - finally { + } finally { server.stop(); } } @@ -5267,8 +5212,7 @@ public class PagingTest extends ActiveMQTestBase { session.close(); waitForNotPaging(store); - } - finally { + } finally { server.stop(); } @@ -5342,8 +5286,7 @@ public class PagingTest extends ActiveMQTestBase { if (browsing) { cons1 = session.createConsumer("Q1", "color='green'", true); - } - else { + } else { cons1 = session.createConsumer("Q1", "color='red'", false); } @@ -5360,8 +5303,7 @@ public class PagingTest extends ActiveMQTestBase { session.commit(); session.close(); - } - finally { + } finally { server.stop(); } @@ -5443,8 +5385,7 @@ public class PagingTest extends ActiveMQTestBase { session.close(); waitForNotPaging(store); - } - finally { + } finally { server.stop(); } @@ -5519,8 +5460,7 @@ public class PagingTest extends ActiveMQTestBase { session.close(); waitForNotPaging(store); - } - finally { + } finally { server.stop(); } @@ -5654,8 +5594,7 @@ public class PagingTest extends ActiveMQTestBase { sf.close(); locator.close(); - } - finally { + } finally { server.stop(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java index 0f9f3d372b..ed3befdccd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java @@ -66,16 +66,14 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { if (backupProcess != null) { backupProcess.destroy(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } backupProcess = null; if (inProcessBackup != null) { try { inProcessBackup.getServer().stop(false); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } @@ -89,8 +87,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { if (liveProcess != null) { liveProcess.destroy(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } liveProcess = null; } @@ -126,8 +123,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { while (this.isAlive()) { try { this.join(5000); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } if (this.isAlive()) { this.interrupt(); @@ -145,8 +141,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { waitNotify.wait(timeWait); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); } @@ -178,8 +173,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { if (txSize == 0) { session = factory.createSession(true, true); - } - else { + } else { session = factory.createSession(false, false); } @@ -204,8 +198,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { session.commit(); if (currentMsg > lastCommit) { lastCommit = currentMsg; - } - else { + } else { System.out.println("Ignoring setting lastCommit (" + lastCommit + ") <= currentMSG (" + currentMsg + ")"); } } @@ -215,15 +208,13 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { if (msgcount % 100 == 0) { System.out.println("received " + msgcount + " on " + queueName); } - } - catch (Throwable e) { + } catch (Throwable e) { System.out.println("=====> expected Error at " + currentMsg + " with lastCommit=" + lastCommit); } } session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -263,8 +254,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { session.deleteQueue("new-queue"); locator.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); fail(e.getMessage()); } @@ -278,8 +268,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { fail("count < 0 .... being " + count); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -325,8 +314,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { ClientMessage msg = session.createMessage(true); msg.putLongProperty("count", i); prod.send(msg); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -334,8 +322,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { try { tConsumer.stopTest(); monitor.stopTest(); - } - finally { + } finally { killBackup(); killLive(); } @@ -370,8 +357,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { try { drainConsumer(session.createConsumer("cons2"), "cons2", messageCount); - } - finally { + } finally { session.close(); factory.close(); locator.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverServer.java index 2cc27e9f63..99e0aacfcd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverServer.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverServer.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.paging; -import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; public class PagingWithFailoverServer extends SpawnedServerSupport { @@ -48,8 +48,7 @@ public class PagingWithFailoverServer extends SpawnedServerSupport { server.start(); System.out.println("Server started!!!"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); System.exit(-1); } @@ -67,8 +66,7 @@ public class PagingWithFailoverServer extends SpawnedServerSupport { try { server.perform(arg[0], Integer.parseInt(arg[1]), Integer.parseInt(arg[2]), Boolean.parseBoolean(arg[3])); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java index cad965c9ba..b309404789 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java @@ -62,8 +62,7 @@ public class SpawnedServerSupport { if (isBackup) { haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration(); ((SharedStoreSlavePolicyConfiguration) haPolicyConfiguration).setAllowFailBack(false); - } - else { + } else { haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration(); } @@ -93,8 +92,7 @@ public class SpawnedServerSupport { if (acceptor) { className = NettyAcceptorFactory.class.getName(); - } - else { + } else { className = NettyConnectorFactory.class.getName(); } Map serverParams = new HashMap<>(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java index 5e24d55a16..9848c39622 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java @@ -50,7 +50,7 @@ public class DeleteMessagesOnStartupTest extends StorageManagerTestBase { // This is only applicable for FILE based store, as the database storage manager will automatically delete records. @Parameterized.Parameters(name = "storeType") public static Collection data() { - Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}}; + Object[][] params = new Object[][]{{StoreConfiguration.StoreType.FILE}}; return Arrays.asList(params); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteQueueRestartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteQueueRestartTest.java index f1e8cfccda..8c68504dec 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteQueueRestartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteQueueRestartTest.java @@ -86,8 +86,7 @@ public class DeleteQueueRestartTest extends ActiveMQTestBase { session.deleteQueue(DeleteQueueRestartTest.ADDRESS); session.close(); count.countDown(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } }.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java index 299022cbf3..832bdfb8f6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java @@ -92,7 +92,6 @@ public class DuplicateCacheTest extends StorageManagerTestBase { } }, true); - Assert.assertTrue(latch.await(1, TimeUnit.MINUTES)); Assert.assertFalse(cache.contains(id)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java index fb8a3e74b0..567e7246df 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.Pair; @@ -28,11 +33,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class JMSConnectionFactoryConfigurationStorageTest extends StorageManagerTestBase { private Map mapExpectedCFs; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSDynamicConfigTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSDynamicConfigTest.java index 8d9dbfaee7..790fc3b066 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSDynamicConfigTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSDynamicConfigTest.java @@ -16,16 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Test; - -import java.util.ArrayList; - import javax.naming.NamingException; +import java.util.ArrayList; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Test; public class JMSDynamicConfigTest extends JMSTestBase { @@ -59,8 +57,7 @@ public class JMSDynamicConfigTest extends JMSTestBase { try { namingContext.lookup("tst"); fail("failure expected"); - } - catch (NamingException excepted) { + } catch (NamingException excepted) { } jmsServer.stop(); @@ -71,8 +68,7 @@ public class JMSDynamicConfigTest extends JMSTestBase { try { namingContext.lookup("tst"); fail("failure expected"); - } - catch (NamingException excepted) { + } catch (NamingException excepted) { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java index f67a1906ad..6186206e65 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/JMSStorageManagerTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; -import org.apache.activemq.artemis.core.config.StoreConfiguration; -import org.junit.Assert; -import org.junit.Test; - import java.util.List; -import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; +import org.apache.activemq.artemis.core.config.StoreConfiguration; import org.apache.activemq.artemis.jms.persistence.config.PersistedBindings; +import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; import org.apache.activemq.artemis.jms.persistence.config.PersistedType; +import org.junit.Assert; +import org.junit.Test; public class JMSStorageManagerTest extends StorageManagerTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java index 1c51b36b2b..5828baf033 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; + import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; @@ -28,11 +33,6 @@ import org.apache.activemq.artemis.utils.ExecutorFactory; import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; - public class RestartSMTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -90,13 +90,11 @@ public class RestartSMTest extends ActiveMQTestBase { journal.loadBindingJournal(queueBindingInfos, new ArrayList()); journal.start(); - } - finally { + } finally { try { journal.stop(); - } - catch (Exception ex) { + } catch (Exception ex) { RestartSMTest.log.warn(ex.getMessage(), ex); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java index 74991093cd..655c500779 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java @@ -16,17 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; -import org.apache.activemq.artemis.core.config.StoreConfiguration; -import org.junit.Before; - -import org.junit.Test; - import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.config.StoreConfiguration; import org.apache.activemq.artemis.core.persistence.config.PersistedRoles; +import org.junit.Before; +import org.junit.Test; public class RolesConfigurationStorageTest extends StorageManagerTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java index cdf67439be..814bf0d79d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java @@ -63,7 +63,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection data() { - Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; + Object[][] params = new Object[][]{{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; return Arrays.asList(params); } @@ -89,8 +89,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { if (journal != null) { try { journal.stop(); - } - catch (Exception e) { + } catch (Exception e) { exception = e; } @@ -100,8 +99,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { if (jmsJournal != null) { try { jmsJournal.stop(); - } - catch (Exception e) { + } catch (Exception e) { if (exception != null) exception = e; } @@ -111,7 +109,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { scheduledExecutorService.shutdown(); - destroyTables(Arrays.asList(new String[] {"MESSAGE", "BINDINGS", "LARGE_MESSAGE"})); + destroyTables(Arrays.asList(new String[]{"MESSAGE", "BINDINGS", "LARGE_MESSAGE"})); super.tearDown(); if (exception != null) throw exception; @@ -124,8 +122,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { if (storeType == StoreConfiguration.StoreType.DATABASE) { journal = createJDBCJournalStorageManager(createDefaultJDBCConfig(true)); - } - else { + } else { journal = createJournalStorageManager(createDefaultInVMConfig()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java index 4854574cbf..7cb280c516 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java @@ -16,23 +16,21 @@ */ package org.apache.activemq.artemis.tests.integration.persistence; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.junit.Test; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.ActiveMQBuffers; +import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.jms.server.config.impl.TransportConfigurationEncodingSupport; import org.apache.activemq.artemis.utils.RandomUtil; -import org.apache.activemq.artemis.api.core.Pair; - import org.junit.Assert; +import org.junit.Test; public class TransportConfigurationEncodingSupportTest extends Assert { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java index bdd9255182..29f280b73d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java @@ -96,7 +96,6 @@ public class XmlImportExportTest extends ActiveMQTestBase { } } - @Test public void testMessageProperties() throws Exception { ClientSession session = basicSetUp(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQActivationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQActivationTest.java index 2fa557866b..c92f75808a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQActivationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQActivationTest.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.ra; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; -import org.junit.Test; - import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Test; public class ActiveMQActivationTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQClusteredTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQClusteredTest.java index 676c8ade30..f8c2032229 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQClusteredTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQClusteredTest.java @@ -142,7 +142,7 @@ public class ActiveMQClusteredTest extends ActiveMQRAClusteredTestBase { managedConnections.add(mc); ActiveMQConnectionFactory cf1 = mc.getConnectionFactory(); - while (!((ServerLocatorImpl)cf1.getServerLocator()).isReceivedTopology()) { + while (!((ServerLocatorImpl) cf1.getServerLocator()).isReceivedTopology()) { Thread.sleep(50); } @@ -156,8 +156,7 @@ public class ActiveMQClusteredTest extends ActiveMQRAClusteredTestBase { assertTrue(server.getConnectionCount() >= (CONNECTION_COUNT / 2)); assertTrue(secondaryServer.getConnectionCount() >= (CONNECTION_COUNT / 2)); - } - finally { + } finally { for (Session s : sessions) { s.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerSecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerSecurityTest.java index b0669f14fa..464c09776c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerSecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerSecurityTest.java @@ -39,7 +39,7 @@ public class ActiveMQMessageHandlerSecurityTest extends ActiveMQRATestBase { @Test public void testSimpleMessageReceivedOnQueueWithSecurityFails() throws Exception { SecurityConfiguration emptyConfiguration = new SecurityConfiguration(); - ((ActiveMQJAASSecurityManager)server.getSecurityManager()).setConfiguration(emptyConfiguration); + ((ActiveMQJAASSecurityManager) server.getSecurityManager()).setConfiguration(emptyConfiguration); ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter(); MyBootstrapContext ctx = new MyBootstrapContext(); qResourceAdapter.start(ctx); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java index 5101cd8449..98e6adb796 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java @@ -16,6 +16,21 @@ */ package org.apache.activemq.artemis.tests.integration.ra; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.Session; +import javax.resource.ResourceException; +import javax.resource.spi.InvalidPropertyException; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -33,21 +48,6 @@ import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.junit.Test; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.Session; -import javax.resource.ResourceException; -import javax.resource.spi.InvalidPropertyException; -import java.io.Serializable; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { @Override @@ -158,8 +158,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { objMsg.setObject(new DummySerializable()); MessageProducer producer = session.createProducer(jmsQueue); producer.send(objMsg); - } - finally { + } finally { connection.close(); } @@ -173,8 +172,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { Object obj = objMsg.getObject(); assertTrue("deserialization should fail but got: " + obj, shouldSucceed); assertTrue(obj instanceof DummySerializable); - } - catch (JMSException e) { + } catch (JMSException e) { assertFalse("got unexpected exception: " + e, shouldSucceed); } @@ -364,8 +362,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { try { spec.setAcknowledgeMode("CLIENT_ACKNOWLEDGE"); fail("should throw exception"); - } - catch (java.lang.IllegalArgumentException e) { + } catch (java.lang.IllegalArgumentException e) { //pass } qResourceAdapter.stop(); @@ -813,8 +810,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { try { qResourceAdapter.endpointActivation(endpointFactory, spec); fail(); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof InvalidPropertyException); assertEquals("subscriptionName", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName()); } @@ -841,8 +837,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { try { qResourceAdapter.endpointActivation(endpointFactory, spec); fail(); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof InvalidPropertyException); assertEquals("destinationType", ((InvalidPropertyException) e).getInvalidPropertyDescriptors()[0].getName()); } @@ -955,13 +950,11 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { try { IntegrationTestLogger.LOGGER.info("pausing for 2 secs"); Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { interrupted.incrementAndGet(); } } - } - finally { + } finally { if (latchDone != null) { latchDone.countDown(); } @@ -970,5 +963,6 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { } static class DummySerializable implements Serializable { + } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java index 4278ef8a75..6ff82edf44 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.ra; +import javax.jms.Message; +import javax.resource.ResourceException; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.lang.reflect.Method; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -27,15 +36,6 @@ import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Test; -import javax.jms.Message; -import javax.resource.ResourceException; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { @Override @@ -205,8 +205,7 @@ public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { super.beforeDelivery(method); try { xaResource.start(xid, XAResource.TMNOFLAGS); - } - catch (XAException e) { + } catch (XAException e) { throw new ResourceException(e.getMessage(), e); } } @@ -215,8 +214,7 @@ public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { public void afterDelivery() throws ResourceException { try { xaResource.end(xid, XAResource.TMSUCCESS); - } - catch (XAException e) { + } catch (XAException e) { throw new ResourceException(e.getMessage(), e); } @@ -258,8 +256,7 @@ public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { super.onMessage(message); try { Thread.sleep(2000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { interrupted = true; } } @@ -269,8 +266,7 @@ public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { try { prepare(); commit(); - } - catch (XAException e) { + } catch (XAException e) { e.printStackTrace(); } super.release(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java index 25bff46501..9e3abf28dd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java @@ -73,14 +73,7 @@ public class ActiveMQRAClusteredTestBase extends ActiveMQRATestBase { index = 1; } - ConfigurationImpl configuration = createBasicConfig(index) - .setJMXManagementEnabled(false) - .clearAcceptorConfigurations() - .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, invmMap)) - .addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, nettyMap)) - .addConnectorConfiguration(secondaryConnectorName, secondaryConnector) - .addConnectorConfiguration(primaryConnectorName, primaryConnector) - .addClusterConfiguration(ActiveMQTestBase.basicClusterConnectionConfig(secondaryConnectorName, primaryConnectorName).setReconnectAttempts(0)); + ConfigurationImpl configuration = createBasicConfig(index).setJMXManagementEnabled(false).clearAcceptorConfigurations().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, invmMap)).addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, nettyMap)).addConnectorConfiguration(secondaryConnectorName, secondaryConnector).addConnectorConfiguration(primaryConnectorName, primaryConnector).addClusterConfiguration(ActiveMQTestBase.basicClusterConnectionConfig(secondaryConnectorName, primaryConnectorName).setReconnectAttempts(0)); recreateDataDirectories(getTestDir(), index, false); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java index 8043689727..3a9e0b046b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java @@ -16,15 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.ra; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.settings.impl.AddressSettings; -import org.apache.activemq.artemis.jms.client.ActiveMQMessage; -import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.junit.Before; - import javax.jms.Message; import javax.jms.MessageListener; import javax.resource.ResourceException; @@ -45,6 +36,15 @@ import java.util.Map; import java.util.Timer; import java.util.concurrent.CountDownLatch; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.jms.client.ActiveMQMessage; +import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.Before; + public abstract class ActiveMQRATestBase extends JMSTestBase { protected ServerLocator locator; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/JMSContextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/JMSContextTest.java index 6ee604584b..ae8872169a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/JMSContextTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/JMSContextTest.java @@ -89,11 +89,9 @@ public class JMSContextTest extends ActiveMQRATestBase { try { jmsctx.createContext(JMSContext.AUTO_ACKNOWLEDGE); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException e) { + } catch (JMSRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("wrong exception thrown: " + e); } } @@ -104,11 +102,9 @@ public class JMSContextTest extends ActiveMQRATestBase { try { jmsctx.createContext(JMSContext.AUTO_ACKNOWLEDGE); fail("expected JMSRuntimeException"); - } - catch (JMSRuntimeException e) { + } catch (JMSRuntimeException e) { //pass - } - catch (Exception e) { + } catch (Exception e) { fail("wrong exception thrown: " + e); } } @@ -118,8 +114,7 @@ public class JMSContextTest extends ActiveMQRATestBase { try { qraConnectionFactory.createContext(JMSContext.SESSION_TRANSACTED); fail(); - } - catch (JMSRuntimeException e) { + } catch (JMSRuntimeException e) { //pass } } @@ -136,8 +131,7 @@ public class JMSContextTest extends ActiveMQRATestBase { try { qraConnectionFactory.createContext(JMSContext.CLIENT_ACKNOWLEDGE); fail(); - } - catch (JMSRuntimeException e) { + } catch (JMSRuntimeException e) { //pass } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTest.java index 190240c30a..c5bdd7c2b7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTest.java @@ -153,8 +153,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { try { conn = qraConnectionFactory.createConnection("IDont", "Exist"); fail("Exception was expected"); - } - catch (JMSSecurityException expected) { + } catch (JMSSecurityException expected) { } conn = qraConnectionFactory.createConnection("testuser", "testpassword"); @@ -163,8 +162,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { try { XAConnection xaconn = qraConnectionFactory.createXAConnection("IDont", "Exist"); fail("Exception was expected"); - } - catch (JMSSecurityException expected) { + } catch (JMSSecurityException expected) { } XAConnection xaconn = qraConnectionFactory.createXAConnection("testuser", "testpassword"); @@ -173,8 +171,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { try { TopicConnection topicconn = qraConnectionFactory.createTopicConnection("IDont", "Exist"); fail("Exception was expected"); - } - catch (JMSSecurityException expected) { + } catch (JMSSecurityException expected) { } TopicConnection topicconn = qraConnectionFactory.createTopicConnection("testuser", "testpassword"); @@ -183,8 +180,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { try { QueueConnection queueconn = qraConnectionFactory.createQueueConnection("IDont", "Exist"); fail("Exception was expected"); - } - catch (JMSSecurityException expected) { + } catch (JMSSecurityException expected) { } QueueConnection queueconn = qraConnectionFactory.createQueueConnection("testuser", "testpassword"); @@ -207,8 +203,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { try { Session s2 = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); fail("should throw javax,jms.IllegalStateException: Only allowed one session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -247,8 +242,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { queueConnection = qraConnectionFactory.createQueueConnection("testuser", "testwrongpassword"); queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE).close(); fail("should throw esxception"); - } - catch (JMSException e) { + } catch (JMSException e) { //pass } } @@ -265,8 +259,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { QueueConnection queueConnection = qraConnectionFactory.createQueueConnection("testuser", "testwrongpassword"); queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE).close(); fail("should throw esxception"); - } - catch (JMSException e) { + } catch (JMSException e) { //make sure the recovery is null assertNull(mcf.getResourceRecovery()); } @@ -344,8 +337,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { // we're not testing equality so don't use equals(); we're testing if they are actually the *same* object assertTrue(cf1 == cf2); - } - finally { + } finally { if (s != null) { s.close(); } @@ -395,8 +387,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { MessageProducer producer = s2.createProducer(ActiveMQJMSClient.createQueue(MDBQUEUE)); producer.send(s2.createTextMessage("x")); - } - finally { + } finally { if (s != null) { s.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTestJTA.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTestJTA.java index d51e0da5a6..b8f529fdc2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTestJTA.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/OutgoingConnectionTestJTA.java @@ -137,8 +137,7 @@ public class OutgoingConnectionTestJTA extends ActiveMQRATestBase { Session s = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); if (inTx) { assertEquals(Session.SESSION_TRANSACTED, s.getAcknowledgeMode()); - } - else { + } else { assertEquals(Session.AUTO_ACKNOWLEDGE, s.getAcknowledgeMode()); } s.close(); @@ -146,8 +145,7 @@ public class OutgoingConnectionTestJTA extends ActiveMQRATestBase { s = queueConnection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); if (inTx) { assertEquals(Session.SESSION_TRANSACTED, s.getAcknowledgeMode()); - } - else { + } else { assertEquals(Session.DUPS_OK_ACKNOWLEDGE, s.getAcknowledgeMode()); } s.close(); @@ -158,13 +156,11 @@ public class OutgoingConnectionTestJTA extends ActiveMQRATestBase { s = queueConnection.createSession(false, Session.SESSION_TRANSACTED); if (inTx) { assertEquals(s.getAcknowledgeMode(), Session.SESSION_TRANSACTED); - } - else { + } else { fail("didn't get expected exception creating session with SESSION_TRANSACTED mode "); } s.close(); - } - catch (JMSException e) { + } catch (JMSException e) { if (inTx) { fail("shouldn't throw exception " + e); } @@ -174,12 +170,10 @@ public class OutgoingConnectionTestJTA extends ActiveMQRATestBase { s = queueConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE); if (inTx) { assertEquals(s.getAcknowledgeMode(), Session.SESSION_TRANSACTED); - } - else { + } else { fail("didn't get expected exception creating session with CLIENT_ACKNOWLEDGE mode"); } - } - catch (JMSException e) { + } catch (JMSException e) { if (inTx) { fail("shouldn't throw exception " + e); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/BatchDelayTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/BatchDelayTest.java index 78ca02ca5c..06dbb17040 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/BatchDelayTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/BatchDelayTest.java @@ -16,26 +16,24 @@ */ package org.apache.activemq.artemis.tests.integration.remoting; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Assert; -import org.junit.Before; - -import org.junit.Test; - import java.util.HashMap; import java.util.Map; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class BatchDelayTest extends ActiveMQTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/DirectDeliverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/DirectDeliverTest.java index 897cec08f7..856562a391 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/DirectDeliverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/DirectDeliverTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.remoting; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -35,9 +38,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - public class DirectDeliverTest extends ActiveMQTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/NetworkAddressTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/NetworkAddressTestBase.java index 366d55d4a1..6268c54490 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/NetworkAddressTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/NetworkAddressTestBase.java @@ -28,13 +28,13 @@ import java.util.Map.Entry; import java.util.Set; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; @@ -54,8 +54,7 @@ public abstract class NetworkAddressTestBase extends ActiveMQTestBase { for (Entry entry : set) { s.append(entry.getKey().getDisplayName() + ": " + entry.getValue().getHostAddress() + "\n"); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -213,17 +212,14 @@ public abstract class NetworkAddressTestBase extends ActiveMQTestBase { } sf.close(); System.out.println("connection OK"); - } - else { + } else { try { locator.createSessionFactory(); Assert.fail("session creation must fail because connector must not be able to connect to the server bound to another network interface"); - } - catch (Exception e) { + } catch (Exception e) { } } - } - finally { + } finally { messagingService.stop(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java index 564c6b616f..0285d56479 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.remoting; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -39,10 +43,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class PingTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -119,8 +119,7 @@ public class PingTest extends ActiveMQTestBase { if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); - } - else { + } else { // It's async so need to wait a while Thread.sleep(10); } @@ -174,8 +173,7 @@ public class PingTest extends ActiveMQTestBase { if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); - } - else { + } else { // It's async so need to wait a while Thread.sleep(10); } @@ -274,8 +272,7 @@ public class PingTest extends ActiveMQTestBase { if (!conns.isEmpty()) { serverConn = server.getRemotingService().getConnections().iterator().next(); - } - else { + } else { // It's async so need to wait a while Thread.sleep(10); } @@ -378,8 +375,7 @@ public class PingTest extends ActiveMQTestBase { if (!conns.isEmpty()) { serverConn = (CoreRemotingConnection) server.getRemotingService().getConnections().iterator().next(); - } - else { + } else { // It's async so need to wait a while Thread.sleep(10); } @@ -402,8 +398,7 @@ public class PingTest extends ActiveMQTestBase { while (true) { if (!server.getRemotingService().getConnections().isEmpty() && System.currentTimeMillis() - start < 10000) { Thread.sleep(500); - } - else { + } else { break; } } @@ -415,4 +410,4 @@ public class PingTest extends ActiveMQTestBase { locator.close(); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/ReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/ReconnectTest.java index 8be703a27d..c2c9f61fab 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/ReconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/ReconnectTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.remoting; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.client.FailoverEventListener; -import org.apache.activemq.artemis.api.core.client.FailoverEventType; -import org.apache.activemq.artemis.core.server.ServerSession; -import org.junit.Test; - import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -29,15 +23,19 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; - +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.api.core.client.FailoverEventListener; +import org.apache.activemq.artemis.api.core.client.FailoverEventType; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.SessionFailureListener; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; public class ReconnectTest extends ActiveMQTestBase { @@ -102,12 +100,10 @@ public class ReconnectTest extends ActiveMQTestBase { Assert.assertEquals(1, count.get()); locator.close(); - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } server.stop(); @@ -174,12 +170,10 @@ public class ReconnectTest extends ActiveMQTestBase { locator.close(); } - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { } server.stop(); @@ -295,8 +289,7 @@ public class ReconnectTest extends ActiveMQTestBase { latchCommit.countDown(); try { session.commit(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); } } @@ -310,8 +303,7 @@ public class ReconnectTest extends ActiveMQTestBase { if (interruptMainThread) { tcommitt.interrupt(); - } - else { + } else { for (Thread tint : threadToBeInterrupted) { tint.interrupt(); } @@ -321,8 +313,7 @@ public class ReconnectTest extends ActiveMQTestBase { assertFalse(tcommitt.isAlive()); locator.close(); - } - finally { + } finally { } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/SynchronousCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/SynchronousCloseTest.java index d34b15b09a..bd48ac1be5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/SynchronousCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/SynchronousCloseTest.java @@ -58,8 +58,7 @@ public class SynchronousCloseTest extends ActiveMQTestBase { ServerLocator locator; if (isNetty()) { locator = createNettyNonHALocator(); - } - else { + } else { locator = createInVMNonHALocator(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationOrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationOrderTest.java index 3a67708993..ab4257d224 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationOrderTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationOrderTest.java @@ -16,21 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.replication; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.tests.integration.cluster.failover.FailoverTestBase; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class ReplicationOrderTest extends FailoverTestBase { @@ -56,8 +54,7 @@ public class ReplicationOrderTest extends FailoverTestBase { ClientSession session = null; if (transactional) { session = csf.createSession(false, false); - } - else { + } else { session = csf.createSession(true, true); } addClientSession(session); @@ -73,8 +70,7 @@ public class ReplicationOrderTest extends FailoverTestBase { session.commit(); durable = !durable; } - } - else { + } else { durable = !durable; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java index e05bdb20df..9d63e1d919 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java @@ -44,10 +44,11 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; +import org.apache.activemq.artemis.core.io.IOCallback; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.IOCompletion; import org.apache.activemq.artemis.core.journal.Journal; @@ -55,7 +56,6 @@ import org.apache.activemq.artemis.core.journal.JournalLoadInformation; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.paging.PagedMessage; @@ -127,8 +127,7 @@ public final class ReplicationTest extends ActiveMQTestBase { liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0); backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0); backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0); - } - else { + } else { liveConnector = TransportConfigurationUtils.getInVMConnector(true); backupConnector = TransportConfigurationUtils.getInVMConnector(false); backupAcceptor = TransportConfigurationUtils.getInVMAcceptor(false); @@ -153,8 +152,7 @@ public final class ReplicationTest extends ActiveMQTestBase { backupServer = createServer(backupConfig); if (useNetty) { locator = createNettyNonHALocator(); - } - else { + } else { locator = createInVMNonHALocator(); } @@ -195,11 +193,9 @@ public final class ReplicationTest extends ActiveMQTestBase { addActiveMQComponent(manager); manager.start(); Assert.fail("Exception was expected"); - } - catch (ActiveMQNotConnectedException nce) { + } catch (ActiveMQNotConnectedException nce) { // ok - } - catch (ActiveMQException expected) { + } catch (ActiveMQException expected) { fail("Invalid Exception type:" + expected.getType()); } } @@ -318,8 +314,7 @@ public final class ReplicationTest extends ActiveMQTestBase { Assert.assertEquals(i, msgRcvd.getIntProperty("counter").intValue()); msgRcvd.acknowledge(); } - } - finally { + } finally { TestInterceptor.value.set(false); if (!session.isClosed()) session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/Order.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/Order.java index 6755e55d17..e73c1e1df3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/Order.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/Order.java @@ -21,6 +21,7 @@ import java.io.Serializable; @XmlRootElement(name = "order") public class Order implements Serializable { + private static final long serialVersionUID = -3462346058107018735L; private String name; private String amount; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java index 814fe6b636..7e78795a32 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestDeserializationTest.java @@ -112,8 +112,7 @@ public class RestDeserializationTest extends RestTestBase { try { String received = restReceiveQueueMessage("orders"); fail("Object should be rejected by blacklist, but " + received); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { String error = e.getMessage(); assertTrue(error, error.contains("ClassNotFoundException")); } @@ -136,8 +135,7 @@ public class RestDeserializationTest extends RestTestBase { try { String received = topicContext.pullMessage(); fail("object should have been rejected but: " + received); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { String error = e.getMessage(); assertTrue(error, error.contains("ClassNotFoundException")); } @@ -172,8 +170,7 @@ public class RestDeserializationTest extends RestTestBase { String jmsDest; if (isQueue) { jmsDest = "jms.queue." + destName; - } - else { + } else { jmsDest = "jms.topic." + destName; } Destination destination = ActiveMQDestination.fromAddress(jmsDest); @@ -186,8 +183,7 @@ public class RestDeserializationTest extends RestTestBase { message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml"); message.setObject(value); producer.send(message); - } - finally { + } finally { conn.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestTestBase.java index f57f0adec4..acd66287dc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/RestTestBase.java @@ -54,8 +54,7 @@ public class RestTestBase extends JMSTestBase { if (server != null) { try { server.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); } } @@ -79,8 +78,7 @@ public class RestTestBase extends JMSTestBase { WebAppContext webapp = new WebAppContext(); if (contextPath.startsWith("/")) { webapp.setContextPath(contextPath); - } - else { + } else { webapp.setContextPath("/" + contextPath); } webapp.setWar(warFile.getAbsolutePath()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/QueueRestMessageContext.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/QueueRestMessageContext.java index 09cc9d697a..265c1fb92d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/QueueRestMessageContext.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/QueueRestMessageContext.java @@ -22,6 +22,7 @@ import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; public class QueueRestMessageContext extends RestMessageContext { + public static final String PREFIX_QUEUE = "/queues/jms.queue."; public QueueRestMessageContext(RestAMQConnection restAMQConnection, String queue) throws IOException { @@ -44,8 +45,7 @@ public class QueueRestMessageContext extends RestMessageContext { CloseableHttpResponse response = null; if (!this.autoAck) { response = connection.post(pullUri, "application/x-www-form-urlencoded", "autoAck=false"); - } - else { + } else { response = connection.post(pullUri); } @@ -61,8 +61,7 @@ public class QueueRestMessageContext extends RestMessageContext { contextMap.put(KEY_MSG_ACK_NEXT, header.getValue()); } } - } - finally { + } finally { response.close(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/ResponseUtil.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/ResponseUtil.java index 7da895704e..e188e3ad78 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/ResponseUtil.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/ResponseUtil.java @@ -16,13 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.rest.util; +import java.io.IOException; + import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.EntityUtils; -import java.io.IOException; - public class ResponseUtil { + public static int getHttpCode(CloseableHttpResponse response) { return response.getStatusLine().getStatusCode(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestAMQConnection.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestAMQConnection.java index 4b3cdd4b6f..593b4b3922 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestAMQConnection.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestAMQConnection.java @@ -31,6 +31,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class RestAMQConnection implements Closeable { + private CloseableHttpClient httpClient = HttpClients.createDefault(); private String targetUri; @@ -77,8 +78,7 @@ public class RestAMQConnection implements Closeable { public CloseableHttpResponse post(String uri, String contentType, String body) throws IOException { String fullLink = getFullLink(uri); HttpPost post = new HttpPost(fullLink); - StringEntity entity = new StringEntity(body, - ContentType.create(contentType)); + StringEntity entity = new StringEntity(body, ContentType.create(contentType)); post.setEntity(entity); CloseableHttpResponse resp = httpClient.execute(post); return resp; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestMessageContext.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestMessageContext.java index a4dfa30423..ffd1428a06 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestMessageContext.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/RestMessageContext.java @@ -28,6 +28,7 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.EntityUtils; public abstract class RestMessageContext implements Closeable { + public static final String KEY_MSG_CREATE = "msg-create"; public static final String KEY_MSG_CREATE_ID = "msg-create-with-id"; public static final String KEY_MSG_PULL = "msg-pull-consumers"; @@ -57,7 +58,10 @@ public abstract class RestMessageContext implements Closeable { this(restAMQConnection, dest, true, false); } - public RestMessageContext(RestAMQConnection restAMQConnection, String dest, boolean isAutoAck, boolean isPush) throws IOException { + public RestMessageContext(RestAMQConnection restAMQConnection, + String dest, + boolean isAutoAck, + boolean isPush) throws IOException { this.connection = restAMQConnection; this.destination = dest; this.autoAck = isAutoAck; @@ -95,8 +99,7 @@ public abstract class RestMessageContext implements Closeable { if (header != null) { contextMap.put(KEY_MSG_PUSH_SUB, header.getValue()); } - } - finally { + } finally { response.close(); } } @@ -112,8 +115,7 @@ public abstract class RestMessageContext implements Closeable { String nextMsgUri = contextMap.get(KEY_MSG_CREATE_NEXT); if (nextMsgUri == null) { postUri = contextMap.get(KEY_MSG_CREATE); - } - else { + } else { postUri = nextMsgUri; } CloseableHttpResponse response = connection.post(postUri, type, content); @@ -125,13 +127,11 @@ public abstract class RestMessageContext implements Closeable { Header redirLoc = response.getFirstHeader("Location"); contextMap.put(KEY_MSG_CREATE_NEXT, redirLoc.getValue()); code = postMessage(content, type);// do it again. - } - else if (code == 201) { + } else if (code == 201) { Header header = response.getFirstHeader(KEY_MSG_CREATE_NEXT); contextMap.put(KEY_MSG_CREATE_NEXT, header.getValue()); } - } - finally { + } finally { response.close(); } return code; @@ -142,8 +142,7 @@ public abstract class RestMessageContext implements Closeable { public boolean acknowledgement(boolean ackValue) throws IOException { String ackUri = contextMap.get(KEY_MSG_ACK); if (ackUri != null) { - CloseableHttpResponse response = connection.post(ackUri, "application/x-www-form-urlencoded", - "acknowledge=" + ackValue); + CloseableHttpResponse response = connection.post(ackUri, "application/x-www-form-urlencoded", "acknowledge=" + ackValue); int code = ResponseUtil.getHttpCode(response); if (code == 200) { contextMap.put(KEY_MSG_ACK_NEXT, response.getFirstHeader(KEY_MSG_ACK_NEXT).getValue()); @@ -162,8 +161,7 @@ public abstract class RestMessageContext implements Closeable { initPullConsumers(); msgPullUri = contextMap.get(KEY_MSG_CONSUME_NEXT); } - } - else { + } else { msgPullUri = contextMap.get(KEY_MSG_ACK_NEXT); if (msgPullUri == null) { initPullConsumers(); @@ -181,8 +179,7 @@ public abstract class RestMessageContext implements Closeable { if (len != -1 && len < 1024000) { message = EntityUtils.toString(entity); - } - else { + } else { // drop message System.err.println("Mesage too large, drop it " + len); } @@ -193,17 +190,14 @@ public abstract class RestMessageContext implements Closeable { if (!autoAck) { header = response.getFirstHeader(KEY_MSG_ACK); contextMap.put(KEY_MSG_ACK, header.getValue()); - } - else { + } else { header = response.getFirstHeader(KEY_MSG_CONSUME_NEXT); contextMap.put(KEY_MSG_CONSUME_NEXT, header.getValue()); } - } - else if (code == 503) { + } else if (code == 503) { if (autoAck) { contextMap.put(KEY_MSG_CONSUME_NEXT, response.getFirstHeader(KEY_MSG_CONSUME_NEXT).getValue()); - } - else { + } else { contextMap.put(KEY_MSG_ACK_NEXT, response.getFirstHeader(KEY_MSG_ACK_NEXT).getValue()); } @@ -212,18 +206,15 @@ public abstract class RestMessageContext implements Closeable { long retryDelay = Long.valueOf(response.getFirstHeader("Retry-After").getValue()); try { Thread.sleep(retryDelay); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } message = pullMessage(); } - } - else { + } else { throw new IllegalStateException("error: " + ResponseUtil.getDetails(response)); } - } - finally { + } finally { response.close(); } @@ -237,11 +228,9 @@ public abstract class RestMessageContext implements Closeable { try { connection.delete(consumerUri); contextMap.remove(KEY_MSG_CONSUMER); - } - catch (ClientProtocolException e) { + } catch (ClientProtocolException e) { e.printStackTrace(); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -250,10 +239,10 @@ public abstract class RestMessageContext implements Closeable { public void setUpPush(String pushTarget) throws Exception { String pushLink = this.contextMap.get(KEY_MSG_PUSH); String pushRegXml = "" + - "" + - ""; + "" + + ""; CloseableHttpResponse response = connection.post(pushLink, "application/xml", pushRegXml); int code = ResponseUtil.getHttpCode(response); @@ -263,8 +252,7 @@ public abstract class RestMessageContext implements Closeable { System.out.println("Location: " + pushLink); throw new Exception("Failed to register push " + ResponseUtil.getDetails(response)); } - } - finally { + } finally { response.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/TopicRestMessageContext.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/TopicRestMessageContext.java index 44bff85ba7..d3419e6525 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/TopicRestMessageContext.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/rest/util/TopicRestMessageContext.java @@ -22,11 +22,14 @@ import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; public class TopicRestMessageContext extends RestMessageContext { + public static final String PREFIX_TOPIC = "/topics/jms.topic."; private boolean durableSub; - public TopicRestMessageContext(RestAMQConnection restAMQConnection, String topic, boolean durable) throws IOException { + public TopicRestMessageContext(RestAMQConnection restAMQConnection, + String topic, + boolean durable) throws IOException { super(restAMQConnection, topic); this.durableSub = durable; } @@ -48,8 +51,7 @@ public class TopicRestMessageContext extends RestMessageContext { if (this.durableSub || !this.autoAck) { String extraOpt = "durable=" + this.durableSub + "&autoAck=" + this.autoAck; response = connection.post(pullUri, "application/x-www-form-urlencoded", extraOpt); - } - else { + } else { response = connection.post(pullUri); } @@ -65,12 +67,10 @@ public class TopicRestMessageContext extends RestMessageContext { if (header != null) { contextMap.put(KEY_MSG_ACK_NEXT, header.getValue()); } - } - else { + } else { throw new IllegalStateException("Failed to init pull consumer " + ResponseUtil.getDetails(response)); } - } - finally { + } finally { response.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java index 1b6b513f74..d4016c26a1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.scheduling; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -36,11 +41,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicInteger; - public class ScheduledMessageTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -773,8 +773,7 @@ public class ScheduledMessageTest extends ActiveMQTestBase { } session.close(); sf.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); count.set(-1); } @@ -864,8 +863,7 @@ public class ScheduledMessageTest extends ActiveMQTestBase { session.end(xid, XAResource.TMSUCCESS); session.prepare(xid); session.commit(xid, false); - } - else { + } else { session.commit(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LDAPSecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LDAPSecurityTest.java index 89c144e66d..a900968e82 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LDAPSecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LDAPSecurityTest.java @@ -82,7 +82,6 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { private static final String PRINCIPAL = "uid=admin,ou=system"; private static final String CREDENTIALS = "secret"; - public LDAPSecurityTest() { File parent = new File(TARGET_TMP); parent.mkdirs(); @@ -99,13 +98,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { testDir = temporaryFolder.getRoot().getAbsolutePath(); ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin"); - Configuration configuration = new ConfigurationImpl() - .setSecurityEnabled(true) - .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())) - .setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)) - .setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)) - .setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)) - .setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)); + Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)); server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false); } @@ -151,8 +144,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { ClientSession session = cf.createSession("first", "secret", false, true, true, false, 0); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } @@ -168,8 +160,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { cf.createSession("first", "badpassword", false, true, true, false, 0); Assert.fail("should throw exception here"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -196,8 +187,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -205,8 +195,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { session.deleteQueue(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -214,8 +203,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -223,8 +211,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { session.deleteQueue(NON_DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -233,8 +220,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -242,8 +228,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { ClientConsumer consumer = session.createConsumer(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -252,8 +237,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -261,8 +245,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { ClientConsumer browser = session.createConsumer(DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -287,8 +270,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { // CREATE_DURABLE_QUEUE try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -296,8 +278,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { // DELETE_DURABLE_QUEUE try { session.deleteQueue(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -305,16 +286,14 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { // CREATE_NON_DURABLE_QUEUE try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_NON_DURABLE_QUEUE try { session.deleteQueue(NON_DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -324,16 +303,14 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -341,16 +318,14 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit { try { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java index f3b7b90030..6ed0cd1513 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java @@ -87,7 +87,6 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes private static final String PRINCIPAL = "uid=admin,ou=system"; private static final String CREDENTIALS = "secret"; - public LegacyLDAPSecuritySettingPluginListenerTest() { File parent = new File(TARGET_TMP); parent.mkdirs(); @@ -115,15 +114,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes legacyLDAPSecuritySettingPlugin.init(map); ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin"); - Configuration configuration = new ConfigurationImpl() - .setSecurityEnabled(true) - .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())) - .setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)) - .setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)) - .setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)) - .setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)) - .setPersistenceEnabled(false) - .addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin); + Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)).setPersistenceEnabled(false).addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin); server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false); } @@ -180,8 +171,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { producer2.send(name, session.createMessage(true)); Assert.fail("Sending here should fail due to the original security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -196,8 +186,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { producer.send(name, session.createMessage(true)); Assert.fail("Sending here should fail due to the modified security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -221,8 +210,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { session2.createConsumer(queue); Assert.fail("Consuming here should fail due to the original security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -239,8 +227,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { session.createConsumer(queue); Assert.fail("Sending here should fail due to the modified security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -260,8 +247,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { session.createConsumer(queue); Assert.fail("Consuming here should fail due to the original security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -283,8 +269,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { session.createConsumer(queue); Assert.fail("Consuming here should fail due to the modified security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -304,8 +289,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { producer.send(session.createMessage(true)); Assert.fail("Producing here should fail due to the original security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } @@ -326,8 +310,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes try { producer.send(session.createMessage(true)); Assert.fail("Producing here should fail due to the modified security data."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ok } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginTest.java index 688e8570c1..bbb9a5f84d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginTest.java @@ -81,7 +81,6 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { private static final String PRINCIPAL = "uid=admin,ou=system"; private static final String CREDENTIALS = "secret"; - public LegacyLDAPSecuritySettingPluginTest() { File parent = new File(TARGET_TMP); parent.mkdirs(); @@ -97,24 +96,10 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getCanonicalName())); testDir = temporaryFolder.getRoot().getAbsolutePath(); - LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = new LegacyLDAPSecuritySettingPlugin() - .setInitialContextFactory("com.sun.jndi.ldap.LdapCtxFactory") - .setConnectionURL("ldap://localhost:1024") - .setConnectionUsername("uid=admin,ou=system") - .setConnectionPassword("secret") - .setConnectionProtocol("s") - .setAuthentication("simple"); + LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = new LegacyLDAPSecuritySettingPlugin().setInitialContextFactory("com.sun.jndi.ldap.LdapCtxFactory").setConnectionURL("ldap://localhost:1024").setConnectionUsername("uid=admin,ou=system").setConnectionPassword("secret").setConnectionProtocol("s").setAuthentication("simple"); ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin"); - Configuration configuration = new ConfigurationImpl() - .setSecurityEnabled(true) - .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())) - .setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)) - .setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)) - .setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)) - .setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)) - .setPersistenceEnabled(false) - .addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin); + Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)).setPersistenceEnabled(false).addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin); server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false); } @@ -163,8 +148,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { ClientProducer producer = session.createProducer(); producer.send(name, session.createMessage(false)); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } @@ -187,8 +171,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { session.createQueue(ADDRESS, QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -196,8 +179,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { session.deleteQueue(QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -205,8 +187,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { session.createQueue(ADDRESS, QUEUE, false); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -214,8 +195,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { session.deleteQueue(QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -224,8 +204,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -233,8 +212,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { ClientConsumer consumer = session.createConsumer(QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -255,8 +233,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { // CREATE_DURABLE_QUEUE try { session.createQueue(ADDRESS, QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -264,8 +241,7 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { // DELETE_DURABLE_QUEUE try { session.deleteQueue(QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -273,16 +249,14 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { // CREATE_NON_DURABLE_QUEUE try { session.createQueue(ADDRESS, QUEUE, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_NON_DURABLE_QUEUE try { session.deleteQueue(QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -292,16 +266,14 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit { try { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java index ad71d26c06..8c876b23a9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java @@ -77,11 +77,9 @@ public class NettySecurityClientTest extends ActiveMQTestBase { line = line.replace('|', '\n'); if (line.startsWith("Listening")) { continue; - } - else if ("OK".equals(line.trim())) { + } else if ("OK".equals(line.trim())) { break; - } - else { + } else { //Assert.fail("Exception when starting the client: " + line); System.out.println(line); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java index 5059fab6b0..8fef6e5906 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java @@ -101,8 +101,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientSession session = cf.createSession("first", "secret", false, true, true, false, 0); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } @@ -137,8 +136,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientSession session = cf.createSession(); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } @@ -154,8 +152,7 @@ public class SecurityTest extends ActiveMQTestBase { try { cf.createSession("first", "badpassword", false, true, true, false, 0); Assert.fail("should throw exception here"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -197,8 +194,7 @@ public class SecurityTest extends ActiveMQTestBase { try { cf.createSession(); fail("Creating session here should fail due to authentication error."); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { assertTrue(e.getType() == ActiveMQExceptionType.SECURITY_EXCEPTION); } } @@ -213,8 +209,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientSession session = cf.createSession("first", "secret", false, true, true, false, 0); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } @@ -242,8 +237,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -251,8 +245,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -260,8 +253,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -269,8 +261,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(NON_DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -279,8 +270,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -288,8 +278,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer consumer = session.createConsumer(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -298,8 +287,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -307,8 +295,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer browser = session.createConsumer(DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } @@ -338,8 +325,7 @@ public class SecurityTest extends ActiveMQTestBase { // client A CONSUME from queue A try { ClientConsumer consumer = aSession.createConsumer(QUEUE_A); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -348,16 +334,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer consumer = bSession.createConsumer(QUEUE_A); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { assertTrue(e instanceof ActiveMQSecurityException); } // client B CONSUME from queue B try { ClientConsumer consumer = bSession.createConsumer(QUEUE_B); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -366,8 +350,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer consumer = aSession.createConsumer(QUEUE_B); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { assertTrue(e instanceof ActiveMQSecurityException); } } @@ -415,8 +398,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -424,8 +406,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -433,8 +414,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -442,8 +422,7 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(NON_DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -452,8 +431,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -461,8 +439,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer consumer = session.createConsumer(DURABLE_QUEUE); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -471,8 +448,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } @@ -480,8 +456,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientConsumer browser = session.createConsumer(DURABLE_QUEUE, true); Assert.fail("should throw exception here"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // ignore } } @@ -505,32 +480,28 @@ public class SecurityTest extends ActiveMQTestBase { // CREATE_DURABLE_QUEUE try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_DURABLE_QUEUE try { session.deleteQueue(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CREATE_NON_DURABLE_QUEUE try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_NON_DURABLE_QUEUE try { session.deleteQueue(NON_DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -540,16 +511,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -557,16 +526,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // BROWSE try { session.createConsumer(DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } } @@ -608,32 +575,28 @@ public class SecurityTest extends ActiveMQTestBase { // CREATE_DURABLE_QUEUE try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_DURABLE_QUEUE try { session.deleteQueue(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CREATE_NON_DURABLE_QUEUE try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_NON_DURABLE_QUEUE try { session.deleteQueue(NON_DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -643,16 +606,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -660,16 +621,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // BROWSE try { session.createConsumer(DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } } @@ -693,8 +652,7 @@ public class SecurityTest extends ActiveMQTestBase { // CREATE_DURABLE_QUEUE try { session.createQueue(ADDRESS, DURABLE_QUEUE, true); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception here"); } @@ -702,24 +660,21 @@ public class SecurityTest extends ActiveMQTestBase { // DELETE_DURABLE_QUEUE try { session.deleteQueue(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CREATE_NON_DURABLE_QUEUE try { session.createQueue(ADDRESS, NON_DURABLE_QUEUE, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // DELETE_NON_DURABLE_QUEUE try { session.deleteQueue(NON_DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -729,16 +684,14 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(ADDRESS); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } // CONSUME try { session.createConsumer(DURABLE_QUEUE); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } @@ -746,8 +699,7 @@ public class SecurityTest extends ActiveMQTestBase { try { ClientProducer producer = session.createProducer(server.getConfiguration().getManagementAddress()); producer.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception here"); } } @@ -765,8 +717,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientSession session = cf.createSession(false, true, true); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception"); } } @@ -789,11 +740,9 @@ public class SecurityTest extends ActiveMQTestBase { try { cf.createSession(false, true, true); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -809,11 +758,9 @@ public class SecurityTest extends ActiveMQTestBase { try { cf.createSession("newuser", "awrongpass", false, true, true, false, -1); Assert.fail("should not throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -830,8 +777,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientSession session = cf.createSession("newuser", "apass", false, true, true, false, -1); session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("should not throw exception"); } } @@ -872,11 +818,9 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -919,11 +863,9 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(SecurityTest.queueA); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -966,11 +908,9 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -1013,11 +953,9 @@ public class SecurityTest extends ActiveMQTestBase { try { session.deleteQueue(SecurityTest.queueA); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -1078,8 +1016,7 @@ public class SecurityTest extends ActiveMQTestBase { boolean failed = false; try { cp.send(session.createMessage(true)); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { failed = true; } // This was added to validate https://issues.jboss.org/browse/SOA-3363 ^^^^^ @@ -1107,11 +1044,9 @@ public class SecurityTest extends ActiveMQTestBase { ClientProducer cp = session.createProducer(SecurityTest.addressA); try { cp.send(session.createMessage(false)); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -1194,11 +1129,9 @@ public class SecurityTest extends ActiveMQTestBase { cp.send(session.createMessage(false)); try { session.createConsumer(SecurityTest.queueA); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -1233,11 +1166,9 @@ public class SecurityTest extends ActiveMQTestBase { cp.send(session.createMessage(false)); try { session.createConsumer(SecurityTest.queueA); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1284,11 +1215,9 @@ public class SecurityTest extends ActiveMQTestBase { cp.send(session.createMessage(false)); try { session.createConsumer(SecurityTest.queueA); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1303,11 +1232,9 @@ public class SecurityTest extends ActiveMQTestBase { try { session.createConsumer(SecurityTest.queueA); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1348,11 +1275,9 @@ public class SecurityTest extends ActiveMQTestBase { cp.send(session.createMessage(false)); try { session.createConsumer(SecurityTest.queueA); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1372,8 +1297,7 @@ public class SecurityTest extends ActiveMQTestBase { try { sendingSession.commit(); Assert.fail("Expected exception"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // I would expect the commit to fail, since there were failures registered } @@ -1392,8 +1316,7 @@ public class SecurityTest extends ActiveMQTestBase { try { sendingSession.prepare(xid); Assert.fail("Exception was expected"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -1449,11 +1372,9 @@ public class SecurityTest extends ActiveMQTestBase { cp.send(session.createMessage(false)); try { cp.send(session.createMessage(false)); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } session.close(); @@ -1540,11 +1461,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession(false, true, true); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1552,11 +1471,9 @@ public class SecurityTest extends ActiveMQTestBase { try { billConnection = factory.createSession("bill", "activemq1", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1671,11 +1588,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession(false, true, true); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1683,11 +1598,9 @@ public class SecurityTest extends ActiveMQTestBase { try { billConnection = factory.createSession("bill", "activemq1", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1744,33 +1657,27 @@ public class SecurityTest extends ActiveMQTestBase { final ActiveMQSecurityManager customSecurityManager = new ActiveMQSecurityManager() { @Override public boolean validateUser(final String username, final String password) { - return (username.equals("foo") || username.equals("bar") || username.equals("all")) && - password.equals("frobnicate"); + return (username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate"); } - @Override - public boolean validateUserAndRole( - final String username, - final String password, - final Set requiredRoles, - final CheckType checkType) { - if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && - password.equals("frobnicate")) { + @Override + public boolean validateUserAndRole(final String username, + final String password, + final Set requiredRoles, + final CheckType checkType) { + + if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate")) { if (username.equals("all")) { return true; - } - else if (username.equals("foo")) { + } else if (username.equals("foo")) { return checkType == CheckType.CONSUME || checkType == CheckType.CREATE_NON_DURABLE_QUEUE; - } - else if (username.equals("bar")) { + } else if (username.equals("bar")) { return checkType == CheckType.SEND || checkType == CheckType.CREATE_NON_DURABLE_QUEUE; - } - else { + } else { return false; } - } - else { + } else { return false; } } @@ -1790,11 +1697,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("baz", "frobnicate", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1802,11 +1707,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("foo", "xxx", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1833,52 +1736,48 @@ public class SecurityTest extends ActiveMQTestBase { fail("Unexpected call to overridden method"); return false; } + @Override - public boolean validateUser(final String username, final String password, final X509Certificate[] certificates) { - return (username.equals("foo") || username.equals("bar") || username.equals("all")) && - password.equals("frobnicate"); + public boolean validateUser(final String username, + final String password, + final X509Certificate[] certificates) { + return (username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate"); } + @Override - public boolean validateUserAndRole( - final String username, - final String password, - final Set requiredRoles, - final CheckType checkType) { + public boolean validateUserAndRole(final String username, + final String password, + final Set requiredRoles, + final CheckType checkType) { fail("Unexpected call to overridden method"); return false; } @Override - public boolean validateUserAndRole( - final String username, - final String password, - final Set requiredRoles, - final CheckType checkType, - final String address, - final RemotingConnection connection) { + public boolean validateUserAndRole(final String username, + final String password, + final Set requiredRoles, + final CheckType checkType, + final String address, + final RemotingConnection connection) { if (!(connection.getTransportConnection() instanceof InVMConnection)) { return false; } - if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && - password.equals("frobnicate")) { + if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate")) { if (username.equals("all")) { return true; - } - else if (username.equals("foo")) { + } else if (username.equals("foo")) { return address.equals("test.queue") && checkType == CheckType.CONSUME; - } - else if (username.equals("bar")) { + } else if (username.equals("bar")) { return address.equals("test.queue") && checkType == CheckType.SEND; - } - else { + } else { return false; } - } - else { + } else { return false; } } @@ -1901,11 +1800,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("baz", "frobnicate", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1913,11 +1810,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("foo", "xxx", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1926,11 +1821,9 @@ public class SecurityTest extends ActiveMQTestBase { final ClientSession session = factory.createSession("foo", "frobnicate", false, true, true, false, -1); checkUserReceiveNoSend(otherQueueName, session, adminSession); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1939,11 +1832,9 @@ public class SecurityTest extends ActiveMQTestBase { final ClientSession session = factory.createSession("foo", "frobnicate", false, true, true, false, -1); checkUserReceiveNoSend(otherQueueName, session, adminSession); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -1969,62 +1860,58 @@ public class SecurityTest extends ActiveMQTestBase { fail("Unexpected call to overridden method"); return false; } + @Override - public String validateUser(final String username, final String password, final X509Certificate[] certificates) { + public String validateUser(final String username, + final String password, + final X509Certificate[] certificates) { if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate")) { return username; - } - else { + } else { return null; } } + @Override - public boolean validateUserAndRole( - final String username, - final String password, - final Set requiredRoles, - final CheckType checkType) { + public boolean validateUserAndRole(final String username, + final String password, + final Set requiredRoles, + final CheckType checkType) { fail("Unexpected call to overridden method"); return false; } @Override - public String validateUserAndRole( - final String username, - final String password, - final Set requiredRoles, - final CheckType checkType, - final String address, - final RemotingConnection connection) { + public String validateUserAndRole(final String username, + final String password, + final Set requiredRoles, + final CheckType checkType, + final String address, + final RemotingConnection connection) { if (!(connection.getTransportConnection() instanceof InVMConnection)) { return null; } - if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && - password.equals("frobnicate")) { + if ((username.equals("foo") || username.equals("bar") || username.equals("all")) && password.equals("frobnicate")) { if (username.equals("all")) { return username; - } - else if (username.equals("foo")) { + } else if (username.equals("foo")) { if (address.equals("test.queue") && checkType == CheckType.CONSUME) return username; else return null; - } - else if (username.equals("bar")) { + } else if (username.equals("bar")) { if (address.equals("test.queue") && checkType == CheckType.SEND) return username; else return null; - } - else { + } else { return null; } - } - else { + } else { return null; } } @@ -2047,11 +1934,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("baz", "frobnicate", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -2059,11 +1944,9 @@ public class SecurityTest extends ActiveMQTestBase { try { factory.createSession("foo", "xxx", false, true, true, false, -1); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -2072,11 +1955,9 @@ public class SecurityTest extends ActiveMQTestBase { final ClientSession session = factory.createSession("foo", "frobnicate", false, true, true, false, -1); checkUserReceiveNoSend(otherQueueName, session, adminSession); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -2085,11 +1966,9 @@ public class SecurityTest extends ActiveMQTestBase { final ClientSession session = factory.createSession("foo", "frobnicate", false, true, true, false, -1); checkUserReceiveNoSend(otherQueueName, session, adminSession); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } @@ -2118,8 +1997,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientMessage rec = con.receive(1000); Assert.assertNotNull(rec); rec.acknowledge(); - } - finally { + } finally { connection.stop(); } } @@ -2135,8 +2013,7 @@ public class SecurityTest extends ActiveMQTestBase { try { prod.send(m); Assert.fail("should throw exception"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // pass } @@ -2146,8 +2023,7 @@ public class SecurityTest extends ActiveMQTestBase { ClientMessage rec = con.receive(1000); Assert.assertNotNull(rec); rec.acknowledge(); - } - finally { + } finally { connection.stop(); } } @@ -2162,8 +2038,7 @@ public class SecurityTest extends ActiveMQTestBase { try { prod.send(m); Assert.fail("should throw exception"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // pass } @@ -2173,12 +2048,10 @@ public class SecurityTest extends ActiveMQTestBase { try { connection.createConsumer(queue); Assert.fail("should throw exception"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // pass } - } - finally { + } finally { connection.stop(); } } @@ -2192,11 +2065,9 @@ public class SecurityTest extends ActiveMQTestBase { try { connection.createConsumer(queue); Assert.fail("should throw exception"); - } - catch (ActiveMQSecurityException se) { + } catch (ActiveMQSecurityException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SimpleClient.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SimpleClient.java index e04a58d1b7..0dd9eb6d35 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SimpleClient.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SimpleClient.java @@ -17,12 +17,12 @@ package org.apache.activemq.artemis.tests.integration.security; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.utils.RandomUtil; @@ -73,12 +73,10 @@ final class SimpleClient { session.close(); sf.close(); System.out.println("OK"); - } - finally { + } finally { locator.close(); } - } - catch (Throwable t) { + } catch (Throwable t) { String allStack = t.getMessage() + "|"; StackTraceElement[] stackTrace = t.getStackTrace(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationFailureListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationFailureListenerTest.java index a43e2c8c7a..597751b145 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationFailureListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationFailureListenerTest.java @@ -49,8 +49,7 @@ public class ActivationFailureListenerTest extends ActiveMQTestBase { }); server.start(); assertTrue(latch.await(3000, TimeUnit.MILLISECONDS)); - } - finally { + } finally { s.close(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java index f2a59bea8f..c27ac36ac1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.server; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.ActiveMQConnectionTimedOutException; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -30,9 +33,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - public class ConnectionLimitTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -62,8 +62,7 @@ public class ConnectionLimitTest extends ActiveMQTestBase { try { ClientSessionFactory extraClientSessionFactory = locator.createSessionFactory(); fail("creating a session factory here should fail"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQNotConnectedException); } } @@ -78,9 +77,8 @@ public class ConnectionLimitTest extends ActiveMQTestBase { ClientSessionFactory extraClientSessionFactory = locator.createSessionFactory(); ClientSession extraClientSession = addClientSession(extraClientSessionFactory.createSession()); fail("creating a session here should fail"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQConnectionTimedOutException); } } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java index ccc0175054..bd63ca2d8a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.server; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -33,11 +38,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class ExpiryRunnerTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -275,8 +275,7 @@ public class ExpiryRunnerTest extends ActiveMQTestBase { payloads.add(message.getBodyBuffer().readString()); Thread.sleep(110); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java index 70b5cb87f8..34916db0bd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java @@ -21,14 +21,14 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.jlibaio.LibaioContext; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; +import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.AfterClass; import org.junit.Assert; @@ -55,8 +55,7 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { ActiveMQServer server1 = createServer(true, config); if (useAIO) { server1.getConfiguration().setJournalType(JournalType.ASYNCIO); - } - else { + } else { server1.getConfiguration().setJournalType(JournalType.NIO); } server1.start(); @@ -64,8 +63,7 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { final ActiveMQServer server2 = createServer(true, config); if (useAIO) { server2.getConfiguration().setJournalType(JournalType.ASYNCIO); - } - else { + } else { server2.getConfiguration().setJournalType(JournalType.NIO); } server2.getConfiguration().setJournalLockAcquisitionTimeout(5000); @@ -77,8 +75,7 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { public void run() { try { server2.start(); - } - catch (final Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -88,8 +85,7 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { try { f.get(15, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { IntegrationTestLogger.LOGGER.warn("aborting test because server is taking too long to start"); } @@ -98,4 +94,4 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { assertTrue("Expected to find AMQ224000", AssertionLoggerHandler.findText("AMQ224000")); assertTrue("Expected to find \"timed out waiting for lock\"", AssertionLoggerHandler.findText("timed out waiting for lock")); } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/GracefulShutdownTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/GracefulShutdownTest.java index f42e585fd6..4940137307 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/GracefulShutdownTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/GracefulShutdownTest.java @@ -49,8 +49,7 @@ public class GracefulShutdownTest extends ActiveMQTestBase { public void run() { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -74,8 +73,7 @@ public class GracefulShutdownTest extends ActiveMQTestBase { try { sf.createSession(); fail("Creating a session here should fail because the acceptors should be paused"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); ActiveMQSessionCreationException activeMQSessionCreationException = (ActiveMQSessionCreationException) e; assertEquals(activeMQSessionCreationException.getType(), ActiveMQExceptionType.SESSION_CREATION_REJECTED); @@ -118,8 +116,7 @@ public class GracefulShutdownTest extends ActiveMQTestBase { public void run() { try { server.stop(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -137,8 +134,7 @@ public class GracefulShutdownTest extends ActiveMQTestBase { try { sf.createSession(); fail("Creating a session here should fail because the acceptors should be paused"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); ActiveMQSessionCreationException activeMQSessionCreationException = (ActiveMQSessionCreationException) e; assertEquals(activeMQSessionCreationException.getType(), ActiveMQExceptionType.SESSION_CREATION_REJECTED); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java index 657f766581..f121cbe4db 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.server; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -33,9 +36,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - public class LVQRecoveryTest extends ActiveMQTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java index a25e674720..d397d00ba2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PotentialOOMELoggingTest.java @@ -40,8 +40,7 @@ public class PotentialOOMELoggingTest extends ActiveMQTestBase { * When running this test from an IDE add this to the test command line so that the AssertionLoggerHandler works properly: * * -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration=file:/tests/config/logging.properties - */ - public void testBlockLogging() throws Exception { + */ public void testBlockLogging() throws Exception { ActiveMQServer server = createServer(false, createDefaultInVMConfig()); for (int i = 0; i < 10000; i++) { server.getConfiguration().addQueueConfiguration(new CoreQueueConfiguration().setAddress(UUID.randomUUID().toString()).setName(UUID.randomUUID().toString())); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PredefinedQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PredefinedQueueTest.java index 1dc666c199..a3c8243c62 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PredefinedQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/PredefinedQueueTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.server; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -36,9 +39,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; - public class PredefinedQueueTest extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -90,33 +90,27 @@ public class PredefinedQueueTest extends ActiveMQTestBase { session.createQueue(testAddress, queueName1, null, false); Assert.fail("Should throw exception"); - } - catch (ActiveMQQueueExistsException se) { + } catch (ActiveMQQueueExistsException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } try { session.createQueue(testAddress, queueName2, null, false); Assert.fail("Should throw exception"); - } - catch (ActiveMQQueueExistsException se) { + } catch (ActiveMQQueueExistsException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } try { session.createQueue(testAddress, queueName3, null, false); Assert.fail("Should throw exception"); - } - catch (ActiveMQQueueExistsException se) { + } catch (ActiveMQQueueExistsException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java index 52524c542e..0f0a0acedc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java @@ -51,10 +51,7 @@ public class ResourceLimitTest extends ActiveMQTestBase { resourceLimitSettings.setMaxConnections(1); resourceLimitSettings.setMaxQueues(1); - Configuration configuration = createBasicConfig() - .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)) - .addResourceLimitSettings(resourceLimitSettings) - .setSecurityEnabled(true); + Configuration configuration = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).addResourceLimitSettings(resourceLimitSettings).setSecurityEnabled(true); server = addServer(ActiveMQServers.newActiveMQServer(configuration, false)); server.start(); @@ -78,8 +75,7 @@ public class ResourceLimitTest extends ActiveMQTestBase { ClientSessionFactory extraClientSessionFactory = locator.createSessionFactory(); ClientSession extraClientSession = extraClientSessionFactory.createSession("myUser", "password", false, true, true, false, 0); fail("creating a session factory here should fail"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); } @@ -91,8 +87,7 @@ public class ResourceLimitTest extends ActiveMQTestBase { ClientSessionFactory extraClientSessionFactory = locator.createSessionFactory(); ClientSession extraClientSession = extraClientSessionFactory.createSession("myUser", "password", false, true, true, false, 0); fail("creating a session factory here should fail"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); } } @@ -106,8 +101,7 @@ public class ResourceLimitTest extends ActiveMQTestBase { try { clientSession.createQueue("address", "anotherQueue"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); } @@ -117,16 +111,14 @@ public class ResourceLimitTest extends ActiveMQTestBase { try { clientSession.createQueue("address", "anotherQueue"); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); } try { clientSession.createSharedQueue(SimpleString.toSimpleString("address"), SimpleString.toSimpleString("anotherQueue"), false); - } - catch (Exception e) { + } catch (Exception e) { assertTrue(e instanceof ActiveMQSessionCreationException); } } -} \ No newline at end of file +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java index cc6055f867..be91bdd79d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java @@ -140,8 +140,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { fileMessage.releaseResources(); message = fileMessage; - } - else { + } else { message = session.createMessage(false); } @@ -167,8 +166,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount = getMessageCount(snfQueue); if (messageCount < TEST_SIZE) { Thread.sleep(200); - } - else { + } else { break; } } @@ -188,8 +186,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount = getMessageCount(((LocalQueueBinding) servers[2].getPostOffice().getBinding(new SimpleString(queueName1))).getQueue()); if (messageCount > 0) { Thread.sleep(200); - } - else { + } else { break; } } @@ -206,8 +203,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount = getMessageCount(((LocalQueueBinding) servers[1].getPostOffice().getBinding(new SimpleString(queueName1))).getQueue()); if (messageCount < TEST_SIZE) { Thread.sleep(200); - } - else { + } else { break; } } @@ -292,8 +288,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount = getMessageCount(snfQueue); if (messageCount < TEST_SIZE * 2) { Thread.sleep(200); - } - else { + } else { break; } } @@ -315,8 +310,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount += getMessageCount(((LocalQueueBinding) servers[2].getPostOffice().getBinding(new SimpleString(queueName3))).getQueue()); if (messageCount > 0) { Thread.sleep(200); - } - else { + } else { break; } } @@ -337,8 +331,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase { messageCount += getMessageCount(((LocalQueueBinding) servers[1].getPostOffice().getBinding(new SimpleString(queueName3))).getQueue()); if (messageCount < TEST_SIZE * 2) { Thread.sleep(200); - } - else { + } else { break; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownDirectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownDirectTest.java index ce05b8adcf..02b81c292d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownDirectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownDirectTest.java @@ -17,6 +17,9 @@ package org.apache.activemq.artemis.tests.integration.server; +import java.util.Arrays; +import java.util.Collection; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; @@ -35,9 +38,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; - /** * On this test we will run ScaleDown directly as an unit-test in several cases, * simulating what would happen during a real scale down. diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java index dfc252ff22..d2c6fc288b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.integration.server; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; @@ -38,10 +42,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - @RunWith(value = Parameterized.class) public class ScaleDownTest extends ClusterTestBase { @@ -519,8 +519,7 @@ public class ScaleDownTest extends ClusterTestBase { if (i % 2 == 0) { message = consumers[0].getConsumer().receive(250); compare = "0"; - } - else { + } else { message = consumers[1].getConsumer().receive(250); compare = "1"; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java index a2a686eb6c..c372a2ddf3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java @@ -80,8 +80,7 @@ public class SimpleStartStopTest extends ActiveMQTestBase { server.stop(); - } - finally { + } finally { AssertionLoggerHandler.stopCapture(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java index 3a6f56bb90..65cd6b9e1b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java @@ -24,11 +24,11 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.core.server.ServiceRegistry; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ServiceRegistry; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Before; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/ExampleListener.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/ExampleListener.java index 8093d28d92..e7f18f7b04 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/ExampleListener.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/ExampleListener.java @@ -33,8 +33,7 @@ public class ExampleListener implements MessageListener { public void onMessage(Message message) { try { lastMessage = ((TextMessage) message).getText(); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } System.out.println("MESSAGE RECEIVED: " + lastMessage); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/MessageSender.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/MessageSender.java index adaae90d80..fd0daa18db 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/MessageSender.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/MessageSender.java @@ -52,8 +52,7 @@ public class MessageSender { TextMessage message = session.createTextMessage(msg); producer.send(message); conn.close(); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java index f2e5cfd54d..e8e5998ce0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java @@ -18,10 +18,10 @@ package org.apache.activemq.artemis.tests.integration.spring; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -56,15 +56,13 @@ public class SpringIntegrationTest extends ActiveMQTestBase { Thread.sleep(500); Assert.assertEquals(ExampleListener.lastMessage, "Hello world"); ((ActiveMQConnectionFactory) sender.getConnectionFactory()).close(); - } - finally { + } finally { try { if (context != null) { DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) context.getBean("listenerContainer"); container.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } try { @@ -72,8 +70,7 @@ public class SpringIntegrationTest extends ActiveMQTestBase { EmbeddedJMS jms = (EmbeddedJMS) context.getBean("EmbeddedJms"); jms.stop(); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { ignored.printStackTrace(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java index de46bcd871..013a62c0e7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java @@ -29,21 +29,21 @@ import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -55,10 +55,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection getParameters() { - return Arrays.asList(new Object[][]{ - {"JCEKS"}, - {"JKS"} - }); + return Arrays.asList(new Object[][]{{"JCEKS"}, {"JKS"}}); } public CoreClientOverOneWaySSLTest(String storeType) { @@ -178,8 +175,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); fail("Creating a session here should fail due to a certificate with a CN that doesn't match the host name."); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -212,8 +208,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { addSessionFactory(createSessionFactory(locator)); fail("Creating session here should fail due to SSL handshake problems."); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -258,8 +253,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -276,8 +270,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -296,8 +289,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -315,8 +307,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -333,8 +324,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -352,8 +342,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -372,8 +361,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.assertTrue(true); } } @@ -394,8 +382,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { ClientSessionFactory sf = null; try { sf = createSessionFactory(locator); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.fail(); } @@ -429,8 +416,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { ClientSessionFactory sf = null; try { sf = createSessionFactory(locator); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.fail(); } @@ -465,8 +451,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { sf = createSessionFactory(locator); Assert.assertTrue(true); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.fail(); } @@ -500,8 +485,7 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { sf = createSessionFactory(locator); Assert.assertTrue(true); - } - catch (ActiveMQNotConnectedException e) { + } catch (ActiveMQNotConnectedException e) { Assert.fail(); } @@ -565,11 +549,9 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException se) { + } catch (ActiveMQNotConnectedException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -586,11 +568,9 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { ClientSessionFactory sf = createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException se) { + } catch (ActiveMQNotConnectedException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -606,11 +586,9 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { ClientSessionFactory sf = createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException se) { + } catch (ActiveMQNotConnectedException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -625,14 +603,11 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); fail("expecting exception"); - } - catch (ActiveMQNotConnectedException se) { + } catch (ActiveMQNotConnectedException se) { //ok - } - catch (ActiveMQConnectionTimedOutException ctoe) { + } catch (ActiveMQConnectionTimedOutException ctoe) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } } @@ -653,15 +628,16 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase { createCustomSslServer(cipherSuites, protocols, false); } - private void createCustomSslServer(String cipherSuites, String protocols, boolean useVerifiedKeystore) throws Exception { + private void createCustomSslServer(String cipherSuites, + String protocols, + boolean useVerifiedKeystore) throws Exception { Map params = new HashMap<>(); params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true); params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, storeType); if (useVerifiedKeystore) { params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "verified-" + SERVER_SIDE_KEYSTORE); - } - else { + } else { params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, SERVER_SIDE_KEYSTORE); } params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, PASSWORD); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverTwoWaySSLTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverTwoWaySSLTest.java index 403ebc33fa..772e44dcb2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverTwoWaySSLTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverTwoWaySSLTest.java @@ -29,23 +29,23 @@ import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,9 +57,7 @@ public class CoreClientOverTwoWaySSLTest extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection getParameters() { - return Arrays.asList(new Object[][]{ - {"JCEKS"}, - {"JKS"}}); + return Arrays.asList(new Object[][]{{"JCEKS"}, {"JKS"}}); } public CoreClientOverTwoWaySSLTest(String storeType) { @@ -119,8 +117,7 @@ public class CoreClientOverTwoWaySSLTest extends ActiveMQTestBase { Assert.assertNotNull(sslHandler.engine().getSession()); Assert.assertNotNull(sslHandler.engine().getSession().getPeerCertificateChain()); } - } - catch (SSLPeerUnverifiedException e) { + } catch (SSLPeerUnverifiedException e) { Assert.fail(e.getMessage()); } } @@ -219,8 +216,7 @@ public class CoreClientOverTwoWaySSLTest extends ActiveMQTestBase { try { ClientSessionFactory sf = createSessionFactory(locator); fail("Creating a session here should fail due to a certificate with a CN that doesn't match the host name."); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -236,11 +232,9 @@ public class CoreClientOverTwoWaySSLTest extends ActiveMQTestBase { try { createSessionFactory(locator); Assert.fail(); - } - catch (ActiveMQNotConnectedException se) { + } catch (ActiveMQNotConnectedException se) { //ok - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("Invalid Exception type:" + e.getType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ConcurrentStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ConcurrentStompTest.java index 2379caf1b1..6917cfb70c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ConcurrentStompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ConcurrentStompTest.java @@ -75,8 +75,7 @@ public class ConcurrentStompTest extends StompTestBase { Assert.assertTrue(frame.indexOf("destination:") > 0); System.out.println("<<< " + i++); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { break; } } @@ -92,8 +91,7 @@ public class ConcurrentStompTest extends StompTestBase { assertTrue(latch.await(60, TimeUnit.SECONDS)); - } - finally { + } finally { stompSocket_2.close(); inputBuffer_2.close(); } @@ -119,8 +117,7 @@ public class ConcurrentStompTest extends StompTestBase { c = is.read(); if (c < 0) { throw new IOException("socket closed."); - } - else if (c == 0) { + } else if (c == 0) { c = is.read(); if (c != '\n') { byte[] ba = input.toByteArray(); @@ -130,8 +127,7 @@ public class ConcurrentStompTest extends StompTestBase { byte[] ba = input.toByteArray(); input.reset(); return new String(ba, StandardCharsets.UTF_8); - } - else { + } else { input.write(c); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ExtraStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ExtraStompTest.java index 723792b89d..a0dcdbfcae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ExtraStompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/ExtraStompTest.java @@ -16,6 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.stomp; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.QueueBrowser; +import javax.jms.TextMessage; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; @@ -47,16 +57,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.QueueBrowser; -import javax.jms.TextMessage; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class ExtraStompTest extends StompTestBase { @Override @@ -93,8 +93,7 @@ public class ExtraStompTest extends StompTestBase { message = (TextMessage) consumer.receiveNoWait(); Assert.assertNull(message); - } - finally { + } finally { cleanUp(); server.stop(); } @@ -169,12 +168,10 @@ public class ExtraStompTest extends StompTestBase { frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; sendFrame(frame); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -233,12 +230,10 @@ public class ExtraStompTest extends StompTestBase { frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; sendFrame(frame); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -296,12 +291,10 @@ public class ExtraStompTest extends StompTestBase { connV12.sendFrame(unsubFrame); connV12.disconnect(); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -354,12 +347,10 @@ public class ExtraStompTest extends StompTestBase { connV12.sendFrame(unsubFrame); connV12.disconnect(); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -419,12 +410,10 @@ public class ExtraStompTest extends StompTestBase { frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; sendFrame(frame); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -476,12 +465,10 @@ public class ExtraStompTest extends StompTestBase { connV12.sendFrame(unsubFrame); connV12.disconnect(); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -534,12 +521,10 @@ public class ExtraStompTest extends StompTestBase { connV12.sendFrame(unsubFrame); connV12.disconnect(); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -600,12 +585,10 @@ public class ExtraStompTest extends StompTestBase { frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; sendFrame(frame); - } - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); throw ex; - } - finally { + } finally { cleanUp(); server.stop(); } @@ -662,8 +645,7 @@ public class ExtraStompTest extends StompTestBase { if (enable != null && enable.booleanValue()) { assertNotNull(msgId); assertTrue(msgId.indexOf("STOMP") == 0); - } - else { + } else { assertNull(msgId); } } @@ -680,8 +662,7 @@ public class ExtraStompTest extends StompTestBase { message = (TextMessage) consumer.receive(2000); Assert.assertNull(message); - } - finally { + } finally { cleanUp(); server.stop(); } @@ -802,8 +783,7 @@ public class ExtraStompTest extends StompTestBase { sendFrame(frame); - } - finally { + } finally { cleanUp(); server.stop(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java index 98259e8ee0..419b339244 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompConnectionCleanupTest.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.stomp; -import org.junit.Test; - import javax.jms.Message; import javax.jms.MessageConsumer; import org.apache.activemq.artemis.core.protocol.stomp.Stomp; import org.apache.activemq.artemis.jms.server.JMSServerManager; +import org.junit.Test; public class StompConnectionCleanupTest extends StompTestBase { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverHttpTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverHttpTest.java index 783f35f6fd..138e37cc71 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverHttpTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverHttpTest.java @@ -70,8 +70,7 @@ public class StompOverHttpTest extends StompTest { FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "", buf); httpRequest.headers().add(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes())); ctx.write(httpRequest, promise); - } - else { + } else { ctx.write(msg, promise); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java index fa8c048a1d..95801f728e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompOverWebsocketTest.java @@ -118,11 +118,9 @@ public class StompOverWebsocketTest extends StompTest { if (frame instanceof BinaryWebSocketFrame) { BinaryWebSocketFrame dataFrame = (BinaryWebSocketFrame) frame; super.channelRead(ctx, dataFrame.content()); - } - else if (frame instanceof PongWebSocketFrame) { + } else if (frame instanceof PongWebSocketFrame) { System.out.println("WebSocket Client received pong"); - } - else if (frame instanceof CloseWebSocketFrame) { + } else if (frame instanceof CloseWebSocketFrame) { System.out.println("WebSocket Client received closing"); ch.close(); } @@ -133,23 +131,19 @@ public class StompOverWebsocketTest extends StompTest { try { if (msg instanceof String) { ctx.write(createFrame((String) msg), promise); - } - else { + } else { super.write(ctx, msg, promise); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } - protected WebSocketFrame createFrame(String msg) { if (useBinaryFrames) { return new BinaryWebSocketFrame(Unpooled.copiedBuffer(msg, StandardCharsets.UTF_8)); - } - else { + } else { return new TextWebSocketFrame(msg); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java index 951aa85c30..7d66465774 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java @@ -137,8 +137,7 @@ public class StompTest extends StompTestBase { // It should encounter the exception on logs AssertionLoggerHandler.findText("AMQ119119"); - } - finally { + } finally { AssertionLoggerHandler.clear(); AssertionLoggerHandler.stopCapture(); } @@ -859,7 +858,6 @@ public class StompTest extends StompTestBase { sendFrame(frame); } - @Test public void testSubscribeWithAutoAckAndHyphenatedSelector() throws Exception { @@ -995,8 +993,7 @@ public class StompTest extends StompTestBase { sendFrame(frame); waitForFrameToTakeEffect(); reconnect(); - } - else { + } else { reconnect(100); waitForFrameToTakeEffect(); } @@ -1308,8 +1305,7 @@ public class StompTest extends StompTestBase { public boolean isSatisfied() throws Exception { if (server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length - baselineQueueCount == 1) { return true; - } - else { + } else { return false; } } @@ -1374,8 +1370,7 @@ public class StompTest extends StompTestBase { public boolean isSatisfied() throws Exception { if (server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length - baselineQueueCount == 1) { return true; - } - else { + } else { return false; } } @@ -1443,7 +1438,7 @@ public class StompTest extends StompTestBase { assertNotNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(ResourceNames.JMS_QUEUE + nonExistentQueue))); - final Queue subscription = ((LocalQueueBinding)server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(ResourceNames.JMS_QUEUE + nonExistentQueue))).getQueue(); + final Queue subscription = ((LocalQueueBinding) server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(ResourceNames.JMS_QUEUE + nonExistentQueue))).getQueue(); assertTrue(Wait.waitFor(new Wait.Condition() { @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java index 2e93b83ef9..2eb95cf10f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java @@ -101,7 +101,7 @@ public abstract class StompTestBase extends ActiveMQTestBase { private List bootstraps = new ArrayList<>(); -// private Channel channel; + // private Channel channel; private List> priorityQueues = new ArrayList<>(); @@ -124,8 +124,7 @@ public abstract class StompTestBase extends ActiveMQTestBase { if (isSecurityEnabled()) { connection = connectionFactory.createConnection("brianm", "wombats"); - } - else { + } else { connection = connectionFactory.createConnection(); } session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -158,8 +157,7 @@ public abstract class StompTestBase extends ActiveMQTestBase { try { channels.add(index, bootstraps.get(index).connect("localhost", port).sync().channel()); handshake(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } @@ -376,6 +374,7 @@ public abstract class StompTestBase extends ActiveMQTestBase { } class StompClientHandler extends SimpleChannelInboundHandler { + int index = 0; StompClientHandler(int index) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java index 240fa655b3..dd1b5ca5a6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.stomp; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; @@ -33,9 +36,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - public class StompWebSocketTest extends ActiveMQTestBase { private JMSServerManager server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/AbstractStompClientConnection.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/AbstractStompClientConnection.java index a4244c10cc..56338e47ae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/AbstractStompClientConnection.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/AbstractStompClientConnection.java @@ -104,8 +104,7 @@ public abstract class AbstractStompClientConnection implements StompClientConnec while (response != null) { if (response.getCommand().equals("STOMP")) { response = receiveFrame(); - } - else { + } else { break; } } @@ -131,8 +130,7 @@ public abstract class AbstractStompClientConnection implements StompClientConnec while (response != null) { if (response.getCommand().equals("STOMP")) { response = receiveFrame(); - } - else { + } else { break; } } @@ -168,18 +166,15 @@ public abstract class AbstractStompClientConnection implements StompClientConnec if (validateFrame(frame)) { frameQueue.offer(frame); receiveList.clear(); - } - else { + } else { receiveList.add(b); } } - } - else { + } else { if (b == 10 && receiveList.size() == 0) { //may be a ping incrementServerPing(); - } - else { + } else { receiveList.add(b); } } @@ -228,12 +223,10 @@ public abstract class AbstractStompClientConnection implements StompClientConnec //peer closed close(); - } - catch (IOException e) { + } catch (IOException e) { try { close(); - } - catch (IOException e1) { + } catch (IOException e1) { //ignore } } @@ -249,10 +242,8 @@ public abstract class AbstractStompClientConnection implements StompClientConnec public void destroy() { try { close(); - } - catch (IOException e) { - } - finally { + } catch (IOException e) { + } finally { this.connected = false; } } @@ -289,8 +280,7 @@ public abstract class AbstractStompClientConnection implements StompClientConnec pinger.stopPing(); try { pinger.join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } pinger = null; @@ -328,8 +318,7 @@ public abstract class AbstractStompClientConnection implements StompClientConnec sendFrame(pingFrame); this.wait(pingInterval); - } - catch (Exception e) { + } catch (Exception e) { stop = true; e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV10.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV10.java index 5f46b0ad8a..7a1a5298a9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV10.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV10.java @@ -37,8 +37,7 @@ public class StompClientConnectionV10 extends AbstractStompClientConnection { if (response.getCommand().equals(CONNECTED_COMMAND)) { connected = true; - } - else { + } else { System.out.println("Connection failed with: " + response); connected = false; } @@ -56,8 +55,7 @@ public class StompClientConnectionV10 extends AbstractStompClientConnection { if (response.getCommand().equals(CONNECTED_COMMAND)) { connected = true; - } - else { + } else { System.out.println("Connection failed with: " + response); connected = false; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV11.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV11.java index 1e2296c69f..aa07145480 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV11.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV11.java @@ -43,8 +43,7 @@ public class StompClientConnectionV11 extends AbstractStompClientConnection { this.username = username; this.passcode = passcode; this.connected = true; - } - else { + } else { connected = false; } return response; @@ -71,8 +70,7 @@ public class StompClientConnectionV11 extends AbstractStompClientConnection { this.username = username; this.passcode = passcode; this.connected = true; - } - else { + } else { connected = false; } } @@ -95,8 +93,7 @@ public class StompClientConnectionV11 extends AbstractStompClientConnection { this.username = username; this.passcode = passcode; this.connected = true; - } - else { + } else { System.out.println("Connection failed with frame " + response); connected = false; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV12.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV12.java index 797f731341..fb77832401 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV12.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompClientConnectionV12.java @@ -49,8 +49,7 @@ public class StompClientConnectionV12 extends AbstractStompClientConnection { this.username = username; this.passcode = passcode; this.connected = true; - } - else { + } else { connected = false; } return response; @@ -96,8 +95,7 @@ public class StompClientConnectionV12 extends AbstractStompClientConnection { this.username = username; this.passcode = passcode; this.connected = true; - } - else { + } else { connected = false; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV11.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV11.java index 173cf941b7..4de0d7d4cf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV11.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV11.java @@ -80,8 +80,7 @@ public class StompFrameFactoryV11 implements StompFrameFactory { //this is a backslash decodedHeader.append(b); isEsc = false; - } - else { + } else { //begin escaping isEsc = true; } @@ -91,8 +90,7 @@ public class StompFrameFactoryV11 implements StompFrameFactory { if (isEsc) { decodedHeader.append(":"); isEsc = false; - } - else { + } else { decodedHeader.append(b); } break; @@ -101,8 +99,7 @@ public class StompFrameFactoryV11 implements StompFrameFactory { if (isEsc) { decodedHeader.append('\n'); isEsc = false; - } - else { + } else { decodedHeader.append(b); } break; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV12.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV12.java index bab606fc7c..5223b4e56a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV12.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/util/StompFrameFactoryV12.java @@ -72,8 +72,7 @@ public class StompFrameFactoryV12 implements StompFrameFactory { //this is a backslash decodedHeader.append(b); isEsc = false; - } - else { + } else { //begin escaping isEsc = true; } @@ -83,8 +82,7 @@ public class StompFrameFactoryV12 implements StompFrameFactory { if (isEsc) { decodedHeader.append(":"); isEsc = false; - } - else { + } else { decodedHeader.append(b); } break; @@ -93,8 +91,7 @@ public class StompFrameFactoryV12 implements StompFrameFactory { if (isEsc) { decodedHeader.append('\n'); isEsc = false; - } - else { + } else { decodedHeader.append(b); } break; @@ -103,8 +100,7 @@ public class StompFrameFactoryV12 implements StompFrameFactory { if (isEsc) { decodedHeader.append('\r'); isEsc = false; - } - else { + } else { decodedHeader.append(b); } break; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/ExtraStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/ExtraStompTest.java index 58a08f533b..a5d306814a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/ExtraStompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/ExtraStompTest.java @@ -50,8 +50,7 @@ public class ExtraStompTest extends StompV11TestBase { try { connV10.disconnect(); connV11.disconnect(); - } - finally { + } finally { super.tearDown(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java index f539cd6f4d..4d42a34c8b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java @@ -31,13 +31,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.protocol.stomp.Stomp; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame; import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection; import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory; import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11; -import org.apache.activemq.artemis.core.protocol.stomp.Stomp; -import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -69,8 +69,7 @@ public class StompV11Test extends StompV11TestBase { if (connected) { connV11.disconnect(); } - } - finally { + } finally { super.tearDown(); } } @@ -456,8 +455,7 @@ public class StompV11Test extends StompV11TestBase { try { connV11.sendFrame(frame); fail("connection should have been destroyed by now"); - } - catch (IOException e) { + } catch (IOException e) { //ignore } @@ -607,8 +605,7 @@ public class StompV11Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { if (newConn != null) newConn.disconnect(); connV11.disconnect(); @@ -667,8 +664,7 @@ public class StompV11Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { newConn.disconnect(); } } @@ -735,8 +731,7 @@ public class StompV11Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { if (newConn != null) newConn.disconnect(); connV11.disconnect(); @@ -771,8 +766,7 @@ public class StompV11Test extends StompV11TestBase { try { connection.disconnect(); fail("Channel should be closed here already due to TTL"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -802,8 +796,7 @@ public class StompV11Test extends StompV11TestBase { try { connection.disconnect(); fail("Channel should be closed here already due to TTL"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -834,8 +827,7 @@ public class StompV11Test extends StompV11TestBase { try { connection.sendFrame(frame); fail("connection should have been destroyed by now"); - } - catch (IOException e) { + } catch (IOException e) { //ignore } @@ -900,8 +892,7 @@ public class StompV11Test extends StompV11TestBase { try { connection.sendFrame(frame); fail("connection should have been destroyed by now"); - } - catch (IOException e) { + } catch (IOException e) { //ignore } } @@ -934,8 +925,7 @@ public class StompV11Test extends StompV11TestBase { try { connection.disconnect(); fail("Connection should be closed here already due to TTL"); - } - catch (Exception e) { + } catch (Exception e) { // ignore } @@ -1489,21 +1479,17 @@ public class StompV11Test extends StompV11TestBase { try { connV11.sendFrame(sendFrame); Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //retry - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { //ok. latch.countDown(); break; - } - catch (IOException e) { + } catch (IOException e) { //ok. latch.countDown(); break; - } - finally { + } finally { connV11.destroy(); } } @@ -2415,12 +2401,14 @@ public class StompV11Test extends StompV11TestBase { } } - private void unsubscribe(StompClientConnection conn, String subId, boolean receipt, boolean durable) throws IOException, InterruptedException { + private void unsubscribe(StompClientConnection conn, + String subId, + boolean receipt, + boolean durable) throws IOException, InterruptedException { ClientStompFrame subFrame = conn.createFrame(Stomp.Commands.UNSUBSCRIBE); if (durable) { subFrame.addHeader(Stomp.Headers.Unsubscribe.DURABLE_SUBSCRIPTION_NAME, subId); - } - else { + } else { subFrame.addHeader(Stomp.Headers.Unsubscribe.ID, subId); } @@ -2463,8 +2451,7 @@ public class StompV11Test extends StompV11TestBase { if (sendDisconnect) { connV11.disconnect(); connV11 = StompClientConnectionFactory.createClientConnection("1.1", hostname, port); - } - else { + } else { connV11.destroy(); connV11 = StompClientConnectionFactory.createClientConnection("1.1", hostname, port); } @@ -2586,10 +2573,7 @@ public class StompV11Test extends StompV11TestBase { TextMessage message = (TextMessage) consumer.receive(1000); Assert.assertNotNull(message); - Assert.assertEquals( - "text/plain", - message.getStringProperty( - org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString())); + Assert.assertEquals("text/plain", message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString())); } @Test @@ -2600,9 +2584,7 @@ public class StompV11Test extends StompV11TestBase { MessageProducer producer = session.createProducer(queue); BytesMessage message = session.createBytesMessage(); - message.setStringProperty( - org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString(), - "text/plain"); + message.setStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString(), "text/plain"); message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8)); producer.send(message); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java index f737455769..c1bdccc1f5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java @@ -16,6 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.stomp.v11; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory; @@ -37,19 +50,6 @@ import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - public abstract class StompV11TestBase extends ActiveMQTestBase { protected String hostname = "127.0.0.1"; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java index adebae6a54..c075da5079 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java @@ -72,8 +72,7 @@ public class StompV12Test extends StompV11TestBase { if (connected) { connV12.disconnect(); } - } - finally { + } finally { super.tearDown(); } } @@ -632,8 +631,7 @@ public class StompV12Test extends StompV11TestBase { try { conn.sendFrame(frame); Assert.fail("connection should have been destroyed by now"); - } - catch (IOException e) { + } catch (IOException e) { //ignore } @@ -778,8 +776,7 @@ public class StompV12Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { if (newConn != null) newConn.disconnect(); connV12.disconnect(); @@ -838,8 +835,7 @@ public class StompV12Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { newConn.disconnect(); } } @@ -906,8 +902,7 @@ public class StompV12Test extends StompV11TestBase { ClientStompFrame unsubFrame = newConn.createFrame("UNSUBSCRIBE"); unsubFrame.addHeader("id", "a-sub"); newConn.sendFrame(unsubFrame); - } - finally { + } finally { if (newConn != null) newConn.disconnect(); connV12.disconnect(); @@ -1483,21 +1478,17 @@ public class StompV12Test extends StompV11TestBase { try { connV12.sendFrame(sendFrame); Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //retry - } - catch (ClosedChannelException e) { + } catch (ClosedChannelException e) { //ok. latch.countDown(); break; - } - catch (IOException e) { + } catch (IOException e) { //ok. latch.countDown(); break; - } - finally { + } finally { connV12.destroy(); } } @@ -1697,8 +1688,7 @@ public class StompV12Test extends StompV11TestBase { latch.countDown(); try { System.out.println("___> latch now: " + latch.getCount() + " m: " + m.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { Assert.fail("here failed"); e.printStackTrace(); } @@ -2455,12 +2445,14 @@ public class StompV12Test extends StompV11TestBase { } } - private void unsubscribe(StompClientConnection conn, String subId, boolean receipt, boolean durable) throws IOException, InterruptedException { + private void unsubscribe(StompClientConnection conn, + String subId, + boolean receipt, + boolean durable) throws IOException, InterruptedException { ClientStompFrame subFrame = conn.createFrame(Stomp.Commands.UNSUBSCRIBE); if (durable) { subFrame.addHeader(Stomp.Headers.Unsubscribe.DURABLE_SUBSCRIPTION_NAME, subId); - } - else { + } else { subFrame.addHeader(Stomp.Headers.Unsubscribe.ID, subId); } @@ -2503,8 +2495,7 @@ public class StompV12Test extends StompV11TestBase { if (sendDisconnect) { connV12.disconnect(); connV12 = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection("1.2", hostname, port); - } - else { + } else { connV12.destroy(); connV12 = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection("1.2", hostname, port); } @@ -2587,8 +2578,7 @@ public class StompV12Test extends StompV11TestBase { frame = connV12.sendFrame(frame); Assert.assertTrue(frame.getCommand().equals("ERROR")); - } - finally { + } finally { //because the last frame is ERROR, the connection //might already have closed by the server. //this is expected so we ignore it. diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java index 6bb90084a0..0afd30cb26 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java @@ -43,22 +43,22 @@ import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.PartialPooledByteBufAllocator; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; +import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -79,6 +79,7 @@ import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; */ @RunWith(value = Parameterized.class) public class NettyConnectorWithHTTPUpgradeTest extends ActiveMQTestBase { + private Boolean useSSL = false; @Parameterized.Parameters(name = "useSSL={0}") @@ -194,8 +195,7 @@ public class NettyConnectorWithHTTPUpgradeTest extends ActiveMQTestBase { // we shouldn't ever get here fail(); - } - catch (Exception x) { + } catch (Exception x) { e = x; } @@ -213,8 +213,7 @@ public class NettyConnectorWithHTTPUpgradeTest extends ActiveMQTestBase { final SSLContext context; if (useSSL) { context = SSLSupport.createContext("JKS", SERVER_SIDE_KEYSTORE, PASSWORD, null, null, null); - } - else { + } else { context = null; } b.childOption(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java index 5c667edb1f..84a3ecc43d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java @@ -713,8 +713,7 @@ public class ActiveMQVertxUnitTest extends ActiveMQTestBase { while (vertxMsg == null && timeout > System.currentTimeMillis()) { try { lock.wait(1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } msg = vertxMsg; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java index 06a3f77fbc..f5f83b5990 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java @@ -16,6 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.xa; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -42,15 +51,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - @RunWith(Parameterized.class) public class BasicXaRecoveryTest extends ActiveMQTestBase { @@ -84,7 +84,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection data() { - Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; + Object[][] params = new Object[][]{{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; return Arrays.asList(params); } @@ -97,17 +97,14 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); } - addressSettings.clear(); if (storeType == StoreConfiguration.StoreType.DATABASE) { configuration = createDefaultJDBCConfig(true).setJMXManagementEnabled(true); - } - else { + } else { configuration = createDefaultInVMConfig().setJMXManagementEnabled(true); } - mbeanServer = MBeanServerFactory.createMBeanServer(); server = createServer(true, configuration, -1, -1, addressSettings); @@ -243,18 +240,21 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { @Test public void testPagingServerRestarted() throws Exception { - if (storeType == StoreConfiguration.StoreType.DATABASE) return; + if (storeType == StoreConfiguration.StoreType.DATABASE) + return; verifyPaging(true); } @Test public void testPaging() throws Exception { - if (storeType == StoreConfiguration.StoreType.DATABASE) return; + if (storeType == StoreConfiguration.StoreType.DATABASE) + return; verifyPaging(false); } public void verifyPaging(final boolean restartServer) throws Exception { - if (storeType == StoreConfiguration.StoreType.DATABASE) return; + if (storeType == StoreConfiguration.StoreType.DATABASE) + return; Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes()); SimpleString pageQueue = new SimpleString("pagequeue"); @@ -285,8 +285,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (restartServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -320,13 +319,15 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { @Test public void testRollbackPaging() throws Exception { - if (storeType == StoreConfiguration.StoreType.DATABASE) return; + if (storeType == StoreConfiguration.StoreType.DATABASE) + return; testRollbackPaging(false); } @Test public void testRollbackPagingServerRestarted() throws Exception { - if (storeType == StoreConfiguration.StoreType.DATABASE) return; + if (storeType == StoreConfiguration.StoreType.DATABASE) + return; testRollbackPaging(true); } @@ -357,8 +358,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (restartServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -414,8 +414,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { Assert.assertEquals(xids.length, 0); if (commit) { clientSession.commit(xid, false); - } - else { + } else { clientSession.rollback(xid); } @@ -474,8 +473,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -524,8 +522,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -572,8 +569,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -632,8 +628,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -703,8 +698,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -752,8 +746,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -811,8 +804,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -888,8 +880,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -956,8 +947,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -1059,8 +1049,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } @@ -1146,8 +1135,7 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase { if (stopServer) { stopAndRestartServer(); - } - else { + } else { recreateClients(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java index 5bd2463044..5ee71b138a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java @@ -77,7 +77,7 @@ public class BasicXaTest extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection data() { - Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; + Object[][] params = new Object[][]{{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; return Arrays.asList(params); } @@ -90,8 +90,7 @@ public class BasicXaTest extends ActiveMQTestBase { if (storeType == StoreConfiguration.StoreType.DATABASE) { configuration = createDefaultJDBCConfig(true); - } - else { + } else { configuration = createDefaultNettyConfig(); } @@ -420,8 +419,7 @@ public class BasicXaTest extends ActiveMQTestBase { try { session.start(xid, XAResource.TMRESUME); Assert.fail("XAException expected"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_PROTO, e.errorCode); } @@ -515,8 +513,7 @@ public class BasicXaTest extends ActiveMQTestBase { try { clientSession.forget(newXID()); Assert.fail("should throw a XAERR_NOTA XAException"); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertEquals(XAException.XAER_NOTA, e.errorCode); } } @@ -726,8 +723,7 @@ public class BasicXaTest extends ActiveMQTestBase { if (tr == 0) { session.rollback(xid); - } - else { + } else { session.commit(xid, onePhase); } @@ -803,13 +799,11 @@ public class BasicXaTest extends ActiveMQTestBase { if (i == 0) { session.rollback(xid); - } - else { + } else { session.commit(xid, false); } } - } - finally { + } finally { if (session != null) { session.close(); } @@ -829,8 +823,7 @@ public class BasicXaTest extends ActiveMQTestBase { if (heuristicCommit) { Assert.assertTrue(messagingService.getActiveMQServerControl().commitPreparedTransaction(XidImpl.toBase64String(xid))); Assert.assertEquals(1, messagingService.getActiveMQServerControl().listHeuristicCommittedTransactions().length); - } - else { + } else { Assert.assertTrue(messagingService.getActiveMQServerControl().rollbackPreparedTransaction(XidImpl.toBase64String(xid))); Assert.assertEquals(1, messagingService.getActiveMQServerControl().listHeuristicRolledBackTransactions().length); } @@ -839,26 +832,21 @@ public class BasicXaTest extends ActiveMQTestBase { try { if (isCommit) { clientSession.commit(xid, false); - } - else { + } else { clientSession.rollback(xid); } Assert.fail("neither commit not rollback must succeed on a heuristically completed tx"); - } - - catch (XAException e) { + } catch (XAException e) { if (heuristicCommit) { Assert.assertEquals(XAException.XA_HEURCOM, e.errorCode); - } - else { + } else { Assert.assertEquals(XAException.XA_HEURRB, e.errorCode); } } if (heuristicCommit) { Assert.assertEquals(1, messagingService.getActiveMQServerControl().listHeuristicCommittedTransactions().length); - } - else { + } else { Assert.assertEquals(1, messagingService.getActiveMQServerControl().listHeuristicRolledBackTransactions().length); } } @@ -881,28 +869,24 @@ public class BasicXaTest extends ActiveMQTestBase { Xid xid = new XidImpl(UUIDGenerator.getInstance().generateStringUUID().getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes()); try { session.start(xid, XAResource.TMNOFLAGS); - } - catch (XAException e) { + } catch (XAException e) { e.printStackTrace(); } try { message.acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { BasicXaTest.log.error("Failed to process message", e); } try { session.end(xid, XAResource.TMSUCCESS); session.rollback(xid); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failedToAck = true; try { session.close(); - } - catch (ActiveMQException e1) { + } catch (ActiveMQException e1) { // } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java index c19a200b89..0cd65ca749 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java @@ -87,7 +87,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection data() { - Object[][] params = new Object[][] {{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; + Object[][] params = new Object[][]{{StoreConfiguration.StoreType.FILE}, {StoreConfiguration.StoreType.DATABASE}}; return Arrays.asList(params); } @@ -100,8 +100,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { if (storeType == StoreConfiguration.StoreType.DATABASE) { configuration = createDefaultJDBCConfig(true); - } - else { + } else { configuration = createBasicConfig(); } configuration.setTransactionTimeoutScanPeriod(500).addAcceptorConfiguration(new TransportConfiguration(ActiveMQTestBase.INVM_ACCEPTOR_FACTORY)); @@ -138,8 +137,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); try { clientSession.commit(xid, true); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertTrue(e.errorCode == XAException.XAER_NOTA); } clientSession.start(); @@ -187,8 +185,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); try { clientSession.commit(xid, true); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertTrue(e.errorCode == XAException.XAER_NOTA); } clientSession.setTransactionTimeout(0); @@ -263,8 +260,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); try { clientSession.commit(xid, true); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertTrue(e.errorCode == XAException.XAER_NOTA); } clientSession.setTransactionTimeout(0); @@ -430,43 +426,37 @@ public class XaTimeoutTest extends ActiveMQTestBase { try { clientSession.end(xid, XAResource.TMSUCCESS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } try { outProducerSession.end(xidOut, XAResource.TMSUCCESS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } if (rollback) { try { clientSession.rollback(xid); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); clientSession.rollback(); } try { outProducerSession.rollback(xidOut); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); outProducerSession.rollback(); } - } - else { + } else { clientSession.prepare(xid); outProducerSession.prepare(xidOut); clientSession.commit(xid, false); outProducerSession.commit(xidOut, false); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -553,8 +543,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { Assert.assertTrue(latch.await(2600, TimeUnit.MILLISECONDS)); try { clientSession.commit(xid, true); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertTrue(e.errorCode == XAException.XAER_NOTA); } clientSession.start(); @@ -613,8 +602,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { for (int i = 0; i < clientSessions.length / 2; i++) { try { clientSessions[i].commit(xids[i], true); - } - catch (XAException e) { + } catch (XAException e) { Assert.assertTrue(e.errorCode == XAException.XAER_NOTA); } } @@ -647,8 +635,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { if (packet instanceof SessionXAStartMessage) { try { latch.await(1, TimeUnit.MINUTES); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -669,8 +656,7 @@ public class XaTimeoutTest extends ActiveMQTestBase { try { sessionTimeout.start(xid, XAResource.TMNOFLAGS); - } - catch (Exception e) { + } catch (Exception e) { expectedException = true; e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSClusteredTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSClusteredTestBase.java index c624322859..322d9a8df8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSClusteredTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSClusteredTestBase.java @@ -16,6 +16,13 @@ */ package org.apache.activemq.artemis.tests.util; +import javax.jms.ConnectionFactory; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import java.util.ArrayList; + import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -33,13 +40,6 @@ import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; import org.junit.Before; -import javax.jms.ConnectionFactory; -import javax.jms.Queue; -import javax.jms.Topic; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import java.util.ArrayList; - public class JMSClusteredTestBase extends ActiveMQTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java index 83dc3ba5fe..f02de797c8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java @@ -37,7 +37,6 @@ import java.util.Set; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; -import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -47,6 +46,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfi import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.artemis.service.extensions.ServiceUtils; import org.apache.activemq.artemis.tests.integration.ra.DummyTransactionManager; +import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -170,18 +170,15 @@ public class JMSTestBase extends ActiveMQTestBase { for (JMSContext jmsContext : contextSet) { jmsContext.close(); } - } - catch (RuntimeException ignored) { + } catch (RuntimeException ignored) { // no-op - } - finally { + } finally { contextSet.clear(); } try { if (conn != null) conn.close(); - } - catch (Exception e) { + } catch (Exception e) { // no-op } @@ -246,8 +243,7 @@ public class JMSTestBase extends ActiveMQTestBase { msg.setIntProperty("counter", j); producer.send(queue, msg); } - } - catch (JMSException cause) { + } catch (JMSException cause) { throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause); } } @@ -266,8 +262,7 @@ public class JMSTestBase extends ActiveMQTestBase { if (ack) message.acknowledge(); } - } - catch (JMSException cause) { + } catch (JMSException cause) { throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java index b4edc54260..17927b102d 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java @@ -453,8 +453,7 @@ public class AcknowledgementTest extends JMSTestCase { } ProxyAssertSupport.assertEquals(NUM_MESSAGES - ACKED_MESSAGES, count); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -619,8 +618,7 @@ public class AcknowledgementTest extends JMSTestCase { } consumerSess.close(); - } - finally { + } finally { if (conn != null) { conn.close(); @@ -780,14 +778,13 @@ public class AcknowledgementTest extends JMSTestCase { ProxyAssertSupport.assertEquals("two", messageReceived.getText()); - messageReceived = (TextMessage)consumer.receiveNoWait(); + messageReceived = (TextMessage) consumer.receiveNoWait(); if (messageReceived != null) { System.out.println("Message received " + messageReceived.getText()); } Assert.assertNull(messageReceived); - consumer.close(); // I can't call xasession.close for this test as JCA layer would cache the session @@ -991,8 +988,7 @@ public class AcknowledgementTest extends JMSTestCase { latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { failed = true; latch.countDown(); } @@ -1051,8 +1047,7 @@ public class AcknowledgementTest extends JMSTestCase { latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { failed = true; latch.countDown(); } @@ -1142,8 +1137,7 @@ public class AcknowledgementTest extends JMSTestCase { latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { log.error("Caught exception", e); failed = true; latch.countDown(); @@ -1225,8 +1219,7 @@ public class AcknowledgementTest extends JMSTestCase { assertRemainingMessages(0); latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { // log.error(e); failed = true; latch.countDown(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java index 5383492544..42d6ea5df3 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java @@ -78,8 +78,7 @@ public abstract class ActiveMQServerTestCase { System.gc(); try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } } @@ -130,8 +129,7 @@ public abstract class ActiveMQServerTestCase { // deploy the objects for this test deployAdministeredObjects(); lookUp(); - } - catch (Exception e) { + } catch (Exception e) { // if we get here we need to clean up for the next test e.printStackTrace(); ActiveMQServerTestCase.servers.get(0).stop(); @@ -257,8 +255,7 @@ public abstract class ActiveMQServerTestCase { for (Server s : servers) { try { s.stop(); - } - catch (Exception cause) { + } catch (Exception cause) { // ignore } } @@ -293,8 +290,7 @@ public abstract class ActiveMQServerTestCase { } log.trace("Drained message"); } - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMesageListenerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMesageListenerTest.java index 13a4699912..e7877ce3c3 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMesageListenerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMesageListenerTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; @@ -26,6 +23,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.Test; @@ -75,8 +74,7 @@ public class AutoAckMesageListenerTest extends JMSTestCase { if (listener.getPassed() == false) { throw new Exception("failed"); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -120,22 +118,19 @@ public class AutoAckMesageListenerTest extends JMSTestCase { log.info("Error: received first message twice"); passed = false; } - } - else { + } else { if (message.getJMSRedelivered() == false) { // received second message for first time log.info("Received second message. Calling recover()"); session.recover(); - } - else { + } else { // should be redelivered after recover log.info("Received second message again as expected"); passed = true; monitor.countDown(); } } - } - catch (JMSException e) { + } catch (JMSException e) { log.warn("Exception caught in message listener:\n" + e); passed = false; monitor.countDown(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/BrowserTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/BrowserTest.java index 009519b4ee..4256e60f96 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/BrowserTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/BrowserTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests; -import java.util.Enumeration; - import javax.jms.Connection; import javax.jms.InvalidDestinationException; import javax.jms.JMSException; @@ -27,6 +25,7 @@ import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Enumeration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -49,8 +48,7 @@ public class BrowserTest extends JMSTestCase { try { session.createBrowser(null); ProxyAssertSupport.fail("should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } } @@ -70,12 +68,10 @@ public class BrowserTest extends JMSTestCase { } }); ProxyAssertSupport.fail("should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } - } - finally { + } finally { if (pconn != null) { pconn.close(); } @@ -155,8 +151,7 @@ public class BrowserTest extends JMSTestCase { m.setIntProperty("test_counter", i + 1); producer.send(m); } - } - finally { + } finally { removeAllMessages(queue1.getQueueName(), true); } } @@ -202,8 +197,7 @@ public class BrowserTest extends JMSTestCase { ProxyAssertSupport.assertEquals("A", rm.getText()); ProxyAssertSupport.assertFalse(en.hasMoreElements()); - } - finally { + } finally { removeAllMessages(queue1.getQueueName(), true); } } @@ -215,8 +209,7 @@ public class BrowserTest extends JMSTestCase { if (conn != null) { conn.close(); } - } - finally { + } finally { super.tearDown(); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/CTSMiscellaneousTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/CTSMiscellaneousTest.java index afa51d7edc..f1245750c8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/CTSMiscellaneousTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/CTSMiscellaneousTest.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.jms.tests; -import java.util.ArrayList; -import java.util.List; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.MessageProducer; import javax.jms.Session; +import java.util.ArrayList; +import java.util.List; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; @@ -57,8 +56,7 @@ public class CTSMiscellaneousTest extends JMSTest { getJmsServerManager().createConnectionFactory("StrictTCKConnectionFactory", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/StrictTCKConnectionFactory"); CTSMiscellaneousTest.cf = (ActiveMQConnectionFactory) getInitialContext().lookup("/StrictTCKConnectionFactory"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -90,8 +88,7 @@ public class CTSMiscellaneousTest extends JMSTest { } assertRemainingMessages(numMessages); - } - finally { + } finally { if (c != null) { c.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionClosedTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionClosedTest.java index d47896ee9e..b19eb8ee8c 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionClosedTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionClosedTest.java @@ -144,14 +144,12 @@ public class ConnectionClosedTest extends JMSTestCase { if (System.currentTimeMillis() - start >= 2000) { // It timed out failed = "Timed out"; - } - else { + } else { if (m != null) { failed = "Message Not null"; } } - } - catch (Exception e) { + } catch (Exception e) { log.error(e); failed = e.getMessage(); } @@ -183,8 +181,7 @@ public class ConnectionClosedTest extends JMSTestCase { try { connection.getMetaData(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } } @@ -197,8 +194,7 @@ public class ConnectionClosedTest extends JMSTestCase { try { conn.createSession(false, Session.AUTO_ACKNOWLEDGE); ProxyAssertSupport.fail("Did not throw javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } } @@ -225,47 +221,41 @@ public class ConnectionClosedTest extends JMSTestCase { try { sess.createMessage(); ProxyAssertSupport.fail("Session is not closed"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } try { sess.getAcknowledgeMode(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { sess.getTransacted(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { sess.getMessageListener(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { sess.createProducer(queue1); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { sess.createConsumer(queue1); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } @@ -277,39 +267,34 @@ public class ConnectionClosedTest extends JMSTestCase { try { producer.send(m); ProxyAssertSupport.fail("Producer is not closed"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } try { producer.getDisableMessageID(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { producer.getPriority(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { producer.getDestination(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { producer.getTimeToLive(); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } @@ -318,24 +303,21 @@ public class ConnectionClosedTest extends JMSTestCase { try { consumer.getMessageSelector(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { consumer.getMessageListener(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } try { consumer.receive(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionFactoryTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionFactoryTest.java index 5c7cfeeede..91e466e709 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionFactoryTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionFactoryTest.java @@ -97,8 +97,7 @@ public class ConnectionFactoryTest extends JMSTestCase { c.setClientID("somethingelse"); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } c.close(); @@ -160,21 +159,18 @@ public class ConnectionFactoryTest extends JMSTestCase { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber(topic, "durableSubscriberChangeSelectorTest", "TEST = 'test'", false); - } - finally { + } finally { try { if (conn != null) { conn.close(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.toString(), e); } try { destroyTopic("TestSubscriber"); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.toString(), e); } @@ -234,8 +230,7 @@ public class ConnectionFactoryTest extends JMSTestCase { while (fast.processed != numMessages - 2) { try { waitLock.wait(20000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } @@ -282,21 +277,18 @@ public class ConnectionFactoryTest extends JMSTestCase { Assert.assertTrue(fast.processed == numMessages - 2); - } - finally { + } finally { try { if (conn != null) { conn.close(); } - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.toString(), e); } try { ActiveMQServerTestCase.undeployConnectionFactory("TestSlowConsumersCF"); - } - catch (Exception e) { + } catch (Exception e) { log.warn(e.toString(), e); } @@ -458,15 +450,13 @@ public class ConnectionFactoryTest extends JMSTestCase { Assert.assertFalse(conn instanceof XAQueueConnection); Assert.assertTrue(conn instanceof TopicConnection); Assert.assertFalse(conn instanceof XATopicConnection); - } - else if ("xa".equals(type) || "xa-queue".equals(type) || "xa-topic".equals(type)) { + } else if ("xa".equals(type) || "xa-queue".equals(type) || "xa-topic".equals(type)) { Assert.assertTrue(conn instanceof XAConnection); Assert.assertTrue(conn instanceof QueueConnection); Assert.assertTrue(conn instanceof XAQueueConnection); Assert.assertTrue(conn instanceof TopicConnection); Assert.assertTrue(conn instanceof XATopicConnection); - } - else { + } else { Assert.fail("Unknown connection type: " + type); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionTest.java index 7faaa0c12a..eab72f0544 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConnectionTest.java @@ -88,8 +88,7 @@ public class ConnectionTest extends JMSTestCase { try { connection2.setClientID(clientID); Assert.fail("setClientID was expected to throw an exception"); - } - catch (JMSException e) { + } catch (JMSException e) { // expected } @@ -110,16 +109,12 @@ public class ConnectionTest extends JMSTestCase { // an attempt to set the client ID now should throw an IllegalStateException connection.setClientID("testSetClientID_2"); ProxyAssertSupport.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { ProxyAssertSupport.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { ProxyAssertSupport.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException"); - } - finally { + } finally { if (connection != null) { connection.close(); } @@ -139,8 +134,7 @@ public class ConnectionTest extends JMSTestCase { try { connection.setClientID(clientID); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { ConnectionTest.log.trace("Caught exception ok"); } @@ -165,8 +159,7 @@ public class ConnectionTest extends JMSTestCase { try { connection.setClientID(clientID); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } connection.close(); @@ -175,8 +168,7 @@ public class ConnectionTest extends JMSTestCase { try { connection.setClientID(clientID); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } connection.close(); } @@ -271,16 +263,12 @@ public class ConnectionTest extends JMSTestCase { try { queueConnection.createDurableConnectionConsumer(ActiveMQServerTestCase.topic1, "subscriptionName", "", (ServerSessionPool) null, 1); ProxyAssertSupport.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (java.lang.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { ProxyAssertSupport.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (JMSException e) { + } catch (JMSException e) { ProxyAssertSupport.fail("Should throw a javax.jms.IllegalStateException, not a " + e); - } - finally { + } finally { queueConnection.close(); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConsumerClosedTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConsumerClosedTest.java index f6c96fc8c7..2505db593c 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConsumerClosedTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ConsumerClosedTest.java @@ -64,8 +64,7 @@ public class ConsumerClosedTest extends JMSTestCase { // make sure that all messages are in queue assertRemainingMessages(ConsumerClosedTest.NUMBER_OF_MESSAGES); - } - finally { + } finally { if (c != null) { c.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DeliveryOrderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DeliveryOrderTest.java index 8cf57198f7..33d895a1d8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DeliveryOrderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DeliveryOrderTest.java @@ -123,8 +123,7 @@ public class DeliveryOrderTest extends JMSTestCase { sess.commit(); latch.countDown(); } - } - catch (JMSException e) { + } catch (JMSException e) { e.printStackTrace(); // Failed diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DurableSubscriptionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DurableSubscriptionTest.java index c89eb5fa6a..428789f240 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DurableSubscriptionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/DurableSubscriptionTest.java @@ -100,8 +100,7 @@ public class DurableSubscriptionTest extends JMSTestCase { durable.close(); s.unsubscribe("monicabelucci"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -155,8 +154,7 @@ public class DurableSubscriptionTest extends JMSTestCase { durable.close(); s.unsubscribe(subscriptionName); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -205,8 +203,7 @@ public class DurableSubscriptionTest extends JMSTestCase { durable.close(); s.unsubscribe("monicabelucci"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -278,8 +275,7 @@ public class DurableSubscriptionTest extends JMSTestCase { durable.close(); s.unsubscribe("monicabelucci"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -300,12 +296,10 @@ public class DurableSubscriptionTest extends JMSTestCase { try { s.createDurableSubscriber(temporaryTopic, "mySubscription"); ProxyAssertSupport.fail("this should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -338,8 +332,7 @@ public class DurableSubscriptionTest extends JMSTestCase { ds.close(); s.unsubscribe("uzzi"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -355,8 +348,7 @@ public class DurableSubscriptionTest extends JMSTestCase { try { s.createDurableSubscriber(ActiveMQServerTestCase.topic1, "mysubscribption", "=TEST 'test'", true); ProxyAssertSupport.fail("this should fail"); - } - catch (InvalidSelectorException e) { + } catch (InvalidSelectorException e) { // OK } } @@ -374,8 +366,7 @@ public class DurableSubscriptionTest extends JMSTestCase { try { s.unsubscribe("dursub0"); ProxyAssertSupport.fail(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Ok - it is illegal to ubscribe a subscription if it has active consumers } @@ -396,8 +387,7 @@ public class DurableSubscriptionTest extends JMSTestCase { try { s.createDurableSubscriber(ActiveMQServerTestCase.topic1, "dursub1"); ProxyAssertSupport.fail(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Ok - it is illegal to have more than one active subscriber on a subscrtiption at any one time } @@ -457,8 +447,7 @@ public class DurableSubscriptionTest extends JMSTestCase { if (noLocal) { ProxyAssertSupport.assertNull(m); - } - else { + } else { ProxyAssertSupport.assertNotNull(m); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTest.java index 02e7f22a96..34d2bdc0d1 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTest.java @@ -49,8 +49,7 @@ public class JMSTest extends JMSTestCase { conn.close(); conn = null; } - } - finally { + } finally { super.tearDown(); } } @@ -262,8 +261,7 @@ public class JMSTest extends JMSTestCase { latch.countDown(); } } - } - catch (Exception e) { + } catch (Exception e) { log.error("receive failed", e); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTestCase.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTestCase.java index 21e482fa6e..8c66e7a6a4 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTestCase.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/JMSTestCase.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests; -import java.util.ArrayList; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSContext; @@ -26,6 +24,7 @@ import javax.jms.QueueConnection; import javax.jms.TopicConnection; import javax.jms.XAConnection; import javax.naming.InitialContext; +import java.util.ArrayList; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java index abd8b1ea5a..f4c99e7cd6 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java @@ -88,8 +88,7 @@ public class MessageConsumerTest extends JMSTestCase { // Now close the session sess2.close(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -131,8 +130,7 @@ public class MessageConsumerTest extends JMSTestCase { if (count == numMessages) { notify(); } - } - catch (JMSException e) { + } catch (JMSException e) { failed = true; } } @@ -161,8 +159,7 @@ public class MessageConsumerTest extends JMSTestCase { conn.close(); ProxyAssertSupport.assertFalse(listener.failed); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -229,8 +226,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("Your mum", tm3.getText()); tm3.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -271,8 +267,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage m = (TextMessage) queueConsumer.receive(); ProxyAssertSupport.assertEquals(tm.getText(), m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -314,8 +309,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage m = (TextMessage) queueConsumer.receive(); ProxyAssertSupport.assertEquals(tm.getText(), m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -357,8 +351,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage m = (TextMessage) queueConsumer.receive(2000); ProxyAssertSupport.assertEquals(tm.getText(), m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -409,8 +402,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage m = (TextMessage) queueConsumer.receiveNoWait(); ProxyAssertSupport.assertEquals(tm.getText(), m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -459,8 +451,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage m = (TextMessage) l.getNextMessage(); ProxyAssertSupport.assertEquals(tm.getText(), m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -491,12 +482,10 @@ public class MessageConsumerTest extends JMSTestCase { } }); ProxyAssertSupport.fail("should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } - } - finally { + } finally { if (pconn != null) { pconn.close(); } @@ -520,12 +509,10 @@ public class MessageConsumerTest extends JMSTestCase { } }); ProxyAssertSupport.fail("should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } - } - finally { + } finally { if (pconn != null) { pconn.close(); } @@ -586,8 +573,7 @@ public class MessageConsumerTest extends JMSTestCase { log.trace("Done test"); - } - finally { + } finally { if (connSend != null) { connSend.close(); } @@ -635,12 +621,10 @@ public class MessageConsumerTest extends JMSTestCase { try { queueConsumer.receive(2000); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -684,8 +668,7 @@ public class MessageConsumerTest extends JMSTestCase { Message r = queueConsumer.receive(2000); ProxyAssertSupport.assertEquals(m.getJMSMessageID(), r.getJMSMessageID()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -751,8 +734,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("Two", m.getText()); consumerSession.commit(); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -801,8 +783,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("c", rm3.getText()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -852,8 +833,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3", rm3.getText()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -903,8 +883,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3-a", rm3.getText()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -957,8 +936,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3", rm4.getText()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1017,8 +995,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3", rm4.getText()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1069,8 +1046,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3", rm4.getText()); rm4.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1129,8 +1105,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("hello3", rm4.getText()); rm4.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1188,8 +1163,7 @@ public class MessageConsumerTest extends JMSTestCase { r1.acknowledge(); r2.acknowledge(); r3.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1233,8 +1207,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(r1); ProxyAssertSupport.assertNotNull(r2); ProxyAssertSupport.assertNotNull(r3); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1290,8 +1263,7 @@ public class MessageConsumerTest extends JMSTestCase { sessReceive = connReceive.createSession(true, Session.SESSION_TRANSACTED); cons = sessReceive.createConsumer(queue1); - } - finally { + } finally { if (connSend != null) { connSend.close(); } @@ -1350,8 +1322,7 @@ public class MessageConsumerTest extends JMSTestCase { } } - } - catch (Exception e) { + } catch (Exception e) { log.error("Failed in receiving messages", e); failed = true; } @@ -1397,8 +1368,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertTrue(!rec1.failed); ProxyAssertSupport.assertTrue(!rec2.failed); ProxyAssertSupport.assertTrue(!rec3.failed); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1422,8 +1392,7 @@ public class MessageConsumerTest extends JMSTestCase { MessageConsumer topicConsumer = consumerSession.createConsumer(ActiveMQServerTestCase.topic1, selector); ProxyAssertSupport.assertEquals(selector, topicConsumer.getMessageSelector()); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1446,12 +1415,10 @@ public class MessageConsumerTest extends JMSTestCase { try { topicConsumer.getMessageSelector(); Assert.fail("must throw a JMS IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1475,12 +1442,10 @@ public class MessageConsumerTest extends JMSTestCase { try { topicConsumer.getNoLocal(); Assert.fail("must throw a JMS IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1501,8 +1466,7 @@ public class MessageConsumerTest extends JMSTestCase { Topic t = ((TopicSubscriber) topicConsumer).getTopic(); ProxyAssertSupport.assertEquals(ActiveMQServerTestCase.topic1, t); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1525,12 +1489,10 @@ public class MessageConsumerTest extends JMSTestCase { try { ((TopicSubscriber) topicConsumer).getTopic(); Assert.fail("must throw a JMS IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1551,8 +1513,7 @@ public class MessageConsumerTest extends JMSTestCase { Queue q = ((QueueReceiver) queueConsumer).getQueue(); ProxyAssertSupport.assertEquals(queue1, q); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1575,12 +1536,10 @@ public class MessageConsumerTest extends JMSTestCase { try { ((QueueReceiver) queueConsumer).getQueue(); Assert.fail("must throw a JMS IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1601,8 +1560,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m = topicConsumer.receive(1000); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1636,16 +1594,14 @@ public class MessageConsumerTest extends JMSTestCase { // this is needed to make sure the main thread has enough time to block Thread.sleep(1000); topicProducer.send(m); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } }, "Producer").start(); ProxyAssertSupport.assertNull(topicConsumer.receive(1500)); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1684,8 +1640,7 @@ public class MessageConsumerTest extends JMSTestCase { // this is needed to make sure the main thread has enough time to block Thread.sleep(1000); topicProducer.send(m1); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -1693,8 +1648,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m2 = topicConsumer.receive(1500); ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1733,8 +1687,7 @@ public class MessageConsumerTest extends JMSTestCase { // this is needed to make sure the main thread has enough time to block Thread.sleep(1000); topicProducer.send(m1); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -1743,8 +1696,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m2 = topicConsumer.receive(3000); ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1788,8 +1740,7 @@ public class MessageConsumerTest extends JMSTestCase { m = topicConsumer.receiveNoWait(); ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), m.getJMSMessageID()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1833,8 +1784,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m = producerSession.createMessage(); queueProducer.send(m); } - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -1844,8 +1794,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m = queueConsumer.receive(1500); ProxyAssertSupport.assertNotNull(m); } - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1894,8 +1843,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m = producerSession.createMessage(); topicProducer.send(m); } - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -1907,8 +1855,7 @@ public class MessageConsumerTest extends JMSTestCase { } checkEmpty(ActiveMQServerTestCase.topic1); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -1938,11 +1885,9 @@ public class MessageConsumerTest extends JMSTestCase { // this is needed to make sure the main thread has enough time to block Thread.sleep(1000); topicConsumer.close(); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); - } - finally { + } finally { latch.countDown(); } } @@ -1955,8 +1900,7 @@ public class MessageConsumerTest extends JMSTestCase { boolean closed = latch.await(5000, TimeUnit.MILLISECONDS); ProxyAssertSupport.assertTrue(closed); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -1997,8 +1941,7 @@ public class MessageConsumerTest extends JMSTestCase { Thread.sleep(timeToSleep); topicConsumer.close(); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); e.printStackTrace(); } @@ -2046,8 +1989,7 @@ public class MessageConsumerTest extends JMSTestCase { receivedObject = topicConsumer.receive(timeToWait); t2 = System.currentTimeMillis(); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); e.printStackTrace(); } @@ -2094,8 +2036,7 @@ public class MessageConsumerTest extends JMSTestCase { // We need to make sure the ProxyAssertSupport.assertTrue("Receive was supposed to receive a notification before 2 seconds", receiver.t2 - receiver.t1 <= 1500); - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -2138,8 +2079,7 @@ public class MessageConsumerTest extends JMSTestCase { l.waitForMessages(); ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), l.getNextMessage().getJMSMessageID()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2192,8 +2132,7 @@ public class MessageConsumerTest extends JMSTestCase { log.debug("testMessageListenerOnTopicMultipleMessages done"); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2246,8 +2185,7 @@ public class MessageConsumerTest extends JMSTestCase { log.debug("testMessageListenerOnTopicMultipleMessages done"); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2296,8 +2234,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), listener2.getNextMessage().getJMSMessageID()); ProxyAssertSupport.assertEquals(0, listener1.size()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2324,8 +2261,7 @@ public class MessageConsumerTest extends JMSTestCase { public void run() { try { topicConsumer.receive(3000); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -2338,13 +2274,11 @@ public class MessageConsumerTest extends JMSTestCase { try { topicConsumer.setMessageListener(new MessageListenerImpl()); ProxyAssertSupport.fail("should have thrown JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // ok log.trace(e.getMessage()); } - } - finally { + } finally { if (consumerConnection != null) { consumerConnection.close(); } @@ -2366,8 +2300,7 @@ public class MessageConsumerTest extends JMSTestCase { messagesReceived.incrementAndGet(); try { Thread.sleep(100L); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // Ignore } } @@ -2427,8 +2360,7 @@ public class MessageConsumerTest extends JMSTestCase { log.trace("Sleeping to allow remaining messages to arrive"); Thread.sleep(15000); ProxyAssertSupport.assertEquals("Should have received all messages after restarting", MESSAGE_COUNT, messagesReceived.get()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2465,8 +2397,7 @@ public class MessageConsumerTest extends JMSTestCase { public void onMessage(final Message message) { try { Thread.sleep(1); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // Ignore } } @@ -2485,8 +2416,7 @@ public class MessageConsumerTest extends JMSTestCase { consumerConnection.close(); consumerConnection = null; - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2540,8 +2470,7 @@ public class MessageConsumerTest extends JMSTestCase { m = (TextMessage) queueConsumer.receive(1500); ProxyAssertSupport.assertEquals("Two", m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2591,8 +2520,7 @@ public class MessageConsumerTest extends JMSTestCase { m = (TextMessage) queueConsumer.receive(1500); ProxyAssertSupport.assertEquals("Two", m.getText()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -2657,8 +2585,7 @@ public class MessageConsumerTest extends JMSTestCase { public void run() { try { m = consumer.receive(1500); - } - catch (Exception e) { + } catch (Exception e) { exceptionThrown = true; } } @@ -2690,8 +2617,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNull(tr1.m); ProxyAssertSupport.assertNotNull(tr2.m); ProxyAssertSupport.assertNotNull(tr3.m); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -2727,8 +2653,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNull(msg); checkEmpty(ActiveMQServerTestCase.topic1); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -2788,8 +2713,7 @@ public class MessageConsumerTest extends JMSTestCase { // but tm1 should not be redelivered tm1 = (TextMessage) cons1.receive(1500); ProxyAssertSupport.assertNull(tm1); - } - finally { + } finally { if (conn1 != null) { log.trace("closing connection"); conn1.close(); @@ -2843,8 +2767,7 @@ public class MessageConsumerTest extends JMSTestCase { conn1 = null; checkEmpty(ActiveMQServerTestCase.topic1); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -2925,8 +2848,7 @@ public class MessageConsumerTest extends JMSTestCase { TextMessage tm2 = (TextMessage) theConsumer.receive(1500); ProxyAssertSupport.assertEquals("aardvark", tm2.getText()); - } - finally { + } finally { if (theConn != null) { theConn.close(); } @@ -2976,8 +2898,7 @@ public class MessageConsumerTest extends JMSTestCase { durable.close(); sess1.unsubscribe("mySubscription"); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3055,8 +2976,7 @@ public class MessageConsumerTest extends JMSTestCase { durable4.close(); sess3.unsubscribe("mySubscription1"); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3167,8 +3087,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNull(tm3); durable.close(); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3256,8 +3175,7 @@ public class MessageConsumerTest extends JMSTestCase { durable2.close(); sess2.unsubscribe("mySubscription"); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3335,8 +3253,7 @@ public class MessageConsumerTest extends JMSTestCase { sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE); sess1.unsubscribe("mySubscription"); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3362,11 +3279,9 @@ public class MessageConsumerTest extends JMSTestCase { try { sess1.unsubscribe("non-existent subscription"); ProxyAssertSupport.fail(); + } catch (JMSException e) { } - catch (JMSException e) { - } - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3392,12 +3307,10 @@ public class MessageConsumerTest extends JMSTestCase { try { sess1.createDurableSubscriber(ActiveMQServerTestCase.topic1, "mySubscription"); ProxyAssertSupport.fail(); - } - catch (JMSException e) { + } catch (JMSException e) { } - } - finally { + } finally { if (conn1 != null) { conn1.close(); } @@ -3440,8 +3353,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("testRedeliveredDifferentSessions", tm3.getText()); ProxyAssertSupport.assertTrue(tm3.getJMSRedelivered()); - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -3488,8 +3400,7 @@ public class MessageConsumerTest extends JMSTestCase { conn = null; ProxyAssertSupport.assertFalse(listener.failed); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3533,8 +3444,7 @@ public class MessageConsumerTest extends JMSTestCase { conn.close(); conn = null; - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3670,8 +3580,7 @@ public class MessageConsumerTest extends JMSTestCase { conn = null; - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3712,8 +3621,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(listener.exception); ProxyAssertSupport.assertTrue(listener.exception instanceof javax.jms.IllegalStateException); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3754,8 +3662,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(listener.exception); ProxyAssertSupport.assertTrue(listener.exception instanceof javax.jms.IllegalStateException); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3796,8 +3703,7 @@ public class MessageConsumerTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(listener.exception); ProxyAssertSupport.assertTrue(listener.exception instanceof javax.jms.IllegalStateException); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -3828,8 +3734,7 @@ public class MessageConsumerTest extends JMSTestCase { public void onMessage(Message message) { try { conn.close(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); @@ -3851,8 +3756,7 @@ public class MessageConsumerTest extends JMSTestCase { public void onMessage(Message message) { try { conn.stop(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); @@ -3874,8 +3778,7 @@ public class MessageConsumerTest extends JMSTestCase { public void onMessage(Message message) { try { session.close(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); @@ -3920,8 +3823,7 @@ public class MessageConsumerTest extends JMSTestCase { latch.countDown(); } throw new RuntimeException("Aardvark"); - } - else if (count == 2) { + } else if (count == 2) { if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) { // Message should be immediately redelivered if (!"a".equals(tm.getText())) { @@ -3932,47 +3834,40 @@ public class MessageConsumerTest extends JMSTestCase { failed("Message was supposed to be a redelivery"); latch.countDown(); } - } - else { + } else { // Transacted or CLIENT_ACKNOWLEDGE - next message should be delivered if (!"b".equals(tm.getText())) { failed("Should be b but was " + tm.getText()); latch.countDown(); } } - } - else if (count == 3) { + } else if (count == 3) { if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) { if (!"b".equals(tm.getText())) { failed("Should be b but was " + tm.getText()); latch.countDown(); } - } - else { + } else { if (!"c".equals(tm.getText())) { failed("Should be c but was " + tm.getText()); latch.countDown(); } latch.countDown(); } - } - - else if (count == 4) { + } else if (count == 4) { if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) { if (!"c".equals(tm.getText())) { failed("Should be c but was " + tm.getText()); latch.countDown(); } latch.countDown(); - } - else { + } else { // Shouldn't get a 4th message failed("Shouldn't get a 4th message"); latch.countDown(); } } - } - catch (JMSException e) { + } catch (JMSException e) { log.error(e.getMessage(), e); failed("Got a JMSException " + e.toString()); latch.countDown(); @@ -4019,8 +3914,7 @@ public class MessageConsumerTest extends JMSTestCase { if (transacted) { sess.rollback(); messageOrder += "RB "; - } - else { + } else { messageOrder += "RC "; sess.recover(); } @@ -4049,15 +3943,13 @@ public class MessageConsumerTest extends JMSTestCase { } if (transacted) { sess.commit(); - } - else { + } else { tm.acknowledge(); } latch.countDown(); } count++; - } - catch (JMSException e) { + } catch (JMSException e) { failed = true; latch.countDown(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageProducerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageProducerTest.java index a9ec1c4eae..7534542131 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageProducerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageProducerTest.java @@ -105,8 +105,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(m.getJMSMessageID(), r.getJMSMessageID()); ProxyAssertSupport.assertEquals("test", r.getText()); - } - finally { + } finally { if (pconn != null) { pconn.close(); } @@ -150,8 +149,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(m.getJMSMessageID(), r.getJMSMessageID()); ProxyAssertSupport.assertEquals("test", r.getText()); - } - finally { + } finally { pconn.close(); cconn.close(); } @@ -179,8 +177,7 @@ public class MessageProducerTest extends JMSTestCase { public synchronized void run() { try { prod.send(m); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); ex = e; @@ -233,8 +230,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("test", m2.getText()); t.join(); - } - finally { + } finally { pconn.close(); cconn.close(); } @@ -263,8 +259,7 @@ public class MessageProducerTest extends JMSTestCase { public void run() { try { anonProducer.send(ActiveMQServerTestCase.topic2, m1); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -274,8 +269,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID()); log.debug("ending test"); - } - finally { + } finally { pconn.close(); cconn.close(); } @@ -303,8 +297,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals("something", rec.getText()); - } - finally { + } finally { pconn.close(); cconn.close(); } @@ -319,8 +312,7 @@ public class MessageProducerTest extends JMSTestCase { MessageProducer p = ps.createProducer(ActiveMQServerTestCase.topic1); Destination dest = p.getDestination(); ProxyAssertSupport.assertEquals(dest, ActiveMQServerTestCase.topic1); - } - finally { + } finally { pconn.close(); } } @@ -337,12 +329,10 @@ public class MessageProducerTest extends JMSTestCase { try { p.getDestination(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -356,12 +346,10 @@ public class MessageProducerTest extends JMSTestCase { try { ps.createProducer(ActiveMQJMSClient.createTopic("NoSuchTopic")); ProxyAssertSupport.fail("should throw exception"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -379,8 +367,7 @@ public class MessageProducerTest extends JMSTestCase { MessageProducer p = ps.createProducer(ActiveMQServerTestCase.topic1); ProxyAssertSupport.assertFalse(p.getDisableMessageID()); - } - finally { + } finally { pconn.close(); } } @@ -398,12 +385,10 @@ public class MessageProducerTest extends JMSTestCase { try { p.getDisableMessageID(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -422,8 +407,7 @@ public class MessageProducerTest extends JMSTestCase { MessageProducer qp = ps.createProducer(queue1); ProxyAssertSupport.assertFalse(tp.getDisableMessageTimestamp()); ProxyAssertSupport.assertFalse(qp.getDisableMessageTimestamp()); - } - finally { + } finally { pconn.close(); } } @@ -464,8 +448,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertTrue(timestamp >= t1); ProxyAssertSupport.assertTrue(timestamp <= t2); - } - finally { + } finally { pconn.close(); cconn.close(); } @@ -484,12 +467,10 @@ public class MessageProducerTest extends JMSTestCase { try { p.getDisableMessageTimestamp(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -509,8 +490,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(DeliveryMode.PERSISTENT, tp.getDeliveryMode()); ProxyAssertSupport.assertEquals(DeliveryMode.PERSISTENT, qp.getDeliveryMode()); - } - finally { + } finally { pconn.close(); } } @@ -528,8 +508,7 @@ public class MessageProducerTest extends JMSTestCase { p.setDeliveryMode(DeliveryMode.PERSISTENT); ProxyAssertSupport.assertEquals(DeliveryMode.PERSISTENT, p.getDeliveryMode()); - } - finally { + } finally { pconn.close(); } } @@ -547,12 +526,10 @@ public class MessageProducerTest extends JMSTestCase { try { p.getDeliveryMode(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -572,8 +549,7 @@ public class MessageProducerTest extends JMSTestCase { ProxyAssertSupport.assertEquals(4, tp.getPriority()); ProxyAssertSupport.assertEquals(4, qp.getPriority()); - } - finally { + } finally { pconn.close(); } } @@ -591,8 +567,7 @@ public class MessageProducerTest extends JMSTestCase { p.setPriority(0); ProxyAssertSupport.assertEquals(0, p.getPriority()); - } - finally { + } finally { pconn.close(); } } @@ -610,12 +585,10 @@ public class MessageProducerTest extends JMSTestCase { try { p.getPriority(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { pconn.close(); } } @@ -660,8 +633,7 @@ public class MessageProducerTest extends JMSTestCase { try { p.setTimeToLive(100L); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } } @@ -744,8 +716,7 @@ public class MessageProducerTest extends JMSTestCase { public void onCompletion(Message message) { try { p.close(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); @@ -771,8 +742,7 @@ public class MessageProducerTest extends JMSTestCase { public void onCompletion(Message message) { try { conn.close(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); @@ -798,8 +768,7 @@ public class MessageProducerTest extends JMSTestCase { public void onCompletion(Message message) { try { session.close(); - } - catch (JMSException e) { + } catch (JMSException e) { this.exception = e; } latch.countDown(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageWithReadResolveTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageWithReadResolveTest.java index 48fc753e1c..2395f6f1ca 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageWithReadResolveTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageWithReadResolveTest.java @@ -99,8 +99,7 @@ public class MessageWithReadResolveTest extends JMSTestCase { this.id = id; if (useSimpleObject) { clazz = String.class; - } - else { + } else { clazz = TestEnum.class; } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MiscellaneousTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MiscellaneousTest.java index d2eb533ca1..9ee99b0def 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MiscellaneousTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MiscellaneousTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests; -import java.util.Enumeration; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Message; @@ -27,6 +25,7 @@ import javax.jms.MessageProducer; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.Enumeration; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; import org.junit.After; @@ -79,8 +78,7 @@ public class MiscellaneousTest extends JMSTestCase { TextMessage bm = (TextMessage) e.nextElement(); ProxyAssertSupport.assertEquals("message one", bm.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -102,8 +100,7 @@ public class MiscellaneousTest extends JMSTestCase { MessageProducer prod = s.createProducer(queue1); Message m = s.createMessage(); prod.send(m); - } - finally { + } finally { if (c != null) { c.close(); } @@ -120,8 +117,7 @@ public class MiscellaneousTest extends JMSTestCase { try { cons.close(); result.setSuccess(); - } - catch (Exception e) { + } catch (Exception e) { result.setFailure(e); } } @@ -156,8 +152,7 @@ public class MiscellaneousTest extends JMSTestCase { MessageProducer prod = s.createProducer(queue1); Message m = s.createMessage(); prod.send(m); - } - finally { + } finally { if (c != null) { c.close(); } @@ -174,8 +169,7 @@ public class MiscellaneousTest extends JMSTestCase { try { cons.close(); result.setSuccess(); - } - catch (Exception e) { + } catch (Exception e) { result.setFailure(e); } } @@ -216,8 +210,7 @@ public class MiscellaneousTest extends JMSTestCase { session1.close(); session2.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/NonDurableSubscriberTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/NonDurableSubscriberTest.java index b3595fdab1..ad0530fe3f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/NonDurableSubscriberTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/NonDurableSubscriberTest.java @@ -50,8 +50,7 @@ public class NonDurableSubscriberTest extends JMSTestCase { try { ts.createSubscriber(null); ProxyAssertSupport.fail("this should fail"); - } - catch (javax.jms.InvalidDestinationException e) { + } catch (javax.jms.InvalidDestinationException e) { // OK } } @@ -69,8 +68,7 @@ public class NonDurableSubscriberTest extends JMSTestCase { try { ts.unsubscribe("invalid-subscription-name"); ProxyAssertSupport.fail("this should fail"); - } - catch (javax.jms.InvalidDestinationException e) { + } catch (javax.jms.InvalidDestinationException e) { // OK } } @@ -85,8 +83,7 @@ public class NonDurableSubscriberTest extends JMSTestCase { try { s.createSubscriber(ActiveMQServerTestCase.topic1, "=TEST 'test'", false); ProxyAssertSupport.fail("this should fail"); - } - catch (InvalidSelectorException e) { + } catch (InvalidSelectorException e) { // OK } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/PersistenceTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/PersistenceTest.java index 69e2080921..3dfca60403 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/PersistenceTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/PersistenceTest.java @@ -68,8 +68,7 @@ public class PersistenceTest extends JMSTestCase { } ProxyAssertSupport.assertEquals("message" + i, tm.getText()); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -151,8 +150,7 @@ public class PersistenceTest extends JMSTestCase { ProxyAssertSupport.assertEquals(3, tm.getIntProperty("JMSXDeliveryCount")); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -261,8 +259,7 @@ public class PersistenceTest extends JMSTestCase { TextMessage t = (TextMessage) cons.receive(500); ProxyAssertSupport.assertNull(t); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -370,8 +367,7 @@ public class PersistenceTest extends JMSTestCase { TextMessage t = (TextMessage) cons.receiveNoWait(); ProxyAssertSupport.assertNull(t); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -423,8 +419,7 @@ public class PersistenceTest extends JMSTestCase { ds.close(); s.unsubscribe("sub"); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -506,8 +501,7 @@ public class PersistenceTest extends JMSTestCase { sessConsume.unsubscribe("sub1"); sessConsume.unsubscribe("sub2"); sessConsume.unsubscribe("sub3"); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueReceiverTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueReceiverTest.java index 1b56ee21a3..8770dc277f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueReceiverTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueReceiverTest.java @@ -59,8 +59,7 @@ public class QueueReceiverTest extends JMSTestCase { TextMessage rm = (TextMessage) qreceiver.receive(1000); ProxyAssertSupport.assertEquals("two", rm.getText()); - } - finally { + } finally { if (qc != null) { qc.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueTest.java index 6f502ff713..f47dfb690f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/QueueTest.java @@ -50,8 +50,7 @@ public class QueueTest extends JMSTestCase { TextMessage m = (TextMessage) c.receive(); ProxyAssertSupport.assertEquals("payload", m.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -157,8 +156,7 @@ public class QueueTest extends JMSTestCase { s2.commit(); checkEmpty(queue1); - } - finally { + } finally { if (conn1 != null) { conn1.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SecurityTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SecurityTest.java index 5cbddd65b1..3d281dfef5 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SecurityTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SecurityTest.java @@ -69,8 +69,7 @@ public class SecurityTest extends JMSTestCase { try { Connection conn1 = createConnection("guest", "not.the.valid.password"); ProxyAssertSupport.fail(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { // Expected } } @@ -84,8 +83,7 @@ public class SecurityTest extends JMSTestCase { try { Connection conn1 = createConnection("not.the.valid.user", "not.the.valid.password"); ProxyAssertSupport.fail(); - } - catch (JMSSecurityException e) { + } catch (JMSSecurityException e) { // Expected } } @@ -104,8 +102,7 @@ public class SecurityTest extends JMSTestCase { conn = cf.createConnection("guest", "guest"); String clientID = conn.getClientID(); ProxyAssertSupport.assertEquals("Invalid ClientID", "dilbert-id", clientID); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -136,11 +133,9 @@ public class SecurityTest extends JMSTestCase { conn = cf.createConnection("guest", "guest"); conn.setClientID("myID"); ProxyAssertSupport.fail(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Expected - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -158,8 +153,7 @@ public class SecurityTest extends JMSTestCase { try { conn.setClientID("myID"); ProxyAssertSupport.fail(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Expected } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SessionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SessionTest.java index 5f2ad279bb..63b8561cc3 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SessionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SessionTest.java @@ -112,8 +112,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { sess.createQueue("QueueThatDoesNotExist"); ProxyAssertSupport.fail(); - } - catch (JMSException e) { + } catch (JMSException e) { } conn.close(); } @@ -126,8 +125,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { s.createQueue("TestQueue"); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } c.close(); @@ -144,8 +142,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { sess.createQueue("TestTopic"); ProxyAssertSupport.fail("should throw JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // OK } conn.close(); @@ -178,8 +175,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { sess.createTopic("TopicThatDoesNotExist"); ProxyAssertSupport.fail("should throw JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // OK } conn.close(); @@ -193,8 +189,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { s.createTopic("TestTopic"); ProxyAssertSupport.fail("should throw IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } c.close(); @@ -208,8 +203,7 @@ public class SessionTest extends ActiveMQServerTestCase { try { sess.createTopic("TestQueue"); ProxyAssertSupport.fail("should throw JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // OK } conn.close(); @@ -244,8 +238,7 @@ public class SessionTest extends ActiveMQServerTestCase { public void run() { try { m = consumer.receive(3000); - } - catch (Exception e) { + } catch (Exception e) { exceptionThrown = true; } } @@ -290,15 +283,13 @@ public class SessionTest extends ActiveMQServerTestCase { try { sess.rollback(); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } try { sess.commit(); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { } conn.close(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java index c75bfc9054..87912781ef 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java @@ -75,16 +75,14 @@ public class TemporaryDestinationTest extends JMSTestCase { try { tempTopic.delete(); ProxyAssertSupport.fail(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // Can't delete temp dest if there are open consumers } consumer.close(); tempTopic.delete(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -121,8 +119,7 @@ public class TemporaryDestinationTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(m2); ProxyAssertSupport.assertEquals(messageText, m2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -146,12 +143,10 @@ public class TemporaryDestinationTest extends JMSTestCase { try { producerSession.createTemporaryQueue(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -177,14 +172,12 @@ public class TemporaryDestinationTest extends JMSTestCase { tempQueue.delete(); ProxyAssertSupport.fail("Should throw JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // Should fail - you can't delete a temp queue if it has active consumers } consumer.close(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -210,14 +203,12 @@ public class TemporaryDestinationTest extends JMSTestCase { tempTopic.delete(); ProxyAssertSupport.fail("Should throw JMSException"); - } - catch (JMSException e) { + } catch (JMSException e) { // Should fail - you can't delete a temp topic if it has active consumers } consumer.close(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -265,11 +256,9 @@ public class TemporaryDestinationTest extends JMSTestCase { try { producer.send(m); ProxyAssertSupport.fail(); + } catch (JMSException e) { } - catch (JMSException e) { - } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -306,8 +295,7 @@ public class TemporaryDestinationTest extends JMSTestCase { // this is needed to make sure the main thread has enough time to block Thread.sleep(500); producer.send(m); - } - catch (Exception e) { + } catch (Exception e) { log.error(e); } } @@ -321,8 +309,7 @@ public class TemporaryDestinationTest extends JMSTestCase { ProxyAssertSupport.assertEquals(messageText, m2.getText()); t.join(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -346,12 +333,10 @@ public class TemporaryDestinationTest extends JMSTestCase { try { producerSession.createTemporaryTopic(); ProxyAssertSupport.fail("should throw exception"); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { // OK } - } - finally { + } finally { if (producerConnection != null) { producerConnection.close(); } @@ -370,8 +355,7 @@ public class TemporaryDestinationTest extends JMSTestCase { try { ic.lookup("/topic/" + topicName); ProxyAssertSupport.fail("The temporary queue should not be bound to JNDI"); - } - catch (NamingException e) { + } catch (NamingException e) { // Expected } } @@ -388,8 +372,7 @@ public class TemporaryDestinationTest extends JMSTestCase { try { ic.lookup("/queue/" + queueName); ProxyAssertSupport.fail("The temporary queue should not be bound to JNDI"); - } - catch (NamingException e) { + } catch (NamingException e) { // Expected } } @@ -412,8 +395,7 @@ public class TemporaryDestinationTest extends JMSTestCase { try { sessFromAnotherConn.createConsumer(tempQueue); ProxyAssertSupport.fail("Only temporary destination's own connection is allowed to create MessageConsumers for them."); - } - catch (JMSException e) { + } catch (JMSException e) { } conn.close(); @@ -438,8 +420,7 @@ public class TemporaryDestinationTest extends JMSTestCase { try { sessFromAnotherConn.createConsumer(tempTopic); ProxyAssertSupport.fail("Only temporary destination's own connection is allowed to create MessageConsumers for them."); - } - catch (JMSException e) { + } catch (JMSException e) { } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TopicTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TopicTest.java index bbeb176644..c2bf023acc 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TopicTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TopicTest.java @@ -166,8 +166,7 @@ public class TopicTest extends JMSTestCase { try { Wibble2 w = (Wibble2) om.getObject(); - } - catch (Exception e) { + } catch (Exception e) { failed = true; } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TransactedSessionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TransactedSessionTest.java index 6f31649a58..213ecdc8de 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TransactedSessionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TransactedSessionTest.java @@ -70,8 +70,7 @@ public class TransactedSessionTest extends JMSTestCase { Long i = getMessageCountForQueue("Queue1"); ProxyAssertSupport.assertEquals(1, i.intValue()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -110,8 +109,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertTrue(mRec1.getJMSRedelivered()); sess1.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -153,8 +151,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertTrue(mRec.getJMSRedelivered()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -204,8 +201,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(mRec2); ProxyAssertSupport.assertEquals(mRec.getText(), mRec2.getText()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -240,8 +236,7 @@ public class TransactedSessionTest extends JMSTestCase { Message m = consumer.receive(500); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -286,8 +281,7 @@ public class TransactedSessionTest extends JMSTestCase { } ProxyAssertSupport.assertEquals(NUM_MESSAGES, count); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -349,8 +343,7 @@ public class TransactedSessionTest extends JMSTestCase { Message m = consumer.receive(500); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -391,8 +384,7 @@ public class TransactedSessionTest extends JMSTestCase { Message m = consumer.receive(500); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -430,8 +422,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertTrue(mRec.getJMSRedelivered()); sess.commit(); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -488,8 +479,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertEquals(2, tm.getIntProperty("JMSXDeliveryCount")); ProxyAssertSupport.assertTrue(tm.getJMSRedelivered()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -573,8 +563,7 @@ public class TransactedSessionTest extends JMSTestCase { } checkEmpty(queue1); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -619,8 +608,7 @@ public class TransactedSessionTest extends JMSTestCase { } ProxyAssertSupport.assertEquals(NUM_MESSAGES, count); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -660,8 +648,7 @@ public class TransactedSessionTest extends JMSTestCase { lastBatchTime = System.currentTimeMillis(); producerSess.commit(); } - } - catch (JMSException e) { + } catch (JMSException e) { //ignore connection closed by consumer } @@ -669,16 +656,14 @@ public class TransactedSessionTest extends JMSTestCase { if (!started) { Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); started = true; - } - else { + } else { if (myReceiver.failed) { throw myReceiver.e; } } } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -716,15 +701,13 @@ public class TransactedSessionTest extends JMSTestCase { conn.close(); } count++; - } - catch (JMSException e) { + } catch (JMSException e) { this.e = e; failed = true; try { conn.close(); - } - catch (JMSException e1) { + } catch (JMSException e1) { e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } @@ -746,14 +729,12 @@ public class TransactedSessionTest extends JMSTestCase { boolean thrown = false; try { producerSess.commit(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { thrown = true; } ProxyAssertSupport.assertTrue(thrown); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -823,8 +804,7 @@ public class TransactedSessionTest extends JMSTestCase { } ProxyAssertSupport.assertEquals(NUM_MESSAGES, count); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -888,8 +868,7 @@ public class TransactedSessionTest extends JMSTestCase { Message m = consumer.receive(500); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -930,8 +909,7 @@ public class TransactedSessionTest extends JMSTestCase { Message m = consumer.receive(500); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -953,8 +931,7 @@ public class TransactedSessionTest extends JMSTestCase { boolean thrown = false; try { producerSess.rollback(); - } - catch (javax.jms.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { thrown = true; } @@ -1027,8 +1004,7 @@ public class TransactedSessionTest extends JMSTestCase { ProxyAssertSupport.assertEquals(NUM_MESSAGES, count); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java index 58e8bd86b8..47e43de676 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java @@ -88,17 +88,14 @@ public class BodyIsAssignableFromTest extends MessageBodyTestCase { Assert.assertTrue("correct type " + c, c.isInstance(receivedBody)); if (body.getClass().isAssignableFrom(byte[].class)) { Arrays.equals((byte[]) body, (byte[]) receivedBody); - } - else { + } else { Assert.assertEquals("clazz=" + c + ", bodies must match.. " + body.equals(receivedBody), body, receivedBody); } - } - else { + } else { try { Object foo = msg.getBody(c); Assert.fail("expected a " + MessageFormatException.class); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { // expected } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSDeliveryModeHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSDeliveryModeHeaderTest.java index 5e35e8cbe2..1c066d7760 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSDeliveryModeHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSDeliveryModeHeaderTest.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Test; - import javax.jms.DeliveryMode; import javax.jms.Message; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.Test; public class JMSDeliveryModeHeaderTest extends MessageHeaderTestBase { // Constants ----------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java index 0babc3cc53..188306f42d 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicBoolean; - import javax.jms.DeliveryMode; import javax.jms.Message; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.artemis.jms.client.ActiveMQMessage; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; @@ -119,11 +118,9 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { public void run() { try { expectedMessage = queueConsumer.receive(100); - } - catch (Exception e) { + } catch (Exception e) { log.trace("receive() exits with an exception", e); - } - finally { + } finally { latch.countDown(); } } @@ -148,11 +145,9 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { long t1 = System.currentTimeMillis(); expectedMessage = queueConsumer.receive(timeToWaitForReceive); effectiveReceiveTime = System.currentTimeMillis() - t1; - } - catch (Exception e) { + } catch (Exception e) { log.trace("receive() exits with an exception", e); - } - finally { + } finally { receiverLatch.countDown(); } } @@ -180,12 +175,10 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { testFailed = true; return; } - } - catch (Exception e) { + } catch (Exception e) { log.error("This exception will fail the test", e); testFailed = true; - } - finally { + } finally { senderLatch.countDown(); } } @@ -246,16 +239,13 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { if (expectedMessage == null) { received.set(false); } - } - catch (Exception e) { + } catch (Exception e) { log.trace("receive() exits with an exception", e); ProxyAssertSupport.fail(); - } - catch (Throwable t) { + } catch (Throwable t) { log.trace("receive() exits with a throwable", t); ProxyAssertSupport.fail(); - } - finally { + } finally { latch.countDown(); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSMessageIDHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSMessageIDHeaderTest.java index 40d20663f3..82a8ae42a2 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSMessageIDHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSMessageIDHeaderTest.java @@ -51,8 +51,7 @@ public class JMSMessageIDHeaderTest extends MessageHeaderTestBase { queueProducer.send(m); ProxyAssertSupport.assertFalse("ID:something".equals(m.getJMSMessageID())); - } - finally { + } finally { removeAllMessages(queue1.getQueueName(), true); } } @@ -67,8 +66,7 @@ public class JMSMessageIDHeaderTest extends MessageHeaderTestBase { ProxyAssertSupport.assertNotNull(m.getJMSMessageID()); ProxyAssertSupport.assertTrue(m.getJMSMessageID().startsWith("ID:")); - } - finally { + } finally { removeAllMessages(queue1.getQueueName(), true); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSReplyToHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSReplyToHeaderTest.java index 6a9c3ee9e4..5556cc5650 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSReplyToHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSReplyToHeaderTest.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Test; - import javax.jms.Message; import javax.jms.TemporaryQueue; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.Test; /** * A JMSReplyToHeaderTest diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTimestampHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTimestampHeaderTest.java index ae16615b4b..8b4cb266d4 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTimestampHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTimestampHeaderTest.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Test; - import javax.jms.Message; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.Test; public class JMSTimestampHeaderTest extends MessageHeaderTestBase { // Constants ----------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTypeHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTypeHeaderTest.java index 8ef8fd8d60..c68d43c52e 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTypeHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSTypeHeaderTest.java @@ -16,11 +16,10 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Test; - import javax.jms.Message; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.Test; public class JMSTypeHeaderTest extends MessageHeaderTestBase { // Constants ----------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java index 4614a6ed05..bf4466d234 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java @@ -89,8 +89,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m.writeObject(new Object()); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { // OK } @@ -98,94 +97,81 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m.readBoolean(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readShort(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readChar(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readInt(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readLong(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readFloat(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readDouble(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readUTF(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readUnsignedByte(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.readUnsignedShort(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { byte[] bytes = new byte[333]; m.readBytes(bytes); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { byte[] bytes = new byte[333]; m.readBytes(bytes, 111); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } try { m.getBodyLength(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { // OK } @@ -241,88 +227,77 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.readBoolean(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readByte(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readChar(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readDouble(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readFloat(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readInt(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readLong(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readShort(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readUnsignedByte(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readUnsignedShort(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readUTF(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } @@ -330,81 +305,70 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.writeBoolean(myBool); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeByte(myByte); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeShort(myShort); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeChar(myChar); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeInt(myInt); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeLong(myLong); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeFloat(myFloat); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeDouble(myDouble); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeUTF(myString); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeBytes(myBytes); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } try { m2.writeObject(myString); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { // OK } @@ -430,8 +394,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getBodyLength(); ProxyAssertSupport.fail(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { // OK } @@ -483,8 +446,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m1.setObject("myIllegal", new Object()); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageFormatException e) { + } catch (javax.jms.MessageFormatException e) { } queueProducer.send(m1); @@ -506,57 +468,49 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.setBoolean("myBool", myBool); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setByte("myByte", myByte); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setShort("myShort", myShort); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setInt("myInt", myInt); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setLong("myLong", myLong); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setFloat("myFloat", myFloat); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setDouble("myDouble", myDouble); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setString("myString", myString); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } ProxyAssertSupport.assertTrue(m2.itemExists("myBool")); @@ -597,43 +551,37 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getByte("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShort("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getInt("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLong("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDouble("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // byte item can be read as short, int, long or String @@ -646,22 +594,19 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getBoolean("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDouble("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // short item can be read as int, long or String @@ -673,29 +618,25 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getByte("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBoolean("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDouble("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // int item can be read as long or String @@ -706,36 +647,31 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getShort("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByte("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBoolean("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDouble("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // long item can be read as String @@ -745,43 +681,37 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getInt("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShort("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByte("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBoolean("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDouble("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // float can be read as double or String @@ -792,36 +722,31 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getInt("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShort("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLong("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByte("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBoolean("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // double can be read as String @@ -831,43 +756,37 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.getFloat("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getInt("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShort("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByte("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBoolean("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloat("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } m2.clearBody(); @@ -899,38 +818,32 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m3.getByte("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getShort("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getInt("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getLong("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getFloat("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getDouble("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -979,8 +892,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m4.setObject(obj); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } m4.clearBody(); @@ -1034,59 +946,50 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m.writeObject(new Object()); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // Reading should not be possible when message is read-write try { m.readBoolean(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readShort(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readChar(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readInt(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readLong(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readFloat(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { m.readDouble(); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } try { byte[] bytes = new byte[333]; m.readBytes(bytes); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotReadableException e) { + } catch (javax.jms.MessageNotReadableException e) { } queueProducer.send(m); @@ -1145,122 +1048,104 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.readBoolean(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readByte(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readChar(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readDouble(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readFloat(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readInt(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readLong(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } try { m2.readShort(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } // Message should not be writable in read-only mode try { m2.writeBoolean(myBool); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeByte(myByte); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeShort(myShort); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeChar(myChar); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeInt(myInt); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeLong(myLong); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeFloat(myFloat); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeDouble(myDouble); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeBytes(myBytes); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } try { m2.writeObject(myString); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageNotWriteableException e) { + } catch (javax.jms.MessageNotWriteableException e) { } m2.reset(); @@ -1282,8 +1167,7 @@ public class MessageBodyTest extends MessageBodyTestCase { // Should now be write only m2.readBoolean(); ProxyAssertSupport.fail(); - } - catch (MessageNotReadableException e) { + } catch (MessageNotReadableException e) { } m2.writeBoolean(myBool); @@ -1294,8 +1178,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.readBoolean(); ProxyAssertSupport.fail(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } // Test that changing the received message doesn't affect the sent message @@ -1340,8 +1223,7 @@ public class MessageBodyTest extends MessageBodyTestCase { try { m2.setText("Should be read-only"); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } m2.clearBody(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java index dcb5d2f1fa..7aa0af34b2 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.io.File; -import java.io.Serializable; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; - import javax.jms.BytesMessage; import javax.jms.DeliveryMode; import javax.jms.Destination; @@ -36,6 +30,11 @@ import javax.jms.TextMessage; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; +import java.io.File; +import java.io.Serializable; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; @@ -189,8 +188,7 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m1.setObjectProperty("myIllegal", new Object()); ProxyAssertSupport.fail(); - } - catch (javax.jms.MessageFormatException e) { + } catch (javax.jms.MessageFormatException e) { } queueProducer.send(m1); @@ -212,57 +210,49 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.setBooleanProperty("myBool", myBool); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setByteProperty("myByte", myByte); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setShortProperty("myShort", myShort); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setIntProperty("myInt", myInt); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setLongProperty("myLong", myLong); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setFloatProperty("myFloat", myFloat); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setDoubleProperty("myDouble", myDouble); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } try { m2.setStringProperty("myString", myString); ProxyAssertSupport.fail(); - } - catch (MessageNotWriteableException e) { + } catch (MessageNotWriteableException e) { } ProxyAssertSupport.assertTrue(m2.propertyExists("myBool")); @@ -304,43 +294,37 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getByteProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getIntProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLongProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // byte property can be read as short, int, long or String @@ -353,22 +337,19 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getBooleanProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // short property can be read as int, long or String @@ -380,29 +361,25 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getByteProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // int property can be read as long or String @@ -413,36 +390,31 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getShortProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // long property can be read as String @@ -452,43 +424,37 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getIntProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // float property can be read as double or String @@ -499,36 +465,31 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getIntProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLongProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } // double property can be read as String @@ -538,43 +499,37 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m2.getFloatProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getIntProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } m2.clearProperties(); @@ -609,38 +564,32 @@ public class MessageHeaderTest extends MessageHeaderTestBase { try { m3.getByteProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getShortProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getIntProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getLongProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getFloatProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m3.getDoubleProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTestBase.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTestBase.java index 219c4c9145..0f6e77cd56 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTestBase.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTestBase.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.util.Arrays; -import java.util.Enumeration; - import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -32,6 +29,8 @@ import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TextMessage; +import java.util.Arrays; +import java.util.Enumeration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; @@ -88,26 +87,22 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { corrIDBytes = m1.getJMSCorrelationIDAsBytes(); - } - catch (JMSException e) { + } catch (JMSException e) { // correlation ID specified as String corrIDString = m1.getJMSCorrelationID(); } if (corrIDBytes != null) { ProxyAssertSupport.assertTrue(Arrays.equals(corrIDBytes, m2.getJMSCorrelationIDAsBytes())); - } - else if (corrIDString != null) { + } else if (corrIDString != null) { ProxyAssertSupport.assertEquals(corrIDString, m2.getJMSCorrelationID()); - } - else { + } else { // no correlation id try { byte[] corrID2 = m2.getJMSCorrelationIDAsBytes(); ProxyAssertSupport.assertNull(corrID2); - } - catch (JMSException e) { + } catch (JMSException e) { // correlatin ID specified as String String corrID2 = m2.getJMSCorrelationID(); ProxyAssertSupport.assertNull(corrID2); @@ -153,8 +148,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { booleanProperty = m1.getBooleanProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a boolean } @@ -167,8 +161,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { byteProperty = m1.getByteProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a byte } @@ -181,8 +174,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { shortProperty = m1.getShortProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a short } @@ -195,8 +187,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { intProperty = m1.getIntProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not an int } @@ -209,8 +200,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { longProperty = m1.getLongProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a long } @@ -223,8 +213,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { floatProperty = m1.getFloatProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a float } @@ -237,8 +226,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { doubleProperty = m1.getDoubleProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a double } @@ -251,8 +239,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { stringProperty = m1.getStringProperty(name); found = true; - } - catch (JMSException e) { + } catch (JMSException e) { // not a String } @@ -276,16 +263,14 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { m1.readByte(); ProxyAssertSupport.fail("should throw MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } try { m2.readByte(); ProxyAssertSupport.fail("should throw MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } } @@ -319,16 +304,14 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { byte b1, b2; try { b1 = m1.readByte(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { m1eof = true; break; } try { b2 = m2.readByte(); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { m2eof = true; break; } @@ -340,8 +323,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { m2.readByte(); ProxyAssertSupport.fail("should throw MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } } @@ -350,8 +332,7 @@ public abstract class MessageHeaderTestBase extends ActiveMQServerTestCase { try { m1.readByte(); ProxyAssertSupport.fail("should throw MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { // OK } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessagePropertyConversionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessagePropertyConversionTest.java index 1283c087b2..f2a8904371 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessagePropertyConversionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessagePropertyConversionTest.java @@ -101,64 +101,55 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.setProperty(null, true); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, "string"); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, 1); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, 1.0); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, 1L); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, 1.10f); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, (byte) 1); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, (short) 1); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } try { producer.setProperty(null, new SimpleString("foo")); ProxyAssertSupport.fail("expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { //pass } } @@ -197,55 +188,45 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getByteProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("did not catch expected Exception -- boolean to byte"); } try { producer.getShortProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getIntProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getLongProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getFloatProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -253,11 +234,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getDoubleProperty("aboolean"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -283,22 +262,18 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getBooleanProperty("abyte"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getFloatProperty("abyte"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -307,11 +282,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getDoubleProperty("abyte"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -333,11 +306,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getBooleanProperty("ashort"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -346,11 +317,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getByteProperty("ashort"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -359,11 +328,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getFloatProperty("ashort"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -371,11 +338,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getDoubleProperty("ashort"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -392,11 +357,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getBooleanProperty("anint"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -404,11 +367,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getByteProperty("anint"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -416,33 +377,27 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getShortProperty("anint"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getFloatProperty("anint"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getDoubleProperty("anint"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -453,66 +408,54 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getBooleanProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getByteProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getShortProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getIntProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getFloatProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getDoubleProperty("along"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -527,44 +470,36 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getBooleanProperty("afloat"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getByteProperty("afloat"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getShortProperty("afloat"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getIntProperty("afloat"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -572,11 +507,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { producer.getLongProperty("afloat"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -587,55 +520,45 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getBooleanProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getByteProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getShortProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getIntProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } try { producer.getLongProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -643,11 +566,9 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { producer.getFloatProperty("adouble"); ProxyAssertSupport.fail("MessageFormatRuntimeException expected"); - } - catch (MessageFormatRuntimeException me) { + } catch (MessageFormatRuntimeException me) { //pass - } - catch (Exception ee) { + } catch (Exception ee) { ProxyAssertSupport.fail("Caught unexpected exception: " + ee); } @@ -719,43 +640,37 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getByteProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getIntProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLongProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myBool"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -780,22 +695,19 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getBooleanProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myByte"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -819,29 +731,25 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getByteProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myShort"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -864,36 +772,31 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getShortProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myInt"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -915,43 +818,37 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getIntProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getDoubleProperty("myLong"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -974,36 +871,31 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getIntProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getLongProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myFloat"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -1025,43 +917,37 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m2.getFloatProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getIntProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getShortProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getByteProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getBooleanProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } try { m2.getFloatProperty("myDouble"); ProxyAssertSupport.fail(); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -1120,38 +1006,32 @@ public class MessagePropertyConversionTest extends ActiveMQServerTestCase { try { m4.getByteProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m4.getShortProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m4.getIntProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m4.getLongProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m4.getFloatProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } try { m4.getDoubleProperty("myIllegal"); ProxyAssertSupport.fail(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageDeliveryTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageDeliveryTest.java index 37c530a5c3..21eeeca899 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageDeliveryTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageDeliveryTest.java @@ -16,19 +16,17 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Test; - -import java.io.Serializable; - import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TopicConnection; import javax.jms.TopicPublisher; import javax.jms.TopicSession; import javax.jms.TopicSubscriber; +import java.io.Serializable; import org.apache.activemq.artemis.jms.tests.ActiveMQServerTestCase; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.Test; /** * ObjectMessageDeliveryTest @@ -113,8 +111,7 @@ public class ObjectMessageDeliveryTest extends ActiveMQServerTestCase { TestObject ro3 = (TestObject) rm3.getObject(); ProxyAssertSupport.assertEquals(to3.text, ro3.text); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageTest.java index ddab13f6f9..bc952c41e1 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/ObjectMessageTest.java @@ -78,8 +78,7 @@ public class ObjectMessageTest extends MessageTestBase { ProxyAssertSupport.assertNotSame(testObject.getClass(), testObject2.getClass()); ProxyAssertSupport.assertNotSame(testObject.getClass().getClassLoader(), testObject2.getClass().getClassLoader()); ProxyAssertSupport.assertSame(testClassLoader, testObject2.getClass().getClassLoader()); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSBytesMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSBytesMessage.java index 8e8c6e417c..9fc193feae 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSBytesMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSBytesMessage.java @@ -16,19 +16,18 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.EOFException; -import java.io.IOException; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.MessageEOFException; import javax.jms.MessageFormatException; import javax.jms.MessageNotReadableException; import javax.jms.MessageNotWriteableException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.EOFException; +import java.io.IOException; public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMessage { // Static ------------------------------------------------------- @@ -61,11 +60,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readBoolean(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -75,11 +72,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readByte(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -89,11 +84,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readUnsignedByte(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -103,11 +96,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readShort(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -117,11 +108,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readUnsignedShort(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -131,11 +120,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readChar(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -145,11 +132,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readInt(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -159,11 +144,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readLong(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -173,11 +156,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readFloat(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -187,11 +168,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readDouble(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -201,11 +180,9 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.readUTF(); - } - catch (EOFException e) { + } catch (EOFException e) { throw new MessageEOFException(""); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -215,8 +192,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.read(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -226,8 +202,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess checkRead(); try { return m.read(value, 0, length); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -239,8 +214,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeBoolean(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -252,8 +226,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeByte(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -265,8 +238,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeShort(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -278,8 +250,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeChar(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -291,8 +262,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeInt(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -304,8 +274,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeLong(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -317,8 +286,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeFloat(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -330,8 +298,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeDouble(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -343,8 +310,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.writeUTF(value); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -356,8 +322,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.write(value, 0, value.length); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -369,8 +334,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } try { p.write(value, offset, length); - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } @@ -386,36 +350,26 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess } if (value instanceof String) { p.writeUTF((String) value); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { p.writeBoolean(((Boolean) value).booleanValue()); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { p.writeByte(((Byte) value).byteValue()); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { p.writeShort(((Short) value).shortValue()); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { p.writeInt(((Integer) value).intValue()); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { p.writeLong(((Long) value).longValue()); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { p.writeFloat(((Float) value).floatValue()); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { p.writeDouble(((Double) value).doubleValue()); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { p.write((byte[]) value, 0, ((byte[]) value).length); - } - else { + } else { throw new MessageFormatException("Invalid object for properties"); } - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } @@ -434,8 +388,7 @@ public class SimpleJMSBytesMessage extends SimpleJMSMessage implements BytesMess m = null; p = null; bodyWriteOnly = false; - } - catch (IOException e) { + } catch (IOException e) { throw new JMSException("IOException"); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMapMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMapMessage.java index 1d02f6189b..457dd59ee1 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMapMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMapMessage.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.MessageFormatException; import javax.jms.MessageNotWriteableException; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage { // Constants ----------------------------------------------------- @@ -181,35 +180,25 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Boolean) { content.put(name, value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { content.put(name, value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { content.put(name, value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { content.put(name, value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { content.put(name, value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { content.put(name, value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { content.put(name, value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { content.put(name, value); - } - else if (value instanceof String) { + } else if (value instanceof String) { content.put(name, value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { content.put(name, ((byte[]) value).clone()); - } - else { + } else { throw new MessageFormatException("Invalid object type."); } @@ -227,11 +216,9 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Boolean.valueOf((String) value).booleanValue(); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -248,11 +235,9 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Byte) { return ((Byte) value).byteValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Byte.parseByte((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -269,14 +254,11 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Byte) { return ((Byte) value).shortValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return ((Short) value).shortValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Short.parseShort((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -293,8 +275,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Character) { return ((Character) value).charValue(); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -311,17 +292,13 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage 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 Integer) { + } else if (value instanceof Integer) { return ((Integer) value).intValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Integer.parseInt((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -338,20 +315,15 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage 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 Long) { + } else if (value instanceof Long) { return ((Long) value).longValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Long.parseLong((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -368,11 +340,9 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Float) { return ((Float) value).floatValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Float.parseFloat((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -389,14 +359,11 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Float) { return ((Float) value).doubleValue(); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { return ((Double) value).doubleValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return Double.parseDouble((String) value); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -413,32 +380,23 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage if (value instanceof Boolean) { return ((Boolean) value).toString(); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { return ((Byte) value).toString(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { return ((Short) value).toString(); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { return ((Character) value).toString(); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { return ((Integer) value).toString(); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { return ((Long) value).toString(); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { return ((Float) value).toString(); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { return ((Double) value).toString(); - } - else if (value instanceof String) { + } else if (value instanceof String) { return (String) value; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } @@ -454,8 +412,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage } if (value instanceof byte[]) { return (byte[]) value; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMessage.java index dc53e7a47e..c112d6a121 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSMessage.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; /** * Foreign message implementation. Used for testing only. diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSObjectMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSObjectMessage.java index fcce6c2045..5b9bc3df5f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSObjectMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSObjectMessage.java @@ -16,10 +16,9 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.io.Serializable; - import javax.jms.JMSException; import javax.jms.ObjectMessage; +import java.io.Serializable; public class SimpleJMSObjectMessage extends SimpleJMSMessage implements ObjectMessage { // Constants ----------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSStreamMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSStreamMessage.java index 8edf307fd3..e43fe273db 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSStreamMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/SimpleJMSStreamMessage.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import java.util.ArrayList; -import java.util.List; - import javax.jms.JMSException; import javax.jms.MessageEOFException; import javax.jms.MessageFormatException; import javax.jms.MessageNotReadableException; import javax.jms.MessageNotWriteableException; import javax.jms.StreamMessage; +import java.util.ArrayList; +import java.util.List; public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMessage { // Constants ----------------------------------------------------- @@ -70,21 +69,17 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { position++; return ((Boolean) value).booleanValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { boolean result = Boolean.valueOf((String) value).booleanValue(); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } @@ -101,21 +96,17 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe offset = 0; if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { position++; return ((Byte) value).byteValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { byte result = Byte.parseByte((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -131,25 +122,20 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { position++; return ((Byte) value).shortValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { position++; return ((Short) value).shortValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { short result = Short.parseShort((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -165,16 +151,13 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { position++; return ((Character) value).charValue(); - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -190,29 +173,23 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { position++; return ((Byte) value).intValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { position++; return ((Short) value).intValue(); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { position++; return ((Integer) value).intValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { int result = Integer.parseInt((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -228,33 +205,26 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { position++; return ((Byte) value).longValue(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { position++; return ((Short) value).longValue(); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { position++; return ((Integer) value).longValue(); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { position++; return ((Long) value).longValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { long result = Long.parseLong((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -270,21 +240,17 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { position++; return ((Float) value).floatValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { float result = Float.parseFloat((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -300,25 +266,20 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { throw new NullPointerException("Value is null"); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { position++; return ((Float) value).doubleValue(); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { position++; return ((Double) value).doubleValue(); - } - else if (value instanceof String) { + } else if (value instanceof String) { double result = Double.parseDouble((String) value); position++; return result; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -335,48 +296,37 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe if (value == null) { position++; return null; - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { position++; return ((Boolean) value).toString(); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { position++; return ((Byte) value).toString(); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { position++; return ((Short) value).toString(); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { position++; return ((Character) value).toString(); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { position++; return ((Integer) value).toString(); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { position++; return ((Long) value).toString(); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { position++; return ((Float) value).toString(); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { position++; return ((Double) value).toString(); - } - else if (value instanceof String) { + } else if (value instanceof String) { position++; return (String) value; - } - else { + } else { throw new MessageFormatException("Invalid conversion"); } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -390,8 +340,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe Object myObj = content.get(position); if (myObj == null) { throw new NullPointerException("Value is null"); - } - else if (!(myObj instanceof byte[])) { + } else if (!(myObj instanceof byte[])) { throw new MessageFormatException("Invalid conversion"); } byte[] obj = (byte[]) myObj; @@ -415,16 +364,14 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe offset = 0; return obj.length - offset; - } - else { + } else { System.arraycopy(obj, offset, value, 0, value.length); offset += value.length; return value.length; } - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -440,8 +387,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe offset = 0; return value; - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -517,8 +463,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe } if (value == null) { content.add(null); - } - else { + } else { content.add(value); } } @@ -553,38 +498,27 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe } if (value == null) { content.add(null); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { content.add(value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { content.add(value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { content.add(value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { content.add(value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { content.add(value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { content.add(value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { content.add(value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { content.add(value); - } - else if (value instanceof String) { + } else if (value instanceof String) { content.add(value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { content.add(((byte[]) value).clone()); - } - else { + } else { throw new MessageFormatException("Invalid object type"); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/TextMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/TextMessageTest.java index 09cc2fa5e8..efdeadae97 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/TextMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/TextMessageTest.java @@ -16,16 +16,14 @@ */ package org.apache.activemq.artemis.jms.tests.message; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.TextMessage; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * A test that sends/receives text messages to the JMS provider and verifies their integrity. diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java index 29a6b70337..9fa08287ff 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.jms.tests.message.foreign; -import org.junit.Before; -import org.junit.After; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.ObjectMessage; import org.apache.activemq.artemis.jms.tests.message.SimpleJMSObjectMessage; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; +import org.junit.After; +import org.junit.Before; /** * Tests the delivery/receipt of a foreign object message diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java index ad56fbe19e..80f0ced630 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java @@ -91,8 +91,7 @@ public class SelectorTest extends ActiveMQServerTestCase { ProxyAssertSupport.assertEquals(rec.getJMSMessageID(), blueMessage.getJMSMessageID()); ProxyAssertSupport.assertEquals("blue", rec.getStringProperty("color")); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -140,8 +139,7 @@ public class SelectorTest extends ActiveMQServerTestCase { Message m = cons1.receiveNoWait(); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -221,8 +219,7 @@ public class SelectorTest extends ActiveMQServerTestCase { // } //ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -313,8 +310,7 @@ public class SelectorTest extends ActiveMQServerTestCase { m = cons1.receiveNoWait(); ProxyAssertSupport.assertNull(m); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -364,8 +360,7 @@ public class SelectorTest extends ActiveMQServerTestCase { sess.close(); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -416,8 +411,7 @@ public class SelectorTest extends ActiveMQServerTestCase { sess.close(); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -499,8 +493,7 @@ public class SelectorTest extends ActiveMQServerTestCase { ProxyAssertSupport.assertEquals("george", r3.getStringProperty("beatle")); ProxyAssertSupport.assertEquals("ringo", r4.getStringProperty("beatle")); ProxyAssertSupport.assertEquals("jesus", r5.getStringProperty("beatle")); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -543,14 +536,12 @@ public class SelectorTest extends ActiveMQServerTestCase { Message m = c.receive(1000); if (m != null) { received.add(m); - } - else { + } else { latch.countDown(); return; } } - } - catch (Exception e) { + } catch (Exception e) { log.error("receive failed", e); } } @@ -564,14 +555,12 @@ public class SelectorTest extends ActiveMQServerTestCase { Message m = c2.receive(1000); if (m != null) { received2.add(m); - } - else { + } else { latch2.countDown(); return; } } - } - catch (Exception e) { + } catch (Exception e) { log.error("receive failed", e); } } @@ -591,8 +580,7 @@ public class SelectorTest extends ActiveMQServerTestCase { int value = m.getIntProperty("weight"); ProxyAssertSupport.assertEquals(value, 2); } - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -640,8 +628,7 @@ public class SelectorTest extends ActiveMQServerTestCase { ProxyAssertSupport.assertEquals("NonPersistent", msg.getText()); ProxyAssertSupport.assertEquals(DeliveryMode.NON_PERSISTENT, msg.getJMSDeliveryMode()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -680,8 +667,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -720,8 +706,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -762,8 +747,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -807,8 +791,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -849,8 +832,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -891,8 +873,7 @@ public class SelectorTest extends ActiveMQServerTestCase { assertNull(cons.receiveNoWait()); - } - finally { + } finally { if (conn != null) { conn.close(); } @@ -1007,8 +988,7 @@ public class SelectorTest extends ActiveMQServerTestCase { tm.acknowledge(); - } - finally { + } finally { if (conn != null) { conn.close(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java index dbe410fcee..ae41ea6f92 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java @@ -91,14 +91,12 @@ public class ServerManagement { if (i > ServerManagement.servers.size()) { ServerManagement.log.error("server " + i + " has not been created or has already been killed, so it cannot be killed"); - } - else { + } else { Server server = ServerManagement.servers.get(i); ServerManagement.log.info("invoking kill() on server " + i); try { server.kill(); - } - catch (Throwable t) { + } catch (Throwable t) { // This is likely to throw an exception since the server dies before the response is received } @@ -110,8 +108,7 @@ public class ServerManagement { ServerManagement.log.debug("server " + i + " still alive ..."); Thread.sleep(100); } - } - catch (Throwable e) { + } catch (Throwable e) { // Ok } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java index d2fe70af20..3745e6b78b 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java @@ -16,15 +16,6 @@ */ package org.apache.activemq.artemis.jms.tests.tools.container; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import javax.naming.Binding; import javax.naming.Context; import javax.naming.Name; @@ -36,6 +27,14 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.apache.activemq.artemis.jms.tests.JmsTestLogger; @@ -93,8 +92,7 @@ public class InVMContext implements Context, Serializable { // we only deal with references create by NonSerializableFactory String key = (String) refAddr.getContent(); return NonSerializableFactory.lookup(key); - } - else { + } else { return value; } } @@ -131,8 +129,7 @@ public class InVMContext implements Context, Serializable { boolean terminal = i == -1; if (terminal) { map.remove(name); - } - else { + } else { String tok = name.substring(0, i); InVMContext c = (InVMContext) map.get(tok); if (c == null) { @@ -173,8 +170,7 @@ public class InVMContext implements Context, Serializable { if (!"".equals(contextName) && !".".equals(contextName)) { try { return ((InVMContext) lookup(contextName)).listBindings(""); - } - catch (Throwable t) { + } catch (Throwable t) { throw new NamingException(t.getMessage()); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactory.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactory.java index b68f667ac7..5952d36bef 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactory.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactory.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.jms.tests.tools.container; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - import javax.naming.Context; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; /** * An in-VM JNDI InitialContextFactory. Lightweight JNDI implementation used for testing. @@ -83,8 +82,7 @@ public class InVMInitialContextFactory implements InitialContextFactory { try { serverIndex = Integer.parseInt(s); - } - catch (Exception e) { + } catch (Exception e) { throw new NamingException("Failure parsing \"" + Constants.SERVER_INDEX_PROPERTY_NAME + "\". " + s + diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java index 21d5c2f528..3bb994c5f3 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.jms.tests.tools.container; -import org.apache.activemq.artemis.jms.tests.JmsTestLogger; - -import java.util.Hashtable; - import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; import javax.naming.spi.InitialContextFactoryBuilder; +import java.util.Hashtable; + +import org.apache.activemq.artemis.jms.tests.JmsTestLogger; public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBuilder { // Constants ------------------------------------------------------------------------------------ @@ -53,20 +52,17 @@ public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBu try { c = Class.forName(icfName); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { InVMInitialContextFactoryBuilder.log.error("\"" + icfName + "\" cannot be loaded", e); throw new NamingException("\"" + icfName + "\" cannot be loaded"); } try { icf = (InitialContextFactory) c.newInstance(); - } - catch (InstantiationException e) { + } catch (InstantiationException e) { InVMInitialContextFactoryBuilder.log.error(c.getName() + " cannot be instantiated", e); throw new NamingException(c.getName() + " cannot be instantiated"); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { InVMInitialContextFactoryBuilder.log.error(c.getName() + " instantiation generated an IllegalAccessException", e); throw new NamingException(c.getName() + " instantiation generated an IllegalAccessException"); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMNameParser.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMNameParser.java index fa006b3c0c..897256dca2 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMNameParser.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMNameParser.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.jms.tests.tools.container; -import java.io.Serializable; -import java.util.Properties; - import javax.naming.CompoundName; import javax.naming.Name; import javax.naming.NameParser; import javax.naming.NamingException; +import java.io.Serializable; +import java.util.Properties; public class InVMNameParser implements NameParser, Serializable { // Constants ----------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java index 54e07e41c3..c749ef1c36 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java @@ -290,8 +290,7 @@ public class LocalTestServer implements Server, Runnable { String destination = (isQueue ? "jms.queue." : "jms.topic.") + destName; if (roles != null) { getActiveMQServer().getSecurityRepository().addMatch(destination, roles); - } - else { + } else { getActiveMQServer().getSecurityRepository().removeMatch(destination); } } @@ -335,8 +334,7 @@ public class LocalTestServer implements Server, Runnable { if (queue != null) { queue.flushExecutor(); return queue.getMessageCount(); - } - else { + } else { return -1L; } } @@ -346,8 +344,7 @@ public class LocalTestServer implements Server, Runnable { if (isQueue) { JMSQueueControl queue = (JMSQueueControl) getActiveMQServer().getManagementService().getResource(ResourceNames.JMS_QUEUE + destination); queue.removeMessages(null); - } - else { + } else { TopicControl topic = (TopicControl) getActiveMQServer().getManagementService().getResource(ResourceNames.JMS_TOPIC + destination); topic.removeMessages(null); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/NonSerializableFactory.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/NonSerializableFactory.java index 04c7e18481..d813a43720 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/NonSerializableFactory.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/NonSerializableFactory.java @@ -16,17 +16,16 @@ */ package org.apache.activemq.artemis.jms.tests.tools.container; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - import javax.naming.Context; import javax.naming.Name; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; /** * used by the default context when running in embedded local configuration @@ -101,4 +100,4 @@ public final class NonSerializableFactory implements ObjectFactory { } private static Map wrapperMap = Collections.synchronizedMap(new HashMap()); -} \ No newline at end of file +} diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/JNDIUtilTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/JNDIUtilTest.java index 184402e3f3..18e2789955 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/JNDIUtilTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/JNDIUtilTest.java @@ -16,15 +16,13 @@ */ package org.apache.activemq.artemis.jms.tests.util; -import org.junit.Before; - -import org.junit.Test; - import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import org.apache.activemq.artemis.jms.tests.ActiveMQServerTestCase; import org.apache.activemq.artemis.utils.JNDIUtil; +import org.junit.Before; +import org.junit.Test; public class JNDIUtilTest extends ActiveMQServerTestCase { // Constants ----------------------------------------------------- @@ -44,8 +42,7 @@ public class JNDIUtilTest extends ActiveMQServerTestCase { try { ic.lookup("/nosuchsubcontext"); ProxyAssertSupport.fail("the name is not supposed to be there"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { // OK } @@ -59,8 +56,7 @@ public class JNDIUtilTest extends ActiveMQServerTestCase { try { ic.lookup("/doesnotexistyet"); ProxyAssertSupport.fail("the name is not supposed to be there"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { // OK } @@ -76,8 +72,7 @@ public class JNDIUtilTest extends ActiveMQServerTestCase { try { ic.lookup("doesnotexistyet"); ProxyAssertSupport.fail("the name is not supposed to be there"); - } - catch (NameNotFoundException e) { + } catch (NameNotFoundException e) { // OK } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java index 50b1d088b3..f852d396b8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java @@ -29,8 +29,7 @@ public class ProxyAssertSupport { public static void assertTrue(final java.lang.String string, final boolean b) { try { Assert.assertTrue(string, b); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -39,8 +38,7 @@ public class ProxyAssertSupport { public static void assertTrue(final boolean b) { try { Assert.assertTrue(b); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -49,8 +47,7 @@ public class ProxyAssertSupport { public static void assertFalse(final java.lang.String string, final boolean b) { try { Assert.assertFalse(string, b); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -59,8 +56,7 @@ public class ProxyAssertSupport { public static void assertFalse(final boolean b) { try { Assert.assertFalse(b); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -69,8 +65,7 @@ public class ProxyAssertSupport { public static void fail(final java.lang.String string) { try { Assert.fail(string); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -79,8 +74,7 @@ public class ProxyAssertSupport { public static void fail() { try { Assert.fail(); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -91,8 +85,7 @@ public class ProxyAssertSupport { final java.lang.Object object1) { try { Assert.assertEquals(string, object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -101,8 +94,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.Object object, final java.lang.Object object1) { try { Assert.assertEquals(object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -113,8 +105,7 @@ public class ProxyAssertSupport { final java.lang.String string2) { try { Assert.assertEquals(string, string1, string2); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -123,8 +114,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final java.lang.String string1) { try { Assert.assertEquals(string, string1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -133,8 +123,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final double v, final double v1, final double v2) { try { Assert.assertEquals(string, v, v1, v2); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -143,8 +132,7 @@ public class ProxyAssertSupport { public static void assertEquals(final double v, final double v1, final double v2) { try { Assert.assertEquals(v, v1, v2); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -153,8 +141,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final float v, final float v1, final float v2) { try { Assert.assertEquals(string, v, v1, v2); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -163,8 +150,7 @@ public class ProxyAssertSupport { public static void assertEquals(final float v, final float v1, final float v2) { try { Assert.assertEquals(v, v1, v2); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -173,8 +159,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final long l, final long l1) { try { Assert.assertEquals(string, l, l1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -183,8 +168,7 @@ public class ProxyAssertSupport { public static void assertEquals(final long l, final long l1) { try { Assert.assertEquals(l, l1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -193,8 +177,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final boolean b, final boolean b1) { try { Assert.assertEquals(string, b, b1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -203,8 +186,7 @@ public class ProxyAssertSupport { public static void assertEquals(final boolean b, final boolean b1) { try { Assert.assertEquals(b, b1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -213,8 +195,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final byte b, final byte b1) { try { Assert.assertEquals(string, b, b1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -223,8 +204,7 @@ public class ProxyAssertSupport { public static void assertEquals(final byte b, final byte b1) { try { Assert.assertEquals(b, b1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -233,8 +213,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final char c, final char c1) { try { Assert.assertEquals(string, c, c1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -243,8 +222,7 @@ public class ProxyAssertSupport { public static void assertEquals(final char c, final char c1) { try { Assert.assertEquals(c, c1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -253,8 +231,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final short i, final short i1) { try { Assert.assertEquals(string, i, i1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -263,8 +240,7 @@ public class ProxyAssertSupport { public static void assertEquals(final short i, final short i1) { try { Assert.assertEquals(i, i1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -273,8 +249,7 @@ public class ProxyAssertSupport { public static void assertEquals(final java.lang.String string, final int i, final int i1) { try { Assert.assertEquals(string, i, i1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -283,8 +258,7 @@ public class ProxyAssertSupport { public static void assertEquals(final int i, final int i1) { try { Assert.assertEquals(i, i1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -293,8 +267,7 @@ public class ProxyAssertSupport { public static void assertNotNull(final java.lang.Object object) { try { Assert.assertNotNull(object); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -303,8 +276,7 @@ public class ProxyAssertSupport { public static void assertNotNull(final java.lang.String string, final java.lang.Object object) { try { Assert.assertNotNull(string, object); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -313,8 +285,7 @@ public class ProxyAssertSupport { public static void assertNull(final java.lang.Object object) { try { Assert.assertNull(object); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -323,8 +294,7 @@ public class ProxyAssertSupport { public static void assertNull(final java.lang.String string, final java.lang.Object object) { try { Assert.assertNull(string, object); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -335,8 +305,7 @@ public class ProxyAssertSupport { final java.lang.Object object1) { try { Assert.assertSame(string, object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -345,8 +314,7 @@ public class ProxyAssertSupport { public static void assertSame(final java.lang.Object object, final java.lang.Object object1) { try { Assert.assertSame(object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -357,8 +325,7 @@ public class ProxyAssertSupport { final java.lang.Object object1) { try { Assert.assertNotSame(string, object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } @@ -367,8 +334,7 @@ public class ProxyAssertSupport { public static void assertNotSame(final java.lang.Object object, final java.lang.Object object1) { try { Assert.assertNotSame(object, object1); - } - catch (AssertionError e) { + } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/ActiveMQAMQPAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/ActiveMQAMQPAdmin.java index f307407bb2..6f6b142d4c 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/ActiveMQAMQPAdmin.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/ActiveMQAMQPAdmin.java @@ -51,8 +51,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { env.put("java.naming.factory.initial", TestContextFactory.class.getName()); env.put("java.naming.provider.url", "tcp://localhost:61616"); context = new InitialContext(env); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -82,8 +81,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { Logger log = Logger.getLogger("FRM"); log.addHandler(handler); log.setLevel(Level.FINEST); - } - catch (FileNotFoundException e) { + } catch (FileNotFoundException e) { throw new RuntimeException(e); } } @@ -103,8 +101,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { super.createQueue(name); try { context.bind(name, new JmsQueue("jms.queue." + name)); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -114,8 +111,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { super.createTopic(name); try { context.bind(name, new JmsTopic("jms.topic." + name)); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -125,8 +121,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { super.deleteQueue(name); try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -136,8 +131,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { super.deleteTopic(name); try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -147,8 +141,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { try { final JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:61616"); context.bind(name, factory); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } @@ -157,8 +150,7 @@ public class ActiveMQAMQPAdmin extends AbstractAdmin { public void deleteConnectionFactory(String name) { try { context.unbind(name); - } - catch (NamingException e) { + } catch (NamingException e) { throw new RuntimeException(e); } } diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java index 246df36c73..1c5f6a3c07 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java @@ -48,10 +48,7 @@ import org.objectweb.jtests.jms.conform.topic.TemporaryTopicTest; import org.objectweb.jtests.jms.framework.JMSTestCase; @RunWith(Suite.class) -@SuiteClasses({TopicConnectionTest.class, ConnectionTest.class, MessageBodyTest.class, MessageDefaultTest.class, - MessageTypeTest.class, MessageHeaderTest.class, JMSXPropertyTest.class, MessagePropertyConversionTest.class, MessagePropertyTest.class, - QueueBrowserTest.class, TemporaryQueueTest.class, SelectorSyntaxTest.class, SelectorTest.class, QueueSessionTest.class, SessionTest.class, - TopicSessionTest.class, UnifiedSessionTest.class, TemporaryTopicTest.class,}) +@SuiteClasses({TopicConnectionTest.class, ConnectionTest.class, MessageBodyTest.class, MessageDefaultTest.class, MessageTypeTest.class, MessageHeaderTest.class, JMSXPropertyTest.class, MessagePropertyConversionTest.class, MessagePropertyTest.class, QueueBrowserTest.class, TemporaryQueueTest.class, SelectorSyntaxTest.class, SelectorTest.class, QueueSessionTest.class, SessionTest.class, TopicSessionTest.class, UnifiedSessionTest.class, TemporaryTopicTest.class,}) public class JoramAMQPAggregationTest extends Assert { /** diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/AbstractAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/AbstractAdmin.java index c9e249ae68..63ae052bb1 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/AbstractAdmin.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/AbstractAdmin.java @@ -122,8 +122,7 @@ public class AbstractAdmin implements Admin { try { result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createQueue", name, name); Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -134,8 +133,7 @@ public class AbstractAdmin implements Admin { try { result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyQueue", name); Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -156,8 +154,7 @@ public class AbstractAdmin implements Admin { try { result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createTopic", name, name); Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -168,8 +165,7 @@ public class AbstractAdmin implements Admin { try { result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyTopic", name); Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } @@ -208,22 +204,19 @@ public class AbstractAdmin implements Admin { while ((line1 = br.readLine()) != null) { System.out.println("SERVER: " + line1); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } }.start(); return; - } - else if ("KO".equals(line.trim())) { + } else if ("KO".equals(line.trim())) { // something went wrong with the server, destroy it: serverProcess.destroy(); throw new IllegalStateException("Unable to start the spawned server :" + line); } } - } - else { + } else { SpawnedJMSServer.startServer(); } } @@ -241,8 +234,7 @@ public class AbstractAdmin implements Admin { if (exitValue != 0) { serverProcess.destroy(); } - } - else { + } else { SpawnedJMSServer.stopServer(); } } @@ -255,8 +247,7 @@ public class AbstractAdmin implements Admin { ClientMessage reply; try { reply = requestor.request(message, 3000); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException("Exception while invoking " + operationName + " on " + resourceName, e); } if (reply == null) { diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java index 8e63326965..e4be7a041a 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java @@ -30,14 +30,12 @@ import org.apache.activemq.artemis.utils.FileUtil; public class SpawnedJMSServer { - public static ActiveMQServer server; public static JMSServerManager serverManager; // Using files may be useful for debugging (through print-data for instance) private static final boolean useFiles = false; - public static void main(final String[] args) throws Exception { try { startServer(); @@ -57,14 +55,12 @@ public class SpawnedJMSServer { stopServer(); System.out.println("Server stopped"); System.exit(0); - } - else { + } else { // stop anyway but with an error status System.exit(1); } } - } - catch (Throwable t) { + } catch (Throwable t) { t.printStackTrace(); String allStack = t.getCause().getMessage() + "|"; StackTraceElement[] stackTrace = t.getCause().getStackTrace(); diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java index 9daecd8720..23b0768231 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java @@ -83,8 +83,7 @@ public class TestContext implements Context, Serializable { public TestContext(Hashtable env) { if (env == null) { this.environment = new Hashtable<>(); - } - else { + } else { this.environment = new Hashtable<>(env); } this.bindings = Collections.EMPTY_MAP; @@ -94,8 +93,7 @@ public class TestContext implements Context, Serializable { public TestContext(Hashtable environment, Map bindings) { if (environment == null) { this.environment = new Hashtable<>(); - } - else { + } else { this.environment = new Hashtable<>(environment); } this.bindings = new HashMap<>(); @@ -104,8 +102,7 @@ public class TestContext implements Context, Serializable { for (Map.Entry binding : bindings.entrySet()) { try { internalBind(binding.getKey(), binding.getValue()); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQClientLogger.LOGGER.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e); } } @@ -163,8 +160,7 @@ public class TestContext implements Context, Serializable { } bindings.put(name, value); newBindings.put(name, value); - } - else { + } else { String segment = name.substring(0, pos); assert segment != null; assert !segment.equals(""); @@ -174,8 +170,7 @@ public class TestContext implements Context, Serializable { treeBindings.put(segment, o); bindings.put(segment, o); newBindings.put(segment, o); - } - else if (!(o instanceof TestContext)) { + } else if (!(o instanceof TestContext)) { throw new NamingException("Something already bound where a subcontext should go"); } TestContext readOnlyContext = (TestContext) o; @@ -228,22 +223,19 @@ public class TestContext implements Context, Serializable { throw new NamingException("scheme " + scheme + " not recognized"); } return ctx.lookup(name); - } - else { + } else { // Split out the first name of the path // and look for it in the bindings map. CompositeName path = new CompositeName(name); if (path.size() == 0) { return this; - } - else { + } else { String first = path.get(0); Object obj = bindings.get(first); if (obj == null) { throw new NameNotFoundException(name); - } - else if (obj instanceof Context && path.size() > 1) { + } else if (obj instanceof Context && path.size() > 1) { Context subContext = (Context) obj; obj = subContext.lookup(path.getSuffix(1)); } @@ -258,11 +250,9 @@ public class TestContext implements Context, Serializable { if (result instanceof Reference) { try { result = NamingManager.getObjectInstance(result, null, null, this.environment); - } - catch (NamingException e) { + } catch (NamingException e) { throw e; - } - catch (Exception e) { + } catch (Exception e) { throw (NamingException) new NamingException("could not look up : " + name).initCause(e); } } @@ -305,11 +295,9 @@ public class TestContext implements Context, Serializable { Object o = lookup(name); if (o == this) { return new ListEnumeration(); - } - else if (o instanceof Context) { + } else if (o instanceof Context) { return ((Context) o).list(""); - } - else { + } else { throw new NotContextException(); } } @@ -319,11 +307,9 @@ public class TestContext implements Context, Serializable { Object o = lookup(name); if (o == this) { return new ListBindingEnumeration(); - } - else if (o instanceof Context) { + } else if (o instanceof Context) { return ((Context) o).listBindings(""); - } - else { + } else { throw new NotContextException(); } } diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java index 3083fd371f..15cc51cb8b 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java @@ -58,8 +58,7 @@ public class TestContextFactory implements InitialContextFactory { try { ConnectionFactory factory = createConnectionFactory((String) environment.get(key), jndiName); data.put(jndiName, factory); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new NamingException("Invalid broker URL"); } diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java index aca9551ade..910f1413e6 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java @@ -31,8 +31,6 @@ public class ActiveMQCoreAdmin extends AbstractAdmin { Hashtable jndiProps = new Hashtable<>(); - - public ActiveMQCoreAdmin() { super(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName()); @@ -41,8 +39,7 @@ public class ActiveMQCoreAdmin extends AbstractAdmin { env.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); env.put("java.naming.provider.url", "tcp://localhost:61616"); context = new InitialContext(env); - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } @@ -68,8 +65,7 @@ public class ActiveMQCoreAdmin extends AbstractAdmin { private void createConnection(final String name, final int cfType) { try { invokeSyncOperation(ResourceNames.JMS_SERVER, "createConnectionFactory", name, false, false, cfType, "netty", name); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } @@ -109,8 +105,7 @@ public class ActiveMQCoreAdmin extends AbstractAdmin { try { invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name); jndiProps.remove("connectionFactory." + name); - } - catch (Exception e) { + } catch (Exception e) { throw new IllegalStateException(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java index 24c4dd6294..04b17e032a 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java @@ -36,11 +36,9 @@ public class AdminFactory { try { Class adminClass = Class.forName(adminClassName); admin = (Admin) adminClass.newInstance(); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Class " + adminClassName + " not found.", e); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } return admin; diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/ConnectionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/ConnectionTest.java index 18c5fd937e..13921fbba3 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/ConnectionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/ConnectionTest.java @@ -57,14 +57,11 @@ public class ConnectionTest extends PTPTestCase { receiverConnection.close(); m.acknowledge(); Assert.fail("sec. 4.3.5 Invoking the acknowledge method of a received message from a closed " + "connection's session must throw a [javax.jms.]IllegalStateException.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("sec. 4.3.5 Invoking the acknowledge method of a received message from a closed " + "connection's session must throw a [javax.jms.]IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("sec. 4.3.5 Invoking the acknowledge method of a received message from a closed " + "connection's session must throw an [javax.jms.]IllegalStateException " + "[not a java.lang.IllegalStateException]"); } } @@ -79,13 +76,10 @@ public class ConnectionTest extends PTPTestCase { senderConnection.close(); senderConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Assert.fail("Should raise a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException"); } } @@ -102,8 +96,7 @@ public class ConnectionTest extends PTPTestCase { sender.send(message); receiver.receive(TestConfig.TIMEOUT); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -119,8 +112,7 @@ public class ConnectionTest extends PTPTestCase { senderConnection.close(); // we close it a second time senderConnection.close(); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("sec. 4.3.5 Closing a closed connection must not throw an exception.\n"); } } @@ -134,8 +126,7 @@ public class ConnectionTest extends PTPTestCase { // senderConnection is already started // start it again should be ignored senderConnection.start(); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -151,8 +142,7 @@ public class ConnectionTest extends PTPTestCase { senderConnection.stop(); // stopping it a second time is ignored senderConnection.stop(); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -171,8 +161,7 @@ public class ConnectionTest extends PTPTestCase { try { Assert.fail("The message must not be received, the consumer connection is stopped"); Assert.assertEquals("test", ((TextMessage) m).getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -184,13 +173,11 @@ public class ConnectionTest extends PTPTestCase { synchronized (this) { try { Thread.sleep(1000); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/TopicConnectionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/TopicConnectionTest.java index 2d8200ffb9..20f20d9004 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/TopicConnectionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/connection/TopicConnectionTest.java @@ -56,13 +56,10 @@ public class TopicConnectionTest extends PubSubTestCase { // an attempt to set a client ID should now throw an IllegalStateException subscriberConnection.setClientID("another client ID"); Assert.fail("Should raise a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException"); } } @@ -93,13 +90,10 @@ public class TopicConnectionTest extends PubSubTestCase { // an attempt to set the client ID now should throw an IllegalStateException subscriberConnection.setClientID("testSetClientID_2"); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException"); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java index d3a1c7b4ff..89b65a1549 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java @@ -42,8 +42,7 @@ public class MessageBodyTest extends PTPTestCase { message.setStringProperty("prop", "foo"); message.clearBody(); Assert.assertEquals("sec. 3.11.1 Clearing a message's body does not clear its property entries.\n", "foo", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -58,8 +57,7 @@ public class MessageBodyTest extends PTPTestCase { message.setText("bar"); message.clearBody(); Assert.assertEquals("sec. 3 .11.1 the clearBody method of Message resets the value of the message body " + "to the 'empty' initial message value as set by the message type's create " + "method provided by Session.\n", null, message.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -80,10 +78,8 @@ public class MessageBodyTest extends PTPTestCase { TextMessage msg = (TextMessage) m; msg.setText("bar"); Assert.fail("should raise a MessageNotWriteableException (sec. 3.11.2)"); - } - catch (MessageNotWriteableException e) { - } - catch (JMSException e) { + } catch (MessageNotWriteableException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageTypeTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageTypeTest.java index 56e133795e..72a38be598 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageTypeTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/MessageTypeTest.java @@ -16,9 +16,6 @@ */ package org.objectweb.jtests.jms.conform.message; -import java.util.Enumeration; -import java.util.Vector; - import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.MapMessage; @@ -26,6 +23,8 @@ import javax.jms.Message; import javax.jms.ObjectMessage; import javax.jms.StreamMessage; import javax.jms.TextMessage; +import java.util.Enumeration; +import java.util.Vector; import org.junit.Assert; import org.junit.Test; @@ -69,8 +68,7 @@ public class MessageTypeTest extends PTPTestCase { StreamMessage msg = (StreamMessage) m; Assert.assertEquals("pi", msg.readString()); Assert.assertEquals(3.14159, msg.readDouble(), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -89,8 +87,7 @@ public class MessageTypeTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of StreamMessage.\n", msg instanceof StreamMessage); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -112,8 +109,7 @@ public class MessageTypeTest extends PTPTestCase { Assert.assertTrue(msg.getObject("pi") instanceof Double); Assert.assertEquals(3.14159, ((Double) msg.getObject("pi")).doubleValue(), 0); Assert.assertEquals(3.14159, msg.getDouble("pi"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -131,10 +127,8 @@ public class MessageTypeTest extends PTPTestCase { MapMessage message = senderSession.createMapMessage(); message.setBoolean(null, true); Assert.fail("Should throw an IllegalArgumentException"); - } - catch (IllegalArgumentException e) { - } - catch (JMSException e) { + } catch (IllegalArgumentException e) { + } catch (JMSException e) { Assert.fail("Should throw an IllegalArgumentException, not a" + e); } } @@ -152,10 +146,8 @@ public class MessageTypeTest extends PTPTestCase { MapMessage message = senderSession.createMapMessage(); message.setBoolean("", true); Assert.fail("Should throw an IllegalArgumentException"); - } - catch (IllegalArgumentException e) { - } - catch (JMSException e) { + } catch (IllegalArgumentException e) { + } catch (JMSException e) { Assert.fail("Should throw an IllegalArgumentException, not a" + e); } } @@ -175,8 +167,7 @@ public class MessageTypeTest extends PTPTestCase { message.setDouble("pi", 3.14159); e = message.getMapNames(); Assert.assertEquals("pi", e.nextElement()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -200,8 +191,7 @@ public class MessageTypeTest extends PTPTestCase { MapMessage msg = (MapMessage) m; Assert.assertEquals("pi", msg.getString("name")); Assert.assertEquals(3.14159, msg.getDouble("value"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -220,8 +210,7 @@ public class MessageTypeTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of MapMessage.\n", msg instanceof MapMessage); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -247,8 +236,7 @@ public class MessageTypeTest extends PTPTestCase { Assert.assertTrue("The message should be an instance of ObjectMessage.\n", m instanceof ObjectMessage); ObjectMessage msg = (ObjectMessage) m; Assert.assertEquals(vector, msg.getObject()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -267,8 +255,7 @@ public class MessageTypeTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of ObjectMessage.\n", msg instanceof ObjectMessage); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -295,8 +282,7 @@ public class MessageTypeTest extends PTPTestCase { msg.readBytes(receivedBytes); Assert.assertEquals(new String(bytes), new String(receivedBytes)); Assert.assertEquals(3.14159, msg.readDouble(), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -315,8 +301,7 @@ public class MessageTypeTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of BytesMessage.\n", msg instanceof BytesMessage); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -338,8 +323,7 @@ public class MessageTypeTest extends PTPTestCase { Assert.assertTrue("The message should be an instance of TextMessage.\n", m instanceof TextMessage); TextMessage msg = (TextMessage) m; Assert.assertEquals("testTextMessage_2", msg.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -358,8 +342,7 @@ public class MessageTypeTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of TextMessage.\n", msg instanceof TextMessage); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java index 559827fdb9..915f2cc05a 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java @@ -25,7 +25,6 @@ import javax.jms.TemporaryQueue; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; - import java.util.Hashtable; import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory; @@ -53,8 +52,7 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertEquals("sec. 3.4.9 After completion of the send it holds the value specified by the " + "method sending the message.\n", 9, message.getJMSPriority()); receiver.receive(TestConfig.TIMEOUT); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -74,8 +72,7 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertEquals("sec. 3.4.9 After completion of the send it holds the value specified by the " + "method sending the message.\n", Message.DEFAULT_PRIORITY, message.getJMSPriority()); receiver.receive(TestConfig.TIMEOUT); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -92,8 +89,7 @@ public class MessageHeaderTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertEquals("sec. 3.4.9 When a message is received its JMSExpiration header field contains this same " + "value [i.e. set on return of the send method].\n", message.getJMSExpiration(), msg.getJMSExpiration()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -112,8 +108,7 @@ public class MessageHeaderTest extends PTPTestCase { Message msg = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("sec. 3.4.3 All JMSMessageID values must start with the prefix 'ID:'.\n", msg.getJMSMessageID().startsWith("ID:")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -130,8 +125,7 @@ public class MessageHeaderTest extends PTPTestCase { sender.send(message); Assert.assertTrue("sec. 3.4.3 When a message is sent this value is ignored.\n", !message.getJMSMessageID().equals("ID:foo")); receiver.receive(TestConfig.TIMEOUT); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -154,8 +148,7 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertEquals("sec. 3.4.2 After completion of the send it holds the delivery mode specified " + "by the sending method (persistent by default).\n", Message.DEFAULT_DELIVERY_MODE, message.getJMSDeliveryMode()); receiver.receive(TestConfig.TIMEOUT); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -190,11 +183,9 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertEquals("sec. 3.4.1 When a message is received, its destination value must be equivalent " + " to the value assigned when it was sent.\n", ((Queue) message.getJMSDestination()).getQueueName(), ((Queue) msg.getJMSDestination()).getQueueName()); admin.deleteQueue("anotherQueue"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); - } - catch (NamingException e) { + } catch (NamingException e) { Assert.fail(e.getMessage()); } } @@ -216,8 +207,7 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertTrue("JMS ReplyTo header field should be a Queue", dest instanceof Queue); Queue replyTo = (Queue) dest; Assert.assertEquals("JMS ReplyTo header field should be equals to the sender queue", replyTo.getQueueName(), senderQueue.getQueueName()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -240,8 +230,7 @@ public class MessageHeaderTest extends PTPTestCase { Assert.assertTrue("JMS ReplyTo header field should be a TemporaryQueue", dest instanceof TemporaryQueue); Queue replyTo = (Queue) dest; Assert.assertEquals("JMS ReplyTo header field should be equals to the temporary queue", replyTo.getQueueName(), tempQueue.getQueueName()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/JMSXPropertyTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/JMSXPropertyTest.java index a7e33eb832..188d212022 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/JMSXPropertyTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/JMSXPropertyTest.java @@ -16,12 +16,11 @@ */ package org.objectweb.jtests.jms.conform.message.properties; -import java.util.Enumeration; - import javax.jms.ConnectionMetaData; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.TextMessage; +import java.util.Enumeration; import org.junit.Assert; import org.junit.Test; @@ -51,8 +50,7 @@ public class JMSXPropertyTest extends PTPTestCase { } } Assert.assertTrue("JMSXGroupID property is not supported", found); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -74,8 +72,7 @@ public class JMSXPropertyTest extends PTPTestCase { TextMessage msg = (TextMessage) m; Assert.assertEquals(groupID, msg.getStringProperty("JMSXGroupID")); Assert.assertEquals("testSupportsJMSXGroupID_1", msg.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -145,11 +142,9 @@ public class JMSXPropertyTest extends PTPTestCase { // ... so it has been delivered a second time jmsxDeliveryCount = msg.getIntProperty("JMSXDeliveryCount"); Assert.assertEquals(2, jmsxDeliveryCount); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyConversionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyConversionTest.java index 25d8cddaa4..414887cce0 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyConversionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyConversionTest.java @@ -67,8 +67,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("pi", "3.14159"); Assert.assertEquals("3.14159", message.getStringProperty("pi")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -86,10 +85,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "not_a_number"); message.getDoubleProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -105,8 +102,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("pi", "3.14159"); Assert.assertEquals(3.14159, message.getDoubleProperty("pi"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -124,10 +120,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "not_a_number"); message.getFloatProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -143,8 +137,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("pi", "3.14159"); Assert.assertEquals(3.14159F, message.getFloatProperty("pi"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -162,10 +155,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "3.14159"); message.getLongProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -181,8 +172,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "0"); Assert.assertEquals(0L, message.getLongProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -200,10 +190,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "3.14159"); message.getIntProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -219,8 +207,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "0"); Assert.assertEquals(0, message.getIntProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -238,10 +225,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "3.14159"); message.getShortProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -257,8 +242,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "0"); Assert.assertEquals((short) 0, message.getShortProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -276,10 +260,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setStringProperty("pi", "3.14159"); message.getByteProperty("pi"); Assert.fail("sec. 3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException " + " if the numeric's valueOf() method does not accept the String value as a valid representation.\n"); - } - catch (java.lang.NumberFormatException e) { - } - catch (JMSException e) { + } catch (java.lang.NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -295,8 +277,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "0"); Assert.assertEquals((byte) 0, message.getByteProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -313,10 +294,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "test"); Assert.assertEquals(false, message.getBooleanProperty("prop")); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -332,8 +311,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setStringProperty("prop", "true"); Assert.assertEquals(true, message.getBooleanProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -348,8 +326,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setDoubleProperty("prop", 127.0); Assert.assertEquals("127.0", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -364,8 +341,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setDoubleProperty("prop", 127.0); Assert.assertEquals(127.0, message.getDoubleProperty("prop"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -381,10 +357,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -400,10 +374,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getLongProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -419,10 +391,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getIntProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -439,10 +409,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getShortProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -459,10 +427,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -479,10 +445,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setDoubleProperty("prop", 127.0); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -497,8 +461,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setFloatProperty("prop", 127.0F); Assert.assertEquals("127.0", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -513,8 +476,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setFloatProperty("prop", 127.0F); Assert.assertEquals(127.0, message.getDoubleProperty("prop"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -529,8 +491,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setFloatProperty("prop", 127.0F); Assert.assertEquals(127.0F, message.getFloatProperty("prop"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -546,10 +507,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setFloatProperty("prop", 127.0F); message.getLongProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -565,10 +524,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setFloatProperty("prop", 127.0F); message.getIntProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -585,10 +542,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setFloatProperty("prop", 127.0F); message.getShortProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -605,10 +560,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setFloatProperty("prop", 127.0F); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -625,10 +578,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setFloatProperty("prop", 127.0F); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -643,8 +594,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setLongProperty("prop", 127L); Assert.assertEquals("127", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -660,10 +610,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getDoubleProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -679,10 +627,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -697,8 +643,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setLongProperty("prop", 127L); Assert.assertEquals(127L, message.getLongProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -714,10 +659,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getIntProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -734,10 +677,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getShortProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -754,10 +695,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -774,10 +713,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setLongProperty("prop", 127L); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -792,8 +729,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setIntProperty("prop", 127); Assert.assertEquals("127", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -809,10 +745,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setIntProperty("prop", 127); message.getDoubleProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -828,10 +762,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setIntProperty("prop", 127); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -846,8 +778,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setIntProperty("prop", 127); Assert.assertEquals(127L, message.getLongProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -862,8 +793,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setIntProperty("prop", 127); Assert.assertEquals(127, message.getIntProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -880,10 +810,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setIntProperty("prop", Integer.MAX_VALUE); message.getShortProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -900,10 +828,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setIntProperty("prop", Integer.MAX_VALUE); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -920,10 +846,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setIntProperty("prop", Integer.MAX_VALUE); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -938,8 +862,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setShortProperty("prop", (short) 127); Assert.assertEquals("127", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -955,10 +878,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setShortProperty("prop", (short) 127); message.getDoubleProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -974,10 +895,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setShortProperty("prop", (short) 127); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -992,8 +911,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setShortProperty("prop", (short) 127); Assert.assertEquals(127L, message.getLongProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1008,8 +926,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setShortProperty("prop", (short) 127); Assert.assertEquals(127, message.getIntProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1024,8 +941,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setShortProperty("prop", (short) 127); Assert.assertEquals((short) 127, message.getShortProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1041,10 +957,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setShortProperty("prop", (short) 127); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1061,10 +975,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setShortProperty("prop", (short) 127); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1079,8 +991,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setByteProperty("prop", (byte) 127); Assert.assertEquals("127", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1096,10 +1007,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setByteProperty("prop", (byte) 127); message.getDoubleProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1115,10 +1024,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setByteProperty("prop", (byte) 127); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1133,8 +1040,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setByteProperty("prop", (byte) 127); Assert.assertEquals(127L, message.getLongProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1149,8 +1055,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setByteProperty("prop", (byte) 127); Assert.assertEquals(127, message.getIntProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1165,8 +1070,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setByteProperty("prop", (byte) 127); Assert.assertEquals((short) 127, message.getShortProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1181,8 +1085,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setByteProperty("prop", (byte) 127); Assert.assertEquals((byte) 127, message.getByteProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1199,10 +1102,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setByteProperty("prop", (byte) 127); message.getBooleanProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1217,8 +1118,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setBooleanProperty("prop", true); Assert.assertEquals("true", message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -1235,10 +1135,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("prop", true); message.getDoubleProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1255,10 +1153,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("prop", true); message.getFloatProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1275,10 +1171,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("true", true); message.getLongProperty("true"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1295,10 +1189,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("prop", true); message.getIntProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1315,10 +1207,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("prop", true); message.getShortProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1335,10 +1225,8 @@ public class MessagePropertyConversionTest extends PTPTestCase { message.setBooleanProperty("prop", true); message.getByteProperty("prop"); Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -1353,8 +1241,7 @@ public class MessagePropertyConversionTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setBooleanProperty("prop", true); Assert.assertEquals(true, message.getBooleanProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java index 28257db3c6..8ac9e86ff9 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java @@ -16,13 +16,12 @@ */ package org.objectweb.jtests.jms.conform.message.properties; -import java.util.Enumeration; -import java.util.Vector; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageFormatException; import javax.jms.TextMessage; +import java.util.Enumeration; +import java.util.Vector; import org.junit.Assert; import org.junit.Test; @@ -46,10 +45,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setObjectProperty("prop", new Vector()); Assert.fail("sec. 3.5.5 An attempt to use any other class [than Boolean, Byte,...,String] must throw " + "a JMS MessageFormatException.\n"); - } - catch (MessageFormatException e) { - } - catch (JMSException e) { + } catch (MessageFormatException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.MessageFormatException, not a " + e); } } @@ -64,8 +61,7 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.setObjectProperty("pi", new Float(3.14159f)); Assert.assertEquals(3.14159f, message.getFloatProperty("pi"), 0); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -79,8 +75,7 @@ public class MessagePropertyTest extends PTPTestCase { try { Message message = senderSession.createMessage(); Assert.assertEquals("sec. 3.5.5 A null value is returned [by the getObjectProperty method] if a property by the specified " + "name does not exits.\n", null, message.getObjectProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -94,8 +89,7 @@ public class MessagePropertyTest extends PTPTestCase { try { Message message = senderSession.createMessage(); Assert.assertEquals("sec. 3.5.5 A null value is returned [by the getStringProperty method] if a property by the specified " + "name does not exits.\n", null, message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -110,10 +104,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getDoubleProperty("prop"); Assert.fail("Should raise a NullPointerException.\n"); - } - catch (NullPointerException e) { - } - catch (JMSException e) { + } catch (NullPointerException e) { + } catch (JMSException e) { fail(e); } } @@ -128,10 +120,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getFloatProperty("prop"); Assert.fail("Should raise a NullPointerException.\n"); - } - catch (NullPointerException e) { - } - catch (JMSException e) { + } catch (NullPointerException e) { + } catch (JMSException e) { fail(e); } } @@ -146,10 +136,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getLongProperty("prop"); Assert.fail("Should raise a NumberFormatException.\n"); - } - catch (NumberFormatException e) { - } - catch (JMSException e) { + } catch (NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -164,10 +152,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getIntProperty("prop"); Assert.fail("Should raise a NumberFormatException.\n"); - } - catch (NumberFormatException e) { - } - catch (JMSException e) { + } catch (NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -182,10 +168,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getShortProperty("prop"); Assert.fail("Should raise a NumberFormatException.\n"); - } - catch (NumberFormatException e) { - } - catch (JMSException e) { + } catch (NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -200,10 +184,8 @@ public class MessagePropertyTest extends PTPTestCase { Message message = senderSession.createMessage(); message.getByteProperty("prop"); Assert.fail("Should raise a NumberFormatException.\n"); - } - catch (NumberFormatException e) { - } - catch (JMSException e) { + } catch (NumberFormatException e) { + } catch (JMSException e) { fail(e); } } @@ -217,8 +199,7 @@ public class MessagePropertyTest extends PTPTestCase { try { Message message = senderSession.createMessage(); Assert.assertEquals(false, message.getBooleanProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -239,8 +220,7 @@ public class MessagePropertyTest extends PTPTestCase { Assert.assertTrue("sec. 3.5.6 The getPropertyNames method does not return the names of " + "the JMS standard header field [e.g. JMSCorrelationID]: " + propName, valid); } - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -272,8 +252,7 @@ public class MessagePropertyTest extends PTPTestCase { } Assert.assertEquals(originalCount + 1, newCount); Assert.assertTrue(foundPiProperty); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -289,8 +268,7 @@ public class MessagePropertyTest extends PTPTestCase { message.setText("foo"); message.clearProperties(); Assert.assertEquals("sec. 3.5.7 Clearing a message's property entries does not clear the value of its body.\n", "foo", message.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -306,8 +284,7 @@ public class MessagePropertyTest extends PTPTestCase { message.setStringProperty("prop", "foo"); message.clearProperties(); Assert.assertEquals("sec. 3.5.7 A message's properties are deleted by the clearProperties method.\n", null, message.getStringProperty("prop")); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java index cada29a358..bd9c0e53fc 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java @@ -16,12 +16,11 @@ */ package org.objectweb.jtests.jms.conform.queue; -import java.util.Enumeration; - import javax.jms.JMSException; import javax.jms.Message; import javax.jms.QueueBrowser; import javax.jms.TextMessage; +import java.util.Enumeration; import org.junit.After; import org.junit.Assert; @@ -98,8 +97,7 @@ public class QueueBrowserTest extends PTPTestCase { // (the two messages have been acknowledged and so removed // from the queue) Assert.assertTrue(!enumeration.hasMoreElements()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -134,8 +132,7 @@ public class QueueBrowserTest extends PTPTestCase { Assert.assertEquals("testBrowserWithMessageSelector:message_2", msg.getText()); } Assert.assertEquals(1, count); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -147,8 +144,7 @@ public class QueueBrowserTest extends PTPTestCase { super.setUp(); receiverBrowser = receiverSession.createBrowser(receiverQueue); senderBrowser = senderSession.createBrowser(senderQueue); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -160,10 +156,8 @@ public class QueueBrowserTest extends PTPTestCase { receiverBrowser.close(); senderBrowser.close(); super.tearDown(); - } - catch (JMSException ignored) { - } - finally { + } catch (JMSException ignored) { + } finally { receiverBrowser = null; senderBrowser = null; } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/TemporaryQueueTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/TemporaryQueueTest.java index 9132c46e0e..870a817c21 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/TemporaryQueueTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/TemporaryQueueTest.java @@ -63,8 +63,7 @@ public class TemporaryQueueTest extends PTPTestCase { Assert.assertTrue(m instanceof TextMessage); TextMessage msg = (TextMessage) m; Assert.assertEquals("testTemporaryQueue", msg.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/selector/SelectorSyntaxTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/selector/SelectorSyntaxTest.java index 5c35673856..1fa7354501 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/selector/SelectorSyntaxTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/selector/SelectorSyntaxTest.java @@ -46,8 +46,7 @@ public class SelectorSyntaxTest extends PTPTestCase { identifier = "$correct"; Assert.assertTrue(identifier + " starts with an invalid Java identifier start character", Character.isJavaIdentifierStart(identifier.charAt(0))); receiver = receiverSession.createReceiver(receiverQueue, identifier + " IS NULL"); - } - catch (JMSException e) { + } catch (JMSException e) { Assert.fail(identifier + " is a correct identifier. \n" + e); } } @@ -66,8 +65,7 @@ public class SelectorSyntaxTest extends PTPTestCase { Assert.assertTrue(identifier + " starts with an invalid Java identifier start character", !Character.isJavaIdentifierStart(identifier.charAt(0))); receiver = receiverSession.createReceiver(receiverQueue, identifier + " IS NULL"); Assert.fail(identifier + " starts with an invalid Java identifier start character"); - } - catch (JMSException e) { + } catch (JMSException e) { } try { @@ -76,8 +74,7 @@ public class SelectorSyntaxTest extends PTPTestCase { Assert.assertTrue(identifier + " starts with an invalid Java identifier start character", !Character.isJavaIdentifierStart(identifier.charAt(0))); receiver = receiverSession.createReceiver(receiverQueue, identifier + " IS NULL"); Assert.fail(identifier + " starts with an invalid Java identifier start character"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -89,8 +86,7 @@ public class SelectorSyntaxTest extends PTPTestCase { public void testEmptyStringAsSelector() { try { receiver = receiverSession.createReceiver(receiverQueue, ""); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -103,10 +99,8 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "NULL = ZERO"); Assert.fail("NULL is not a valid identifier"); - } - catch (InvalidSelectorException e) { - } - catch (JMSException e) { + } catch (InvalidSelectorException e) { + } catch (JMSException e) { fail(e); } } @@ -119,8 +113,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "TRUE > 0"); Assert.fail("TRUE is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -132,8 +125,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "FALSE > 0"); Assert.fail("FALSE is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -145,8 +137,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "NOT > 0"); Assert.fail("NOT is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -158,8 +149,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "AND > 0"); Assert.fail("AND is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -171,8 +161,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "OR > 0"); Assert.fail("OR is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -184,8 +173,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "BETWEEN > 0"); Assert.fail("BETWEEN is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -197,8 +185,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "LIKE > 0"); Assert.fail("LIKE is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -210,8 +197,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "IN > 0"); Assert.fail("IN is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -223,8 +209,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "IS > 0"); Assert.fail("IS is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -236,8 +221,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "ESCAPE > 0"); Assert.fail("ESCAPE is not a valid identifier"); - } - catch (JMSException e) { + } catch (JMSException e) { } } @@ -249,8 +233,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "prop_name IS NULL"); receiver = receiverSession.createReceiver(receiverQueue, "prop_name IS NOT NULL"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -265,8 +248,7 @@ public class SelectorSyntaxTest extends PTPTestCase { receiver = receiverSession.createReceiver(receiverQueue, "word LIKE 'l_se'"); receiver = receiverSession.createReceiver(receiverQueue, "underscored LIKE '\\_%' ESCAPE '\\'"); receiver = receiverSession.createReceiver(receiverQueue, "phone NOT LIKE '12%3'"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -279,8 +261,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "Country IN ('UK', 'US', 'France')"); receiver = receiverSession.createReceiver(receiverQueue, "Country NOT IN ('UK', 'US', 'France')"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -293,8 +274,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "age BETWEEN 15 and 19"); receiver = receiverSession.createReceiver(receiverQueue, "age NOT BETWEEN 15 and 19"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -308,8 +288,7 @@ public class SelectorSyntaxTest extends PTPTestCase { receiver = receiverSession.createReceiver(receiverQueue, "average = +6.2"); receiver = receiverSession.createReceiver(receiverQueue, "average = -95.7"); receiver = receiverSession.createReceiver(receiverQueue, "average = 7."); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -323,8 +302,7 @@ public class SelectorSyntaxTest extends PTPTestCase { receiver = receiverSession.createReceiver(receiverQueue, "average = +62"); receiver = receiverSession.createReceiver(receiverQueue, "max = -957"); receiver = receiverSession.createReceiver(receiverQueue, "max = 57"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -338,8 +316,7 @@ public class SelectorSyntaxTest extends PTPTestCase { receiver = receiverSession.createReceiver(receiverQueue, "max = 0"); receiver = receiverSession.createReceiver(receiverQueue, "max = 0.0"); receiver = receiverSession.createReceiver(receiverQueue, "max = 0."); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -352,8 +329,7 @@ public class SelectorSyntaxTest extends PTPTestCase { try { receiver = receiverSession.createReceiver(receiverQueue, "string = 'literal'"); receiver = receiverSession.createReceiver(receiverQueue, "string = 'literal''s'"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/QueueSessionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/QueueSessionTest.java index 93e847feac..f717d775d8 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/QueueSessionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/QueueSessionTest.java @@ -94,8 +94,7 @@ public class QueueSessionTest extends PTPTestCase { // .. but this time, it has been redelivered Assert.assertEquals(true, msg.getJMSRedelivered()); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } @@ -109,10 +108,8 @@ public class QueueSessionTest extends PTPTestCase { try { senderSession.createBrowser(senderQueue, "definitely not a message selector!"); Assert.fail("Should throw a javax.jms.InvalidSelectorException.\n"); - } - catch (InvalidSelectorException e) { - } - catch (JMSException e) { + } catch (InvalidSelectorException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidSelectorException, not a " + e); } } @@ -126,10 +123,8 @@ public class QueueSessionTest extends PTPTestCase { try { senderSession.createBrowser((Queue) null); Assert.fail("Should throw a javax.jms.InvalidDestinationException.\n"); - } - catch (InvalidDestinationException e) { - } - catch (JMSException e) { + } catch (InvalidDestinationException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidDestinationException, not a " + e); } } @@ -143,10 +138,8 @@ public class QueueSessionTest extends PTPTestCase { try { receiver = senderSession.createReceiver(senderQueue, "definitely not a message selector!"); Assert.fail("Should throw a javax.jms.InvalidSelectorException.\n"); - } - catch (InvalidSelectorException e) { - } - catch (JMSException e) { + } catch (InvalidSelectorException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidSelectorException, not a " + e); } } @@ -160,11 +153,9 @@ public class QueueSessionTest extends PTPTestCase { try { receiver = senderSession.createReceiver((Queue) null); Assert.fail("Should throw a javax.jms.InvalidDestinationException.\n"); - } - catch (InvalidDestinationException e) { + } catch (InvalidDestinationException e) { // expected - } - catch (JMSException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidDestinationException, not a " + e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/SessionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/SessionTest.java index f76510fe96..43ca343b79 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/SessionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/SessionTest.java @@ -48,13 +48,10 @@ public class SessionTest extends PTPTestCase { Assert.assertEquals(true, senderSession.getTransacted()); senderSession.recover(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (java.lang.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } } @@ -83,8 +80,7 @@ public class SessionTest extends PTPTestCase { TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received Assert.assertEquals(null, m); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } @@ -117,8 +113,7 @@ public class SessionTest extends PTPTestCase { m = (TextMessage) receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue(m != null); Assert.assertEquals("testCommitTransactedSession", m.getText()); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } @@ -135,13 +130,10 @@ public class SessionTest extends PTPTestCase { Assert.assertEquals(false, senderSession.getTransacted()); senderSession.rollback(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (java.lang.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } } @@ -158,13 +150,10 @@ public class SessionTest extends PTPTestCase { Assert.assertEquals(false, senderSession.getTransacted()); senderSession.commit(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (java.lang.IllegalStateException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } } @@ -181,8 +170,7 @@ public class SessionTest extends PTPTestCase { // we re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); Assert.assertEquals(true, senderSession.getTransacted()); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } @@ -207,13 +195,10 @@ public class SessionTest extends PTPTestCase { receiverSession.close(); m.acknowledge(); Assert.fail("sec. 4.4.1 Invoking the acknowledge method of a received message from a closed " + " session must throw an [javax.jms.]IllegalStateException.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("sec. 4.4.1 Invoking the acknowledge method of a received message from a closed " + "session must throw an [javax.jms.]IllegalStateException, " + "[not a java.lang.IllegalStateException]"); } } @@ -232,8 +217,7 @@ public class SessionTest extends PTPTestCase { TextMessage m = (TextMessage) receiver.receive(TestConfig.TIMEOUT); receiverSession.close(); Assert.assertEquals("testUseMessage", m.getText()); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("sec. 4.4.1 It is valid to continue to use message objects created or received via " + "the [closed] session.\n"); } } @@ -248,13 +232,10 @@ public class SessionTest extends PTPTestCase { senderSession.close(); senderSession.createMessage(); Assert.fail("sec. 4.4.1 An attempt to use [a closed session] must throw a [javax.jms.]IllegalStateException.\n"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); - } - catch (java.lang.IllegalStateException e) { + } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException"); } } @@ -271,8 +252,7 @@ public class SessionTest extends PTPTestCase { senderSession.close(); // we close it a second time senderSession.close(); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("sec. 4.4.1 Closing a closed session must NOT throw an exception.\n"); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/TopicSessionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/TopicSessionTest.java index 09ea38a0a4..7ad6c7602a 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/TopicSessionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/TopicSessionTest.java @@ -86,8 +86,7 @@ public class TopicSessionTest extends PubSubTestCase { // finally we commit the subscriberSession transaction subscriberSession.commit(); - } - catch (Exception e) { + } catch (Exception e) { fail(e); } } @@ -116,8 +115,7 @@ public class TopicSessionTest extends PubSubTestCase { TextMessage m = (TextMessage) subscriber.receive(TestConfig.TIMEOUT); Assert.assertTrue(m != null); Assert.assertEquals("test", m.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -132,8 +130,7 @@ public class TopicSessionTest extends PubSubTestCase { subscriber.close(); // nothing should happen when unsubscribing the durable subscriber subscriberSession.unsubscribe("topic"); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } @@ -147,10 +144,8 @@ public class TopicSessionTest extends PubSubTestCase { try { subscriberSession.createDurableSubscriber(subscriberTopic, "topic", "definitely not a message selector!", true); Assert.fail("Should throw a javax.jms.InvalidSelectorException.\n"); - } - catch (InvalidSelectorException e) { - } - catch (JMSException e) { + } catch (InvalidSelectorException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidSelectorException, not a " + e); } } @@ -164,10 +159,8 @@ public class TopicSessionTest extends PubSubTestCase { try { subscriberSession.createDurableSubscriber((Topic) null, "topic"); Assert.fail("Should throw a javax.jms.InvalidDestinationException.\n"); - } - catch (InvalidDestinationException e) { - } - catch (JMSException e) { + } catch (InvalidDestinationException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidDestinationException, not a " + e); } } @@ -181,10 +174,8 @@ public class TopicSessionTest extends PubSubTestCase { try { subscriberSession.createSubscriber(subscriberTopic, "definitely not a message selector!", true); Assert.fail("Should throw a javax.jms.InvalidSelectorException.\n"); - } - catch (InvalidSelectorException e) { - } - catch (JMSException e) { + } catch (InvalidSelectorException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidSelectorException, not a " + e); } } @@ -198,10 +189,8 @@ public class TopicSessionTest extends PubSubTestCase { try { subscriberSession.createSubscriber((Topic) null); Assert.fail("Should throw a javax.jms.InvalidDestinationException.\n"); - } - catch (InvalidDestinationException e) { - } - catch (JMSException e) { + } catch (InvalidDestinationException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.InvalidDestinationException, not a " + e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java index c8501b1588..5b20f398c5 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java @@ -72,10 +72,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueConnection.createDurableConnectionConsumer(topic, "subscriptionName", "", (ServerSessionPool) null, 1); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -93,10 +91,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueSession.createDurableSubscriber(topic, "subscriptionName"); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -114,10 +110,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueSession.createTemporaryTopic(); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -135,10 +129,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueSession.createTopic("topic_name"); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -156,10 +148,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueSession.unsubscribe("subscriptionName"); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -177,10 +167,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { topicSession.createBrowser(queue); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -198,10 +186,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { topicSession.createQueue("queue_name"); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -219,10 +205,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { topicSession.createTemporaryQueue(); Assert.fail("Should throw a javax.jms.IllegalStateException"); - } - catch (javax.jms.IllegalStateException e) { - } - catch (JMSException e) { + } catch (javax.jms.IllegalStateException e) { + } catch (JMSException e) { Assert.fail("Should throw a javax.jms.IllegalStateException, not a " + e); } } @@ -239,8 +223,7 @@ public class UnifiedSessionTest extends UnifiedTestCase { queueConnection.start(); topicConnection.start(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -251,10 +234,8 @@ public class UnifiedSessionTest extends UnifiedTestCase { try { queueConnection.close(); topicConnection.close(); - } - catch (Exception ignored) { - } - finally { + } catch (Exception ignored) { + } finally { queueConnection = null; queueSession = null; topicConnection = null; diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/topic/TemporaryTopicTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/topic/TemporaryTopicTest.java index da6b4170c8..71e5baed82 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/topic/TemporaryTopicTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/topic/TemporaryTopicTest.java @@ -63,8 +63,7 @@ public class TemporaryTopicTest extends PubSubTestCase { Assert.assertTrue(m instanceof TextMessage); TextMessage msg = (TextMessage) m; Assert.assertEquals("testTemporaryTopic", msg.getText()); - } - catch (JMSException e) { + } catch (JMSException e) { fail(e); } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java index f51dea86b4..8964470ecd 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java @@ -66,8 +66,7 @@ public abstract class JMSTestCase extends Assert { message += " [linked exception: " + linkedException + "]"; } Assert.fail(message); - } - else { + } else { Assert.fail(e.getMessage()); } } @@ -105,8 +104,7 @@ public abstract class JMSTestCase extends Assert { if (startServer) { admin.stopServer(); } - } - finally { + } finally { } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java index 0902a03998..3dd2aba8a6 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java @@ -128,8 +128,7 @@ public abstract class PTPTestCase extends JMSTestCase { senderConnection.start(); receiverConnection.start(); // end of client step - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -146,11 +145,9 @@ public abstract class PTPTestCase extends JMSTestCase { admin.deleteQueueConnectionFactory(PTPTestCase.QCF_NAME); admin.deleteQueue(PTPTestCase.QUEUE_NAME); - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); - } - finally { + } finally { senderQueue = null; sender = null; senderQCF = null; diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java index 9974afb9be..d5792c0dc6 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java @@ -130,8 +130,7 @@ public abstract class PubSubTestCase extends JMSTestCase { publisherConnection.start(); subscriberConnection.start(); // end of client step - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } @@ -149,10 +148,8 @@ public abstract class PubSubTestCase extends JMSTestCase { admin.deleteTopicConnectionFactory(PubSubTestCase.TCF_NAME); admin.deleteTopic(PubSubTestCase.TOPIC_NAME); - } - catch (Exception ignored) { - } - finally { + } catch (Exception ignored) { + } finally { publisherTopic = null; publisher = null; publisherTCF = null; diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/TestConfig.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/TestConfig.java index dcc948a5f8..2491f4e377 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/TestConfig.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/TestConfig.java @@ -43,12 +43,10 @@ public class TestConfig { props.load(ClassLoader.getSystemResourceAsStream(TestConfig.PROP_FILE_NAME)); System.out.println("Found " + TestConfig.PROP_FILE_NAME); tempTimeOut = Long.parseLong(props.getProperty(TestConfig.PROP_NAME, "0")); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); tempTimeOut = 30000; - } - finally { + } finally { TIMEOUT = tempTimeOut; } } diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java index bab66d84d9..7d0901cb62 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java @@ -188,8 +188,7 @@ public abstract class UnifiedTestCase extends JMSTestCase { producerConnection.start(); consumerConnection.start(); // end of client step - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -210,10 +209,8 @@ public abstract class UnifiedTestCase extends JMSTestCase { admin.deleteQueue(UnifiedTestCase.DESTINATION_NAME); admin.deleteQueue(UnifiedTestCase.QUEUE_NAME); admin.deleteTopic(UnifiedTestCase.TOPIC_NAME); - } - catch (Exception ignored) { - } - finally { + } catch (Exception ignored) { + } finally { producerDestination = null; producer = null; producerCF = null; diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/journal/JournalImplTestUnit.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/journal/JournalImplTestUnit.java index 5e2d69ed95..a127ee9e33 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/journal/JournalImplTestUnit.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/journal/JournalImplTestUnit.java @@ -218,8 +218,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { double rate = 1000 * (double) numMessages / (end - start); JournalImplTestUnit.log.info("Rate " + rate + " records/sec"); - } - finally { + } finally { journal.stop(); } diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java index e19b190137..575a9e6d64 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.performance.paging; +import java.util.HashMap; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -28,9 +31,6 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; - public class MeasurePagingMultiThreadTest extends ActiveMQTestBase { @Test @@ -96,8 +96,7 @@ public class MeasurePagingMultiThreadTest extends ActiveMQTestBase { " finished sending in " + (end - start) + " milliseconds"); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } @@ -137,8 +136,7 @@ public class MeasurePagingMultiThreadTest extends ActiveMQTestBase { s.cleanUp(); } - } - finally { + } finally { locator.close(); messagingService.stop(); diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/AbstractSendReceivePerfTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/AbstractSendReceivePerfTest.java index be8093c917..f939eaaac2 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/AbstractSendReceivePerfTest.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/AbstractSendReceivePerfTest.java @@ -32,9 +32,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.JMSTestBase; import org.junit.Before; import org.junit.Test; @@ -108,12 +108,10 @@ public abstract class AbstractSendReceivePerfTest extends JMSTestBase { try { if (pendingCredit.tryAcquire(1, TimeUnit.SECONDS)) { return; - } - else { + } else { System.out.println("Couldn't get credits!"); } - } - catch (Throwable e) { + } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } } @@ -141,12 +139,10 @@ public abstract class AbstractSendReceivePerfTest extends JMSTestBase { consumeMessages(c, qName); c.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed = true; - } - finally { + } finally { running.set(false); } } @@ -176,13 +172,11 @@ public abstract class AbstractSendReceivePerfTest extends JMSTestBase { c.close(); - } - catch (Exception e) { + } catch (Exception e) { failed = true; if (e instanceof InterruptedException) { LOGGER.info("Sender done."); - } - else { + } else { e.printStackTrace(); } } @@ -205,4 +199,4 @@ public abstract class AbstractSendReceivePerfTest extends JMSTestBase { producer.send(q, s.createTextMessage("Message_" + (sent++))); } } -} \ No newline at end of file +} diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/ClientACKPerf.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/ClientACKPerf.java index 9758346780..cd37e2dc19 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/ClientACKPerf.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/sends/ClientACKPerf.java @@ -21,7 +21,6 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.Queue; import javax.jms.Session; - import java.util.Arrays; import java.util.Collection; import java.util.List; diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java index b70d432b4c..0ee92e9ce9 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java @@ -17,6 +17,14 @@ package org.apache.activemq.artemis.tests.performance.storage; +import java.io.File; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReentrantReadWriteLock; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.paging.PagingManager; @@ -38,14 +46,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; -import java.io.File; -import java.util.Collection; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReentrantReadWriteLock; - public class PersistMultiThreadTest extends ActiveMQTestBase { final String DIRECTORY = "./target/journaltmp"; @@ -178,12 +178,10 @@ public class PersistMultiThreadTest extends ActiveMQTestBase { deletes.add(deleteID); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { finish.countDown(); } @@ -238,12 +236,10 @@ public class PersistMultiThreadTest extends ActiveMQTestBase { storage.storeAcknowledge(1, deleteID); storage.deleteMessage(deleteID); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(System.out); errors.incrementAndGet(); - } - finally { + } finally { System.err.println("Finished the delete loop!!!! deleted " + deletesNr); } } diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/SendReceiveMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/SendReceiveMultiThreadTest.java index 8cde45eeda..2a89afb774 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/SendReceiveMultiThreadTest.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/SendReceiveMultiThreadTest.java @@ -120,15 +120,12 @@ public class SendReceiveMultiThreadTest extends ActiveMQTestBase { Thread.sleep(1000); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { try { conn.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -234,8 +231,7 @@ public class SendReceiveMultiThreadTest extends ActiveMQTestBase { } session.commit(); connection.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors++; } @@ -287,12 +283,10 @@ public class SendReceiveMultiThreadTest extends ActiveMQTestBase { connection.close(); System.out.println("Send " + numberOfMessages + " messages on thread " + Thread.currentThread().getName()); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { finish.countDown(); } } diff --git a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientAbstract.java b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientAbstract.java index 48105058dd..7b06b55de7 100644 --- a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientAbstract.java +++ b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientAbstract.java @@ -97,8 +97,7 @@ public abstract class ClientAbstract extends Thread { if (!found) { if (pendingCommit) { onCommit(); - } - else { + } else { onRollback(); } @@ -111,14 +110,12 @@ public abstract class ClientAbstract extends Thread { connectClients(); break; - } - catch (Exception e) { + } catch (Exception e) { ClientAbstract.log.warn("Can't connect to server, retrying"); disconnect(); try { Thread.sleep(1000); - } - catch (InterruptedException ignored) { + } catch (InterruptedException ignored) { // if an interruption was sent, we will respect it and leave the loop break; } @@ -177,8 +174,7 @@ public abstract class ClientAbstract extends Thread { if (session != null) { session.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { ignored.printStackTrace(); } diff --git a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientSoakTest.java b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientSoakTest.java index 77d09a8df3..be07b79584 100644 --- a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientSoakTest.java +++ b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientSoakTest.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.tests.soak.client; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; @@ -30,10 +34,6 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - public class ClientSoakTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Receiver.java b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Receiver.java index e0dc1f1317..aef8e5e376 100644 --- a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Receiver.java +++ b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Receiver.java @@ -91,8 +91,7 @@ public class Receiver extends ClientAbstract { } endTX(); - } - catch (Exception e) { + } catch (Exception e) { connect(); } @@ -145,8 +144,7 @@ public class Receiver extends ClientAbstract { latchMax.setCount(currentDiff.get() - MAX_DIFF); try { latchMax.await(5, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } diff --git a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Sender.java b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Sender.java index 6d40e8ce13..26f006363e 100644 --- a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Sender.java +++ b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/Sender.java @@ -67,8 +67,7 @@ public class Sender extends ClientAbstract { pendingMsgs++; } endTX(); - } - catch (Exception e) { + } catch (Exception e) { connect(); } } diff --git a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/SimpleSendReceiveSoakTest.java b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/SimpleSendReceiveSoakTest.java index c2259a8190..559727e7b6 100644 --- a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/SimpleSendReceiveSoakTest.java +++ b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/SimpleSendReceiveSoakTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.soak.client; -import org.junit.Before; - -import org.junit.Test; - import java.util.HashMap; import org.apache.activemq.artemis.api.core.SimpleString; @@ -33,6 +29,8 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Before; +import org.junit.Test; public class SimpleSendReceiveSoakTest extends ActiveMQTestBase { diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/client/SendStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/client/SendStressTest.java index d667786e2f..e99fd83716 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/client/SendStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/client/SendStressTest.java @@ -105,14 +105,12 @@ public class SendStressTest extends ActiveMQTestBase { } session.commit(); - } - finally { + } finally { if (session != null) { try { sf.close(); session.close(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java index eb49a99c5f..0162dcc326 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java @@ -19,14 +19,14 @@ package org.apache.activemq.artemis.tests.stress.journal; import java.util.ArrayList; import java.util.List; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; -import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java index 48895ba317..f1aa8b6dbe 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java @@ -182,8 +182,7 @@ public class CompactingStressTest extends ActiveMQTestBase { } session.commit(); - } - finally { + } finally { session.close(); } @@ -229,21 +228,17 @@ public class CompactingStressTest extends ActiveMQTestBase { prod.send(msg); } sessionSlow.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } try { sessionSlow.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -273,15 +268,12 @@ public class CompactingStressTest extends ActiveMQTestBase { } Assert.assertNull(cons.receiveImmediate()); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -351,12 +343,10 @@ public class CompactingStressTest extends ActiveMQTestBase { Assert.assertNull(cons.receiveImmediate()); - } - finally { + } finally { try { sess.close(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } @@ -375,20 +365,17 @@ public class CompactingStressTest extends ActiveMQTestBase { try { sess.createQueue(CompactingStressTest.AD1, CompactingStressTest.Q1, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } try { sess.createQueue(CompactingStressTest.AD2, CompactingStressTest.Q2, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } try { sess.createQueue(CompactingStressTest.AD3, CompactingStressTest.Q3, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } sess.close(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java index 849e285442..c08f1dddd6 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java @@ -34,13 +34,13 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.core.io.IOCallback; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; -import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; @@ -109,8 +109,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { if (LibaioContext.isLoaded()) { factory = new AIOSequentialFileFactory(dir, 10); maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(); - } - else { + } else { factory = new NIOSequentialFileFactory(dir, true, 1); maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio(); } @@ -134,8 +133,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { journal.appendDeleteRecord(id, id == 20); } // System.out.println("OnCompactStart leave"); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -158,8 +156,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { if (journal.isStarted()) { journal.stop(); } - } - catch (Exception e) { + } catch (Exception e) { // don't care :-) } @@ -278,8 +275,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { for (RecordInfo record : committedRecords) { if (record.isUpdate) { updates++; - } - else { + } else { appends++; } } @@ -355,13 +351,11 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { rwLock.readLock().lock(); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); running = false; errors.incrementAndGet(); - } - finally { + } finally { rwLock.readLock().unlock(); } } @@ -419,13 +413,11 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { if (txCount > 0) { journal.appendCommitRecord(txID, true); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); running = false; errors.incrementAndGet(); - } - finally { + } finally { rwLock.readLock().unlock(); } } @@ -451,14 +443,12 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { numberOfDeletes.incrementAndGet(); } } - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Can't delete id"); e.printStackTrace(); running = false; errors.incrementAndGet(); - } - finally { + } finally { rwLock.readLock().unlock(); } } @@ -507,12 +497,10 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase { numberOfDeletes.incrementAndGet(); } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); System.exit(-1); - } - finally { + } finally { rwLock.readLock().unlock(); } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalRestartStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalRestartStressTest.java index 6373a2fd37..da6ff41cbc 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalRestartStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalRestartStressTest.java @@ -67,8 +67,7 @@ public class JournalRestartStressTest extends ActiveMQTestBase { try { session.createQueue("slow-queue", "slow-queue"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } session.start(); @@ -113,8 +112,7 @@ public class JournalRestartStressTest extends ActiveMQTestBase { try { sessionSend.createQueue("Queue", "Queue", true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } final ClientSession sessionReceive = sf.createSession(true, true); @@ -142,8 +140,7 @@ public class JournalRestartStressTest extends ActiveMQTestBase { } msg.acknowledge(); } - } - catch (Exception e) { + } catch (Exception e) { errors.add(e); } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java index ac0003880c..0dc3423a95 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.stress.journal; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -32,9 +35,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - public class LargeJournalStressTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -116,21 +116,17 @@ public class LargeJournalStressTest extends ActiveMQTestBase { prod.send(msg); } sessionSlow.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } try { sessionSlow.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -160,15 +156,12 @@ public class LargeJournalStressTest extends ActiveMQTestBase { } Assert.assertNull(cons.receiveImmediate()); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -252,14 +245,12 @@ public class LargeJournalStressTest extends ActiveMQTestBase { try { sess.createQueue(LargeJournalStressTest.AD1, LargeJournalStressTest.Q1, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } try { sess.createQueue(LargeJournalStressTest.AD2, LargeJournalStressTest.Q2, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } sess.close(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MixupCompactorTestBase.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MixupCompactorTestBase.java index 93e631bfff..12c6e23a98 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MixupCompactorTestBase.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MixupCompactorTestBase.java @@ -19,10 +19,10 @@ package org.apache.activemq.artemis.tests.stress.journal; import java.io.File; import java.io.FilenameFilter; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.core.io.SequentialFileFactory; -import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; +import org.apache.activemq.artemis.core.journal.impl.JournalImpl; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.SimpleIDGenerator; import org.junit.After; @@ -105,8 +105,7 @@ public abstract class MixupCompactorTestBase extends JournalImplTestBase { startedCompactingLatch.countDown(); try { releaseCompactingLatch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -133,8 +132,7 @@ public abstract class MixupCompactorTestBase extends JournalImplTestBase { tearDown(); setUp(); testMix(startAt, joinAt, secondAt); - } - catch (Throwable e) { + } catch (Throwable e) { throw new Exception("Error at compact=" + startCompactAt + ", joinCompactAt=" + joinCompactAt + @@ -197,8 +195,7 @@ public abstract class MixupCompactorTestBase extends JournalImplTestBase { public void run() { try { journal.testCompact(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java index e4add672e8..64f16d860d 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.stress.journal; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; + import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -32,9 +35,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; - /** * A MultiThreadConsumerStressTest *
@@ -157,8 +157,7 @@ public class MultiThreadConsumerStressTest extends ActiveMQTestBase { try { sess.createQueue(ADDRESS, QUEUE, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } sess.close(); @@ -234,16 +233,13 @@ public class MultiThreadConsumerStressTest extends ActiveMQTestBase { " sent " + numberOfMessages + " messages"); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -286,15 +282,12 @@ public class MultiThreadConsumerStressTest extends ActiveMQTestBase { " messages"); session.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java index b55530234b..e954a85dcc 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java @@ -33,10 +33,10 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.jlibaio.LibaioContext; @@ -259,8 +259,7 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase { ClientSession session = sf.createSession(false, false); try { session.createQueue(queue, queue, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } ClientProducer prod = session.createProducer(queue); @@ -284,8 +283,7 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase { if (server != null && server.isStarted()) { server.stop(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(System.out); // System.out => junit reports } @@ -317,8 +315,7 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase { try { sess.createQueue(ADDRESS, QUEUE, true); - } - catch (Exception ignored) { + } catch (Exception ignored) { } sess.close(); @@ -401,16 +398,13 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase { " sent " + numberOfMessages + " messages"); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } @@ -454,15 +448,12 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase { " messages"); session.commit(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; - } - finally { + } finally { try { session.close(); - } - catch (Throwable e) { + } catch (Throwable e) { this.e = e; } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java index a9116a9fe4..af9d7adadc 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.stress.paging; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -32,11 +37,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; - public class MultipleConsumersPageStressTest extends ActiveMQTestBase { private final UnitTestLogger log = UnitTestLogger.LOGGER; @@ -135,8 +135,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { try { internalMultipleConsumers(); - } - catch (Throwable e) { + } catch (Throwable e) { TestConsumer tstConsumer = consumers.get(0); System.out.println("first retry: " + tstConsumer.consumer.receive(1000)); @@ -235,8 +234,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { int numberOfMessages = random.nextInt(20); if (numberOfMessages <= 0) { return 1; - } - else { + } else { return numberOfMessages; } } @@ -266,8 +264,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { sf.close(); locator.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -304,8 +301,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { try { if (shareConnectionFactory) { session = sharedSf.createSession(false, false); - } - else { + } else { locator = createInVMNonHALocator(); sf = createSessionFactory(locator); session = sf.createSession(false, false); @@ -360,8 +356,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { } } - } - catch (Throwable e) { + } catch (Throwable e) { exceptionHappened(e); } @@ -381,8 +376,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { try { session.rollback(); session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -397,8 +391,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { try { if (shareConnectionFactory) { session = sharedSf.createSession(false, false); - } - else { + } else { locator = createInVMNonHALocator(); sf = createSessionFactory(locator); session = sf.createSession(false, false); @@ -421,8 +414,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { messagesAvailable.addAndGet(numberOfMessages); session.commit(); } - } - catch (Throwable e) { + } catch (Throwable e) { exceptionHappened(e); } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java index 5fbc733195..b69cc313ba 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.stress.paging; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.config.Configuration; @@ -45,14 +53,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; - public class PageCursorStressTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -150,8 +150,7 @@ public class PageCursorStressTest extends ActiveMQTestBase { Boolean property = message.getBooleanProperty("even"); if (property == null) { return false; - } - else { + } else { return property.booleanValue(); } } @@ -170,8 +169,7 @@ public class PageCursorStressTest extends ActiveMQTestBase { Boolean property = message.getBooleanProperty("even"); if (property == null) { return false; - } - else { + } else { return !property.booleanValue(); } } @@ -544,8 +542,7 @@ public class PageCursorStressTest extends ActiveMQTestBase { } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); exceptions.incrementAndGet(); } @@ -563,8 +560,7 @@ public class PageCursorStressTest extends ActiveMQTestBase { ref = iterator.next(); if (ref == null) { Thread.sleep(1000); - } - else { + } else { break; } } @@ -803,8 +799,7 @@ public class PageCursorStressTest extends ActiveMQTestBase { try { queue = server.createQueue(ADDRESS, ADDRESS, null, true, false); queue.pause(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/remote/PingStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/remote/PingStressTest.java index 9af6b90445..7fc46dd99d 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/remote/PingStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/remote/PingStressTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.stress.remote; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -31,9 +34,6 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - public class PingStressTest extends ActiveMQTestBase { private static final UnitTestLogger log = UnitTestLogger.LOGGER; @@ -77,8 +77,7 @@ public class PingStressTest extends ActiveMQTestBase { if (packet.getType() == PacketImpl.PING) { PingStressTest.log.info("Ignoring Ping packet.. it will be dropped"); return false; - } - else { + } else { return true; } } @@ -127,8 +126,7 @@ public class PingStressTest extends ActiveMQTestBase { // them) if (RandomUtil.randomBoolean()) { session = csf1.createSession(false, false, false); - } - else { + } else { session = csf2.createSession(false, false, false); } @@ -141,8 +139,7 @@ public class PingStressTest extends ActiveMQTestBase { locator.close(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); failure = e; } @@ -176,4 +173,4 @@ public class PingStressTest extends ActiveMQTestBase { locator.close(); } -} \ No newline at end of file +} diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java index 71485edff3..331c7d4f0c 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.stress.stomp; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -31,18 +25,21 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; - -import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.protocol.stomp.Stomp; +import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class StompStressTest extends ActiveMQTestBase { @@ -151,8 +148,7 @@ public class StompStressTest extends ActiveMQTestBase { c = is.read(); if (c < 0) { throw new IOException("socket closed."); - } - else if (c == 0) { + } else if (c == 0) { c = is.read(); if (c != '\n') { byte[] ba = inputBuffer.toByteArray(); @@ -162,8 +158,7 @@ public class StompStressTest extends ActiveMQTestBase { byte[] ba = inputBuffer.toByteArray(); inputBuffer.reset(); return new String(ba, StandardCharsets.UTF_8); - } - else { + } else { inputBuffer.write(c); } } diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java index f407d9eb75..4e8e9623db 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java @@ -18,9 +18,9 @@ package org.apache.activemq.artemis.tests.timing.core.journal.impl; import java.io.File; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.BeforeClass; public class AIOJournalImplTest extends JournalImplTestUnit { diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/FakeJournalImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/FakeJournalImplTest.java index 4c272bf948..1052bd1ccb 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/FakeJournalImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/FakeJournalImplTest.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.artemis.tests.timing.core.journal.impl; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; public class FakeJournalImplTest extends JournalImplTestUnit { diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java index 34433ff4b4..34ce7ac95f 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java @@ -188,8 +188,7 @@ public class QueueConcurrentTest extends ActiveMQTestBase { while (System.currentTimeMillis() - start < testTime) { if (toggle) { consumer.setStatusImmediate(HandleStatus.BUSY); - } - else { + } else { consumer.setStatusImmediate(HandleStatus.HANDLED); queue.deliverNow(); diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java index 18ab995ed1..c0a41128f4 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.timing.core.server.impl; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -31,14 +24,18 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.HandleStatus; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.impl.QueueImpl; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class QueueImplTest extends ActiveMQTestBase { diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java index d322a1add7..34bbdb253f 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java @@ -16,33 +16,6 @@ */ package org.apache.activemq.artemis.tests.timing.jms.bridge.impl; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; -import org.apache.activemq.artemis.core.server.ActiveMQServers; -import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; -import org.apache.activemq.artemis.jms.bridge.DestinationFactory; -import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; -import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl; -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; -import org.apache.activemq.artemis.jms.server.JMSServerManager; -import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; -import org.apache.activemq.artemis.tests.unit.UnitTestLogger; -import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -71,6 +44,33 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; +import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory; +import org.apache.activemq.artemis.jms.bridge.DestinationFactory; +import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; +import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl; +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.jms.server.JMSServerManager; +import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; +import org.apache.activemq.artemis.tests.unit.UnitTestLogger; +import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + public class JMSBridgeImplTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -175,8 +175,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase { try { tcclClassLoader.loadClass("com.class.only.visible.to.tccl.SomeClass"); tcclClassFound.set(true); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { e.printStackTrace(); } } @@ -241,8 +240,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase { if (firstTime) { firstTime = false; throw new JMSException("unable to create a conn"); - } - else { + } else { return super.createConnection(); } } @@ -541,8 +539,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase { firstTime = false; sourceConn.set(super.createConnection()); return sourceConn.get(); - } - else { + } else { throw new JMSException("exception while retrying to connect"); } } @@ -637,13 +634,12 @@ public class JMSBridgeImplTest extends ActiveMQTestBase { bridge.stop(); Assert.assertFalse(bridge.isStarted()); assertTrue(tcclClassFound.get()); - } - finally { - if (mockTccl != null) unsetMockTCCL(mockTccl); + } finally { + if (mockTccl != null) + unsetMockTCCL(mockTccl); } } - // Package protected --------------------------------------------- // Protected ----------------------------------------------------- @@ -742,6 +738,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase { // Inner classes ------------------------------------------------- private static class MockContextClassLoader extends ClassLoader { + private final ClassLoader original; private final String knownClass = "com.class.only.visible.to.tccl.SomeClass"; diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java index 52a6b8a290..288ec119c5 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java @@ -17,11 +17,9 @@ package org.apache.activemq.artemis.tests.timing.util; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.utils.ReusableLatch; +import org.junit.Assert; +import org.junit.Test; public class ReusableLatchTest extends ActiveMQTestBase { diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java index 6dca39773e..1f8bff1d59 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java @@ -130,8 +130,7 @@ public class TokenBucketLimiterImplTest extends ActiveMQTestBase { // any variation on 1 could make the test to fail, for that reason we make it this way Assert.assertTrue(count == 5 || count == 6); - } - else { + } else { double actualRate = (double) (1000 * count) / measureTime; Assert.assertTrue("actual rate = " + actualRate + " expected=" + rate, actualRate > rate * (1 - error)); @@ -186,8 +185,7 @@ public class TokenBucketLimiterImplTest extends ActiveMQTestBase { if (calculatedRate > rate * error) { System.out.println("got more than " + rate + " tokens / second"); rateError.set(true); - } - else if (calculatedRate > rate) { + } else if (calculatedRate > rate) { System.out.println("got more than " + rate + " tokens / second but still on the error marging" + "make sure it's ok though, if you see to many of this message it's an issue"); } @@ -197,8 +195,7 @@ public class TokenBucketLimiterImplTest extends ActiveMQTestBase { lastRun = tmpValue; try { Thread.sleep(window * 1000); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java index 244c04c204..e0d5a74a6c 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java @@ -18,14 +18,11 @@ package org.apache.activemq.artemis.tests.timing.util; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.junit.After; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.UTF8Util; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; public class UTF8Test extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java index fb0f96613e..526663f97d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java @@ -16,6 +16,14 @@ */ package org.apache.activemq.artemis.tests.unit.core.asyncio; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.aio.AIOSequentialFile; import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory; @@ -28,14 +36,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - /** * you need to define -Djava.library.path=${project-root}/native/src/.libs when calling the JVM * If you are running this test in eclipse you should do: @@ -137,8 +137,7 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { (endTime - startTime) + " total number of records = " + MultiThreadAsynchronousFileTest.NUMBER_OF_THREADS * MultiThreadAsynchronousFileTest.NUMBER_OF_LINES); - } - finally { + } finally { file.close(); factory.stop(); } @@ -229,12 +228,10 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { assertFalse(callback.errorCalled != 0); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); failed = e; - } - finally { + } finally { synchronized (MultiThreadAsynchronousFileTest.class) { LibaioContext.freeBuffer(buffer); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java index 32937a3184..a0bc01ca65 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java @@ -16,6 +16,19 @@ */ package org.apache.activemq.artemis.tests.unit.core.client.impl; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; @@ -38,19 +51,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class LargeMessageBufferTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -84,8 +84,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { for (int i = 1; i <= 15; i++) { try { Assert.assertEquals(i, buffer.readByte()); - } - catch (Exception e) { + } catch (Exception e) { throw new Exception("Exception at position " + i, e); } } @@ -93,8 +92,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { buffer.readByte(); Assert.fail("supposed to throw an exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { } } @@ -114,8 +112,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { bytes = new byte[16]; buffer.getBytes(0, bytes); Assert.fail("supposed to throw an exception"); - } - catch (java.lang.IndexOutOfBoundsException e) { + } catch (java.lang.IndexOutOfBoundsException e) { } } @@ -148,8 +145,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { buffer.readByte(); Assert.fail("supposed to throw an exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { } } @@ -179,8 +175,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { buffer.readByte(); Assert.fail("supposed to throw an exception"); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { } } @@ -282,13 +277,10 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { latchGo.countDown(); buffer.readBytes(new byte[5]); - } - catch (IndexOutOfBoundsException ignored) { - } - catch (IllegalAccessError ignored) { + } catch (IndexOutOfBoundsException ignored) { + } catch (IllegalAccessError ignored) { - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errorCount.incrementAndGet(); } @@ -344,8 +336,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { for (int i = 0; i < 10240 * 10; i++) { assertEquals("position " + i, getSamplebyte(i), outBuffer.readByte()); } - } - finally { + } finally { outBuffer.close(); } @@ -384,12 +375,10 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { } } } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); - } - finally { + } finally { done1.countDown(); done2.countDown(); } @@ -413,8 +402,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { outBuffer.waitCompletion(0); waiting.countDown(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -481,8 +469,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { outBuffer.waitCompletion(0); fail("supposed to throw an exception"); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } assertTrue("It was supposed to wait at least 1 second", System.currentTimeMillis() - time > 1000); @@ -511,8 +498,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { outBuffer.addPacket(new byte[]{0}, 1, true); Thread.sleep(200); outBuffer.addPacket(new byte[]{0}, 1, false); - } - catch (Exception e) { + } catch (Exception e) { } } }; @@ -545,8 +531,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { try { outBuffer.readByte(); Assert.fail("supposed to throw an exception"); - } - catch (IllegalAccessError ignored) { + } catch (IllegalAccessError ignored) { } Assert.assertTrue("It waited too much", System.currentTimeMillis() - start < 30000); @@ -633,8 +618,7 @@ public class LargeMessageBufferTest extends ActiveMQTestBase { System.arraycopy(splitElement, 0, newSplit, 0, size); outBuffer.addPacket(newSplit, 1, input.available() > 0); - } - else { + } else { outBuffer.addPacket(splitElement, 1, input.available() > 0); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java index a87c71c008..ac6e4bea12 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java @@ -17,13 +17,11 @@ package org.apache.activemq.artemis.tests.unit.core.config.impl; import org.apache.activemq.artemis.core.config.FileDeploymentManager; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.XMLUtil; +import org.junit.Assert; +import org.junit.Test; import org.w3c.dom.Element; public class ConfigurationValidationTest extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java index 300f9782b0..aee7a71c6c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java @@ -20,16 +20,16 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import org.apache.activemq.artemis.core.server.ServiceRegistry; -import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.ConnectorService; +import org.apache.activemq.artemis.core.server.ServiceRegistry; import org.apache.activemq.artemis.core.server.impl.ConnectorsService; import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl; import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService; +import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Before; import org.junit.Test; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java index e670bbc4c4..7b02089d92 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java @@ -16,18 +16,16 @@ */ package org.apache.activemq.artemis.tests.unit.core.config.impl; +import java.util.HashMap; +import java.util.Map; + +import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.remoting.impl.TransportConfigurationUtil; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Test; - import org.junit.Assert; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; - -import java.util.HashMap; -import java.util.Map; +import org.junit.Test; public class TransportConfigurationTest extends ActiveMQTestBase { @@ -128,7 +126,6 @@ public class TransportConfigurationTest extends ActiveMQTestBase { Assert.assertFalse(TransportConfigurationUtil.isSameHost(tc1, tc2)); } - @Test public void testSameHostInVMTrueDefault() { Map params1 = new HashMap<>(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java index 64558db034..080db78bfa 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; @@ -32,18 +25,22 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; - +import org.apache.activemq.artemis.core.io.SequentialFile; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFile; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class AlignedJournalImplTest extends ActiveMQTestBase { @@ -131,8 +128,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { Assert.assertEquals("Position " + i, (byte) 2, buffer.get(i)); } - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -143,8 +139,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { try { journalImpl = new JournalImpl(2000, 2, 2, 0, 0, factory, "tt", "tt", 1000); Assert.fail("Expected IllegalArgumentException"); - } - catch (IllegalArgumentException ignored) { + } catch (IllegalArgumentException ignored) { // expected } @@ -236,8 +231,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { for (int j = 0; j < 5; j++) { Assert.assertEquals((byte) i, recordItem.data[j]); } - } - else { + } else { Assert.assertEquals((i - 10) * 100L, recordItem.id); Assert.assertEquals(i - 10, recordItem.getUserRecordType()); Assert.assertTrue(recordItem.isUpdate); @@ -381,8 +375,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { // This was supposed to throw an exception, as the transaction was // forgotten (interrupted by a reload). Assert.fail("Supposed to throw exception"); - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.warn(e); } @@ -430,8 +423,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { // This was supposed to throw an exception, as the transaction was // forgotten (interrupted by a reload). Assert.fail("Supposed to throw exception"); - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.debug("Expected exception " + e, e); } @@ -1144,8 +1136,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { queueDelete.offer(i); } finishedOK.incrementAndGet(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -1165,8 +1156,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { journalImpl.appendDeleteRecord(toDelete, false); } finishedOK.incrementAndGet(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java index f21757be64..48cba761fc 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java @@ -87,13 +87,11 @@ public class CleanBufferTest extends ActiveMQTestBase { for (byte b = 0; b < 100; b++) { if (b < 10) { Assert.assertEquals(0, buffer.get()); - } - else { + } else { Assert.assertEquals(b, buffer.get()); } } - } - finally { + } finally { factory.releaseBuffer(buffer); factory.stop(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeJournalImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeJournalImplTest.java index ecf44c1006..ce8c30fbc8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeJournalImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeJournalImplTest.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; public class FakeJournalImplTest extends JournalImplTestUnit { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeSequentialFileFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeSequentialFileFactoryTest.java index 8612ae4564..70e8fa54a8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeSequentialFileFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FakeSequentialFileFactoryTest.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.core.io.SequentialFileFactory; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; public class FakeSequentialFileFactoryTest extends SequentialFileFactoryTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java index c3b37e1a0f..41058c685b 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java @@ -20,12 +20,12 @@ import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -85,12 +85,10 @@ public class JournalAsyncTest extends ActiveMQTestBase { factory.setHoldCallbacks(false, null); if (isCommit) { journalImpl.appendCommitRecord(1L, true); - } - else { + } else { journalImpl.appendRollbackRecord(1L, true); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); this.e = e; } @@ -141,8 +139,7 @@ public class JournalAsyncTest extends ActiveMQTestBase { // of the elements on this transaction. // We can't accept any more elements on // the transaction - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -157,8 +154,7 @@ public class JournalAsyncTest extends ActiveMQTestBase { try { journalImpl.appendAddRecord(1L, (byte) 0, new SimpleEncoding(1, (byte) 0), true); Assert.fail("Exception expected"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } @@ -189,8 +185,7 @@ public class JournalAsyncTest extends ActiveMQTestBase { if (journalImpl != null) { try { journalImpl.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java index 524c1a816c..3d70b1a636 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java @@ -28,10 +28,10 @@ import java.util.Map; import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal; import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal; +import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TestableJournal; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; @@ -131,7 +131,11 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { this.maxAIO = maxAIO; } - protected void setup(final int minFreeFiles, final int poolSize, final int fileSize, final boolean sync, final int maxAIO) { + protected void setup(final int minFreeFiles, + final int poolSize, + final int fileSize, + final boolean sync, + final int maxAIO) { minFiles = minFreeFiles; this.poolSize = poolSize; this.fileSize = fileSize; @@ -155,8 +159,7 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { System.out.println("Waiting on Compact"); try { latchWait.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Waiting on Compact Done"); @@ -177,8 +180,7 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { public void run() { try { journal.testCompact(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java index e64947c7c5..8f23c2c70c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java @@ -16,19 +16,19 @@ */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; +import java.io.File; import java.nio.ByteBuffer; import java.util.List; -import java.io.File; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; -import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.utils.RandomUtil; +import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; +import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; +import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -58,23 +58,20 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { try { load(); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { stopJournal(); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } startJournal(); try { startJournal(); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } stopJournal(); @@ -83,15 +80,13 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { try { load(); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } try { startJournal(); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // OK } stopJournal(); @@ -124,8 +119,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(JournalImpl.MIN_FILE_SIZE - 1, 10, 10, 0, 0, fileFactory, filePrefix, fileExtension, 1); Assert.fail("Should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -133,8 +127,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(10 * 1024, 1, 0, 0, 0, fileFactory, filePrefix, fileExtension, 1); Assert.fail("Should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -142,8 +135,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(10 * 1024, 10, 0, 0, 0, null, filePrefix, fileExtension, 1); Assert.fail("Should throw exception"); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { // Ok } @@ -151,8 +143,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(10 * 1024, 10, 0, 0, 0, fileFactory, null, fileExtension, 1); Assert.fail("Should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -160,8 +151,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(10 * 1024, 10, 0, 0, 0, fileFactory, filePrefix, null, 1); Assert.fail("Should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -169,8 +159,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { new JournalImpl(10 * 1024, 10, 0, 0, 0, fileFactory, filePrefix, null, 0); Assert.fail("Should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -217,11 +206,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { boolean exceptionHappened = false; try { load(); - } - catch (ActiveMQIOErrorException ioe) { + } catch (ActiveMQIOErrorException ioe) { exceptionHappened = true; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { Assert.fail("invalid exception type:" + e.getType()); } @@ -347,8 +334,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { } stopJournal(); - } - finally { + } finally { filePrefix = "amq"; fileExtension = "amq"; @@ -467,12 +453,10 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { if (numberOfRecords < recordsFit) { currentPosition = currentPosition + numberOfRecords * recordSize; numberOfRecords = 0; - } - else if (recordsFit > 0) { + } else if (recordsFit > 0) { currentPosition = currentPosition + recordsFit * recordSize; numberOfRecords -= recordsFit; - } - else { + } else { totalFiles++; currentPosition = headerSize; } @@ -567,7 +551,6 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { stopJournal(); } - @Test public void testOrganicallyGrowNoLimit() throws Exception { setup(2, -1, 10 * 1024, true, 50); @@ -592,7 +575,6 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.forceMoveNextFile(); } - for (int i = 0; i < 200; i++) { delete(i); } @@ -600,8 +582,6 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.checkReclaimStatus(); - - files1 = fileFactory.listFiles(fileExtension); Assert.assertTrue(files1.size() > 200); @@ -613,7 +593,6 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { } journal.checkReclaimStatus(); - files1 = fileFactory.listFiles(fileExtension); Assert.assertTrue(files1.size() > 200); @@ -650,7 +629,6 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.checkReclaimStatus(); - for (int i = 0; i < 200; i++) { delete(i); } @@ -989,8 +967,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { if (commit) { commit(1); - } - else { + } else { rollback(1); } @@ -2665,8 +2642,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { try { update(1); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Ok } @@ -2686,8 +2662,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { try { delete(1); Assert.fail("Should throw exception"); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { // Ok } @@ -3045,8 +3020,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { try { load(); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail("Unexpected exception: " + e.toString()); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java index 8216800740..e4dbad0169 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java @@ -18,6 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.journal.impl; import java.util.HashMap; import java.util.Map; + import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; @@ -741,8 +742,7 @@ public class ReclaimerTest extends ActiveMQTestBase { if (count != null) { return count.intValue(); - } - else { + } else { return 0; } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java index a3da5fa440..da7fc782cb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java @@ -137,8 +137,7 @@ public abstract class SequentialFileFactoryTestBase extends ActiveMQTestBase { checkFill(sf, 512); checkFill(sf, 512 * 4); - } - finally { + } finally { sf.close(); } } @@ -339,12 +338,10 @@ public abstract class SequentialFileFactoryTestBase extends ActiveMQTestBase { ActiveMQTestBase.assertEqualsByteArrays(bytes1, rbytes1); - } - finally { + } finally { try { sf.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -373,8 +370,7 @@ public abstract class SequentialFileFactoryTestBase extends ActiveMQTestBase { sf.write(wrapBuffer(bytes1), true); Assert.fail("Should throw exception"); - } - catch (Exception e) { + } catch (Exception e) { } sf.open(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java index 780c4ed4ff..31cb9703b1 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java @@ -119,8 +119,7 @@ public class TimedBufferTest extends ActiveMQTestBase { for (int i = 0; i < 100; i++) { Assert.assertEquals(ActiveMQTestBase.getSamplebyte(i), flushedBuffer.get()); } - } - finally { + } finally { timedBuffer.stop(); } @@ -201,8 +200,7 @@ public class TimedBufferTest extends ActiveMQTestBase { for (int i = 0; i < 20; i++) { Assert.assertEquals(ActiveMQTestBase.getSamplebyte(i), flushedBuffer.get()); } - } - finally { + } finally { timedBuffer.stop(); } @@ -279,8 +277,7 @@ public class TimedBufferTest extends ActiveMQTestBase { sleptLatch.await(10, TimeUnit.SECONDS); assertFalse(timedBuffer.isUseSleep()); - } - finally { + } finally { timedBuffer.stop(); } @@ -362,8 +359,7 @@ public class TimedBufferTest extends ActiveMQTestBase { Thread.sleep(100); assertTrue(timedBuffer.isUseSleep()); - } - finally { + } finally { timedBuffer.stop(); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java index fd44f2bcf2..d0676eebc2 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java @@ -28,10 +28,10 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.core.io.IOCallback; -import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFileFactory; import org.apache.activemq.artemis.core.io.buffer.TimedBuffer; +import org.apache.activemq.artemis.core.journal.EncodingSupport; public class FakeSequentialFileFactory implements SequentialFileFactory { @@ -74,8 +74,7 @@ public class FakeSequentialFileFactory implements SequentialFileFactory { sf = newSequentialFile(fileName); fileMap.put(fileName, sf); - } - else { + } else { sf.getData().position(0); // log.debug("positioning data to 0"); @@ -230,15 +229,13 @@ public class FakeSequentialFileFactory implements SequentialFileFactory { if (sendError) { callback.onError(ActiveMQExceptionType.UNSUPPORTED_PACKET.getCode(), "Fake aio error"); - } - else { + } else { try { file.data.put(bytes); if (callback != null) { callback.done(); } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); callback.onError(ActiveMQExceptionType.GENERIC_EXCEPTION.getCode(), e.getMessage()); } @@ -392,8 +389,7 @@ public class FakeSequentialFileFactory implements SequentialFileFactory { if (holdCallbacks) { addCallback(bytes, action); - } - else { + } else { action.run(); } @@ -410,8 +406,7 @@ public class FakeSequentialFileFactory implements SequentialFileFactory { public long size() throws Exception { if (data == null) { return 0; - } - else { + } else { return data.limit(); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java index 2a377ff589..c559bf9a61 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java @@ -23,11 +23,11 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Test; @@ -252,15 +252,13 @@ public class MessageImplTest extends ActiveMQTestBase { latchAlign.countDown(); try { latchReady.await(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } for (int i = 0; i < RUNS; i++) { try { ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } @@ -284,8 +282,7 @@ public class MessageImplTest extends ActiveMQTestBase { latchAlign.countDown(); try { latchReady.await(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } for (int i = 0; i < RUNS; i++) { @@ -293,8 +290,7 @@ public class MessageImplTest extends ActiveMQTestBase { SessionSendMessage ssm = new SessionSendMessage(msg); ActiveMQBuffer buf = ssm.encode(null); simulateRead(buf); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.incrementAndGet(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java index 9731277148..923e719560 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java @@ -412,8 +412,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase { final RoutingContextImpl ctx2 = new RoutingContextImpl(null); if (storeImpl.page(msg, ctx2.getTransaction(), ctx2.getContextListing(storeImpl.getStoreName()), lock)) { buffers.put(id, msg); - } - else { + } else { break; } @@ -423,12 +422,10 @@ public class PagingStoreImplTest extends ActiveMQTestBase { firstTime = false; } } - } - catch (Exception e1) { + } catch (Exception e1) { e1.printStackTrace(); this.e = e1; - } - finally { + } finally { aliveProducers.decrementAndGet(); } } @@ -450,8 +447,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase { readPages.add(page); } } - } - catch (Exception e1) { + } catch (Exception e1) { e1.printStackTrace(); this.e = e1; } @@ -659,8 +655,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase { producedLatch.countDown(); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.add(e); } @@ -695,15 +690,13 @@ public class PagingStoreImplTest extends ActiveMQTestBase { page.close(); page.delete(null); - } - else { + } else { System.out.println("Depaged!!!! numerOfMessages = " + msgsRead + " of " + NUMBER_OF_MESSAGES); Thread.sleep(500); } } - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); errors.add(e); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java index 88cbcaad0a..4b380ceeba 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java @@ -21,16 +21,16 @@ import java.util.ArrayList; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.impl.journal.BatchingIDGenerator; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; @@ -142,8 +142,7 @@ public class BatchIDGeneratorUnitTest extends ActiveMQTestBase { try { storageManager.start(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } return storageManager; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java index e3321307e3..83c6bcdcec 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java @@ -24,8 +24,8 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.core.io.IOCallback; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Assert; import org.junit.Test; @@ -95,8 +95,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { assertTrue(latch2.await(10, TimeUnit.SECONDS)); - } - finally { + } finally { executor.shutdown(); } } @@ -126,8 +125,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { public void run() { try { impl.waitCompletion(5000); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); numberOfFailures.incrementAndGet(); } @@ -171,8 +169,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { public void run() { try { context.waitCompletion(5000); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); failures.incrementAndGet(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java index 1ad0f79b9b..9c3b37912a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java @@ -16,14 +16,12 @@ */ package org.apache.activemq.artemis.tests.unit.core.postoffice.impl; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.postoffice.Address; import org.apache.activemq.artemis.core.postoffice.impl.AddressImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; public class AddressImplTest extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java index 013ab085dd..8cc138d37d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java @@ -16,17 +16,12 @@ */ package org.apache.activemq.artemis.tests.unit.core.postoffice.impl; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.core.server.impl.RefsOperation; -import org.junit.Test; - +import javax.transaction.xa.Xid; import java.util.Collections; import java.util.List; import java.util.Set; -import javax.transaction.xa.Xid; - +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.postoffice.Binding; @@ -37,10 +32,13 @@ import org.apache.activemq.artemis.core.server.Bindable; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RoutingContext; import org.apache.activemq.artemis.core.server.ServerMessage; +import org.apache.activemq.artemis.core.server.impl.RefsOperation; import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.TransactionOperation; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Test; public class BindingsImplTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -82,8 +80,7 @@ public class BindingsImplTest extends ActiveMQTestBase { public void run() { try { bind.removeBinding(fake); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -95,8 +92,7 @@ public class BindingsImplTest extends ActiveMQTestBase { for (int i = 0; i < 100; i++) { if (route) { bind.route(new ServerMessageImpl(i, 100), new RoutingContextImpl(new FakeTransaction())); - } - else { + } else { bind.redistribute(new ServerMessageImpl(i, 100), queue, new RoutingContextImpl(new FakeTransaction())); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java index 0b3fe59fae..fcd32c5ada 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java @@ -26,9 +26,6 @@ import java.util.concurrent.ScheduledExecutorService; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; -import org.apache.activemq.artemis.tests.unit.util.FakePagingManager; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; @@ -37,6 +34,9 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.postoffice.impl.DuplicateIDCacheImpl; import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader; import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl; +import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; +import org.apache.activemq.artemis.tests.unit.util.FakePagingManager; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ExecutorFactory; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; @@ -146,13 +146,11 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { values = mapDups.get(ADDRESS); Assert.assertEquals(10, values.size()); - } - finally { + } finally { if (journal != null) { try { journal.stop(); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java index 61783ac386..c797955c54 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.Collection; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.BindingType; @@ -32,6 +30,8 @@ import org.apache.activemq.artemis.core.server.Bindable; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RoutingContext; import org.apache.activemq.artemis.core.server.ServerMessage; +import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; /** @@ -49,8 +49,7 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase { ad.removeBinding(SimpleString.toSimpleString("one"), null); try { ad.removeBinding(SimpleString.toSimpleString("two"), null); - } - catch (Throwable e) { + } catch (Throwable e) { // We are not failing the test here as this test is replicating the exact scenario // that was happening under https://issues.jboss.org/browse/HORNETQ-988 // In which this would be ignored @@ -59,8 +58,7 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase { } try { ad.addBinding(new BindingFake("jms.topic.Topic1", "three")); - } - catch (Throwable e) { + } catch (Throwable e) { // We are not failing the test here as this test is replicating the exact scenario // that was happening under https://issues.jboss.org/browse/HORNETQ-988 // In which this would be ignored diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java index cf51451b19..f4611405e9 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java @@ -17,16 +17,13 @@ package org.apache.activemq.artemis.tests.unit.core.remoting; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Before; import org.junit.After; - -import org.junit.Test; - import org.junit.Assert; - -import org.apache.activemq.artemis.api.core.SimpleString; +import org.junit.Before; +import org.junit.Test; public abstract class ActiveMQBufferTestBase extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java index 7f410ef0c2..fb4382e827 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java @@ -25,14 +25,14 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager; -import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQComponent; +import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager; import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; +import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Assert; @@ -56,8 +56,7 @@ public class NettyAcceptorTest extends ActiveMQTestBase { public void tearDown() throws Exception { try { ActiveMQTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); - } - finally { + } finally { if (pool2 != null) pool2.shutdownNow(); super.tearDown(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java index b96a9be112..f99b25a32a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java @@ -26,11 +26,11 @@ import io.netty.channel.embedded.EmbeddedChannel; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java index e8178ed29d..34b9abb820 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java @@ -16,24 +16,22 @@ */ package org.apache.activemq.artemis.tests.unit.core.remoting.impl.netty; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; -import org.junit.Test; - import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; -import org.junit.Assert; - +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; +import org.junit.Assert; +import org.junit.Test; public class NettyConnectorTest extends ActiveMQTestBase { @@ -105,8 +103,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { new NettyConnector(params, null, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); Assert.fail("Should throw Exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } @@ -114,8 +111,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { new NettyConnector(params, handler, null, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); Assert.fail("Should throw Exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Ok } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java index 6ecb385c15..adcb235aeb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java @@ -21,8 +21,8 @@ import java.net.URL; import java.util.Arrays; import java.util.Collection; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -100,8 +100,7 @@ public class SSLSupportTest extends ActiveMQTestBase { try { SSLSupport.createContext(storeType, "not a keystore", keyStorePassword, storeType, trustStorePath, trustStorePassword); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -109,8 +108,7 @@ public class SSLSupportTest extends ActiveMQTestBase { public void testContextWithNullKeyStorePath() throws Exception { try { SSLSupport.createContext(storeType, null, keyStorePassword, storeType, trustStorePath, trustStorePassword); - } - catch (Exception e) { + } catch (Exception e) { Assert.fail(); } } @@ -132,8 +130,7 @@ public class SSLSupportTest extends ActiveMQTestBase { try { SSLSupport.createContext(storeType, keyStorePath, "bad password", storeType, trustStorePath, trustStorePassword); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -142,8 +139,7 @@ public class SSLSupportTest extends ActiveMQTestBase { try { SSLSupport.createContext(storeType, keyStorePath, null, storeType, trustStorePath, trustStorePassword); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { assertFalse(e instanceof NullPointerException); } } @@ -153,8 +149,7 @@ public class SSLSupportTest extends ActiveMQTestBase { try { SSLSupport.createContext(storeType, keyStorePath, keyStorePassword, storeType, "not a trust store", trustStorePassword); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } @@ -163,8 +158,7 @@ public class SSLSupportTest extends ActiveMQTestBase { try { SSLSupport.createContext(storeType, keyStorePath, keyStorePassword, storeType, trustStorePath, "bad passord"); Assert.fail(); - } - catch (Exception e) { + } catch (Exception e) { } } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java index bf1b2b61a7..87da4cc533 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java @@ -16,19 +16,16 @@ */ package org.apache.activemq.artemis.tests.unit.core.security.impl; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - import java.util.HashSet; -import org.junit.Assert; - import org.apache.activemq.artemis.core.security.CheckType; import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * tests ActiveMQSecurityManagerImpl @@ -92,15 +89,13 @@ public class ActiveMQSecurityManagerImplTest extends ActiveMQTestBase { try { securityManager.getConfiguration().addUser("newuser2", null); Assert.fail("password cannot be null"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // pass } try { securityManager.getConfiguration().addUser(null, "newpassword2"); Assert.fail("password cannot be null"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // pass } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java index f33e0798e8..c0114c6bc9 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java @@ -17,8 +17,8 @@ package org.apache.activemq.artemis.tests.unit.core.server.cluster.impl; import org.apache.activemq.artemis.api.core.management.ManagementHelper; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionBridge; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; public class ClusterConnectionBridgeTest extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java index 577736a497..66528da343 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java @@ -16,15 +16,14 @@ */ package org.apache.activemq.artemis.tests.unit.core.server.cluster.impl; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Test; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.server.Queue; -import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl; - public class RemoteQueueBindImplTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java index e70c66f868..aa2b666e89 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java @@ -17,8 +17,8 @@ package org.apache.activemq.artemis.tests.unit.core.server.group.impl; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; public class SystemPropertyOverrideTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java index 4fc2a8edac..76dcfa8f4f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java @@ -61,8 +61,7 @@ public class FileLockTest extends ActiveMQTestBase { public void run() { try { lockManager2.startLiveNode(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java index b98c419e47..b9bdba7cf0 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java @@ -31,22 +31,22 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer; -import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeFilter; -import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.filter.impl.FilterImpl; import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding; -import org.apache.activemq.artemis.core.server.Consumer; -import org.apache.activemq.artemis.core.server.HandleStatus; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.core.server.Consumer; +import org.apache.activemq.artemis.core.server.HandleStatus; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.impl.QueueImpl; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer; +import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeFilter; +import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.FutureLatch; import org.apache.activemq.artemis.utils.LinkedListIterator; @@ -1233,8 +1233,7 @@ public class QueueImplTest extends ActiveMQTestBase { public void run() { if (first) { queue.addHead(messageReference, false); - } - else { + } else { queue.addTail(messageReference); } added = true; @@ -1283,8 +1282,7 @@ public class QueueImplTest extends ActiveMQTestBase { MessageReference ref = totalIterator.next(); Assert.assertEquals(i++, ref.getMessage().getIntProperty("order").intValue()); } - } - finally { + } finally { totalIterator.close(); server.stop(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeConsumer.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeConsumer.java index 81015e4f46..665686c402 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeConsumer.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeConsumer.java @@ -60,8 +60,7 @@ public class FakeConsumer implements Consumer { long start = System.currentTimeMillis(); try { wait(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } timeout -= System.currentTimeMillis() - start; } @@ -105,8 +104,7 @@ public class FakeConsumer implements Consumer { notify(); return HandleStatus.HANDLED; - } - else { + } else { return HandleStatus.NO_MATCH; } } @@ -116,8 +114,7 @@ public class FakeConsumer implements Consumer { statusToReturn = newStatus; newStatus = null; - } - else { + } else { delayCountdown--; } } @@ -129,8 +126,7 @@ public class FakeConsumer implements Consumer { } return statusToReturn; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException(e.getMessage(), e); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java index aa41a518c0..6f23e34031 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java @@ -148,26 +148,29 @@ public class FakePostOffice implements PostOffice { } @Override - public RoutingStatus route(ServerMessage message, QueueCreator creator, Transaction tx, boolean direct) throws Exception { + public RoutingStatus route(ServerMessage message, + QueueCreator creator, + Transaction tx, + boolean direct) throws Exception { return RoutingStatus.OK; } @Override public RoutingStatus route(ServerMessage message, - QueueCreator creator, - RoutingContext context, - boolean direct, - boolean rejectDuplicates) throws Exception { + QueueCreator creator, + RoutingContext context, + boolean direct, + boolean rejectDuplicates) throws Exception { return RoutingStatus.OK; } @Override public RoutingStatus route(ServerMessage message, - QueueCreator creator, - Transaction tx, - boolean direct, - boolean rejectDuplicates) throws Exception { + QueueCreator creator, + Transaction tx, + boolean direct, + boolean rejectDuplicates) throws Exception { return RoutingStatus.OK; } @@ -179,4 +182,4 @@ public class FakePostOffice implements PostOffice { public RoutingStatus route(ServerMessage message, QueueCreator queueCreator, boolean direct) throws Exception { return RoutingStatus.OK; } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java index 68b348a3a1..1d8146c78d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.tests.unit.core.util; - import java.util.HashSet; import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; @@ -25,16 +24,18 @@ import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.Assert; import org.junit.Test; -/** This test will start many parallel VMs, to make sure each VM would generate a good distribution of random numbers */ +/** + * This test will start many parallel VMs, to make sure each VM would generate a good distribution of random numbers + */ public class RandomUtilDistributionTest { + public static void main(String[] arg) { long start = Long.parseLong(arg[0]); try { Thread.sleep((start - System.currentTimeMillis()) / 2); - } - catch (Exception e) { + } catch (Exception e) { } while (System.currentTimeMillis() < start) { Thread.yield(); @@ -59,7 +60,7 @@ public class RandomUtilDistributionTest { // I'm using an extra parenthesis here to avoid rounding problems. // Be careful removing it (make sure you know what you're doing in case you do so) - int minimumExpected = (int)((iterations * numberOfStarts) * 0.80); + int minimumExpected = (int) ((iterations * numberOfStarts) * 0.80); System.out.println("value=" + value + ", minimum expected = " + minimumExpected); Assert.assertTrue("The Random distribution is pretty bad. All tries have returned duplicated randoms. value=" + value + ", minimum expected = " + minimumExpected, value > minimumExpected); @@ -75,7 +76,6 @@ public class RandomUtilDistributionTest { process[i] = SpawnedVMSupport.spawnVM(RandomUtilDistributionTest.class.getName(), true, "" + timeStart); } - HashSet valueSet = new HashSet<>(); for (int i = 0; i < numberOfTries; i++) { @@ -88,9 +88,7 @@ public class RandomUtilDistributionTest { return valueSet.size(); - - } - finally { + } finally { for (Process p : process) { if (p != null) { p.destroy(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java index a8cd905f37..06389ecbb1 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java @@ -16,17 +16,15 @@ */ package org.apache.activemq.artemis.tests.unit.jms; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Test; - import javax.jms.JMSRuntimeException; import javax.jms.Queue; import javax.jms.Topic; -import org.junit.Assert; - import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class ActiveMQDestinationTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -79,8 +77,7 @@ public class ActiveMQDestinationTest extends ActiveMQTestBase { try { ActiveMQDestination.fromAddress(address); Assert.fail("IllegalArgumentException"); - } - catch (JMSRuntimeException e) { + } catch (JMSRuntimeException e) { } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java index 972273eb9d..774ddab450 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java @@ -18,9 +18,9 @@ package org.apache.activemq.artemis.tests.unit.jms.client; import javax.jms.MessageFormatException; +import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.RandomUtil; -import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,8 +70,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.setBoolean(null, true); Assert.fail("item name can not be null"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } @@ -82,8 +81,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.setBoolean("", true); Assert.fail("item name can not be empty"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { } } @@ -122,8 +120,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getBoolean(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -144,8 +141,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getByte(itemName); Assert.fail("NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -167,8 +163,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getByte(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -199,8 +194,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getShort(itemName); Assert.fail("NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -222,8 +216,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getShort(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -264,8 +257,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getInt(itemName); Assert.fail("NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -287,8 +279,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getInt(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -309,8 +300,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getChar(itemName); Assert.fail("NullPointerException"); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { } } @@ -322,8 +312,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getChar(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -374,8 +363,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getLong(itemName); Assert.fail("NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } } @@ -397,8 +385,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getLong(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -419,8 +406,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getFloat(itemName); Assert.fail("NullPointerException"); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { } } @@ -442,8 +428,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getFloat(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -474,8 +459,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getDouble(itemName); Assert.fail("NullPointerException"); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { } } @@ -497,8 +481,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getDouble(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -623,8 +606,7 @@ public class ActiveMQMapMessageTest extends ActiveMQTestBase { try { message.getBytes(itemName); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java index 8bd80c9110..d13e287417 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java @@ -16,18 +16,15 @@ */ package org.apache.activemq.artemis.tests.unit.jms.client; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Test; - -import java.util.ArrayList; - import javax.jms.MessageEOFException; import javax.jms.MessageFormatException; - -import org.junit.Assert; +import java.util.ArrayList; import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class ActiveMQStreamMessageTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- @@ -337,8 +334,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { try { message.readChar(); fail(); - } - catch (NullPointerException e) { + } catch (NullPointerException e) { } } @@ -556,8 +552,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { try { message.readByte(); fail("must throw a NumberFormatException"); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { } // we can read the String without resetting the message @@ -767,8 +762,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { try { message.writeObject(new ArrayList()); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -892,8 +886,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { try { reader.readType(message); Assert.fail("MessageEOFException"); - } - catch (MessageEOFException e) { + } catch (MessageEOFException e) { } } @@ -906,8 +899,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { try { reader.readType(message); Assert.fail("MessageFormatException"); - } - catch (MessageFormatException e) { + } catch (MessageFormatException e) { } } @@ -920,8 +912,7 @@ public class ActiveMQStreamMessageTest extends ActiveMQTestBase { Object v = reader.readType(message); if (value instanceof byte[]) { ActiveMQTestBase.assertEqualsByteArrays((byte[]) value, (byte[]) v); - } - else { + } else { Assert.assertEquals(value, v); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java index bc83e963ea..079c78f3fe 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.unit.jms.client; -import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.CONNECTION_TIMEDOUT; -import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.GENERIC_EXCEPTION; -import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.INVALID_FILTER_EXPRESSION; - import javax.jms.IllegalStateException; import javax.jms.InvalidDestinationException; import javax.jms.InvalidSelectorException; @@ -28,11 +24,15 @@ import javax.jms.JMSSecurityException; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.jms.client.JMSExceptionHelper; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Assert; import org.junit.Test; +import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.CONNECTION_TIMEDOUT; +import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.GENERIC_EXCEPTION; +import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.INVALID_FILTER_EXPRESSION; + public class JMSExceptionHelperTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java index d0ceea4c0b..c2b14eba37 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java @@ -18,10 +18,8 @@ package org.apache.activemq.artemis.tests.unit.jms.client; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.SelectorTranslator; -import org.junit.Test; - import org.junit.Assert; - +import org.junit.Test; public class SelectorTranslatorTest extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java index ef434b17ed..719f6401a2 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java @@ -16,23 +16,20 @@ */ package org.apache.activemq.artemis.tests.unit.jms.misc; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Test; - +import javax.jms.ConnectionMetaData; import java.io.File; import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; -import javax.jms.ConnectionMetaData; - -import org.junit.Assert; - import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionMetaData; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; +import org.junit.Test; public class ManifestTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java index a223c8e9fd..7bbbf31c75 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java @@ -16,17 +16,15 @@ */ package org.apache.activemq.artemis.tests.unit.jms.referenceable; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.apache.activemq.artemis.utils.RandomUtil; -import org.junit.Test; - import javax.naming.Reference; -import org.junit.Assert; - import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.referenceable.DestinationObjectFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.RandomUtil; +import org.junit.Assert; +import org.junit.Test; public class DestinationObjectFactoryTest extends ActiveMQTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java index 7b5ecf87d4..1da68a9b5f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java @@ -453,8 +453,7 @@ public class ActiveMQResourceAdapterConfigTest extends ActiveMQTestBase { } System.out.println(newConfig); fail("methods not shown please see previous and add"); - } - else { + } else { System.out.println(commentedOutConfigs); } } @@ -468,14 +467,11 @@ public class ActiveMQResourceAdapterConfigTest extends ActiveMQTestBase { if (clzz == Boolean.class) { return Boolean.TYPE; - } - else if (clzz == Long.class) { + } else if (clzz == Long.class) { return Long.TYPE; - } - else if (clzz == Integer.class) { + } else if (clzz == Integer.class) { return Integer.TYPE; - } - else { + } else { return clzz; } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java index 4e617aebba..b3ed958e5c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java @@ -25,10 +25,10 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import org.apache.activemq.artemis.ra.ConnectionFactoryProperties; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.ConnectionFactoryProperties; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.junit.Test; import static java.beans.Introspector.getBeanInfo; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java index eb2bb600a8..0ca9a2877c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java @@ -374,8 +374,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase { try { ra.getConnectionFactory(connectionFactoryProperties); Assert.fail("should throw exception"); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // pass } } @@ -468,8 +467,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase { locator.close(); - } - finally { + } finally { server.stop(); } } @@ -505,8 +503,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase { ra.stop(); - } - finally { + } finally { server.stop(); } } @@ -548,14 +545,12 @@ public class ResourceAdapterTest extends ActiveMQTestBase { try { activation.start(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } assertEquals(0, server.getRemotingService().getConnections().size()); - } - finally { + } finally { if (activation != null) activation.stop(); if (ra != null) diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMContext.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMContext.java index fddff5d740..17326deaaf 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMContext.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMContext.java @@ -16,15 +16,6 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import javax.naming.Binding; import javax.naming.Context; import javax.naming.Name; @@ -36,6 +27,14 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; @@ -91,8 +90,7 @@ public class InVMContext implements Context, Serializable { // we only deal with references create by NonSerializableFactory String key = (String) refAddr.getContent(); return NonSerializableFactory.lookup(key); - } - else { + } else { return value; } } @@ -129,8 +127,7 @@ public class InVMContext implements Context, Serializable { boolean terminal = i == -1; if (terminal) { map.remove(name); - } - else { + } else { String tok = name.substring(0, i); InVMContext c = (InVMContext) map.get(tok); if (c == null) { @@ -171,8 +168,7 @@ public class InVMContext implements Context, Serializable { if (!"".equals(contextName) && !".".equals(contextName)) { try { return ((InVMContext) lookup(contextName)).listBindings(""); - } - catch (Throwable t) { + } catch (Throwable t) { throw new NamingException(t.getMessage()); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNameParser.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNameParser.java index 059a646ea2..4b0bb07c53 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNameParser.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNameParser.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import java.io.Serializable; -import java.util.Properties; - import javax.naming.CompoundName; import javax.naming.Name; import javax.naming.NameParser; import javax.naming.NamingException; +import java.io.Serializable; +import java.util.Properties; public class InVMNameParser implements NameParser, Serializable { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNamingContext.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNamingContext.java index 10000dc89f..6def1c8831 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNamingContext.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/InVMNamingContext.java @@ -16,15 +16,6 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import javax.naming.Binding; import javax.naming.Context; import javax.naming.Name; @@ -36,6 +27,14 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; @@ -91,8 +90,7 @@ public class InVMNamingContext implements Context, Serializable { // we only deal with references create by NonSerializableFactory String key = (String) refAddr.getContent(); return NonSerializableFactory.lookup(key); - } - else { + } else { return value; } } @@ -129,8 +127,7 @@ public class InVMNamingContext implements Context, Serializable { boolean terminal = i == -1; if (terminal) { map.remove(name); - } - else { + } else { String tok = name.substring(0, i); InVMNamingContext c = (InVMNamingContext) map.get(tok); if (c == null) { @@ -171,8 +168,7 @@ public class InVMNamingContext implements Context, Serializable { if (!"".equals(contextName) && !".".equals(contextName)) { try { return ((InVMNamingContext) lookup(contextName)).listBindings(""); - } - catch (Throwable t) { + } catch (Throwable t) { throw new NamingException(t.getMessage()); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java index d035b01a88..1b7010ed69 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java @@ -176,8 +176,7 @@ public class LinkedListTest extends ActiveMQTestBase { while (ref.get() != null) { toOME.add("sdlfkjshadlfkjhas dlfkjhas dlfkjhads lkjfhads lfkjhads flkjashdf " + someCount++); } - } - catch (Throwable expectedThrowable) { + } catch (Throwable expectedThrowable) { } toOME.clear(); @@ -310,8 +309,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.remove(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } } @@ -417,8 +415,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.next(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } } @@ -433,8 +430,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.remove(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } @@ -448,8 +444,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.remove(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } @@ -473,8 +468,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.remove(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } @@ -486,8 +480,7 @@ public class LinkedListTest extends ActiveMQTestBase { iter.remove(); fail("Should throw NoSuchElementException"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { // OK } @@ -668,8 +661,7 @@ public class LinkedListTest extends ActiveMQTestBase { try { iter.remove(); fail("Should throw exception"); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { } iter = list.iterator(); @@ -755,8 +747,7 @@ public class LinkedListTest extends ActiveMQTestBase { for (int i = 0; i < num; i++) { if (i % 2 == 0) { list.addHead(i); - } - else { + } else { list.addTail(i); } assertEquals(1, list.size()); @@ -811,8 +802,7 @@ public class LinkedListTest extends ActiveMQTestBase { try { iter.next(); - } - catch (NoSuchElementException e) { + } catch (NoSuchElementException e) { } for (int i = 0; i < num; i++) { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java index 052afaf7e6..3fa2df8639 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java @@ -16,14 +16,12 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; import org.apache.activemq.artemis.utils.MemorySize; +import org.junit.Assert; +import org.junit.Test; public class MemorySizeTest extends Assert { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java index 00720cd6e2..7caa46a7f5 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.EnclosingClass; -import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1; -import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -44,9 +39,12 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; -import org.junit.Assert; - +import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.EnclosingClass; +import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1; +import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; +import org.junit.Assert; import org.junit.Test; public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { @@ -101,8 +99,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { //Class.isAnonymousClass() call used in ObjectInputStreamWithClassLoader //need to access the enclosing class and its parent class of the obj //i.e. ActiveMQTestBase and Assert. - ClassLoader testClassLoader = ObjectInputStreamWithClassLoaderTest.newClassLoader( - obj.getClass(), ActiveMQTestBase.class, Assert.class); + ClassLoader testClassLoader = ObjectInputStreamWithClassLoaderTest.newClassLoader(obj.getClass(), ActiveMQTestBase.class, Assert.class); Thread.currentThread().setContextClassLoader(testClassLoader); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); @@ -114,8 +111,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { Assert.assertNotSame(obj.getClass(), deserializedObj.getClass()); Assert.assertNotSame(obj.getClass().getClassLoader(), deserializedObj.getClass().getClassLoader()); Assert.assertSame(testClassLoader, deserializedObj.getClass().getClassLoader()); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } @@ -130,8 +126,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { originalProxy.setMyInt(100); byte[] bytes = ObjectInputStreamWithClassLoaderTest.toBytes(originalProxy); - ClassLoader testClassLoader = ObjectInputStreamWithClassLoaderTest.newClassLoader(this.getClass(), - ActiveMQTestBase.class, Assert.class); + ClassLoader testClassLoader = ObjectInputStreamWithClassLoaderTest.newClassLoader(this.getClass(), ActiveMQTestBase.class, Assert.class); Thread.currentThread().setContextClassLoader(testClassLoader); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStreamWithClassLoader ois = new ObjectInputStreamWithClassLoader(bais); @@ -143,8 +138,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { toRun.run(); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } @@ -157,8 +151,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { try { outputStream.writeObject(new TestClass1()); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -237,8 +230,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { try { outputStream.writeObject(sourceObject); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -274,8 +266,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { try { outputStream.writeObject(sourceObject); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -302,8 +293,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { //now add List to white list, it should pass blackList = null; - whiteList = "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1," + - "java.util.ArrayList"; + whiteList = "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1," + "java.util.ArrayList"; result = readSerializedObject(whiteList, blackList, serailizeFile); assertNull(result); @@ -319,8 +309,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { try { outputStream.writeObject(sourceObject); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -360,8 +349,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { //both key and value are in the whitelist, it should fail because HashMap not permitted blackList = null; - whiteList = "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1," + - "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2"; + whiteList = "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1," + "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2"; result = readSerializedObject(whiteList, blackList, serailizeFile); assertTrue(result instanceof ClassNotFoundException); @@ -369,8 +357,8 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { //now add HashMap, test should pass. blackList = null; whiteList = "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass1," + - "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2," + - "java.util.HashMap"; + "org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2," + + "java.util.HashMap"; result = readSerializedObject(whiteList, blackList, serailizeFile); assertNull(result); @@ -386,8 +374,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { assertTrue(object.getClass().isAnonymousClass()); outputStream.writeObject(object); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -417,8 +404,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { assertTrue(object.getClass().isLocalClass()); outputStream.writeObject(object); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -447,8 +433,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { try { outputStream.writeObject(new TestClass1()); outputStream.flush(); - } - finally { + } finally { outputStream.close(); } @@ -461,8 +446,7 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { assertEquals("wrong black list: " + bList, "system.defined.black.list", bList); assertEquals("wrong white list: " + wList, "system.defined.white.list", wList); ois.close(); - } - finally { + } finally { System.clearProperty(ObjectInputStreamWithClassLoader.BLACKLIST_PROPERTY); System.clearProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY); } @@ -478,15 +462,12 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { ois.setWhiteList(whiteList); ois.setBlackList(blackList); ois.readObject(); - } - catch (Exception e) { + } catch (Exception e) { result = e; - } - finally { + } finally { try { ois.close(); - } - catch (IOException e) { + } catch (IOException e) { result = e; } } @@ -537,11 +518,9 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { if (myInterface.getMyInt() != 200) { throw new RuntimeException("invalid result"); } - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } @@ -608,11 +587,10 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { Object obj = method.invoke(anObject, args); if (obj instanceof Integer) { return ((Integer) obj).intValue() * 2; - } - else { + } else { return obj; } } } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java index 97d8904dcb..2e14d1e60a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java @@ -84,8 +84,7 @@ public class ReusableLatchTest extends ActiveMQTestBase { if (!latch.await(5000)) { UnitTestLogger.LOGGER.error("Latch timed out"); } - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.error(e); } waiting = false; @@ -113,8 +112,7 @@ public class ReusableLatchTest extends ActiveMQTestBase { for (int i = 0; i < numberOfAdds; i++) { latch.countUp(); } - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.error(e.getMessage(), e); } } @@ -167,8 +165,7 @@ public class ReusableLatchTest extends ActiveMQTestBase { for (int i = 0; i < numberOfAdds; i++) { latch.countDown(); } - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.error(e.getMessage(), e); } } @@ -235,8 +232,7 @@ public class ReusableLatchTest extends ActiveMQTestBase { if (!latch.await(1000)) { UnitTestLogger.LOGGER.error("Latch timed out!", new Exception("trace")); } - } - catch (Exception e) { + } catch (Exception e) { UnitTestLogger.LOGGER.error(e); this.e = e; } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java index ffaf6aa755..b07f5bf09b 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java @@ -16,24 +16,21 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.After; - -import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.nio.ByteBuffer; -import org.junit.Assert; - +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.ActiveMQBuffers; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.DataConstants; import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.UTF8Util; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; public class UTF8Test extends ActiveMQTestBase { @@ -111,8 +108,7 @@ public class UTF8Test extends ActiveMQTestBase { try { UTF8Util.saveUTF(buffer, str); Assert.fail("String is too big, supposed to throw an exception"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } Assert.assertEquals("A buffer was supposed to be untouched since the string was too big", 0, buffer.writerIndex()); @@ -128,8 +124,7 @@ public class UTF8Test extends ActiveMQTestBase { try { UTF8Util.saveUTF(buffer, str); Assert.fail("Encoded String is too big, supposed to throw an exception"); - } - catch (Exception ignored) { + } catch (Exception ignored) { } Assert.assertEquals("A buffer was supposed to be untouched since the string was too big", 0, buffer.writerIndex()); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java index a7f5cd09a9..6aff0c3963 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java @@ -16,16 +16,14 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; -import org.junit.Test; - import java.util.HashSet; import java.util.Set; -import org.junit.Assert; - +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.UUID; import org.apache.activemq.artemis.utils.UUIDGenerator; +import org.junit.Assert; +import org.junit.Test; public class UUIDTest extends ActiveMQTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java index e9c447db00..1df3b7a146 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java @@ -19,8 +19,8 @@ package org.apache.activemq.artemis.tests.unit.util; import java.util.Properties; import java.util.StringTokenizer; -import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.version.Version; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.VersionLoader; import org.junit.Assert; import org.junit.Test; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/EnclosingClass.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/EnclosingClass.java index 379da857af..796390983e 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/EnclosingClass.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/EnclosingClass.java @@ -25,6 +25,7 @@ public class EnclosingClass implements Serializable { public static Object getLocalObject() { class LocalClass implements Serializable { + } return new LocalClass(); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass1.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass1.java index 3c6cbef301..595943095f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass1.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass1.java @@ -19,4 +19,5 @@ package org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1; import java.io.Serializable; public class TestClass1 implements Serializable { + } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass2.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass2.java index afc52ccc76..6728f333c3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass2.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/deserialization/pkg1/TestClass2.java @@ -19,4 +19,5 @@ package org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1; import java.io.Serializable; public class TestClass2 implements Serializable { + } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java index 0ae36b5f3d..57bc23a23a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java @@ -60,10 +60,12 @@ public final class SpawnedVMSupport { return SpawnedVMSupport.spawnVM(className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args); } - public static Process spawnVMWithLogMacher(String wordMatch, Runnable runnable, final String className, - final String[] vmargs, - final boolean logOutput, - final String... args) throws Exception { + public static Process spawnVMWithLogMacher(String wordMatch, + Runnable runnable, + final String className, + final String[] vmargs, + final boolean logOutput, + final String... args) throws Exception { return SpawnedVMSupport.spawnVM(wordMatch, runnable, className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args); } @@ -135,7 +137,11 @@ public final class SpawnedVMSupport { * @param process * @throws ClassNotFoundException */ - public static void startLogger(final boolean print, final String wordMatch, final Runnable wordRunanble, final String className, final Process process) throws ClassNotFoundException { + public static void startLogger(final boolean print, + final String wordMatch, + final Runnable wordRunanble, + final String className, + final Process process) throws ClassNotFoundException { ProcessLogger outputLogger = new ProcessLogger(print, process.getInputStream(), className, wordMatch, wordRunanble); outputLogger.start(); } @@ -171,12 +177,10 @@ public final class SpawnedVMSupport { int exitValue = future.get(10, SECONDS); if (sameValue) { Assert.assertSame(value, exitValue); - } - else { + } else { Assert.assertNotSame(value, exitValue); } - } - finally { + } finally { p.destroy(); } } @@ -195,10 +199,15 @@ public final class SpawnedVMSupport { private final String wordMatch; /** * This will be executed when wordMatch is within any line on the log * - * * */ + * * + */ private final Runnable wordRunner; - ProcessLogger(final boolean print, final InputStream is, final String className, String wordMatch, Runnable wordRunner) throws ClassNotFoundException { + ProcessLogger(final boolean print, + final InputStream is, + final String className, + String wordMatch, + Runnable wordRunner) throws ClassNotFoundException { this.is = is; this.print = print; this.className = className; @@ -223,8 +232,7 @@ public final class SpawnedVMSupport { System.out.println(className + ":" + line); } } - } - catch (IOException ioe) { + } catch (IOException ioe) { ioe.printStackTrace(); } }