mirror of https://github.com/apache/lucene.git
LUCENE-6120: Fix MockDirectoryWrapper close() handling
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1647599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8c3a8f6e6
commit
7d4ba636b0
|
@ -419,6 +419,9 @@ Tests
|
||||||
* LUCENE-5968: Improve error message when 'ant beast' is run on top-level
|
* LUCENE-5968: Improve error message when 'ant beast' is run on top-level
|
||||||
modules. (Ramkumar Aiyengar, Uwe Schindler)
|
modules. (Ramkumar Aiyengar, Uwe Schindler)
|
||||||
|
|
||||||
|
* LUCENE-6120: Fix MockDirectoryWrapper's close() handling.
|
||||||
|
(Mike McCandless, Robert Muir)
|
||||||
|
|
||||||
Build
|
Build
|
||||||
|
|
||||||
* LUCENE-5909: Smoke tester now has better command line parsing and
|
* LUCENE-5909: Smoke tester now has better command line parsing and
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.apache.lucene.store;
|
package org.apache.lucene.store;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -43,21 +44,20 @@ public class MockIndexInputWrapper extends IndexInput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
// TODO turn on the following to look for leaks closing inputs,
|
||||||
|
// after fixing TestTransactions
|
||||||
|
// dir.maybeThrowDeterministicException();
|
||||||
if (closed) {
|
if (closed) {
|
||||||
delegate.close(); // don't mask double-close bugs
|
delegate.close(); // don't mask double-close bugs
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
closed = true;
|
closed = true;
|
||||||
|
|
||||||
try {
|
try (Closeable delegate = this.delegate) {
|
||||||
// turn on the following to look for leaks closing inputs,
|
|
||||||
// after fixing TestTransactions
|
|
||||||
// dir.maybeThrowDeterministicException();
|
|
||||||
} finally {
|
|
||||||
delegate.close();
|
|
||||||
// Pending resolution on LUCENE-686 we may want to
|
// Pending resolution on LUCENE-686 we may want to
|
||||||
// remove the conditional check so we also track that
|
// remove the conditional check so we also track that
|
||||||
// all clones get closed:
|
// all clones get closed:
|
||||||
|
assert delegate != null;
|
||||||
if (!isClone) {
|
if (!isClone) {
|
||||||
dir.removeIndexInput(this, name);
|
dir.removeIndexInput(this, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.lucene.store;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
@ -98,10 +99,11 @@ public class MockIndexOutputWrapper extends IndexOutput {
|
||||||
}
|
}
|
||||||
closed = true;
|
closed = true;
|
||||||
|
|
||||||
try {
|
try (Closeable delegate = this.delegate) {
|
||||||
|
assert delegate != null;
|
||||||
dir.maybeThrowDeterministicException();
|
dir.maybeThrowDeterministicException();
|
||||||
} finally {
|
} finally {
|
||||||
delegate.close();
|
dir.removeIndexOutput(this, name);
|
||||||
if (dir.trackDiskUsage) {
|
if (dir.trackDiskUsage) {
|
||||||
// Now compute actual disk usage & track the maxUsedSize
|
// Now compute actual disk usage & track the maxUsedSize
|
||||||
// in the MockDirectoryWrapper:
|
// in the MockDirectoryWrapper:
|
||||||
|
@ -110,7 +112,6 @@ public class MockIndexOutputWrapper extends IndexOutput {
|
||||||
dir.maxUsedSize = size;
|
dir.maxUsedSize = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dir.removeIndexOutput(this, name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue