diff options
| author | Keith Wall <kwall@apache.org> | 2014-10-30 16:58:52 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2014-10-30 16:58:52 +0000 |
| commit | d67392a88b4889247ff60e2773055cc41981ade7 (patch) | |
| tree | d0235b7101366bc45ea77c8a8a952d6a9c79c858 /qpid/java | |
| parent | 6c4648a65b1b8679beeeedc55bb12c2bf416aab1 (diff) | |
| download | qpid-python-d67392a88b4889247ff60e2773055cc41981ade7.tar.gz | |
QPID-6202: [Java Broker] Ensure AMQProtocolEngine#closeSession() completes closure even if AMQChannel fails to close cleanly
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1635548 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
| -rw-r--r-- | qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java index d3f48fc664..b2b2f904a6 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java @@ -727,17 +727,41 @@ public class AMQProtocolEngine implements ServerProtocolEngine, */ private void closeAllChannels() { - for (AMQChannel channel : getChannels()) - { - channel.close(); - } - synchronized (_channelMap) + try { - _channelMap.clear(); + RuntimeException firstException = null; + for (AMQChannel channel : getChannels()) + { + try + { + channel.close(); + } + catch (RuntimeException re) + { + if (!(re instanceof ConnectionScopedRuntimeException)) + { + _logger.error("Unexpected exception closing channel", re); + } + firstException = re; + } + } + + if (firstException != null) + { + throw firstException; + } } - for (int i = 0; i <= CHANNEL_CACHE_SIZE; i++) + finally { - _cachedChannels[i] = null; + synchronized (_channelMap) + { + _channelMap.clear(); + } + for (int i = 0; i <= CHANNEL_CACHE_SIZE; i++) + { + _cachedChannels[i] = null; + } + } } @@ -767,19 +791,24 @@ public class AMQProtocolEngine implements ServerProtocolEngine, _virtualHost.getConnectionRegistry().deregisterConnection(this); } - closeAllChannels(); - - for (Action<? super AMQProtocolEngine> task : _taskList) + try { - task.performAction(this); + closeAllChannels(); } - - synchronized(this) + finally { - _closed = true; - notifyAll(); + for (Action<? super AMQProtocolEngine> task : _taskList) + { + task.performAction(this); + } + + synchronized (this) + { + _closed = true; + notifyAll(); + } + getEventLogger().message(_logSubject, ConnectionMessages.CLOSE()); } - getEventLogger().message(_logSubject, ConnectionMessages.CLOSE()); } } else |
