From 8ad277c7077c82297893206add08e4836d2abffe Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 29 Sep 2026 15:18:25 +0200 Subject: [PATCH] Bound resource deletion in tests and drop fixed auto-build delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The force-delete helpers of AbstractJavaProjectTest looped forever when a resource could not be deleted, and tearDown wrapped them in up to 5000 more retries, so a locked file hung the build until the CI job timeout. The helpers now fail after 30 seconds with an error naming the resource, and the redundant outer retry is removed. waitForAutoBuild() also no longer sleeps 25 ms before joining the auto-build job. Assisted-by: multiple AI agents and layers of automated tooling 🤖 --- .../core/AbstractJavaProjectTest.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/AbstractJavaProjectTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/AbstractJavaProjectTest.java index f3ab3f2e8..45bdb03e7 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/AbstractJavaProjectTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/AbstractJavaProjectTest.java @@ -62,6 +62,7 @@ @ExtendWith(AnnotationExtension.class) public abstract class AbstractJavaProjectTest extends DesignerTestCase { private static final List m_createdResources = new ArrayList<>(); + private static final long DELETE_TIMEOUT_MILLIS = 30_000; //////////////////////////////////////////////////////////////////////////// // @@ -71,28 +72,16 @@ public abstract class AbstractJavaProjectTest extends DesignerTestCase { @Override @AfterEach public void tearDown() throws Exception { - // remove resources (with retries) + // remove resources { for (IFile resource : m_createdResources) { - int maxCount = 5000; - for (int i = 0; i < maxCount; i++) { - try { - // remove read-only attr, if has - if (resource.isReadOnly()) { - ResourceAttributes attributes = new ResourceAttributes(); - attributes.setReadOnly(false); - resource.setResourceAttributes(attributes); - } - // do deleting - forceDeleteResource(resource); - break; - } catch (Exception e) { - if (i == maxCount - 1) { - throw e; - } - } - waitEventLoop(10); + // remove read-only attr, if has + if (resource.isReadOnly()) { + ResourceAttributes attributes = new ResourceAttributes(); + attributes.setReadOnly(false); + resource.setResourceAttributes(attributes); } + forceDeleteResource(resource); } m_createdResources.clear(); } @@ -226,8 +215,7 @@ public static void forgetCreatedResources() { * problems. */ public static void waitForAutoBuild() throws Exception { - // Wait for workspace jobs such as file creation - waitEventLoop(25); + waitEventLoop(0); // Wait for auto-builder to handle all newly created files TestProject.waitForAutoBuild(); // check for compilation problems @@ -584,6 +572,7 @@ public static void forceDeleteResource(IResource resource) { forceDeleteCompilationUnit(cu); return; } + long deadline = System.currentTimeMillis() + DELETE_TIMEOUT_MILLIS; while (resource.exists()) { try { resource.refreshLocal(IResource.DEPTH_INFINITE, null); @@ -592,6 +581,7 @@ public static void forceDeleteResource(IResource resource) { try { resource.delete(true, null); } catch (Throwable e) { + failIfPastDeadline(deadline, resource, e); waitEventLoop(100); } } @@ -601,6 +591,7 @@ public static void forceDeleteResource(IResource resource) { * Force deletes {@link ICompilationUnit}. */ public static void forceDeleteCompilationUnit(ICompilationUnit cu) { + long deadline = System.currentTimeMillis() + DELETE_TIMEOUT_MILLIS; while (cu.exists()) { try { cu.discardWorkingCopy(); @@ -613,11 +604,18 @@ public static void forceDeleteCompilationUnit(ICompilationUnit cu) { try { cu.delete(true, null); } catch (Throwable e) { + failIfPastDeadline(deadline, cu.getResource(), e); waitEventLoop(100); } } } + private static void failIfPastDeadline(long deadline, IResource resource, Throwable cause) { + if (System.currentTimeMillis() > deadline) { + throw new IllegalStateException("Could not delete " + resource.getFullPath(), cause); + } + } + //////////////////////////////////////////////////////////////////////////// // // PNG image creation