Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 51467200BA4 for ; Fri, 30 Sep 2016 17:26:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 500EB160AF6; Fri, 30 Sep 2016 15:26:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 40E00160AFD for ; Fri, 30 Sep 2016 17:26:05 +0200 (CEST) Received: (qmail 88772 invoked by uid 500); 30 Sep 2016 15:26:04 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 86721 invoked by uid 99); 30 Sep 2016 15:26:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Sep 2016 15:26:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1A238E0902; Fri, 30 Sep 2016 15:26:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: martyntaylor@apache.org To: commits@activemq.apache.org Date: Fri, 30 Sep 2016 15:26:23 -0000 Message-Id: In-Reply-To: <5ac6d0226a5f467aa1c95175e44ed5d6@git.apache.org> References: <5ac6d0226a5f467aa1c95175e44ed5d6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/52] [partial] activemq-artemis git commit: ARTEMIS-765 Improve Checkstyle archived-at: Fri, 30 Sep 2016 15:26:08 -0000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 5323d98..2c3add2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -358,8 +358,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final ServiceRegistry serviceRegistry) { if (configuration == null) { configuration = new ConfigurationImpl(); - } - else { + } else { ConfigurationUtils.validateConfiguration(configuration); } @@ -406,11 +405,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { NodeManager manager; if (!configuration.isPersistenceEnabled()) { manager = new InVMNodeManager(replicatingBackup); - } - else if (configuration.getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { + } else if (configuration.getJournalType() == JournalType.ASYNCIO && LibaioContext.isLoaded()) { manager = new AIOFileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); - } - else { + } else { manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout()); } return manager; @@ -457,8 +454,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (haPolicy.isBackup()) { if (haPolicy.isSharedStore()) { activation = haPolicy.createActivation(this, false, activationParams, shutdownOnCriticalIO); - } - else { + } else { activation = haPolicy.createActivation(this, wasLive, activationParams, shutdownOnCriticalIO); } @@ -467,15 +463,13 @@ public class ActiveMQServerImpl implements ActiveMQServer { } backupActivationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); backupActivationThread.start(); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverStarted(getVersion().getFullVersion(), configuration.getName(), nodeManager.getNodeId(), identity != null ? identity : ""); } // start connector service connectorsService = new ConnectorsService(configuration, storageManager, scheduledPool, postOffice, serviceRegistry); connectorsService.start(); - } - finally { + } finally { // this avoids embedded applications using dirty contexts from startup OperationContextImpl.clearContext(); } @@ -490,8 +484,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public void lockActivation() { try { activationLock.acquire(); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -590,8 +583,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public void run() { try { ActiveMQServerImpl.this.stop(false, criticalIOError, false); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingServer(e); } } @@ -667,15 +659,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { SimpleString filterString = filter == null ? null : filter.getFilterString(); response = new QueueQueryResult(name, binding.getAddress(), queue.isDurable(), queue.isTemporary(), filterString, queue.getConsumerCount(), queue.getMessageCount(), autoCreateJmsQueues); - } - // make an exception for the management address (see HORNETQ-29) - else if (name.equals(managementAddress)) { + } else if (name.equals(managementAddress)) { + // make an exception for the management address (see HORNETQ-29) response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1, autoCreateJmsQueues); - } - else if (autoCreateJmsQueues) { + } else if (autoCreateJmsQueues) { response = new QueueQueryResult(name, name, true, false, null, 0, 0, true, false); - } - else { + } else { response = new QueueQueryResult(null, null, false, false, null, 0, 0, false, false); } @@ -740,15 +729,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (replicationManager == null) { return false; - } - else { + } else { return !replicationManager.isSynchronizing(); } - } - else if (activation instanceof SharedNothingBackupActivation) { + } else if (activation instanceof SharedNothingBackupActivation) { return ((SharedNothingBackupActivation) activation).isRemoteBackupUpToDate(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.methodNotApplicable(); } } @@ -793,12 +779,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { if (timeout == -1) { remotingService.getConnectionCountLatch().await(); - } - else { + } else { remotingService.getConnectionCountLatch().await(timeout); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(remotingService.getClass().getName()); } } @@ -829,8 +813,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { activation.preStorageClose(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName()); } @@ -839,8 +822,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (storageManager != null) try { storageManager.stop(criticalIOError); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, storageManager.getClass().getName()); } @@ -849,8 +831,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (remotingService != null) try { remotingService.stop(criticalIOError); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, remotingService.getClass().getName()); } @@ -858,8 +839,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (managementService != null) try { managementService.unregisterServer(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, managementService.getClass().getName()); } @@ -887,8 +867,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { logger.debug("Cancelled the execution of " + r); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(threadPool.getClass().getName()); } } @@ -901,8 +880,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (securityStore != null) { try { securityStore.stop(); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, managementService.getClass().getName()); } } @@ -929,8 +907,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (activation != null) { try { activation.close(failoverOnServerShutdown, restarting); - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName()); } } @@ -938,8 +915,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (backupActivationThread != null) { try { backupActivationThread.join(30000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.interruptWhilstStoppingComponent(backupActivationThread.getClass().getName()); } @@ -962,16 +938,14 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ActiveMQComponent externalComponent : externalComponents) { try { externalComponent.stop(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(e, externalComponent.getClass().getName()); } } if (identity != null) { ActiveMQServerLogger.LOGGER.serverStopped("identity=" + identity + ",version=" + getVersion().getFullVersion(), tempNodeID, getUptime()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverStopped(getVersion().getFullVersion(), tempNodeID, getUptime()); } } @@ -979,8 +953,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { public boolean checkLiveIsNotColocated(String nodeId) { if (parentServer == null) { return true; - } - else { + } else { return !parentServer.getNodeID().toString().equals(nodeId); } } @@ -998,8 +971,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession serverSession : sessions.values()) { try { serverSession.close(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSession(e); } } @@ -1018,8 +990,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession session : sessions.values()) { try { session.close(true); - } - catch (Exception e) { + } catch (Exception e) { // If anything went wrong with closing sessions.. we should ignore it // such as transactions.. etc. ActiveMQServerLogger.LOGGER.errorClosingSessionsWhileStoppingServer(e); @@ -1029,8 +1000,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ServerSession session : sessions.values()) { try { session.waitContextCompletion(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingSessionsWhileStoppingServer(e); } } @@ -1043,8 +1013,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (component != null) { component.stop(); } - } - catch (Throwable t) { + } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, component.getClass().getName()); } } @@ -1086,8 +1055,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { session.close(true); sessions.remove(session.getName()); } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -1099,8 +1067,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { operationsExecuted.append("**************************************************************************************************"); return operationsExecuted.toString(); - } - finally { + } finally { // This operation is critical for the knowledge of the admin, so we need to add info logs for later knowledge ActiveMQServerLogger.LOGGER.info(operationsExecuted.toString()); } @@ -1230,8 +1197,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (limits.getMaxConnections() == -1) { return; - } - else if (limits.getMaxConnections() == 0 || getSessionCountForUser(username) >= limits.getMaxConnections()) { + } else if (limits.getMaxConnections() == 0 || getSessionCountForUser(username) >= limits.getMaxConnections()) { throw ActiveMQMessageBundle.BUNDLE.sessionLimitReached(username, limits.getMaxConnections()); } } @@ -1256,8 +1222,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (limits.getMaxQueues() == -1) { return; - } - else if (limits.getMaxQueues() == 0 || getQueueCountForUser(username) >= limits.getMaxQueues()) { + } else if (limits.getMaxQueues() == 0 || getQueueCountForUser(username) >= limits.getMaxQueues()) { throw ActiveMQMessageBundle.BUNDLE.queueLimitReached(username, limits.getMaxQueues()); } } @@ -1292,11 +1257,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { SessionCallback callback, OperationContext context, boolean autoCreateJMSQueues) throws Exception { - return new ServerSessionImpl(name, username, password, validatedUser, minLargeMessageSize, autoCommitSends, - autoCommitAcks, preAcknowledge, configuration.isPersistDeliveryCountBeforeDelivery(), xa, - connection, storageManager, postOffice, resourceManager, securityStore, managementService, - this, configuration.getManagementAddress(), defaultAddress == null ? null : new SimpleString(defaultAddress), - callback, context, autoCreateJMSQueues ? jmsQueueCreator : null, pagingManager); + return new ServerSessionImpl(name, username, password, validatedUser, minLargeMessageSize, autoCommitSends, autoCommitAcks, preAcknowledge, configuration.isPersistDeliveryCountBeforeDelivery(), xa, connection, storageManager, postOffice, resourceManager, securityStore, managementService, this, configuration.getManagementAddress(), defaultAddress == null ? null : new SimpleString(defaultAddress), callback, context, autoCreateJMSQueues ? jmsQueueCreator : null, pagingManager); } @Override @@ -1526,8 +1487,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (resourceName.toString().toLowerCase().startsWith("jms.topic")) { ActiveMQServerLogger.LOGGER.deployTopic(resourceName); - } - else { + } else { ActiveMQServerLogger.LOGGER.deployQueue(resourceName); } @@ -1581,8 +1541,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (queue.isDurable()) { // make sure the user has privileges to delete this queue securityStore.check(address, CheckType.DELETE_DURABLE_QUEUE, session); - } - else { + } else { securityStore.check(address, CheckType.DELETE_NON_DURABLE_QUEUE, session); } } @@ -1796,9 +1755,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (configuration.isPersistenceEnabled()) { if (configuration.getStoreConfiguration() != null && configuration.getStoreConfiguration().getStoreType() == StoreConfiguration.StoreType.DATABASE) { return new JDBCJournalStorageManager(configuration, getScheduledPool(), executorFactory, shutdownOnCriticalIO); - } - // Default to File Based Storage Manager, (Legacy default configuration). - else { + } else { + // Default to File Based Storage Manager, (Legacy default configuration). return new JournalStorageManager(configuration, executorFactory, scheduledPool, shutdownOnCriticalIO); } } @@ -1821,8 +1779,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ActivateCallback callback : activateCallbacks) { try { callback.deActivate(); - } - catch (Throwable e) { + } catch (Throwable e) { // https://bugzilla.redhat.com/show_bug.cgi?id=1009530: // we won't interrupt the shutdown sequence because of a failed callback here ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); @@ -1852,12 +1809,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { }); if (configuration.getThreadPoolMaxSize() == -1) { threadPool = Executors.newCachedThreadPool(tFactory); - } - else { + } else { threadPool = Executors.newFixedThreadPool(configuration.getThreadPoolMaxSize(), tFactory); } - } - else { + } else { threadPool = serviceRegistry.getExecutorService(); this.threadPoolSupplied = true; } @@ -1874,8 +1829,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { } }); scheduledPool = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), tFactory); - } - else { + } else { this.scheduledPoolSupplied = true; this.scheduledPool = serviceRegistry.getScheduledExecutorService(); } @@ -1905,8 +1859,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (!AIOSequentialFileFactory.isSupported()) { ActiveMQServerLogger.LOGGER.switchingNIO(); configuration.setJournalType(JournalType.NIO); - } - else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) { + } else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation())) { ActiveMQServerLogger.LOGGER.switchingNIOonPath(configuration.getJournalLocation().getAbsolutePath()); configuration.setJournalType(JournalType.NIO); } @@ -2036,8 +1989,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { groupingHandler.awaitBindings(); remotingService.start(); - } - else { + } else { remotingService.start(); clusterManager.start(); @@ -2053,8 +2005,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { injectMonitor(new FileStoreMonitor(getScheduledPool(), executorFactory.getExecutor(), configuration.getDiskScanPeriod(), TimeUnit.MILLISECONDS, configuration.getMaxDiskUsage() / 100f)); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -2157,8 +2108,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (pendingNonTXPageCounter.size() != 0) { try { journalLoader.recoverPendingPageCounters(pendingNonTXPageCounter); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorRecoveringPageCounter(e); } } @@ -2199,8 +2149,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (binding != null) { if (ignoreIfExists) { return binding.getQueue(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.queueAlreadyExists(queueName); } } @@ -2213,8 +2162,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final QueueConfig.Builder queueConfigBuilder; if (address == null) { queueConfigBuilder = QueueConfig.builderWith(queueID, queueName); - } - else { + } else { queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, address); } @@ -2222,8 +2170,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final Queue queue = queueFactory.createQueueWith(queueConfig); if (transientQueue) { queue.setConsumersRefCount(new TransientQueueManagerImpl(this, queue.getName())); - } - else if (queue.isAutoCreated()) { + } else if (queue.isAutoCreated()) { queue.setConsumersRefCount(new AutoCreatedQueueManagerImpl(this.getJMSQueueDeleter(), queue.getName())); } @@ -2238,8 +2185,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (queue.isDurable()) { storageManager.commitBindings(txID); } - } - catch (Exception e) { + } catch (Exception e) { try { if (durable) { storageManager.rollbackBindings(txID); @@ -2247,14 +2193,12 @@ public class ActiveMQServerImpl implements ActiveMQServer { final PageSubscription pageSubscription = queue.getPageSubscription(); try { queue.close(); - } - finally { + } finally { if (pageSubscription != null) { pageSubscription.destroy(); } } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } throw e; @@ -2279,8 +2223,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { GroupingHandler groupingHandler1; if (config.getType() == GroupingHandlerConfiguration.TYPE.LOCAL) { groupingHandler1 = new LocalGroupingHandler(executorFactory, scheduledPool, managementService, config.getName(), config.getAddress(), getStorageManager(), config.getTimeout(), config.getGroupTimeout(), config.getReaperPeriod()); - } - else { + } else { groupingHandler1 = new RemoteGroupingHandler(executorFactory, managementService, config.getName(), config.getAddress(), config.getTimeout(), config.getGroupTimeout()); } @@ -2299,8 +2242,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (!journalDir.exists() && configuration.isPersistenceEnabled()) { if (configuration.isCreateJournalDir()) { journalDir.mkdirs(); - } - else { + } else { throw ActiveMQMessageBundle.BUNDLE.cannotCreateDir(journalDir.getAbsolutePath()); } } @@ -2320,8 +2262,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (file == null) { ActiveMQServerLogger.LOGGER.ioCriticalIOError(message, "NULL", cause); - } - else { + } else { ActiveMQServerLogger.LOGGER.ioCriticalIOError(message, file.toString(), cause); } @@ -2401,8 +2342,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (i != null) { if (unique && i.get() != 0) { return false; - } - else if (i.incrementAndGet() > 0) { + } else if (i.incrementAndGet() > 0) { connectedClientIds.put(clientId, i); } } @@ -2431,8 +2371,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { lockActivation(); try { runnable.run(); - } - finally { + } finally { unlockActivation(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java index 60506d8..a446b2e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForReplication.java @@ -64,19 +64,16 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { try { if (timeout != -1L) { ConcurrentUtil.await(condition, timeout); - } - else { + } else { while (untriedConnectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } - } - finally { + } finally { lock.unlock(); } } @@ -91,8 +88,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { untriedConnectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -112,8 +108,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { if (untriedConnectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -133,8 +128,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { nodeID = iterator.next(); } return untriedConnectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -148,8 +142,7 @@ public class AnyLiveNodeLocatorForReplication extends LiveNodeLocator { if (tc != null) { triedConnectors.put(nodeID, tc); } - } - finally { + } finally { lock.unlock(); } super.notifyRegistrationFailed(alreadyReplicating); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java index 189e8cf..3141b6c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java @@ -68,19 +68,16 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (!ConcurrentUtil.await(condition, timeout)) { throw new ActiveMQException("Timeout elapsed while waiting for cluster node"); } - } - else { + } else { while (connectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { } } - } - finally { + } finally { lock.unlock(); } } @@ -94,7 +91,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -103,8 +100,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { connectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -117,8 +113,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (connectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -138,8 +133,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { nodeID = iterator.next(); } return connectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -149,8 +143,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { try { lock.lock(); connectors.remove(nodeID); - } - finally { + } finally { lock.unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java index 10f9f56..535e53b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AutoCreatedQueueManagerImpl.java @@ -35,8 +35,7 @@ public class AutoCreatedQueueManagerImpl implements AutoCreatedQueueManager { if (deleter != null) { deleter.delete(queueName); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRemovingAutoCreatedQueue(e, queueName); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java index 9b70f27..1a58908 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/BackupTopologyListener.java @@ -59,8 +59,7 @@ final class BackupTopologyListener implements ClusterTopologyListener { boolean waitForBackup() { try { return latch.await(WAIT_TIMEOUT, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java index be2011f..73770e5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; @@ -38,12 +44,6 @@ import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteHandler; import org.apache.activemq.artemis.core.server.cluster.qourum.Vote; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.concurrent.TimeUnit; - public class ColocatedActivation extends LiveActivation { private static final SimpleString REQUEST_BACKUP_QUORUM_VOTE = new SimpleString("RequestBackupQuorumVote"); @@ -125,13 +125,11 @@ public class ColocatedActivation extends LiveActivation { boolean started = false; try { started = colocatedHAManager.activateBackup(backupRequestMessage.getBackupSize(), backupRequestMessage.getJournalDirectory(), backupRequestMessage.getBindingsDirectory(), backupRequestMessage.getLargeMessagesDirectory(), backupRequestMessage.getPagingDirectory(), backupRequestMessage.getNodeID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } channel.send(new BackupResponseMessage(started)); - } - else if (activationChannelHandler != null) { + } else if (activationChannelHandler != null) { activationChannelHandler.handlePacket(packet); } } @@ -221,12 +219,10 @@ public class ColocatedActivation extends LiveActivation { } }, colocatedPolicy.getBackupRequestRetryInterval(), TimeUnit.MILLISECONDS); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } - } - else { + } else { nodes.clear(); server.getScheduledPool().schedule(new Runnable() { @Override http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java index 912f721..1397070 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ConnectorsService.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.core.server.impl; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; + import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; @@ -28,11 +33,6 @@ import org.apache.activemq.artemis.core.server.ConnectorServiceFactory; import org.apache.activemq.artemis.core.server.ServiceRegistry; import org.apache.activemq.artemis.utils.ConfigurationHelper; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - /** * ConnectorsService will pool some resource for updates, e.g. Twitter, then the changes are picked * and converted into a ServerMessage for a given destination (queue). @@ -79,8 +79,7 @@ public final class ConnectorsService implements ActiveMQComponent { for (ConnectorService connector : connectors) { try { connector.start(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorStartingConnectorService(e, connector.getName()); } } @@ -113,8 +112,7 @@ public final class ConnectorsService implements ActiveMQComponent { for (ConnectorService connector : connectors) { try { connector.stop(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorStoppingConnectorService(e, connector.getName()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java index ad24a44..e583fc0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java @@ -100,8 +100,7 @@ public class DivertImpl implements Divert { if (transformer != null) { copy = transformer.transform(copy); } - } - else { + } else { copy = message; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java index 1ebf82c..694b112 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java @@ -88,8 +88,7 @@ public class FileLockNodeManager extends NodeManager { liveAttemptLock = tryLock(FileLockNodeManager.LIVE_LOCK_POS); if (liveAttemptLock == null) { return true; - } - else { + } else { liveAttemptLock.release(); return false; } @@ -132,13 +131,11 @@ public class FileLockNodeManager extends NodeManager { liveLock.release(); logger.debug("awaiting live node restarting"); Thread.sleep(2000); - } - else if (state == FileLockNodeManager.FAILINGBACK) { + } else if (state == FileLockNodeManager.FAILINGBACK) { liveLock.release(); logger.debug("awaiting live node failing back"); Thread.sleep(2000); - } - else if (state == FileLockNodeManager.LIVE) { + } else if (state == FileLockNodeManager.LIVE) { logger.debug("acquired live node lock state = " + (char) state); break; } @@ -185,8 +182,7 @@ public class FileLockNodeManager extends NodeManager { public void activationComplete() { try { setLive(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -248,8 +244,7 @@ public class FileLockNodeManager extends NodeManager { read = channel.read(bb, 0); if (read <= 0) { return FileLockNodeManager.NOT_STARTED; - } - else { + } else { return bb.get(0); } } @@ -271,8 +266,7 @@ public class FileLockNodeManager extends NodeManager { protected FileLock tryLock(final int lockPos) throws Exception { try { return channel.tryLock(lockPos, LOCK_LENGTH, false); - } - catch (java.nio.channels.OverlappingFileLockException ex) { + } catch (java.nio.channels.OverlappingFileLockException ex) { // This just means that another object on the same JVM is holding the lock return null; } @@ -285,24 +279,21 @@ public class FileLockNodeManager extends NodeManager { FileLock lock = null; try { lock = channel.tryLock(liveLockPos, 1, false); - } - catch (java.nio.channels.OverlappingFileLockException ex) { + } catch (java.nio.channels.OverlappingFileLockException ex) { // This just means that another object on the same JVM is holding the lock } if (lock == null) { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return null; } if (lockAcquisitionTimeout != -1 && (System.currentTimeMillis() - start) > lockAcquisitionTimeout) { throw new Exception("timed out waiting for lock"); } - } - else { + } else { return lock; } } @@ -315,8 +306,7 @@ public class FileLockNodeManager extends NodeManager { if (lock == null) { try { Thread.sleep(500); - } - catch (InterruptedException e1) { + } catch (InterruptedException e1) { // } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java index d735852..ade3480 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java @@ -78,12 +78,10 @@ public final class InVMNodeManager extends NodeManager { if (state == PAUSED) { liveLock.release(); Thread.sleep(2000); - } - else if (state == FAILING_BACK) { + } else if (state == FAILING_BACK) { liveLock.release(); Thread.sleep(2000); - } - else if (state == LIVE) { + } else if (state == LIVE) { break; } } while (true); @@ -125,8 +123,7 @@ public final class InVMNodeManager extends NodeManager { public void activationComplete() { try { state = LIVE; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java index 906a43e..453f588 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java @@ -81,16 +81,14 @@ public class LastValueQueue extends QueueImpl { replaceLVQMessage(ref, hr); - } - else { + } else { hr = new HolderReference(prop, ref); map.put(prop, hr); super.addTail(hr, direct); } - } - else { + } else { super.addTail(ref, direct); } } @@ -107,29 +105,25 @@ public class LastValueQueue extends QueueImpl { // We need to overwrite the old ref with the new one and ack the old one replaceLVQMessage(ref, hr); - } - else { + } else { // We keep the current ref and ack the one we are returning super.referenceHandled(); try { super.acknowledge(ref); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorAckingOldReference(e); } } - } - else { + } else { hr = new HolderReference(prop, ref); map.put(prop, hr); super.addHead(hr, scheduling); } - } - else { + } else { super.addHead(ref, scheduling); } } @@ -141,15 +135,13 @@ public class LastValueQueue extends QueueImpl { try { oldRef.acknowledge(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorAckingOldReference(e); } hr.setReference(ref); } - @Override protected void refRemoved(MessageReference ref) { synchronized (this) { @@ -339,8 +331,7 @@ public class LastValueQueue extends QueueImpl { if (other.map != null) { return false; } - } - else if (!map.equals(other.map)) { + } else if (!map.equals(other.map)) { return false; } return true; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java index 4397eb4..8468115 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java @@ -238,8 +238,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { try { context.getAttributes(""); alive = true; - } - catch (Exception e) { + } catch (Exception e) { } } return alive; @@ -267,14 +266,12 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); if (connectionUsername != null && !"".equals(connectionUsername)) { env.put(Context.SECURITY_PRINCIPAL, connectionUsername); - } - else { + } else { throw new NamingException("Empty username is not allowed"); } if (connectionPassword != null && !"".equals(connectionPassword)) { env.put(Context.SECURITY_CREDENTIALS, connectionPassword); - } - else { + } else { throw new NamingException("Empty password is not allowed"); } env.put(Context.SECURITY_PROTOCOL, connectionProtocol); @@ -295,8 +292,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { ActiveMQServerLogger.LOGGER.populatingSecurityRolesFromLDAP(connectionURL); try { open(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorOpeningContextForLDAP(e); return this; } @@ -311,8 +307,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { while (searchResults.hasMore()) { processSearchResult(securityRoles, searchResults.next()); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorPopulatingSecurityRolesFromLDAP(e); } @@ -324,7 +319,8 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { this.securityRepository = securityRepository; } - private void processSearchResult(Map> securityRoles, SearchResult searchResult) throws NamingException { + private void processSearchResult(Map> securityRoles, + SearchResult searchResult) throws NamingException { Attributes attrs = searchResult.getAttributes(); if (attrs == null || attrs.size() == 0) { return; @@ -347,8 +343,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { String rawDestinationType = rdn.getValue().toString(); if (rawDestinationType.toLowerCase().contains("queue")) { destinationType = "queue"; - } - else if (rawDestinationType.toLowerCase().contains("topic")) { + } else if (rawDestinationType.toLowerCase().contains("topic")) { destinationType = "topic"; } logger.debug("\tDestination type: " + destinationType); @@ -361,8 +356,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { boolean exists = false; if (roles == null) { roles = new HashSet<>(); - } - else { + } else { exists = true; } @@ -372,14 +366,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { Rdn rdn = ldapname.getRdn(ldapname.size() - 1); String roleName = rdn.getValue().toString(); logger.debug("\tRole name: " + roleName); - Role role = new Role(roleName, - permissionType.equalsIgnoreCase(writePermissionValue), - permissionType.equalsIgnoreCase(readPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - permissionType.equalsIgnoreCase(adminPermissionValue), - false, // there is no permission from ActiveMQ 5.x that corresponds to the "manage" permission in ActiveMQ Artemis + Role role = new Role(roleName, permissionType.equalsIgnoreCase(writePermissionValue), permissionType.equalsIgnoreCase(readPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), false, // there is no permission from ActiveMQ 5.x that corresponds to the "manage" permission in ActiveMQ Artemis permissionType.equalsIgnoreCase(readPermissionValue)); // the "browse" permission matches "read" from ActiveMQ 5.x roles.add(role); } @@ -393,8 +380,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { public SecuritySettingPlugin stop() { try { eventContext.close(); - } - catch (NamingException e) { + } catch (NamingException e) { // ignore } @@ -402,8 +388,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { if (context != null) { context.close(); } - } - catch (NamingException e) { + } catch (NamingException e) { // ignore } @@ -413,8 +398,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for new policy entries in the directory. * - * @param namingEvent - * the new entry event that occurred + * @param namingEvent the new entry event that occurred */ public void objectAdded(NamingEvent namingEvent) { Map> newRoles = new HashMap<>(); @@ -427,8 +411,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { existingRoles.add(role); } } - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } @@ -436,8 +419,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for removed policy entries in the directory. * - * @param namingEvent - * the removed entry event that occurred + * @param namingEvent the removed entry event that occurred */ public void objectRemoved(NamingEvent namingEvent) { try { @@ -461,16 +443,14 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { rolesToRemove.add(role); } } - } - else if (rdn.getValue().equals(readPermissionValue)) { + } else if (rdn.getValue().equals(readPermissionValue)) { logger.debug("Removing read permission"); for (Role role : roles) { if (role.isConsume()) { rolesToRemove.add(role); } } - } - else if (rdn.getValue().equals(adminPermissionValue)) { + } else if (rdn.getValue().equals(adminPermissionValue)) { logger.debug("Removing admin permission"); for (Role role : roles) { if (role.isCreateDurableQueue() || role.isCreateNonDurableQueue() || role.isDeleteDurableQueue() || role.isDeleteNonDurableQueue()) { @@ -483,15 +463,13 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { roles.remove(roleToRemove); } } - } - catch (NamingException e) { + } catch (NamingException e) { e.printStackTrace(); } } /** - * @param namingEvent - * the renaming entry event that occurred + * @param namingEvent the renaming entry event that occurred */ public void objectRenamed(NamingEvent namingEvent) { @@ -500,8 +478,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for changed policy entries in the directory. * - * @param namingEvent - * the changed entry event that occurred + * @param namingEvent the changed entry event that occurred */ public void objectChanged(NamingEvent namingEvent) { objectRemoved(namingEvent); @@ -511,8 +488,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { /** * Handler for exception events from the registry. * - * @param namingExceptionEvent - * the exception event + * @param namingExceptionEvent the exception event */ public void namingExceptionThrown(NamingExceptionEvent namingExceptionEvent) { context = null; @@ -520,6 +496,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { } protected class LDAPNamespaceChangeListener implements NamespaceChangeListener, ObjectChangeListener { + @Override public void namingExceptionThrown(NamingExceptionEvent evt) { LegacyLDAPSecuritySettingPlugin.this.namingExceptionThrown(evt); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java index de7f598..7ffb817 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java @@ -39,6 +39,7 @@ import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy; import org.jboss.logging.Logger; public class LiveOnlyActivation extends Activation { + private static final Logger logger = Logger.getLogger(LiveOnlyActivation.class); //this is how we act when we initially start as live @@ -66,12 +67,10 @@ public class LiveOnlyActivation extends Activation { if (activeMQServer.getIdentity() != null) { ActiveMQServerLogger.LOGGER.serverIsLive(activeMQServer.getIdentity()); - } - else { + } else { ActiveMQServerLogger.LOGGER.serverIsLive(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.initializationError(e); activeMQServer.callActivationFailureListeners(e); } @@ -105,11 +104,9 @@ public class LiveOnlyActivation extends Activation { if (liveOnlyPolicy.getScaleDownPolicy() != null && liveOnlyPolicy.getScaleDownPolicy().isEnabled() && scaleDownClientSessionFactory != null) { try { scaleDown(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToScaleDown(e); - } - finally { + } finally { scaleDownClientSessionFactory.close(); scaleDownServerLocator.close(); } @@ -136,8 +133,7 @@ public class LiveOnlyActivation extends Activation { if (possibleLive == null) // we've tried every connector break; clientSessionFactory = (ClientSessionFactoryInternal) scaleDownServerLocator.createSessionFactory(possibleLive.getA(), 0, false); - } - catch (Exception e) { + } catch (Exception e) { logger.trace("Failed to connect to " + possibleLive.getA()); nodeLocator.notifyRegistrationFailed(false); if (clientSessionFactory != null) { @@ -149,12 +145,10 @@ public class LiveOnlyActivation extends Activation { } if (clientSessionFactory != null) { scaleDownClientSessionFactory = clientSessionFactory; - } - else { + } else { throw new ActiveMQException("Unable to connect to server for scale-down"); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToScaleDown(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java index 866265e..6d9030e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java @@ -57,8 +57,7 @@ public class MessageReferenceImpl implements MessageReference { if (MemorySize.is64bitArch()) { memoryOffset = 48; - } - else { + } else { memoryOffset = 32; } } @@ -199,8 +198,7 @@ public class MessageReferenceImpl implements MessageReference { public void acknowledge(Transaction tx, AckReason reason) throws Exception { if (tx == null) { getQueue().acknowledge(this, reason); - } - else { + } else { getQueue().acknowledge(tx, this, reason); } } @@ -249,4 +247,4 @@ public class MessageReferenceImpl implements MessageReference { public int hashCode() { return this.getMessage().hashCode(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java index e669ec7..101ae3b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java @@ -60,19 +60,16 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { try { if (timeout != -1L) { ConcurrentUtil.await(condition, timeout); - } - else { + } else { while (liveConfiguration == null) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - finally { + } finally { lock.unlock(); } } @@ -86,8 +83,7 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { nodeID = topologyMember.getNodeId(); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -113,8 +109,7 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator { lock.lock(); liveConfiguration = null; super.notifyRegistrationFailed(alreadyReplicating); - } - finally { + } finally { lock.unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java index 97d97b8..32c6392 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java @@ -69,19 +69,16 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (!ConcurrentUtil.await(condition, timeout)) { throw new ActiveMQException("Timeout elapsed while waiting for cluster node"); } - } - else { + } else { while (connectors.isEmpty()) { condition.await(); } } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { //ignore } } - } - finally { + } finally { lock.unlock(); } } @@ -95,7 +92,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -105,8 +102,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { connectors.put(topologyMember.getNodeId(), connector); condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -119,8 +115,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (connectors.size() > 0) { condition.signal(); } - } - finally { + } finally { lock.unlock(); } } @@ -140,8 +135,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { nodeID = iterator.next(); } return connectors.get(nodeID); - } - finally { + } finally { lock.unlock(); } } @@ -151,8 +145,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { try { lock.lock(); connectors.remove(nodeID); - } - finally { + } finally { lock.unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java index ff93ffe..ccb00cb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java @@ -128,8 +128,7 @@ public class PostOfficeJournalLoader implements JournalLoader { storageManager.deleteQueueBinding(tx, queueBindingInfo.getId()); storageManager.commitBindings(tx); continue; - } - else { + } else { final SimpleString newName = queueBindingInfo.getQueueName().concat("-" + (duplicateID++)); ActiveMQServerLogger.LOGGER.queueDuplicatedRenaming(queueBindingInfo.getQueueName().toString(), newName.toString()); queueBindingInfo.replaceQueueName(newName); @@ -138,8 +137,7 @@ public class PostOfficeJournalLoader implements JournalLoader { final QueueConfig.Builder queueConfigBuilder; if (queueBindingInfo.getAddress() == null) { queueConfigBuilder = QueueConfig.builderWith(queueBindingInfo.getId(), queueBindingInfo.getQueueName()); - } - else { + } else { queueConfigBuilder = QueueConfig.builderWith(queueBindingInfo.getId(), queueBindingInfo.getQueueName(), queueBindingInfo.getAddress()); } queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(queueBindingInfo.getUser()).durable(true).temporary(false).autoCreated(queueBindingInfo.isAutoCreated()); @@ -213,8 +211,7 @@ public class PostOfficeJournalLoader implements JournalLoader { ActiveMQServerLogger.LOGGER.journalUnreferencedMessage(msg.getMessageID()); try { storageManager.deleteMessage(msg.getMessageID()); - } - catch (Exception ignored) { + } catch (Exception ignored) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(ignored, msg.getMessageID()); } } @@ -281,8 +278,7 @@ public class PostOfficeJournalLoader implements JournalLoader { if (removed == null) { ActiveMQServerLogger.LOGGER.journalErrorRemovingRef(messageID); - } - else { + } else { referencesToAck.add(removed); } } @@ -363,14 +359,12 @@ public class PostOfficeJournalLoader implements JournalLoader { if (value == null) { logger.debug("Page " + entry.getKey() + " wasn't open, so we will just ignore"); - } - else { + } else { logger.debug("Replacing counter " + value.get()); counter.increment(txRecoverCounter, value.get()); } } - } - else { + } else { // on this case the page file didn't exist, we just remove all the records since the page is already gone logger.debug("Page " + pageId + " didn't exist on address " + addressPageMapEntry.getKey() + ", so we are just removing records"); for (List records : perQueue.values()) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java index d8f772d..5686c7b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueFactoryImpl.java @@ -72,8 +72,7 @@ public class QueueFactoryImpl implements QueueFactory { final Queue queue; if (addressSettings.isLastValueQueue()) { queue = new LastValueQueue(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); - } - else { + } else { queue = new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); } return queue; @@ -95,8 +94,7 @@ public class QueueFactoryImpl implements QueueFactory { Queue queue; if (addressSettings.isLastValueQueue()) { queue = new LastValueQueue(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); - } - else { + } else { queue = new QueueImpl(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor()); }