lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shai Erera (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-3139) LuceneTestCase.afterClass does not print enough information if a temp-test-dir fails to delete
Date Wed, 25 May 2011 04:01:47 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-3139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038948#comment-13038948
] 

Shai Erera commented on LUCENE-3139:
------------------------------------

I think I've found the problem - MockIndexOutputWrapper did not close delegate if dir.maybeThrowEx
actually threw an exception. Here's a patch that fixes it:

{code}
Index: lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java       (revision
1127062)
+++ lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java       (working
copy)
@@ -45,20 +45,23 @@

   @Override
   public void close() throws IOException {
-    dir.maybeThrowDeterministicException();
-    delegate.close();
-    if (dir.trackDiskUsage) {
-      // Now compute actual disk usage & track the maxUsedSize
-      // in the MockDirectoryWrapper:
-      long size = dir.getRecomputedActualSizeInBytes();
-      if (size > dir.maxUsedSize) {
-        dir.maxUsedSize = size;
+    try {
+      dir.maybeThrowDeterministicException();
+    } finally {
+      delegate.close();
+      if (dir.trackDiskUsage) {
+        // Now compute actual disk usage & track the maxUsedSize
+        // in the MockDirectoryWrapper:
+        long size = dir.getRecomputedActualSizeInBytes();
+        if (size > dir.maxUsedSize) {
+          dir.maxUsedSize = size;
+        }
       }
+      synchronized(dir) {
+        dir.openFileHandles.remove(this);
+        dir.openFilesForWrite.remove(name);
+      }
     }
-    synchronized(dir) {
-      dir.openFileHandles.remove(this);
-      dir.openFilesForWrite.remove(name);
-    }
   }

   @Override
{code}

Maybe we solve it by moving delegate.close() before dir.maybeThrow, instead of the try-finally?

> LuceneTestCase.afterClass does not print enough information if a temp-test-dir fails
to delete
> ----------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3139
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3139
>             Project: Lucene - Java
>          Issue Type: Test
>          Components: general/test
>            Reporter: Shai Erera
>            Priority: Minor
>             Fix For: 3.2, 4.0
>
>         Attachments: LUCENE-3139.patch, LUCENE-3139.patch
>
>
> I've hit an exception from LTC.afterClass when _TestUtil.rmDir failed (on write.lock,
as if some test did not release resources). However, I had no idea which test caused that
(i.e. opened the temp directory and did not release resources).
> I think we should do the following:
> * Track in LTC a map from dirName -> StackTraceElement
> * In afterClass if _TestUtil.rmDir fails, print the STE of that particular dir, so we
know where was this directory created from
> * Make tempDirs private and create accessor method, so that we control the inserts to
this map (today the Set is updated by LTC, _TestUtils and TestBackwards !)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message