From 78e1d29ecefa2db572cbcc8158792133302aba9f Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Fri, 23 May 2014 16:32:58 +0000 Subject: QPID-5784: [Java Broker] Prevent NPE possibility from BDB store\'s coalescing committer on shutdown git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1597122 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/store/berkeleydb/CoalescingCommiter.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'java') diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CoalescingCommiter.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CoalescingCommiter.java index a137e38baf..c9341dce02 100644 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CoalescingCommiter.java +++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CoalescingCommiter.java @@ -24,6 +24,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; +import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary; import org.apache.log4j.Logger; import org.apache.qpid.server.store.StoreFuture; @@ -242,6 +243,10 @@ public class CoalescingCommiter implements Committer for(int i = 0; i < size; i++) { BDBCommitFuture commit = _jobQueue.poll(); + if (commit == null) + { + break; + } commit.complete(); } @@ -255,6 +260,10 @@ public class CoalescingCommiter implements Committer for(int i = 0; i < size; i++) { BDBCommitFuture commit = _jobQueue.poll(); + if (commit == null) + { + break; + } commit.abort(e); } } @@ -302,10 +311,16 @@ public class CoalescingCommiter implements Committer { _stopped.set(true); BDBCommitFuture commit = null; + int abortedCommits = 0; while ((commit = _jobQueue.poll()) != null) { + abortedCommits++; commit.abort(e); } + if (LOGGER.isDebugEnabled() && abortedCommits > 0) + { + LOGGER.debug(abortedCommits + " commit(s) were aborted during close."); + } _lock.notifyAll(); } } -- cgit v1.2.1