From 31404f8a388b0716574d39283119d54c53f5b37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 5 Mar 2016 11:29:34 +0200 Subject: [PATCH] Remove redundant null checks --- .../core/client/impl/ServerLocatorImpl.java | 4 +--- .../artemis/core/remoting/impl/ssl/SSLSupport.java | 4 ++-- .../artemis/jlibaio/util/CallbackCache.java | 10 ++++------ .../java/org/apache/activemq/artemis/rest/Jms.java | 3 +-- .../paging/cursor/impl/PageSubscriptionImpl.java | 2 +- .../artemis/core/server/impl/QueueImpl.java | 8 +++----- .../core/server/impl/ServerConsumerImpl.java | 8 ++------ .../management/impl/ManagementServiceImpl.java | 14 ++++++++------ .../core/security/ActiveMQSecurityManagerImpl.java | 2 +- .../spi/core/security/jaas/LDAPLoginModule.java | 8 ++------ .../artemis/jms/example/JMSBridgeExample.java | 4 +--- .../artemis/jms/example/SecurityExample.java | 1 - .../apache/activemq/JmsRollbackRedeliveryTest.java | 6 +++--- .../java/org/apache/activemq/bugs/AMQ4671Test.java | 4 +--- .../java/org/apache/activemq/bugs/AMQ4952Test.java | 6 ++---- .../activemq/bugs/RedeliveryPluginHeaderTest.java | 4 +--- .../org/apache/activemq/config/ConfigTest.java | 4 +--- .../jndi/ActiveMQInitialContextFactoryTest.java | 3 --- .../apache/activemq/jndi/InitialContextTest.java | 4 ---- .../tests/integration/divert/DivertTest.java | 1 - .../server/management/JMSServerControlTest.java | 8 ++------ 21 files changed, 36 insertions(+), 72 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 53ba9df862..e7cc55ad57 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 @@ -809,9 +809,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); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java index 092b1c7fb7..5320bacac9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java @@ -81,7 +81,7 @@ public class SSLSupport { private static TrustManager[] loadTrustManager(final String trustStoreProvider, final String trustStorePath, final String trustStorePassword) throws Exception { - if (trustStorePath == null && (trustStoreProvider == null || (trustStoreProvider != null && !"PKCS11".equals(trustStoreProvider.toUpperCase())))) { + if (trustStorePath == null && (trustStoreProvider == null || !"PKCS11".equals(trustStoreProvider.toUpperCase()))) { return null; } else { @@ -120,7 +120,7 @@ public class SSLSupport { private static KeyManager[] loadKeyManagers(final String keyStoreProvider, final String keystorePath, final String keystorePassword) throws Exception { - if (keystorePath == null && (keyStoreProvider == null || (keyStoreProvider != null && !"PKCS11".equals(keyStoreProvider.toUpperCase())))) { + if (keystorePath == null && (keyStoreProvider == null || !"PKCS11".equals(keyStoreProvider.toUpperCase()))) { return null; } else { diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java index 00a3826cfd..22051033f7 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java @@ -49,12 +49,10 @@ public class CallbackCache { if (retValue == null) { throw new NullPointerException("You should initialize the pool before using it"); } - if (retValue != null) { - available--; - get++; - if (get >= size) { - get = 0; - } + available--; + get++; + if (get >= size) { + get = 0; } return retValue; } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java index 5f25d48b57..692bddbbf6 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/Jms.java @@ -109,8 +109,7 @@ public class Jms { public static boolean isHttpMessage(Message message) { try { - Boolean aBoolean = message.getBooleanProperty(HttpMessageHelper.POSTED_AS_HTTP_MESSAGE); - return aBoolean != null && aBoolean.booleanValue() == true; + return message.getBooleanProperty(HttpMessageHelper.POSTED_AS_HTTP_MESSAGE); } catch (JMSException e) { return false; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java index 3b74b76c1f..eae44dd2d8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java @@ -1236,7 +1236,7 @@ final class PageSubscriptionImpl implements PageSubscription { else if (ignored) { positionIgnored(message.getPosition()); } - } while (message != null && !match); + } while (!match); if (message != null) { lastOperation = lastPosition; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index b74ecc4c96..8bf5d08a7f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -2943,12 +2943,10 @@ public class QueueImpl implements Queue { props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address); - if (connection != null) { - props.putSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS, SimpleString.toSimpleString(connection.getRemoteAddress())); + props.putSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS, SimpleString.toSimpleString(connection.getRemoteAddress())); - if (connection.getID() != null) { - props.putSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME, SimpleString.toSimpleString(connection.getID().toString())); - } + if (connection.getID() != null) { + props.putSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME, SimpleString.toSimpleString(connection.getID().toString())); } props.putLongProperty(ManagementHelper.HDR_CONSUMER_NAME, serverConsumer.getID()); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java index 1cfc4f89b1..25c657e245 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java @@ -682,9 +682,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (ref == null) { ActiveMQIllegalStateException ils = ActiveMQMessageBundle.BUNDLE.consumerNoReference(id, messageID, messageQueue.getName()); - if (tx != null) { - tx.markAsRollbackOnly(ils); - } + tx.markAsRollbackOnly(ils); throw ils; } @@ -752,9 +750,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { if (ref == null) { ActiveMQIllegalStateException ils = new ActiveMQIllegalStateException("Cannot find ref to ack " + messageID); - if (tx != null) { - tx.markAsRollbackOnly(ils); - } + tx.markAsRollbackOnly(ils); throw ils; } 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 c4d0cd65f8..a65498d12d 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 @@ -392,13 +392,14 @@ public class ManagementServiceImpl implements ManagementService { catch (Exception e) { ActiveMQServerLogger.LOGGER.managementOperationError(e, operation, resourceName); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, false); - String exceptionMessage = e.getMessage(); + String exceptionMessage; if (e instanceof InvocationTargetException) { exceptionMessage = ((InvocationTargetException) e).getTargetException().getMessage(); } - if (e != null) { - ManagementHelper.storeResult(reply, exceptionMessage); + else { + exceptionMessage = e.getMessage(); } + ManagementHelper.storeResult(reply, exceptionMessage); } } else { @@ -415,13 +416,14 @@ public class ManagementServiceImpl implements ManagementService { catch (Exception e) { ActiveMQServerLogger.LOGGER.managementAttributeError(e, attribute, resourceName); reply.putBooleanProperty(ManagementHelper.HDR_OPERATION_SUCCEEDED, false); - String exceptionMessage = e.getMessage(); + String exceptionMessage; if (e instanceof InvocationTargetException) { exceptionMessage = ((InvocationTargetException) e).getTargetException().getMessage(); } - if (e != null) { - ManagementHelper.storeResult(reply, exceptionMessage); + else { + exceptionMessage = e.getMessage(); } + ManagementHelper.storeResult(reply, exceptionMessage); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java index ba869eda83..def688f973 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQSecurityManagerImpl.java @@ -52,7 +52,7 @@ public class ActiveMQSecurityManagerImpl implements ActiveMQSecurityManager { User user = configuration.getUser(username); return user != null && user.isValid(username, password); } - else if (username == null && password == null) { + else if (password == null) { return configuration.getDefaultUser() != null; } else { // the only possible case here is user == null, password != null 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 3802d7bcc3..512f02e8a7 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 @@ -246,9 +246,7 @@ public class LDAPLoginModule implements LoginModule { } } catch (URISyntaxException e) { - if (context != null) { - close(context); - } + close(context); FailedLoginException ex = new FailedLoginException("Error parsing absolute name as URI."); ex.initCause(e); throw ex; @@ -289,9 +287,7 @@ public class LDAPLoginModule implements LoginModule { throw ex; } catch (NamingException e) { - if (context != null) { - close(context); - } + close(context); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; diff --git a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java index f15db57d25..23946b0bd0 100644 --- a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java +++ b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java @@ -102,9 +102,7 @@ public class JMSBridgeExample { } finally { // Step 12. Be sure to close the resources! - if (jmsBridge != null) { - jmsBridge.stop(); - } + jmsBridge.stop(); if (sourceContext != null) { sourceContext.close(); } diff --git a/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java index 88fd1dab40..90cf72ca54 100644 --- a/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ b/examples/features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java @@ -60,7 +60,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/JmsRollbackRedeliveryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java index 5b99ad98d9..8a64a85a26 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsRollbackRedeliveryTest.java @@ -118,7 +118,7 @@ public class JmsRollbackRedeliveryTest { MessageConsumer consumer = session.createConsumer(destination); TextMessage msg = (TextMessage) consumer.receive(6000000); if (msg != null) { - if (msg != null && rolledback.put(msg.getText(), Boolean.TRUE) != null) { + if (rolledback.put(msg.getText(), Boolean.TRUE) != null) { LOG.info("Received message " + msg.getText() + " (" + received.getAndIncrement() + ")" + msg.getJMSMessageID()); assertTrue(msg.getJMSRedelivered()); assertEquals(2, msg.getLongProperty("JMSXDeliveryCount")); @@ -155,7 +155,7 @@ public class JmsRollbackRedeliveryTest { while (received.get() < nbMessages) { TextMessage msg = (TextMessage) consumer.receive(6000000); if (msg != null) { - if (msg != null && rolledback.put(msg.getText(), Boolean.TRUE) != null) { + if (rolledback.put(msg.getText(), Boolean.TRUE) != null) { LOG.info("Received message " + msg.getText() + " (" + received.getAndIncrement() + ")" + msg.getJMSMessageID()); assertTrue(msg.getJMSRedelivered()); session.commit(); @@ -190,7 +190,7 @@ public class JmsRollbackRedeliveryTest { MessageConsumer consumer = session.createConsumer(destination); TextMessage msg = (TextMessage) consumer.receive(6000000); if (msg != null) { - if (msg != null && rolledback.put(msg.getText(), Boolean.TRUE) != null) { + if (rolledback.put(msg.getText(), Boolean.TRUE) != null) { LOG.info("Received message " + msg.getText() + " (" + received.getAndIncrement() + ")" + msg.getJMSMessageID()); assertTrue(msg.getJMSRedelivered()); session.commit(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java index 562d978d92..165d5fd03e 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java @@ -75,9 +75,7 @@ public class AMQ4671Test { } } finally { - if (connection != null) { - connection.close(); - } + connection.close(); } } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java index dd4c7b31b1..0b74979901 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java @@ -319,12 +319,10 @@ public class AMQ4952Test { // network to consumerBroker - if (networkToPorts != null && networkToPorts.length > 0) { + if (networkToPorts.length > 0) { StringBuilder builder = new StringBuilder("static:(failover:(tcp://localhost:2006)?maxReconnectAttempts=0)?useExponentialBackOff=false"); NetworkConnector nc = broker.addNetworkConnector(builder.toString()); - if (networkProps != null) { - IntrospectionSupport.setProperties(nc, networkProps); - } + IntrospectionSupport.setProperties(nc, networkProps); nc.setStaticallyIncludedDestinations(Arrays.asList(new ActiveMQQueue[]{QUEUE_NAME})); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java index 62723afaf4..b0e7bd3151 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java @@ -121,9 +121,7 @@ public class RedeliveryPluginHeaderTest extends TestCase { } finally { - if (connection != null) { - connection.close(); - } + connection.close(); if (broker != null) { broker.stop(); diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java index 9ded99d8e6..f0640b630a 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java @@ -398,9 +398,7 @@ public class ConfigTest { LOG.info("Success"); } finally { - if (broker != null) { - broker.stop(); - } + broker.stop(); } } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java index 9ebd776c66..86904729c9 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/ActiveMQInitialContextFactoryTest.java @@ -39,9 +39,6 @@ public class ActiveMQInitialContextFactoryTest extends JNDITestSupport { InitialContext context = new InitialContext(); - // make sure context is not null - assertTrue("Created context", context != null); - Object topicDestination = context.lookup("MyTopic"); // check if MyTopic is an ActiveMQTopic diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java index 5903d3f9d1..575ab880f4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/jndi/InitialContextTest.java @@ -37,7 +37,6 @@ public class InitialContextTest extends TestCase { public void testInitialContext() throws Exception { InitialContext context = new InitialContext(); - assertTrue("Created context", context != null); ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory"); @@ -49,7 +48,6 @@ public class InitialContextTest extends TestCase { public void testInitialContextHasXA() throws Exception { InitialContext context = new InitialContext(); - assertTrue("Created context", context != null); ActiveMQXAConnectionFactory connectionFactory = (ActiveMQXAConnectionFactory) context.lookup("XAConnectionFactory"); @@ -66,7 +64,6 @@ public class InitialContextTest extends TestCase { properties.put(Context.PROVIDER_URL, expected); InitialContext context = new InitialContext(properties); - assertTrue("Created context", context != null); ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory"); @@ -85,7 +82,6 @@ public class InitialContextTest extends TestCase { properties.put("redeliveryPolicy.backOffMultiplier", "32"); InitialContext context = new InitialContext(properties); - assertTrue("Created context", context != null); ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java index 806ac8356d..10c887e011 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java @@ -187,7 +187,6 @@ public class DivertTest extends ActiveMQTestBase { } int count2 = 0; - message = null; while ((message = consumer2.receiveImmediate()) != null) { message.acknowledge(); count2++; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java index a1c770f14a..1dd3c0a281 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java @@ -370,9 +370,7 @@ public class JMSServerControlTest extends ManagementTestBase { Assert.assertNotNull(cons.receive(5000)); } finally { - if (connection != null) { - connection.close(); - } + connection.close(); } } @@ -415,9 +413,7 @@ public class JMSServerControlTest extends ManagementTestBase { Assert.assertNotNull(cons.receive(5000)); } finally { - if (connection != null) { - connection.close(); - } + connection.close(); } }