activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6309
Date Fri, 03 Jun 2016 22:06:00 GMT
Repository: activemq
Updated Branches:
  refs/heads/master db71b43b1 -> 28e7cb0b2


https://issues.apache.org/jira/browse/AMQ-6309

Fix some minor issues shown by static code analysis

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/28e7cb0b
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/28e7cb0b
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/28e7cb0b

Branch: refs/heads/master
Commit: 28e7cb0b21825f0be517673c3004c689d6f448c2
Parents: db71b43
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Jun 3 18:05:40 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Jun 3 18:05:40 2016 -0400

----------------------------------------------------------------------
 .../activemq/transport/amqp/AmqpSupport.java    |  2 +-
 .../transport/amqp/protocol/AmqpSender.java     |  8 ++---
 .../JMSClientProducerFlowSendFailIfNoSpace.java |  5 ---
 .../amqp/JMSClientRequestResponseTest.java      |  4 ---
 .../amqp/client/AmqpTransactionCoordinator.java |  5 ++-
 .../client/transport/NettyTransportOptions.java |  2 +-
 .../amqp/interop/AmqpConnectionsTest.java       | 32 +++++++++-----------
 .../amqp/profile/QueueBrowserStressTest.java    | 28 ++++++++---------
 8 files changed, 34 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
index 9544e33..cf86f01 100644
--- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
+++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpSupport.java
@@ -102,7 +102,7 @@ public class AmqpSupport {
     public static Map.Entry<Symbol, DescribedType> findFilter(Map<Symbol, Object>
filters, Object[] filterIds) {
 
         if (filterIds == null || filterIds.length == 0) {
-            throw new IllegalArgumentException("Invalid Filter Ids array passed: " + filterIds);
+            throw new IllegalArgumentException("Invalid empty Filter Ids array passed: ");
         }
 
         if (filters == null || filters.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java
b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java
index 567c507..9fb85a3 100644
--- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java
+++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java
@@ -275,11 +275,9 @@ public class AmqpSender extends AmqpAbstractLink<Sender> {
                     @Override
                     public void onResponse(AmqpProtocolConverter converter, Response response)
throws IOException {
                         if (response.isException()) {
-                            if (response.isException()) {
-                                Throwable exception = ((ExceptionResponse) response).getException();
-                                exception.printStackTrace();
-                                getEndpoint().close();
-                            }
+                            Throwable exception = ((ExceptionResponse) response).getException();
+                            exception.printStackTrace();
+                            getEndpoint().close();
                         }
                         session.pumpProtonToSocket();
                     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientProducerFlowSendFailIfNoSpace.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientProducerFlowSendFailIfNoSpace.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientProducerFlowSendFailIfNoSpace.java
index 09d28fe..72ea82a 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientProducerFlowSendFailIfNoSpace.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientProducerFlowSendFailIfNoSpace.java
@@ -36,15 +36,10 @@ import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
 import org.apache.activemq.broker.region.policy.VMPendingSubscriberMessageStoragePolicy;
 import org.apache.qpid.jms.JmsConnection;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
 
 public class JMSClientProducerFlowSendFailIfNoSpace extends JMSClientTestSupport {
 
-    @Rule
-    public TestName name = new TestName();
-
     // used to test sendFailIfNoSpace on SystemUsage
     protected final AtomicBoolean gotResourceException = new AtomicBoolean(false);
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientRequestResponseTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientRequestResponseTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientRequestResponseTest.java
index 7d8a44f..c99c74b 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientRequestResponseTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientRequestResponseTest.java
@@ -36,9 +36,7 @@ import javax.jms.TextMessage;
 import javax.jms.Topic;
 
 import org.junit.After;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,8 +44,6 @@ public class JMSClientRequestResponseTest extends AmqpTestSupport implements
Mes
 
     private static final Logger LOG = LoggerFactory.getLogger(JMSClientRequestResponseTest.class);
 
-    @Rule public TestName name = new TestName();
-
     private Connection requestorConnection;
     private Destination requestDestination;
     private Session requestorSession;

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java
index 8ce1f09..73822a8 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/AmqpTransactionCoordinator.java
@@ -30,7 +30,6 @@ import javax.jms.TransactionRolledBackException;
 
 import org.apache.activemq.transport.amqp.client.util.AsyncResult;
 import org.apache.activemq.transport.amqp.client.util.IOExceptionSupport;
-import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.apache.qpid.proton.amqp.messaging.Rejected;
 import org.apache.qpid.proton.amqp.messaging.Source;
@@ -110,7 +109,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource<Sender>
{
 
                 // Clear state data
                 pendingDelivery.settle();
-                pendingRequests.remove(txId.getTxId());
+                pendingRequests.remove(txId);
                 deliveries.remove();
             }
 
@@ -165,7 +164,7 @@ public class AmqpTransactionCoordinator extends AmqpAbstractResource<Sender>
{
         Message message = Message.Factory.create();
         Discharge discharge = new Discharge();
         discharge.setFail(!commit);
-        discharge.setTxnId((Binary) txId.getRemoteTxId());
+        discharge.setTxnId(txId.getRemoteTxId());
         message.setBody(new AmqpValue(discharge));
 
         Delivery pendingDelivery = getEndpoint().delivery(tagGenerator.getNextTag());

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportOptions.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportOptions.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportOptions.java
index 745a40d..7b3dc9b 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportOptions.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/client/transport/NettyTransportOptions.java
@@ -19,7 +19,7 @@ package org.apache.activemq.transport.amqp.client.transport;
 /**
  * Encapsulates all the TCP Transport options in one configuration object.
  */
-public class NettyTransportOptions {
+public class NettyTransportOptions implements Cloneable {
 
     public static final int DEFAULT_SEND_BUFFER_SIZE = 64 * 1024;
     public static final int DEFAULT_RECEIVE_BUFFER_SIZE = DEFAULT_SEND_BUFFER_SIZE;

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
index 971b1df..fa519ab 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java
@@ -192,31 +192,29 @@ public class AmqpConnectionsTest extends AmqpClientTestSupport {
             @Override
             public void inspectClosedResource(Connection connection) {
                 ErrorCondition remoteError = connection.getRemoteCondition();
-                if (remoteError == null) {
+                if (remoteError == null || remoteError.getCondition() == null) {
                     markAsInvalid("Broker did not add error condition for duplicate client
ID");
-                }
-
-                if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
-                    markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
-                }
+                } else {
+                    if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
+                        markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
+                    }
 
-                if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
-                    markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
+                    if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) {
+                        markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD);
+                    }
                 }
 
                 // Validate the info map contains a hint that the container/client id was
the problem
                 Map<?, ?> infoMap = remoteError.getInfo();
-                if(infoMap == null) {
+                if (infoMap == null) {
                     markAsInvalid("Broker did not set an info map on condition");
-                }
-
-                if(!infoMap.containsKey(AmqpSupport.INVALID_FIELD)) {
+                } else if (!infoMap.containsKey(AmqpSupport.INVALID_FIELD)) {
                     markAsInvalid("Info map does not contain expected key");
-                }
-
-                Object value = infoMap.get(AmqpSupport.INVALID_FIELD);
-                if(!AmqpSupport.CONTAINER_ID.equals(value)) {
-                    markAsInvalid("Info map does not contain expected value: " + value);
+                } else {
+                    Object value = infoMap.get(AmqpSupport.INVALID_FIELD);
+                    if(!AmqpSupport.CONTAINER_ID.equals(value)) {
+                        markAsInvalid("Info map does not contain expected value: " + value);
+                    }
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/activemq/blob/28e7cb0b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/profile/QueueBrowserStressTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/profile/QueueBrowserStressTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/profile/QueueBrowserStressTest.java
index 77e83d2..f2968ec 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/profile/QueueBrowserStressTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/profile/QueueBrowserStressTest.java
@@ -68,25 +68,21 @@ public class QueueBrowserStressTest extends JMSClientTestSupport {
                 }
             }
 
-            if (browser != null) {
-                LOG.debug("close browser for {}", queue.getQueueName());
-                try {
-                    browser.close();
-                } catch (JMSException e) {
-                    LOG.error("Error on browser close: {}", e);
-                }
-                browser = null;
+            LOG.debug("close browser for {}", queue.getQueueName());
+            try {
+                browser.close();
+            } catch (JMSException e) {
+                LOG.error("Error on browser close: {}", e);
             }
+            browser = null;
 
-            if (session != null) {
-                LOG.debug("close session for {}", queue.getQueueName());
-                try {
-                    session.close();
-                } catch (JMSException e) {
-                    LOG.error("Error on session close: {}", e);
-                }
-                session = null;
+            LOG.debug("close session for {}", queue.getQueueName());
+            try {
+                session.close();
+            } catch (JMSException e) {
+                LOG.error("Error on session close: {}", e);
             }
+            session = null;
         }
 
         LOG.info("Task complete, capture heap dump now");


Mime
View raw message