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 16b8880305..dfcba279ea 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 @@ -1375,10 +1375,7 @@ public class QueueImpl implements Queue { @Override public synchronized boolean expireReference(final long messageID) throws Exception { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return false; } @@ -1400,10 +1397,7 @@ public class QueueImpl implements Queue { @Override public synchronized int expireReferences(final Filter filter) throws Exception { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return 0; } @@ -1432,10 +1426,7 @@ public class QueueImpl implements Queue { @Override public void expireReferences() { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return; } @@ -1445,6 +1436,18 @@ public class QueueImpl implements Queue { } } + public boolean isExpirationRedundant() { + if (expiryAddress != null && expiryAddress.equals(this.address)) { + // check expire with itself would be silly (waste of time) + if (logger.isTraceEnabled()) + logger.trace("Redundant expiration from " + address + " to " + expiryAddress); + + return true; + } + + return false; + } + class ExpiryScanner implements Runnable { public AtomicInteger scannerRunning = new AtomicInteger(0);