ARTEMIS-908: Hold connection lock when issuing credits
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f2f35520 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f2f35520 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f2f35520 Branch: refs/heads/master Commit: f2f355206740b6efb2359ad7296409fbfd62c5b3 Parents: 4dc9751 Author: Ulf Lilleengen <[email protected]> Authored: Tue Jan 3 11:03:38 2017 +0100 Committer: Justin Bertram <[email protected]> Committed: Wed Jan 4 10:59:33 2017 -0600 ---------------------------------------------------------------------- .../artemis/protocol/amqp/broker/AMQPSessionCallback.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f2f35520/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java index d8c908c..3dce5dc 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java @@ -433,9 +433,11 @@ public class AMQPSessionCallback implements SessionCallback { store.checkMemory(new Runnable() { @Override public void run() { - if (receiver.getRemoteCredit() < threshold) { - receiver.flow(credits); - connection.flush(); + synchronized (connection.getLock()) { + if (receiver.getRemoteCredit() < threshold) { + receiver.flow(credits); + connection.flush(); + } } } });
