Index: lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (revision 1127062) +++ lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -28,6 +28,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -135,7 +136,7 @@ } /** set of directories we created, in afterclass we try to clean these up */ - static final Set tempDirs = Collections.synchronizedSet(new HashSet()); + private static final Map tempDirs = Collections.synchronizedMap(new HashMap()); // by default we randomly pick a different codec for // each test case (non-J4 tests) and each test class (J4 @@ -177,7 +178,7 @@ SETUP, // test has called setUp() RANTEST, // test is running TEARDOWN // test has called tearDown() - }; + } private static class UncaughtExceptionEntry { public final Thread thread; @@ -303,11 +304,20 @@ } // clear out any temp directories if we can if (!testsFailed) { - for (String path : tempDirs) { + for (Entry entry : tempDirs.entrySet()) { try { - _TestUtil.rmDir(new File(path)); + _TestUtil.rmDir(entry.getKey()); } catch (IOException e) { e.printStackTrace(); + System.err.println("path " + entry.getKey() + " allocated from"); + // first two STE's are Java's + StackTraceElement[] elements = entry.getValue(); + for (int i = 2; i < elements.length; i++) { + StackTraceElement ste = elements[i]; + // print only our code's stack information + if (ste.getClassName().indexOf("org.apache.lucene") == -1) break; + System.err.println("\t" + ste); + } } } } @@ -986,6 +996,11 @@ return d; } + /** Registers a temp file that will be deleted when tests are done. */ + public static void registerTempFile(File tmpFile) { + tempDirs.put(tmpFile.getAbsoluteFile(), Thread.currentThread().getStackTrace()); + } + static Directory newDirectoryImpl(Random random, String clazzName) { if (clazzName.equals("random")) clazzName = randomDirectory(random); @@ -998,7 +1013,7 @@ final File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR); tmpFile.delete(); tmpFile.mkdir(); - tempDirs.add(tmpFile.getAbsolutePath()); + registerTempFile(tmpFile); return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), tmpFile, null); } Index: lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java =================================================================== --- lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (revision 1127062) +++ lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (working copy) @@ -50,7 +50,7 @@ * does not create the directory. */ public static File getTempDir(String desc) { File f = new File(LuceneTestCase.TEMP_DIR, desc + "." + new Random().nextLong()); - LuceneTestCase.tempDirs.add(f.getAbsolutePath()); + LuceneTestCase.registerTempFile(f); return f; } @@ -86,7 +86,7 @@ rmDir(destDir); destDir.mkdir(); - LuceneTestCase.tempDirs.add(destDir.getAbsolutePath()); + LuceneTestCase.registerTempFile(destDir); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); Index: lucene/backwards/src/test-framework/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/backwards/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (revision 1127062) +++ lucene/backwards/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -28,6 +28,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -52,6 +53,7 @@ import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.LockFactory; import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.util._TestUtil; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; import org.junit.After; import org.junit.AfterClass; @@ -131,7 +133,7 @@ } /** set of directories we created, in afterclass we try to clean these up */ - static final Set tempDirs = Collections.synchronizedSet(new HashSet()); + private static final Map tempDirs = Collections.synchronizedMap(new HashMap()); // by default we randomly pick a different codec for // each test case (non-J4 tests) and each test class (J4 @@ -284,11 +286,20 @@ } // clear out any temp directories if we can if (!testsFailed) { - for (String path : tempDirs) { + for (Entry entry : tempDirs.entrySet()) { try { - _TestUtil.rmDir(new File(path)); + _TestUtil.rmDir(entry.getKey()); } catch (IOException e) { e.printStackTrace(); + System.err.println("path " + entry.getKey() + " allocated from"); + // first two STE's are Java's + StackTraceElement[] elements = entry.getValue(); + for (int i = 2; i < elements.length; i++) { + StackTraceElement ste = elements[i]; + // print only our code's stack information + if (ste.getClassName().indexOf("org.apache.lucene") == -1) break; + System.err.println("\t" + ste); + } } } } @@ -914,6 +925,11 @@ } } + /** Registers a temp file that will be deleted when tests are done. */ + public static void registerTempFile(File tmpFile) { + tempDirs.put(tmpFile.getAbsoluteFile(), Thread.currentThread().getStackTrace()); + } + static Directory newDirectoryImpl(Random random, String clazzName) { if (clazzName.equals("random")) clazzName = randomDirectory(random); @@ -926,7 +942,7 @@ final File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR); tmpFile.delete(); tmpFile.mkdir(); - tempDirs.add(tmpFile.getAbsolutePath()); + registerTempFile(tmpFile); return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), tmpFile, null); } Index: lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java =================================================================== --- lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java (revision 1127062) +++ lucene/backwards/src/test-framework/org/apache/lucene/util/_TestUtil.java (working copy) @@ -48,7 +48,7 @@ * does not create the directory. */ public static File getTempDir(String desc) { File f = new File(LuceneTestCase.TEMP_DIR, desc + "." + new Random().nextLong()); - LuceneTestCase.tempDirs.add(f.getAbsolutePath()); + LuceneTestCase.registerTempFile(f); return f; } @@ -84,7 +84,7 @@ rmDir(destDir); destDir.mkdir(); - LuceneTestCase.tempDirs.add(destDir.getAbsolutePath()); + LuceneTestCase.registerTempFile(destDir); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement();