diff --git a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndex.java b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndex.java index 08e68f617b4..3d88e0cc8de 100644 --- a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndex.java +++ b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndex.java @@ -18,6 +18,7 @@ package org.apache.lucene.store.instantiated; import java.io.IOException; import java.io.Serializable; +import java.io.Closeable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -52,7 +53,7 @@ import org.apache.lucene.index.TermPositions; * Consider using InstantiatedIndex as if it was immutable. */ public class InstantiatedIndex - implements Serializable { + implements Serializable,Closeable { private static final long serialVersionUID = 1l; diff --git a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java index 84a514c2da0..14ab38efb8b 100644 --- a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java +++ b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java @@ -19,6 +19,7 @@ package org.apache.lucene.store.instantiated; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; +import java.io.Closeable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -58,7 +59,7 @@ import org.apache.lucene.util.AttributeImpl; * * @see org.apache.lucene.index.IndexWriter */ -public class InstantiatedIndexWriter { +public class InstantiatedIndexWriter implements Closeable { private PrintStream infoStream = null; diff --git a/src/java/org/apache/lucene/analysis/Analyzer.java b/src/java/org/apache/lucene/analysis/Analyzer.java index d98438bb86e..a4f064b54db 100644 --- a/src/java/org/apache/lucene/analysis/Analyzer.java +++ b/src/java/org/apache/lucene/analysis/Analyzer.java @@ -19,6 +19,7 @@ package org.apache.lucene.analysis; import java.io.Reader; import java.io.IOException; +import java.io.Closeable; import java.lang.reflect.Method; import org.apache.lucene.util.CloseableThreadLocal; @@ -33,7 +34,7 @@ import org.apache.lucene.document.Fieldable; * characters from the Reader into raw Tokens. One or more TokenFilters may * then be applied to the output of the Tokenizer. */ -public abstract class Analyzer { +public abstract class Analyzer implements Closeable { /** Creates a TokenStream which tokenizes all the text in the provided * Reader. Must be able to handle null field name for * backward compatibility. diff --git a/src/java/org/apache/lucene/analysis/TokenStream.java b/src/java/org/apache/lucene/analysis/TokenStream.java index 0ff7622f452..96b0ed99cdd 100644 --- a/src/java/org/apache/lucene/analysis/TokenStream.java +++ b/src/java/org/apache/lucene/analysis/TokenStream.java @@ -18,6 +18,7 @@ package org.apache.lucene.analysis; */ import java.io.IOException; +import java.io.Closeable; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -76,7 +77,7 @@ import org.apache.lucene.util.AttributeSource; * {@link AttributeSource#captureState} and {@link AttributeSource#restoreState} * can be used. */ -public abstract class TokenStream extends AttributeSource { +public abstract class TokenStream extends AttributeSource implements Closeable { /** * A TokenStream using the default attribute factory. diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.java index eeaebd2b6f4..3509e7de459 100644 --- a/src/java/org/apache/lucene/index/IndexReader.java +++ b/src/java/org/apache/lucene/index/IndexReader.java @@ -25,6 +25,7 @@ import org.apache.lucene.store.*; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.Closeable; import java.util.Arrays; import java.util.Collection; import java.util.Map; @@ -75,7 +76,7 @@ import java.util.Map; IndexReader instance; use your own (non-Lucene) objects instead. */ -public abstract class IndexReader implements Cloneable { +public abstract class IndexReader implements Cloneable,Closeable { /** * Constants describing field properties, for example used for diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index eeff9621d28..86f99021c40 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -30,6 +30,7 @@ import org.apache.lucene.store.BufferedIndexInput; import org.apache.lucene.util.Constants; import java.io.IOException; +import java.io.Closeable; import java.io.PrintStream; import java.util.List; import java.util.Collection; @@ -165,7 +166,7 @@ import java.util.Map; * referenced by the "front" of the index). For this, IndexFileDeleter * keeps track of the last non commit checkpoint. */ -public class IndexWriter { +public class IndexWriter implements Closeable { /** * Default value for the write lock timeout (1,000). diff --git a/src/java/org/apache/lucene/index/MergePolicy.java b/src/java/org/apache/lucene/index/MergePolicy.java index 60457195689..7ad0b3f3a2a 100644 --- a/src/java/org/apache/lucene/index/MergePolicy.java +++ b/src/java/org/apache/lucene/index/MergePolicy.java @@ -61,7 +61,7 @@ import java.util.Set; * these APIs. */ -public abstract class MergePolicy { +public abstract class MergePolicy implements java.io.Closeable { /** OneMerge provides the information necessary to perform * an individual primitive merge operation, resulting in diff --git a/src/java/org/apache/lucene/index/TermDocs.java b/src/java/org/apache/lucene/index/TermDocs.java index b92af683df8..5a653ec027a 100644 --- a/src/java/org/apache/lucene/index/TermDocs.java +++ b/src/java/org/apache/lucene/index/TermDocs.java @@ -18,6 +18,7 @@ package org.apache.lucene.index; */ import java.io.IOException; +import java.io.Closeable; /** TermDocs provides an interface for enumerating <document, frequency> pairs for a term.

The document portion names each document containing @@ -28,7 +29,7 @@ import java.io.IOException; @see IndexReader#termDocs() */ -public interface TermDocs { +public interface TermDocs extends Closeable { /** Sets this to the data for a term. * The enumeration is reset to the start of the data for this term. */ diff --git a/src/java/org/apache/lucene/index/TermEnum.java b/src/java/org/apache/lucene/index/TermEnum.java index 39859906c55..ac99e2bf14e 100644 --- a/src/java/org/apache/lucene/index/TermEnum.java +++ b/src/java/org/apache/lucene/index/TermEnum.java @@ -18,13 +18,14 @@ package org.apache.lucene.index; */ import java.io.IOException; +import java.io.Closeable; /** Abstract class for enumerating terms.

Term enumerations are always ordered by Term.compareTo(). Each term in the enumeration is greater than all that precede it. */ -public abstract class TermEnum { +public abstract class TermEnum implements Closeable { /** Increments the enumeration to the next element. True if one exists.*/ public abstract boolean next() throws IOException; diff --git a/src/java/org/apache/lucene/search/Searchable.java b/src/java/org/apache/lucene/search/Searchable.java index 5f0e8ed0a31..f6bc747d91e 100644 --- a/src/java/org/apache/lucene/search/Searchable.java +++ b/src/java/org/apache/lucene/search/Searchable.java @@ -18,6 +18,7 @@ package org.apache.lucene.search; */ import java.io.IOException; +import java.io.Closeable; import org.apache.lucene.document.Document; import org.apache.lucene.document.FieldSelector; @@ -41,7 +42,7 @@ import org.apache.lucene.index.Term; * expected to be implemented directly, it may be changed unexpectedly between * releases. */ -public interface Searchable { +public interface Searchable extends Closeable { /** * Lower-level search API. diff --git a/src/java/org/apache/lucene/store/Directory.java b/src/java/org/apache/lucene/store/Directory.java index 6f2bedc5dc0..026c3df8175 100644 --- a/src/java/org/apache/lucene/store/Directory.java +++ b/src/java/org/apache/lucene/store/Directory.java @@ -18,6 +18,7 @@ package org.apache.lucene.store; */ import java.io.IOException; +import java.io.Closeable; import org.apache.lucene.index.IndexFileNameFilter; @@ -37,7 +38,7 @@ import org.apache.lucene.index.IndexFileNameFilter; * instance using {@link #setLockFactory}. * */ -public abstract class Directory { +public abstract class Directory implements Closeable { volatile protected boolean isOpen = true; diff --git a/src/java/org/apache/lucene/store/IndexInput.java b/src/java/org/apache/lucene/store/IndexInput.java index b22208e8f59..9b52b633740 100644 --- a/src/java/org/apache/lucene/store/IndexInput.java +++ b/src/java/org/apache/lucene/store/IndexInput.java @@ -18,6 +18,7 @@ package org.apache.lucene.store; */ import java.io.IOException; +import java.io.Closeable; import java.util.Map; import java.util.HashMap; @@ -25,7 +26,7 @@ import java.util.HashMap; * random-access input stream. Used for all Lucene index input operations. * @see Directory */ -public abstract class IndexInput implements Cloneable { +public abstract class IndexInput implements Cloneable,Closeable { private byte[] bytes; // used by readString() private char[] chars; // used by readModifiedUTF8String() private boolean preUTF8Strings; // true if we are reading old (modified UTF8) string format diff --git a/src/java/org/apache/lucene/store/IndexOutput.java b/src/java/org/apache/lucene/store/IndexOutput.java index 8536b9050a8..12753c50269 100644 --- a/src/java/org/apache/lucene/store/IndexOutput.java +++ b/src/java/org/apache/lucene/store/IndexOutput.java @@ -18,6 +18,7 @@ package org.apache.lucene.store; */ import java.io.IOException; +import java.io.Closeable; import java.util.Map; import org.apache.lucene.util.UnicodeUtil; @@ -26,7 +27,7 @@ import org.apache.lucene.util.UnicodeUtil; * @see Directory * @see IndexInput */ -public abstract class IndexOutput { +public abstract class IndexOutput implements Closeable { private UnicodeUtil.UTF8Result utf8Result = new UnicodeUtil.UTF8Result(); diff --git a/src/java/org/apache/lucene/util/CloseableThreadLocal.java b/src/java/org/apache/lucene/util/CloseableThreadLocal.java index 4c998f6581b..16a3b4d4d5f 100644 --- a/src/java/org/apache/lucene/util/CloseableThreadLocal.java +++ b/src/java/org/apache/lucene/util/CloseableThreadLocal.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.lang.ref.WeakReference; +import java.io.Closeable; /** Java's builtin ThreadLocal has a serious flaw: * it can take an arbitrarily long amount of time to @@ -42,7 +43,7 @@ import java.lang.ref.WeakReference; * references are cleared and then GC is freely able to * reclaim space by objects stored in it. */ -public class CloseableThreadLocal { +public class CloseableThreadLocal implements Closeable { private ThreadLocal> t = new ThreadLocal>(); diff --git a/src/java/org/apache/lucene/util/cache/Cache.java b/src/java/org/apache/lucene/util/cache/Cache.java index b8282cb98e3..1c42533f004 100644 --- a/src/java/org/apache/lucene/util/cache/Cache.java +++ b/src/java/org/apache/lucene/util/cache/Cache.java @@ -17,11 +17,12 @@ package org.apache.lucene.util.cache; * limitations under the License. */ +import java.io.Closeable; /** * Base class for cache implementations. */ -public abstract class Cache { +public abstract class Cache implements Closeable { /** * Simple Cache wrapper that synchronizes all