summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2015-02-24 17:40:09 +0000
committerRobert Godfrey <rgodfrey@apache.org>2015-02-24 17:40:09 +0000
commit6d9968a608a52cb5a6b98b9e0f5ceb6826ee0bf2 (patch)
tree9ca6bf126fe7eac874686e1668c78bc1f86c8434
parentc2beb82164dee5571907d1508ff59b2812f94662 (diff)
downloadqpid-python-6d9968a608a52cb5a6b98b9e0f5ceb6826ee0bf2.tar.gz
QPID-6411 : Don't throw an NPE if there is no Error associated with the a broker initiated detach
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1662051 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Receiver.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Receiver.java b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Receiver.java
index be43601e63..5d4374fec5 100644
--- a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Receiver.java
+++ b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Receiver.java
@@ -38,8 +38,10 @@ import org.apache.qpid.amqp_1_0.transport.ReceivingLinkListener;
import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
import org.apache.qpid.amqp_1_0.type.Binary;
import org.apache.qpid.amqp_1_0.type.DeliveryState;
+import org.apache.qpid.amqp_1_0.type.ErrorCondition;
import org.apache.qpid.amqp_1_0.type.Outcome;
import org.apache.qpid.amqp_1_0.type.Section;
+import org.apache.qpid.amqp_1_0.type.Symbol;
import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
import org.apache.qpid.amqp_1_0.type.messaging.Accepted;
import org.apache.qpid.amqp_1_0.type.messaging.Modified;
@@ -58,6 +60,20 @@ import org.apache.qpid.amqp_1_0.type.transport.Transfer;
public class Receiver implements DeliveryStateHandler
{
+ private static final ErrorCondition UNKNOWN_ERROR_CONDITION = new ErrorCondition()
+ {
+ @Override
+ public Symbol getValue()
+ {
+ return Symbol.valueOf("Unknown");
+ }
+
+ @Override
+ public String toString()
+ {
+ return getValue().toString();
+ }
+ };
private ReceivingLinkEndpoint _endpoint;
private int _id;
private static final UnsignedInteger DEFAULT_INITIAL_CREDIT = UnsignedInteger.valueOf(100);
@@ -196,16 +212,20 @@ public class Receiver implements DeliveryStateHandler
{
throw new ConnectionErrorException(AmqpError.INTERNAL_ERROR,"Interrupted while waiting for detach following failed attach");
}
- throw new ConnectionErrorException(getError().getCondition(),
- getError().getDescription() == null
- ? "AMQP error: '" + getError().getCondition().toString()
+
+ Error error = getError() == null
+ ? new Error(UNKNOWN_ERROR_CONDITION, "Unknown")
+ : getError();
+
+
+ ErrorCondition condition = error.getCondition() == null ? UNKNOWN_ERROR_CONDITION : error.getCondition();
+
+ throw new ConnectionErrorException(condition,
+ error.getDescription() == null
+ ? "AMQP error: '" + condition.toString()
+ "' when attempting to create a receiver"
+ (source != null ? " from: '" + source.getAddress() +"'" : "")
- : getError().getDescription());
- }
- else
- {
-
+ : error.getDescription());
}
}