This is an automated email from the ASF dual-hosted git repository. rnewson pushed a commit to branch nouveau-indexmanager-improvements in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a0ed2d00c67eac058971858fb4a46aea7d85f48c Author: Robert Newson <[email protected]> AuthorDate: Wed Oct 4 09:45:38 2023 +0100 remove volatile boolean closed --- .../java/org/apache/couchdb/nouveau/core/Index.java | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java index e6e1cad62..2db7a674b 100644 --- a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java +++ b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java @@ -41,7 +41,6 @@ public abstract class Index implements Closeable { private long purgeSeq; private boolean deleteOnClose = false; private long lastCommit = now(); - private volatile boolean closed; private final Semaphore permits = new Semaphore(Integer.MAX_VALUE); protected Index(final long updateSeq, final long purgeSeq) { @@ -50,14 +49,7 @@ public abstract class Index implements Closeable { } public final boolean tryAcquire() { - if (permits.tryAcquire() == false) { - return false; - } - if (closed) { - permits.release(); - return false; - } - return true; + return permits.tryAcquire(); } public final void release() { @@ -143,16 +135,10 @@ public abstract class Index implements Closeable { @Override public final void close() throws IOException { - synchronized (this) { - closed = true; - } // Ensures exclusive access to the index before closing. permits.acquireUninterruptibly(Integer.MAX_VALUE); - try { - doClose(); - } finally { - permits.release(Integer.MAX_VALUE); - } + doClose(); + // Never release permits. } protected abstract void doClose() throws IOException;
