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

boris-petrov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/main by this push:
     new 890f2aa76 bugfix(test): fix flaky 
ExecutorServiceSessionValidationSchedulerTest… (#2820)
890f2aa76 is described below

commit 890f2aa764153a5fbf620d3e90480b433493613b
Author: Lenny Primak <[email protected]>
AuthorDate: Mon Jul 6 01:56:32 2026 -0500

    bugfix(test): fix flaky ExecutorServiceSessionValidationSchedulerTest… 
(#2820)
    
    * bugfix(test): fix flaky ExecutorServiceSessionValidationSchedulerTest in 
core
    
    * enh(codespell): added atMost to dictionary
    
    * more codespell
---
 .github/linters/codespell.txt                           |  1 +
 .../ExecutorServiceSessionValidationSchedulerTest.java  | 17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/.github/linters/codespell.txt b/.github/linters/codespell.txt
index 3459c9359..6ae8a35cf 100644
--- a/.github/linters/codespell.txt
+++ b/.github/linters/codespell.txt
@@ -2,6 +2,7 @@ afile
 afterall
 aline
 atleast
+atmost
 bais
 bu
 crypted
diff --git 
a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
 
b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
index 0e3a09c96..3b0d65a0c 100644
--- 
a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
+++ 
b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java
@@ -23,7 +23,9 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.time.Duration;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
 
 @SuppressWarnings("checkstyle:MagicNumber")
 public class ExecutorServiceSessionValidationSchedulerTest {
@@ -47,8 +49,9 @@ public class ExecutorServiceSessionValidationSchedulerTest {
         Session session = new SimpleSession();
         session.setTimeout(2000L);
         defaultSessionManager.create(session);
-        Thread.sleep(5000L);
-        assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
+        await().atMost(Duration.ofSeconds(10))
+                .pollInterval(Duration.ofMillis(100))
+                .untilAsserted(() -> 
assertThat(defaultSessionManager.getActiveSessions()).isEmpty());
         
assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
     }
 
@@ -59,8 +62,9 @@ public class ExecutorServiceSessionValidationSchedulerTest {
         defaultSessionManager.create(session);
         Thread.sleep(1000L);
         session.stop();
-        Thread.sleep(3000L);
-        assertThat(defaultSessionManager.getActiveSessions()).isEmpty();
+        await().atMost(Duration.ofSeconds(10))
+                .pollInterval(Duration.ofMillis(100))
+                .untilAsserted(() -> 
assertThat(defaultSessionManager.getActiveSessions()).isEmpty());
         
assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
     }
 
@@ -88,8 +92,9 @@ public class ExecutorServiceSessionValidationSchedulerTest {
         defaultSessionManager.create(session);
         Thread.sleep(2000L);
         session.stop();
-        Thread.sleep(2000L);
-        assertThat(defaultSessionManager.getActiveSessions()).isNotEmpty();
+        await().atMost(Duration.ofSeconds(10))
+                .pollInterval(Duration.ofMillis(100))
+                .untilAsserted(() -> 
assertThat(defaultSessionManager.getActiveSessions()).isNotEmpty());
         
assertThat(executorServiceSessionValidationScheduler.isEnabled()).isTrue();
     }
 

Reply via email to