From 519e03e59ae0a5f4f3f51ce477278c16c28eaa81 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Thu, 8 Oct 2026 09:51:16 +0200 Subject: [PATCH] Run SafeRunnableErrorTest's other-thread case on another thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit testSafeRunnableHandlerOtherThread called Thread.run() instead of start(), so the runnable ran on the UI thread like the other tests and the non-UI code path was never exercised. The thread is now started, the test checks that the runnable ran without an exception escaping the thread, and it processes the error dialog that the workbench posts asynchronously from that thread. Assisted-by: multiple AI agents and layers of automated tooling 🤖 --- .../tests/dialogs/SafeRunnableErrorTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java index 5c417c20c4a..d29156d7c33 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/dialogs/SafeRunnableErrorTest.java @@ -13,7 +13,12 @@ ******************************************************************************/ package org.eclipse.jface.tests.dialogs; +import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.jface.util.SafeRunnable; @@ -56,9 +61,16 @@ public void run() throws Exception { @Test public void testSafeRunnableHandlerOtherThread() throws Exception { + AtomicReference uncaught = new AtomicReference<>(); Thread t = runner(); - t.run(); - t.join(); + t.setUncaughtExceptionHandler((thread, e) -> uncaught.set(e)); + t.start(); + t.join(10_000); + assertFalse(t.isAlive()); + assertNull(uncaught.get()); + assertEquals(1, count); + // the error dialog is posted with asyncExec from the other thread + processEvents(); } @Test