diff --git a/hutool-core/src/test/java/org/dromara/hutool/core/thread/SyncFinisherTest.java b/hutool-core/src/test/java/org/dromara/hutool/core/thread/SyncFinisherTest.java index 5887c5197..5ee58e506 100755 --- a/hutool-core/src/test/java/org/dromara/hutool/core/thread/SyncFinisherTest.java +++ b/hutool-core/src/test/java/org/dromara/hutool/core/thread/SyncFinisherTest.java @@ -16,6 +16,8 @@ import org.dromara.hutool.core.lang.Console; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.concurrent.atomic.AtomicBoolean; + public class SyncFinisherTest { /** @@ -23,16 +25,21 @@ public class SyncFinisherTest { */ @Test void executeExceptionTest() { + final AtomicBoolean hasException = new AtomicBoolean(false); final SyncFinisher syncFinisher = new SyncFinisher(10); syncFinisher.addWorker(()->{ Console.log(Integer.parseInt("XYZ"));//这里会抛RuntimeException }); syncFinisher.setExceptionHandler((t, e) -> { + hasException.set(true); Assertions.assertEquals("For input string: \"XYZ\"", e.getMessage()); }); syncFinisher.start(); syncFinisher.close(); + ThreadUtil.sleep(300); + Assertions.assertTrue(hasException.get()); } + }