mirror of https://github.com/apache/lucene.git
LUCENE-5577: the cleanup code didn't cleanup after itself...
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1585053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8c0e119ba
commit
a0e6d12d00
|
@ -2338,35 +2338,45 @@ public abstract class LuceneTestCase extends Assert {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
synchronized (cleanupQueue) {
|
||||
if (tempDirBase != null) {
|
||||
System.err.println("NOTE: leaving temporary files on disk at: " +
|
||||
tempDirBase.getAbsolutePath());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
synchronized (cleanupQueue) {
|
||||
if (tempDirBase != null) {
|
||||
System.err.println("NOTE: leaving temporary files on disk at: " +
|
||||
tempDirBase.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
tempDirBase = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue