http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java ---------------------------------------------------------------------- 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 091c35c..37d99bb 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<UUID, AtomicLong> 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(); } }
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServiceRegistryImpl.java ---------------------------------------------------------------------- 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 46dbd58..d2d66a4 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); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java ---------------------------------------------------------------------- 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 d279864..8351c4d 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); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java ---------------------------------------------------------------------- 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 938f5dd..c984ae2 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); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java ---------------------------------------------------------------------- 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 d9963ee..097ecb8 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); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java ---------------------------------------------------------------------- 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 ff688d1..485ae16 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(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java ---------------------------------------------------------------------- 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 6a491a5..a8da6eb 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); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java ---------------------------------------------------------------------- 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 c98c22e..5f40c53 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java ---------------------------------------------------------------------- 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 4fe6f9d..73248f0 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 } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/protocol/websocket/WebSocketServerHandler.java ---------------------------------------------------------------------- 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 671cb76..56ece3e 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<Object> 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<Object> // 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<Object> // 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<Object> 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; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadCallback.java ---------------------------------------------------------------------- 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 cc4f5df..cd5bd04 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; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManager.java ---------------------------------------------------------------------- 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 0dfe6a7..497a584 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); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java ---------------------------------------------------------------------- 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 fd4929e..a8c8b69 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<ReloadCallback> getCallbacks() { return callbacks; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java ---------------------------------------------------------------------- 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 f5f00f7..0d14c7c 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<AddressSettings>, Serializable if (policyStr != null) { addressFullMessagePolicy = AddressFullMessagePolicy.valueOf(policyStr.toString()); - } - else { + } else { addressFullMessagePolicy = null; } @@ -525,8 +524,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable if (policyStr != null) { slowConsumerPolicy = SlowConsumerPolicy.valueOf(policyStr.toString()); - } - else { + } else { slowConsumerPolicy = null; } @@ -677,161 +675,135 @@ public class AddressSettings implements Mergeable<AddressSettings>, 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; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java ---------------------------------------------------------------------- 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 6e032d1..1d648ed 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<T> implements HierarchicalRepository<T lock.writeLock().lock(); try { this.listenersEnabled = false; - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -110,8 +109,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T lock.writeLock().lock(); try { this.listenersEnabled = true; - } - finally { + } finally { lock.writeLock().unlock(); } onChange(); @@ -133,8 +131,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T } return values; - } - finally { + } finally { lock.readLock().unlock(); } } @@ -162,8 +159,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T Match<T> match1 = new Match<>(match); match1.setValue(value); matches.put(match, match1); - } - finally { + } finally { lock.writeLock().unlock(); } @@ -201,8 +197,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T cache.put(match, value); } return value; - } - finally { + } finally { lock.readLock().unlock(); } } @@ -221,8 +216,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T if (!Mergeable.class.isAssignableFrom(actualMatch.getClass())) { break; } - } - else { + } else { ((Mergeable) actualMatch).merge(match.getValue()); } } @@ -258,8 +252,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T boolean isImmutable = immutables.contains(match); if (isImmutable) { logger.debug("Cannot remove match " + match + " since it came from a main config"); - } - else { + } else { /** * clear the cache before removing the match. This will force any thread at * {@link #getMatch(String)} to get the lock to recompute. @@ -268,8 +261,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T matches.remove(match); onChange(); } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -282,8 +274,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T if (listenersEnabled) { listener.onChange(); } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -293,8 +284,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T lock.writeLock().lock(); try { listeners.remove(listener); - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -317,8 +307,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T clearCache(); listeners.clear(); matches.clear(); - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -333,8 +322,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T for (Map.Entry<String, T> entry : entries) { addMatch(entry.getKey(), entry.getValue(), true, false); } - } - finally { + } finally { lock.writeLock().unlock(); } @@ -358,14 +346,12 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T for (HierarchicalRepositoryChangeListener listener : listeners) { try { listener.onChange(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorCallingRepoListener(e); } } } - } - finally { + } finally { lock.readLock().unlock(); } } @@ -399,20 +385,15 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T public int compare(final String o1, final String o2) { if (o1.contains(Match.WILDCARD) && !o2.contains(Match.WILDCARD)) { return +1; - } - else if (!o1.contains(Match.WILDCARD) && o2.contains(Match.WILDCARD)) { + } else if (!o1.contains(Match.WILDCARD) && o2.contains(Match.WILDCARD)) { return -1; - } - else if (o1.contains(Match.WILDCARD) && o2.contains(Match.WILDCARD)) { + } else if (o1.contains(Match.WILDCARD) && o2.contains(Match.WILDCARD)) { return o2.length() - o1.length(); - } - else if (o1.contains(Match.WORD_WILDCARD) && !o2.contains(Match.WORD_WILDCARD)) { + } else if (o1.contains(Match.WORD_WILDCARD) && !o2.contains(Match.WORD_WILDCARD)) { return +1; - } - else if (!o1.contains(Match.WORD_WILDCARD) && o2.contains(Match.WORD_WILDCARD)) { + } else if (!o1.contains(Match.WORD_WILDCARD) && o2.contains(Match.WORD_WILDCARD)) { return -1; - } - else if (o1.contains(Match.WORD_WILDCARD) && o2.contains(Match.WORD_WILDCARD)) { + } else if (o1.contains(Match.WORD_WILDCARD) && o2.contains(Match.WORD_WILDCARD)) { String[] leftSplits = o1.split("\\."); String[] rightSplits = o2.split("\\."); for (int i = 0; i < leftSplits.length; i++) { @@ -420,8 +401,7 @@ public class HierarchicalObjectRepository<T> implements HierarchicalRepository<T if (left.equals(Match.WORD_WILDCARD)) { if (rightSplits.length < i || !rightSplits[i].equals(Match.WORD_WILDCARD)) { return -1; - } - else { + } else { return +1; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/Match.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/Match.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/Match.java index d7d6b4c..940dff3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/Match.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/Match.java @@ -51,8 +51,7 @@ public class Match<T> { // 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);
