diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java index e7c67cf812..a2c1922b55 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java @@ -787,7 +787,6 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } catch (ActiveMQException e) { factory.close(); - factory = null; if (e.getType() == ActiveMQExceptionType.NOT_CONNECTED) { attempts++; @@ -813,9 +812,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery // how the sendSubscription happens. // in case this ever changes. if (topology != null && !factory.waitForTopology(callTimeout, TimeUnit.MILLISECONDS)) { - if (factory != null) { - factory.cleanup(); - } + factory.cleanup(); throw ActiveMQClientMessageBundle.BUNDLE.connectionTimedOutOnReceiveTopology(discoveryGroup); } @@ -1647,21 +1644,19 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery initialise(); - ClientSessionFactory csf = null; - createConnectors(); try { int retryNumber = 0; - while (csf == null && !isClosed()) { + while (!isClosed()) { retryNumber++; for (Connector conn : connectors) { if (logger.isDebugEnabled()) { logger.debug(this + "::Submitting connect towards " + conn); } - csf = conn.tryConnect(); + ClientSessionFactory csf = conn.tryConnect(); if (csf != null) { csf.getConnection().addFailureListener(new FailureListener() { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java index ad9af036bd..ce1053ff64 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java @@ -363,13 +363,7 @@ public class JSONObject { } } } - catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - catch (JSONException e) { - throw new RuntimeException(e); - } - catch (InvocationTargetException e) { + catch (IllegalAccessException | InvocationTargetException | JSONException e) { throw new RuntimeException(e); } } diff --git a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java index 4b937a8a24..f4744533d0 100644 --- a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java +++ b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java @@ -102,9 +102,7 @@ public class XmlUtil { XMLStreamReader reader = factory.createXMLStreamReader(new FileInputStream(configuration)); - if (props != null) { - reader = new PropertiesFilter(reader, props); - } + reader = new PropertiesFilter(reader, props); return clazz.cast(unmarshaller.unmarshal(reader)); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java index 7734c9eef7..b457831bbb 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeControlImpl.java @@ -176,9 +176,6 @@ public class JMSBridgeControlImpl extends StandardMBean implements JMSBridgeCont if (mode != null) { bridge.setQualityOfServiceMode(QualityOfServiceMode.valueOf(mode)); } - else { - mode = null; - } } @Override diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java index 157305ccdd..c3636514e9 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java @@ -1523,8 +1523,7 @@ public final class JMSBridgeImpl implements JMSBridge { targetProducer.send(targetDestination, msg, msg.getJMSDeliveryMode(), msg.getJMSPriority(), timeToLive); - if (msg != null) - messageCount++; + messageCount++; if (JMSBridgeImpl.trace) { ActiveMQJMSBridgeLogger.LOGGER.trace("Sent message " + msg); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java index 5543abc1f9..99d742d80f 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java @@ -891,10 +891,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo ActiveMQDestination.decomposeQueueNameForDurableSubscription(consumer.getQueue().getName().toString()); obj.put("durable", true); } - catch (IllegalArgumentException e) { - obj.put("durable", false); - } - catch (JMSRuntimeException e) { + catch (IllegalArgumentException | JMSRuntimeException e) { obj.put("durable", false); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java index cc3c2ace60..46dc2695ae 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java @@ -148,16 +148,11 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { String msgId = msg.getJMSMessageID(); - if (msgId != null) { - try { - props.setMessageId(AMQPMessageIdHelper.INSTANCE.toIdObject(msgId)); - } - catch (ActiveMQAMQPIllegalStateException e) { - props.setMessageId(msgId); - } + try { + props.setMessageId(AMQPMessageIdHelper.INSTANCE.toIdObject(msgId)); } - else { - props.setMessageId(msgId.toString()); + catch (ActiveMQAMQPIllegalStateException e) { + props.setMessageId(msgId); } } if (msg.getJMSDestination() != null) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java index a978be88f2..803c6f05f1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java @@ -956,10 +956,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scheduleRetryConnect(); } } - catch (ActiveMQInterruptedException e) { - ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); - } - catch (InterruptedException e) { + catch (ActiveMQInterruptedException | InterruptedException e) { ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); } catch (Exception e) { @@ -1138,10 +1135,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } ActiveMQServerLogger.LOGGER.bridgeStopped(name); } - catch (RuntimeException e) { - ActiveMQServerLogger.LOGGER.error("Failed to stop bridge", e); - } - catch (InterruptedException e) { + catch (InterruptedException | RuntimeException e) { ActiveMQServerLogger.LOGGER.error("Failed to stop bridge", e); } } 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 3822fff3c4..d9963ee27b 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 @@ -120,11 +120,8 @@ public final class SharedStoreBackupActivation extends Activation { startFailbackChecker(); } } - catch (InterruptedException e) { - // this is ok, we are being stopped - } - catch (ClosedChannelException e) { - // this is ok too, we are being stopped + catch (ClosedChannelException | InterruptedException e) { + // these are ok, we are being stopped } catch (Exception e) { if (!(e.getCause() instanceof InterruptedException)) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java index 18bae341a9..a19a5fc6e6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java @@ -90,9 +90,7 @@ public class GuestLoginModule implements LoginModule { passwordCallback.clearPassword(); } } - catch (IOException ioe) { - } - catch (UnsupportedCallbackException uce) { + catch (IOException | UnsupportedCallbackException e) { } } if (debug) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java index 386d536f6a..edcf38e949 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java @@ -102,11 +102,8 @@ public class LDAPLoginModule implements LoginModule { try { handler.handle(callbacks); } - catch (IOException ioe) { - throw (LoginException) new LoginException().initCause(ioe); - } - catch (UnsupportedCallbackException uce) { - throw (LoginException) new LoginException().initCause(uce); + catch (IOException | UnsupportedCallbackException e) { + throw (LoginException) new LoginException().initCause(e); } String password; diff --git a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java index 94f4b43477..abf5fac48d 100644 --- a/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ b/examples/features/standard/security-ldap/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java @@ -64,7 +64,6 @@ public class SecurityExample { } // Step 5. bill tries to make a connection using wrong password - billConnection = null; try { billConnection = createConnection("bill", "activemq1", cf); result = false; diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java index 534e68b883..cafc701458 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java @@ -20,7 +20,6 @@ import java.net.URI; import java.util.Collection; import java.util.Iterator; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean;