This is an automated email from the ASF dual-hosted git repository.

linghengqian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 53cbc73ed Fix ElasticJobExecutorServiceTest Flakiness (#2242)
53cbc73ed is described below

commit 53cbc73edd06429450fef0cf3ff793120fc0b75d
Author: Alisha-0321 <[email protected]>
AuthorDate: Mon Sep 4 19:08:21 2023 -0500

    Fix ElasticJobExecutorServiceTest Flakiness (#2242)
    
    Co-authored-by: other <[email protected]>
---
 .../elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
 
b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
index c7ffe38da..e92c078fa 100644
--- 
a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
+++ 
b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorServiceTest.java
@@ -28,6 +28,8 @@ import static org.junit.Assert.assertTrue;
 
 public final class ElasticJobExecutorServiceTest {
     
+    private static boolean hasExecuted;
+
     @Test
     public void assertCreateExecutorService() {
         ElasticJobExecutorService executorServiceObject = new 
ElasticJobExecutorService("executor-service-test", 1);
@@ -48,6 +50,7 @@ public final class ElasticJobExecutorServiceTest {
         executorService.shutdownNow();
         assertThat(executorServiceObject.getWorkQueueSize(), is(0));
         assertTrue(executorServiceObject.isShutdown());
+        hasExecuted = true;
     }
     
     static class FooTask implements Runnable {
@@ -55,6 +58,9 @@ public final class ElasticJobExecutorServiceTest {
         @Override
         public void run() {
             BlockUtils.sleep(1000L);
+            while (!hasExecuted) {
+                Thread.yield();
+            }
         }
     }
 }

Reply via email to