From aa9b85c26058ac544028daf40c7dceab9d3cb730 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sat, 20 Mar 2010 15:15:34 +0000 Subject: [PATCH] tweaks git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/branches/newtrunk@925626 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/solr/core/RefCntRamDirectory.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/solr/src/java/org/apache/solr/core/RefCntRamDirectory.java b/solr/src/java/org/apache/solr/core/RefCntRamDirectory.java index 3655fdf8900..55af3e73b21 100644 --- a/solr/src/java/org/apache/solr/core/RefCntRamDirectory.java +++ b/solr/src/java/org/apache/solr/core/RefCntRamDirectory.java @@ -7,37 +7,35 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; public class RefCntRamDirectory extends RAMDirectory { - + private final AtomicInteger refCount = new AtomicInteger(); - + public RefCntRamDirectory() { super(); - incRef(); + refCount.set(1); } public RefCntRamDirectory(Directory dir) throws IOException { this(); Directory.copy(dir, this, false); } - + public void incRef() { ensureOpen(); refCount.incrementAndGet(); } - + public void decRef() { ensureOpen(); if (refCount.getAndDecrement() == 1) { super.close(); } } - + public final synchronized void close() { - if (isOpen) { - decRef(); - } + decRef(); } - + public boolean isOpen() { return isOpen; }