[ARTEMIS-708] small improvements on remove call from DelayedAddRedistributor
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ac69fed4 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ac69fed4 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ac69fed4 Branch: refs/heads/ARTEMIS-780 Commit: ac69fed4e78a9463c4e52dd010346c69d86e1268 Parents: 028f92f Author: Clebert Suconic <[email protected]> Authored: Wed Oct 19 15:34:37 2016 -0400 Committer: Clebert Suconic <[email protected]> Committed: Wed Oct 19 15:34:37 2016 -0400 ---------------------------------------------------------------------- .../artemis/core/server/impl/QueueImpl.java | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ac69fed4/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index 9e610b2..d515b3d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -768,11 +768,7 @@ public class QueueImpl implements Queue { @Override public synchronized void addRedistributor(final long delay) { - if (redistributorFuture != null) { - redistributorFuture.cancel(false); - - futures.remove(redistributorFuture); - } + clearRedistributorFuture(); if (redistributor != null) { // Just prompt delivery @@ -792,6 +788,16 @@ public class QueueImpl implements Queue { } } + private void clearRedistributorFuture() { + ScheduledFuture<?> future = redistributorFuture; + redistributorFuture = null; + if (future != null) { + future.cancel(false); + + futures.remove(future); + } + } + @Override public synchronized void cancelRedistributor() throws Exception { if (redistributor != null) { @@ -802,11 +808,7 @@ public class QueueImpl implements Queue { removeConsumer(redistributorToRemove); } - if (redistributorFuture != null) { - redistributorFuture.cancel(false); - - redistributorFuture = null; - } + clearRedistributorFuture(); } @Override @@ -2709,7 +2711,7 @@ public class QueueImpl implements Queue { synchronized (QueueImpl.this) { internalAddRedistributor(executor1); - futures.remove(redistributorFuture); + clearRedistributorFuture(); } } }
