QPID-8180: [Qpid JMS AMQP 0-8..0-91] Improve error message used to handle a channel not found condition during frame dispatch.
diff --git a/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
index 1739a78..51eb4cf 100644
--- a/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
+++ b/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
@@ -73,7 +73,7 @@
private final AMQProtocolHandler _protocolHandler;
- private ConcurrentMap<Integer,AMQSession<?,?>> _closingChannels = new ConcurrentHashMap<>();
+ private final ConcurrentMap<Integer,AMQSession<?,?>> _closingChannels = new ConcurrentHashMap<>();
/**
* Maps from a channel id to an unprocessed message. This is used to tie together the JmsDeliverBody (which arrives
@@ -317,7 +317,19 @@
protected AMQSession getSession(int channelId)
{
- return _connection.getSession(channelId);
+ AMQSession session = _connection.getSession(channelId);
+ if (session == null)
+ {
+ if (_closingChannels.containsKey(channelId))
+ {
+ throw new IllegalStateException(String.format("Channel %d is being closed.", channelId));
+ }
+ else
+ {
+ throw new IllegalStateException(String.format("Channel %d does not exist", channelId));
+ }
+ }
+ return session;
}
@Override