You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2016/04/05 18:50:43 UTC

[3/3] qpid-jms git commit: QPIDJMS-168 Ensure we throw a more meaningful exception if the remote doesn't provide one when pending sends are awaiting a response.

QPIDJMS-168 Ensure we throw a more meaningful exception if the remote
doesn't provide one when pending sends are awaiting a response.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/e97a6f94
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/e97a6f94
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/e97a6f94

Branch: refs/heads/master
Commit: e97a6f94b81b82b0afc4f5786cbda5c55c43150d
Parents: a02c533
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Apr 5 12:50:19 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Apr 5 12:50:19 2016 -0400

----------------------------------------------------------------------
 .../jms/provider/amqp/AmqpFixedProducer.java    |  6 ++++--
 .../qpid/jms/provider/amqp/AmqpSupport.java     | 21 ++++++++++++++++++--
 2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e97a6f94/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
index 3dbb85a..ef526c9 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
@@ -309,12 +309,14 @@ public class AmqpFixedProducer extends AmqpProducer {
     public void remotelyClosed(AmqpProvider provider) {
         super.remotelyClosed(provider);
 
-        Exception ex = AmqpSupport.convertToException(getEndpoint(), getEndpoint().getRemoteCondition());
-        if (ex == null) {
+        Exception ex = null;
+        if (!sent.isEmpty()) {
             // TODO: create/use a more specific/appropriate exception type?
             ex = new JMSException("Producer closed remotely before message transfer result was notified");
         }
 
+        ex = AmqpSupport.convertToException(getEndpoint(), getEndpoint().getRemoteCondition(), ex);
+
         for (Delivery delivery : sent) {
             try {
                 AsyncResult request = (AsyncResult) delivery.getContext();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e97a6f94/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java
index f218fa2..4d9c728 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java
@@ -100,7 +100,24 @@ public class AmqpSupport {
      * @return a new Exception instance that best matches the ErrorCondition value.
      */
     public static Exception convertToException(Endpoint endpoint, ErrorCondition errorCondition) {
-        Exception remoteError = null;
+        return convertToException(endpoint, errorCondition, null);
+    }
+
+    /**
+     * Given an ErrorCondition instance create a new Exception that best matches
+     * the error type.
+     *
+     * @param endpoint
+     *      The target of the error.
+     * @param errorCondition
+     *      The ErrorCondition returned from the remote peer.
+     * @param defaultException
+     *      The default exception to throw if no error information is provided from the remote.
+     *
+     * @return a new Exception instance that best matches the ErrorCondition value.
+     */
+    public static Exception convertToException(Endpoint endpoint, ErrorCondition errorCondition, Exception defaultException) {
+        Exception remoteError = defaultException;
 
         if (errorCondition != null && errorCondition.getCondition() != null) {
             Symbol error = errorCondition.getCondition();
@@ -130,7 +147,7 @@ public class AmqpSupport {
             } else {
                 remoteError = new JMSException(message);
             }
-        } else {
+        } else if (remoteError == null) {
             remoteError = new JMSException("Unknown error from remote peer");
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org