Apache Solr open-source search software
LUCENE-1322: remove unnecessary synchronization in CSIndexInput
Michael McCandlessb60829fb0cb9
diff --git a/src/java/org/apache/lucene/index/CompoundFileReader.java b/src/java/org/apache/lucene/index/CompoundFileReader.javaindex b8006cc7879..03291b16cfd 100644--- a/src/java/org/apache/lucene/index/CompoundFileReader.java+++ b/src/java/org/apache/lucene/index/CompoundFileReader.java@@ -218,11 +218,19 @@ class CompoundFileReader extends Directory {CSIndexInput(final IndexInput base, final long fileOffset, final long length, int readBufferSize){super(readBufferSize);- this.base = base;+ this.base = (IndexInput)base.clone();this.fileOffset = fileOffset;this.length = length;}-++ public Object clone() {+ CSIndexInput clone = (CSIndexInput)super.clone();+ clone.base = (IndexInput)base.clone();+ clone.fileOffset = fileOffset;+ clone.length = length;+ return clone;+ }+/** Expert: implements buffer refill. Reads bytes from the current* position in the input.* @param b the array to read bytes into@@ -232,13 +240,11 @@ class CompoundFileReader extends Directory {protected void readInternal(byte[] b, int offset, int len)throws IOException{- synchronized (base) {- long start = getFilePointer();- if(start + len > length)- throw new IOException("read past EOF");- base.seek(fileOffset + start);- base.readBytes(b, offset, len, false);- }+ long start = getFilePointer();+ if(start + len > length)+ throw new IOException("read past EOF");+ base.seek(fileOffset + start);+ base.readBytes(b, offset, len, false);}/** Expert: implements seek. Sets current position in this file, where@@ -248,7 +254,9 @@ class CompoundFileReader extends Directory {protected void seekInternal(long pos) {}/** Closes the stream to further operations. */- public void close() {}+ public void close() throws IOException {+ base.close();+ }public long length() {return length;diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.javaindex cec28fe59c3..351611f3612 100644--- a/src/java/org/apache/lucene/index/SegmentReader.java+++ b/src/java/org/apache/lucene/index/SegmentReader.java@@ -296,7 +296,6 @@ class SegmentReader extends DirectoryIndexReader {} elsestoreDir = null;- // No compound file exists - use the multi-file formatfieldInfos = new FieldInfos(cfsDir, segment + ".fnm");final String fieldsSegment;diff --git a/src/test/org/apache/lucene/index/TestFieldsReader.java b/src/test/org/apache/lucene/index/TestFieldsReader.javaindex e5a698ad0d6..6277dc319cc 100644--- a/src/test/org/apache/lucene/index/TestFieldsReader.java+++ b/src/test/org/apache/lucene/index/TestFieldsReader.java@@ -367,6 +367,9 @@ public class TestFieldsReader extends LuceneTestCase {public void close() throws IOException {delegate.close();}+ public Object clone() {+ return new FaultyIndexInput((IndexInput) delegate.clone());+ }}// LUCENE-1262