You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/05/31 10:05:55 UTC
svn commit: r1682691 - in
/lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store:
TestNativeFSLockFactory.java TestSimpleFSLockFactory.java
Author: mikemccand
Date: Sun May 31 08:05:54 2015
New Revision: 1682691
URL: http://svn.apache.org/r1682691
Log:
LUCENE-6508: fix 'mock directory not closed' test bugs
Modified:
lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestNativeFSLockFactory.java
lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
Modified: lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestNativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestNativeFSLockFactory.java?rev=1682691&r1=1682690&r2=1682691&view=diff
==============================================================================
--- lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestNativeFSLockFactory.java (original)
+++ lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestNativeFSLockFactory.java Sun May 31 08:05:54 2015
@@ -80,25 +80,29 @@ public class TestNativeFSLockFactory ext
/** delete the lockfile and test ensureValid fails */
public void testDeleteLockFile() throws IOException {
Directory dir = getDirectory(createTempDir());
- Lock lock = dir.obtainLock("test.lock");
- lock.ensureValid();
-
- try {
- dir.deleteFile("test.lock");
- } catch (Exception e) {
- // we can't delete a file for some reason, just clean up and assume the test.
- IOUtils.closeWhileHandlingException(lock);
- assumeNoException("test requires the ability to delete a locked file", e);
- }
-
try {
+ Lock lock = dir.obtainLock("test.lock");
lock.ensureValid();
- fail("no exception");
- } catch (IOException expected) {
- // ok
+
+ try {
+ dir.deleteFile("test.lock");
+ } catch (Exception e) {
+ // we can't delete a file for some reason, just clean up and assume the test.
+ IOUtils.closeWhileHandlingException(lock);
+ assumeNoException("test requires the ability to delete a locked file", e);
+ }
+
+ try {
+ lock.ensureValid();
+ fail("no exception");
+ } catch (IOException expected) {
+ // ok
+ } finally {
+ IOUtils.closeWhileHandlingException(lock);
+ }
} finally {
- IOUtils.closeWhileHandlingException(lock);
+ // Do this in finally clause in case the assumeNoException is false:
+ dir.close();
}
- dir.close();
}
}
Modified: lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java?rev=1682691&r1=1682690&r2=1682691&view=diff
==============================================================================
--- lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java (original)
+++ lucene/dev/branches/lucene6508/lucene/core/src/test/org/apache/lucene/store/TestSimpleFSLockFactory.java Sun May 31 08:05:54 2015
@@ -33,25 +33,29 @@ public class TestSimpleFSLockFactory ext
/** delete the lockfile and test ensureValid fails */
public void testDeleteLockFile() throws IOException {
Directory dir = getDirectory(createTempDir());
- Lock lock = dir.obtainLock("test.lock");
- lock.ensureValid();
-
- try {
- dir.deleteFile("test.lock");
- } catch (Exception e) {
- // we can't delete a file for some reason, just clean up and assume the test.
- IOUtils.closeWhileHandlingException(lock);
- assumeNoException("test requires the ability to delete a locked file", e);
- }
-
try {
+ Lock lock = dir.obtainLock("test.lock");
lock.ensureValid();
- fail("no exception");
- } catch (IOException expected) {
- // ok
+
+ try {
+ dir.deleteFile("test.lock");
+ } catch (Exception e) {
+ // we can't delete a file for some reason, just clean up and assume the test.
+ IOUtils.closeWhileHandlingException(lock);
+ assumeNoException("test requires the ability to delete a locked file", e);
+ }
+
+ try {
+ lock.ensureValid();
+ fail("no exception");
+ } catch (IOException expected) {
+ // ok
+ } finally {
+ IOUtils.closeWhileHandlingException(lock);
+ }
} finally {
- IOUtils.closeWhileHandlingException(lock);
+ // Do this in finally clause in case the assumeNoException is false:
+ dir.close();
}
- dir.close();
}
}