LUCENE-3637: change IndexReader.decRef to call decrementAndGet

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1213033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2011-12-11 17:52:52 +00:00
parent 503097ac71
commit 9e193b62bc

View File

@ -257,8 +257,8 @@ public abstract class IndexReader implements Cloneable,Closeable {
*/
public final void decRef() throws IOException {
ensureOpen();
final int rc = refCount.getAndDecrement();
if (rc == 1) {
final int rc = refCount.decrementAndGet();
if (rc == 0) {
boolean success = false;
try {
doClose();
@ -270,8 +270,8 @@ public abstract class IndexReader implements Cloneable,Closeable {
}
}
readerFinished();
} else if (rc <= 0) {
throw new IllegalStateException("too many decRef calls: refCount was " + rc + " before decrement");
} else if (rc < 0) {
throw new IllegalStateException("too many decRef calls: refCount is " + rc + " after decrement");
}
}