You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/12/23 16:47:51 UTC
svn commit: r1647600 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/test-framework/
lucene/test-framework/src/java/org/apache/lucene/store/
Author: rmuir
Date: Tue Dec 23 15:47:51 2014
New Revision: 1647600
URL: http://svn.apache.org/r1647600
Log:
LUCENE-6120: Fix MockDirectoryWrapper close() handling
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1647600&r1=1647599&r2=1647600&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Tue Dec 23 15:47:51 2014
@@ -405,6 +405,9 @@ Tests
* LUCENE-5968: Improve error message when 'ant beast' is run on top-level
modules. (Ramkumar Aiyengar, Uwe Schindler)
+* LUCENE-6120: Fix MockDirectoryWrapper's close() handling.
+ (Mike McCandless, Robert Muir)
+
Build
* LUCENE-5909: Smoke tester now has better command line parsing and
Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java?rev=1647600&r1=1647599&r2=1647600&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java Tue Dec 23 15:47:51 2014
@@ -1,5 +1,6 @@
package org.apache.lucene.store;
+import java.io.Closeable;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
@@ -43,21 +44,20 @@ public class MockIndexInputWrapper exten
@Override
public void close() throws IOException {
+ // TODO turn on the following to look for leaks closing inputs,
+ // after fixing TestTransactions
+ // dir.maybeThrowDeterministicException();
if (closed) {
delegate.close(); // don't mask double-close bugs
return;
}
closed = true;
- try {
- // turn on the following to look for leaks closing inputs,
- // after fixing TestTransactions
- // dir.maybeThrowDeterministicException();
- } finally {
- delegate.close();
+ try (Closeable delegate = this.delegate) {
// Pending resolution on LUCENE-686 we may want to
// remove the conditional check so we also track that
// all clones get closed:
+ assert delegate != null;
if (!isClone) {
dir.removeIndexInput(this, name);
}
Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java?rev=1647600&r1=1647599&r2=1647600&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexOutputWrapper.java Tue Dec 23 15:47:51 2014
@@ -17,6 +17,7 @@ package org.apache.lucene.store;
* limitations under the License.
*/
+import java.io.Closeable;
import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase;
@@ -98,10 +99,11 @@ public class MockIndexOutputWrapper exte
}
closed = true;
- try {
+ try (Closeable delegate = this.delegate) {
+ assert delegate != null;
dir.maybeThrowDeterministicException();
} finally {
- delegate.close();
+ dir.removeIndexOutput(this, name);
if (dir.trackDiskUsage) {
// Now compute actual disk usage & track the maxUsedSize
// in the MockDirectoryWrapper:
@@ -110,7 +112,6 @@ public class MockIndexOutputWrapper exte
dir.maxUsedSize = size;
}
}
- dir.removeIndexOutput(this, name);
}
}