lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwe...@apache.org
Subject svn commit: r1585053 - in /lucene/dev/trunk: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Date Sat, 05 Apr 2014 11:45:22 GMT
Author: dweiss
Date: Sat Apr  5 11:45:22 2014
New Revision: 1585053

URL: http://svn.apache.org/r1585053
Log:
LUCENE-5577: the cleanup code didn't cleanup after itself...

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/test-framework/   (props changed)
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1585053&r1=1585052&r2=1585053&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Sat Apr  5 11:45:22 2014
@@ -2338,35 +2338,45 @@ public abstract class LuceneTestCase ext
 
   private static class TemporaryFilesCleanupRule extends TestRuleAdapter {
     @Override
-    protected void afterAlways(List<Throwable> errors) throws Throwable {
-      if (LuceneTestCase.suiteFailureMarker.wasSuccessful()) {
-        synchronized (cleanupQueue) {
-          File [] everything = new File [cleanupQueue.size()];
-          for (int i = 0; !cleanupQueue.isEmpty(); i++) {
-            everything[i] = cleanupQueue.removeLast();
-          }
+    protected void before() throws Throwable {
+      super.before();
+      assert tempDirBase == null;
+    }
 
-          // Will throw an IOException on un-removable files.
-          try {
-            TestUtil.rm(everything);
-          } catch (IOException e) {
-            Class<?> suiteClass = RandomizedContext.current().getTargetClass();
-            if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
-              System.err.println("WARNING: Leftover undeleted temporary files (bugUrl: "
-                  + suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "):
"
-                  + e.getMessage());
-              return;
+    @Override
+    protected void afterAlways(List<Throwable> errors) throws Throwable {
+      try {
+        if (LuceneTestCase.suiteFailureMarker.wasSuccessful()) {
+          synchronized (cleanupQueue) {
+            File [] everything = new File [cleanupQueue.size()];
+            for (int i = 0; !cleanupQueue.isEmpty(); i++) {
+              everything[i] = cleanupQueue.removeLast();
+            }
+  
+            // Will throw an IOException on un-removable files.
+            try {
+              TestUtil.rm(everything);
+            } catch (IOException e) {
+              Class<?> suiteClass = RandomizedContext.current().getTargetClass();
+              if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
+                System.err.println("WARNING: Leftover undeleted temporary files (bugUrl:
"
+                    + suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "):
"
+                    + e.getMessage());
+                return;
+              }
+              throw e;
             }
-            throw e;
           }
-        }
-      } else {
-        synchronized (cleanupQueue) {
-          if (tempDirBase != null) {
-            System.err.println("NOTE: leaving temporary files on disk at: " +
-                tempDirBase.getAbsolutePath());
+        } else {
+          synchronized (cleanupQueue) {
+            if (tempDirBase != null) {
+              System.err.println("NOTE: leaving temporary files on disk at: " +
+                  tempDirBase.getAbsolutePath());
+            }
           }
         }
+      } finally {
+        tempDirBase = null;
       }
     }
   }



Mime
View raw message