From 149216e8ecc2ba812959ad696b0a664b1b2cf813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 2 Jul 2016 00:31:06 +0300 Subject: [PATCH] Remove unnecessary null checks and assignments --- .../artemis/core/client/impl/ServerLocatorImpl.java | 11 +++-------- .../org/apache/activemq/artemis/dto/XmlUtil.java | 4 +--- .../jms/bridge/impl/JMSBridgeControlImpl.java | 3 --- .../artemis/jms/bridge/impl/JMSBridgeImpl.java | 3 +-- .../message/JMSMappingOutboundTransformer.java | 13 ++++--------- .../artemis/jms/example/SecurityExample.java | 1 - 6 files changed, 9 insertions(+), 26 deletions(-) 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-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-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/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;