From 8f30866fdf89f25188a358f1b1c161b2f06de3f5 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Wed, 25 Nov 2015 16:02:52 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-6063 Fixing potential NullPointerException during KahaDB index recovery. --- .../activemq/store/kahadb/MessageDatabase.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index 85e25d0bea..cd9067d2d4 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -762,12 +762,14 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe for (Long sequenceId : matches) { MessageKeys keys = sd.orderIndex.remove(tx, sequenceId); - sd.locationIndex.remove(tx, keys.location); - sd.messageIdIndex.remove(tx, keys.messageId); - metadata.producerSequenceIdTracker.rollback(keys.messageId); - undoCounter++; - decrementAndSubSizeToStoreStat(key, keys.location.getSize()); - // TODO: do we need to modify the ack positions for the pub sub case? + if (keys != null) { + sd.locationIndex.remove(tx, keys.location); + sd.messageIdIndex.remove(tx, keys.messageId); + metadata.producerSequenceIdTracker.rollback(keys.messageId); + undoCounter++; + decrementAndSubSizeToStoreStat(key, keys.location.getSize()); + // TODO: do we need to modify the ack positions for the pub sub case? + } } }