linghengqian commented on issue #2473: URL: https://github.com/apache/shardingsphere-elasticjob/issues/2473#issuecomment-3280771518
- I re-verified https://github.com/apache/shardingsphere-elasticjob/pull/2477 and it seems that the following form of unit test has become very unstable, with 1 failure in every 3 executions. ```java @Test void testWhenShutdownThenTaskCanCaptureInterruptedException() { testCaptureInterruptedException(1); testCaptureInterruptedException(2); } @SuppressWarnings({"BusyWait", "InfiniteLoopStatement"}) private void testCaptureInterruptedException(final int shardingTotalCount) { String jobName = "testTaskCaptureInterruptedTask" + shardingTotalCount; AtomicBoolean captured = new AtomicBoolean(false); AtomicBoolean running = new AtomicBoolean(false); LocalTime oneSecondLater = LocalTime.now().plusSeconds(1); String cronExpression = String.format("%d %d %d * * ?", oneSecondLater.getSecond(), oneSecondLater.getMinute(), oneSecondLater.getHour()); SimpleJob captureInterruptedTask = shardingContext -> { try { running.set(true); while (true) { Thread.sleep(100L); } } catch (final InterruptedException ex) { captured.set(true); Thread.currentThread().interrupt(); } }; ScheduleJobBootstrap job = new ScheduleJobBootstrap(regCenter, captureInterruptedTask, JobConfiguration.newBuilder(jobName, shardingTotalCount).cron(cronExpression).build()); job.schedule(); Awaitility.await().atMost(10L, TimeUnit.SECONDS).ignoreExceptions().until(running::get); job.shutdown(); Awaitility.await().atMost(10L, TimeUnit.SECONDS).ignoreExceptions().until(captured::get); } ``` - Of course, without the handling of https://github.com/apache/shardingsphere-elasticjob/pull/2475 , this unit test would never even succeed. Is there some timing-related statement I'm missing? Why is the cron that reproduces this bug so related to a specific time? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
