marmot-z commented on code in PR #2475:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/2475#discussion_r2340738231


##########
test/native/src/test/java/org/apache/shardingsphere/elasticjob/test/natived/it/operation/JavaTest.java:
##########
@@ -305,4 +308,45 @@ void testShardingStatisticsAPI() {
         });
         job.shutdown();
     }
+    
+    @Test
+    void testWhenShutdownThenTaskCanCaptureInterruptedException() throws 
Exception {
+        testCaptureInterruptedException(1);
+        testCaptureInterruptedException(2);
+    }
+    
+    private void testCaptureInterruptedException(final int shardingTotalCount) 
throws Exception {
+        String jobName = "testTaskCaptureInterruptedTask" + shardingTotalCount;
+        AtomicBoolean captured = new AtomicBoolean(false);
+        AtomicBoolean running = new AtomicBoolean(false);
+        LocalTime oneSecondsLater = LocalTime.now().plusSeconds(1);
+        String cronExpression = String.format("%d %d %d * * ?", 
oneSecondsLater.getSecond(), oneSecondsLater.getMinute(), 
oneSecondsLater.getHour());
+        SimpleJob captureInterruptedTask = shardingContext -> {
+            try {
+                running.set(true);
+                
+                while (true) {
+                    if (Thread.currentThread().isInterrupted()) {
+                        captured.set(true);
+                        running.set(false);
+                        break;
+                    }

Review Comment:
   It has no sense here, you can delete it.



-- 
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]

Reply via email to