/** * Expert: decreases the refCount of this IndexReader * instance. If the refCount drops to 0, then this * reader is closed. If an exception is hit, the refCount * is unchanged. * * @throws IOException in case an IOException occurs in doClose() * * @see #incRef */ @SuppressWarnings("try") public final void decRef() throws IOException { // only check refcount here (don't call ensureOpen()), so we can // still close the reader if it was made invalid by a child: if (refCount.get() <= 0) { throw new AlreadyClosedException("this IndexReader is closed"); } final int rc = refCount.decrementAndGet(); if (rc == 0) { closed = true; try (Closeable finalizer = this::reportCloseToParentReaders; Closeable finalizer1 = this::notifyReaderClosedListeners) { doClose(); } } else if (rc < 0) { throw new IllegalStateException("too many decRef calls: refCount is " + rc + " after decrement"); } }
/** * Closes files associated with this index. * Also saves any new deletions to disk. * No other methods should be called after this has been called. */ public final synchronized void close() throws IOException { commit(); doClose(); if(closeDirectory) directory.close(); }
/** * Expert: decreases the refCount of this IndexReader * instance. If the refCount drops to 0, then this * reader is closed. If an exception is hit, the refCount * is unchanged. * * @throws IOException in case an IOException occurs in doClose() * * @see #incRef */ @SuppressWarnings("try") public final void decRef() throws IOException { // only check refcount here (don't call ensureOpen()), so we can // still close the reader if it was made invalid by a child: if (refCount.get() <= 0) { throw new AlreadyClosedException("this IndexReader is closed"); } final int rc = refCount.decrementAndGet(); if (rc == 0) { closed = true; try (Closeable finalizer = this::reportCloseToParentReaders; Closeable finalizer1 = this::notifyReaderClosedListeners) { doClose(); } } else if (rc < 0) { throw new IllegalStateException("too many decRef calls: refCount is " + rc + " after decrement"); } }
/** * Expert: decreases the refCount of this IndexReader * instance. If the refCount drops to 0, then pending * changes (if any) are committed to the index and this * reader is closed. * * @throws IOException in case an IOException occurs in commit() or doClose() * * @see #incRef */ public synchronized void decRef() throws IOException { assert refCount > 0; ensureOpen(); if (refCount == 1) { commit(); doClose(); } refCount--; }
/** * Expert: decreases the refCount of this IndexReader * instance. If the refCount drops to 0, then pending * changes (if any) are committed to the index and this * reader is closed. * * @throws IOException in case an IOException occurs in commit() or doClose() * * @see #incRef */ public synchronized void decRef() throws IOException { assert refCount > 0; ensureOpen(); if (refCount == 1) { commit(); doClose(); } refCount--; }
Throwable throwable = null; try { doClose(); } catch (Throwable th) { throwable = th;
Throwable throwable = null; try { doClose(); } catch (Throwable th) { throwable = th;
reader.doCommit(); } finally { reader.doClose();
reader.doCommit(); } finally { reader.doClose();