diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java index cb3db7a0ff7..ab5d657a1b0 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java +++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java @@ -509,27 +509,18 @@ final class DocumentsWriterDeleteQueue implements Accountable, Closeable { } } - private boolean forceApplyGlobalSlice() { - globalBufferLock.lock(); - final Node currentTail = tail; + public int getBufferedUpdatesTermsSize() { + final ReentrantLock lock = globalBufferLock; // Trusted final + lock.lock(); try { + final Node currentTail = tail; if (globalSlice.sliceTail != currentTail) { globalSlice.sliceTail = currentTail; globalSlice.apply(globalBufferedUpdates, BufferedUpdates.MAX_INT); } - return globalBufferedUpdates.any(); - } finally { - globalBufferLock.unlock(); - } - } - - public int getBufferedUpdatesTermsSize() { - globalBufferLock.lock(); - try { - forceApplyGlobalSlice(); return globalBufferedUpdates.deleteTerms.size(); } finally { - globalBufferLock.unlock(); + lock.unlock(); } }