Skip to content

Commit

Permalink
AbstractApiTest: retry delete resource after GC eclipse-pde#1483
Browse files Browse the repository at this point in the history
Failing tests on windows. Since JDK sometimes keeps handles open until
GC it is worth a retry.

eclipse-pde#1483
  • Loading branch information
EcljpseB0T authored and jukzi committed Nov 19, 2024
1 parent 108129f commit f16299a
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.concurrent.TimeUnit;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
Expand Down Expand Up @@ -194,7 +196,17 @@ protected void deleteProject(String name) throws CoreException {
if (pro.exists()) {
ResourceEventWaiter waiter = new ResourceEventWaiter(IPath.fromOSString(name), IResourceChangeEvent.POST_CHANGE,
IResourceDelta.CHANGED, 0);
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
try {
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
} catch (CoreException canNotDelete) {
System.gc();
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException ignored) {
}
// retry:
pro.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
}
Object obj = waiter.waitForEvent();
assertNotNull("the project delete event did not arrive", obj); //$NON-NLS-1$
}
Expand Down

0 comments on commit f16299a

Please sign in to comment.