From d0036ee0cc8ad64cf97820ce1e30736b7384ed1d Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 14 Apr 2022 17:12:39 -0400 Subject: [PATCH] ARTEMIS-3778 Just avoiding NPE on Expiry Reaper Added an extra check on null, just in case it should not happen, but I preferred adding this clause on the safe side --- .../artemis/core/postoffice/impl/PostOfficeImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index 94eb81845c..744f41f2b8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -1873,8 +1873,15 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding currentQueue = iterator.next(); - // we will expire messages on this queue, once done we move to the next queue - currentQueue.expireReferences(this::done); + if (currentQueue == null) { + logger.debug("iterator.next returned null on ExpiryReaper, giving up iteration"); + // I don't think this should ever happen, this check should be moot + // However I preferred to have this in place just in case + iterator = null; + } else { + // we will expire messages on this queue, once done we move to the next queue + currentQueue.expireReferences(this::done); + } } }