http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java ---------------------------------------------------------------------- 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 f73a1b1..f0b8c3c 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); }
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ConsumerThread.java ---------------------------------------------------------------------- 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 fea2f3e..fc63518 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<Message> 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(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java ---------------------------------------------------------------------- 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 aaf08d3..67cef67 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); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/SyncCalculation.java ---------------------------------------------------------------------- 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 e3799d9..468eabf 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java ---------------------------------------------------------------------- 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 86c66af..5e4acf4 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 } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/package-info.java ---------------------------------------------------------------------- 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 d902bbd..b4826af 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java ---------------------------------------------------------------------- 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 29d83c4..54567fd 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()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java ---------------------------------------------------------------------- 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 189ccdd..2c1cba3 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java ---------------------------------------------------------------------- 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 dc677e0..9f0c489 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java ---------------------------------------------------------------------- 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 c422308..4b71029 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!"); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java ---------------------------------------------------------------------- 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 a84343b..272e46d 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 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java ---------------------------------------------------------------------- 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 494101e..8da0480 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(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java ---------------------------------------------------------------------- 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 b120cc7..82224b9 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java ---------------------------------------------------------------------- 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 d036f1d..fa443b5 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 } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java ---------------------------------------------------------------------- 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 969138f..58e91bd 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()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java ---------------------------------------------------------------------- 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 7e34ccd..baef0fe 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) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/ArtemisConstants.java ---------------------------------------------------------------------- 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 4e3602c..35bcec0 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); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java ---------------------------------------------------------------------- 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 b3e130f..392974c 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<A, B> 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()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java ---------------------------------------------------------------------- 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 70cf4cf..b4a02ea 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(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java ---------------------------------------------------------------------- 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 aea9867..60262f8 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); } - } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java ---------------------------------------------------------------------- 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 efa0cab..d62a744 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()) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java ---------------------------------------------------------------------- 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 664470a..91744c3 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 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java ---------------------------------------------------------------------- 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 d7d9214..ac89fc2 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; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java ---------------------------------------------------------------------- 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 3a4de3e..130a6d8 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); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java ---------------------------------------------------------------------- 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 8471dac..a87b18a 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<Runnable> { + 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);
