Skip to content

Commit f16299a

Browse files
EcljpseB0Tjukzi
authored andcommitted
AbstractApiTest: retry delete resource after GC #1483
Failing tests on windows. Since JDK sometimes keeps handles open until GC it is worth a retry. #1483
1 parent 108129f commit f16299a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/AbstractApiTest.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import static org.junit.Assert.assertNotNull;
1717
import static org.junit.Assert.assertTrue;
1818

19+
import java.util.concurrent.TimeUnit;
20+
1921
import org.eclipse.core.resources.IProject;
2022
import org.eclipse.core.resources.IResource;
2123
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -194,7 +196,17 @@ protected void deleteProject(String name) throws CoreException {
194196
if (pro.exists()) {
195197
ResourceEventWaiter waiter = new ResourceEventWaiter(IPath.fromOSString(name), IResourceChangeEvent.POST_CHANGE,
196198
IResourceDelta.CHANGED, 0);
197-
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
199+
try {
200+
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
201+
} catch (CoreException canNotDelete) {
202+
System.gc();
203+
try {
204+
TimeUnit.MILLISECONDS.sleep(1);
205+
} catch (InterruptedException ignored) {
206+
}
207+
// retry:
208+
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
209+
}
198210
Object obj = waiter.waitForEvent();
199211
assertNotNull("the project delete event did not arrive", obj); //$NON-NLS-1$
200212
}

0 commit comments

Comments
 (0)