From 9b31d35b67991d0e2a5d055d2fa0d3ddec82dac0 Mon Sep 17 00:00:00 2001 From: Santhosh Date: Thu, 21 May 2026 22:21:41 +0530 Subject: [PATCH 1/3] Apply suggested fix to netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .../socketio/scheduler/HashedWheelTimeoutSchedulerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java index 161fcbad..d1e94310 100644 --- a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java +++ b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java @@ -781,6 +781,7 @@ void shouldHandleRaceConditionBetweenCancelAndSchedule() throws InterruptedExcep // Then boolean completed = completionLatch.await(5, TimeUnit.SECONDS); + raceThread.join(1000); // The task might or might not execute due to race condition, but no exception should occur assertThat(raceThread.isAlive()).isFalse(); } From 6ee1da275e52bcb486bad76d1332f349f51d8510 Mon Sep 17 00:00:00 2001 From: Santhosh Date: Thu, 21 May 2026 22:21:42 +0530 Subject: [PATCH 2/3] Apply suggested fix to netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .../HashedWheelTimeoutSchedulerTest.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java index d1e94310..f5c472d2 100644 --- a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java +++ b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java @@ -611,30 +611,35 @@ void shouldHandleConcurrentCancellation() throws InterruptedException { CountDownLatch startLatch = new CountDownLatch(1); CountDownLatch completionLatch = new CountDownLatch(threadCount); AtomicInteger executionCount = new AtomicInteger(0); + Thread[] workers = new Thread[threadCount]; // When for (int i = 0; i < threadCount; i++) { final int threadId = i; - new Thread(() -> { + workers[i] = new Thread(() -> { try { startLatch.await(); SchedulerKey key = new SchedulerKey(SchedulerKey.Type.PING, "session-" + threadId); - + // Schedule and immediately cancel scheduler.schedule(key, () -> { executionCount.incrementAndGet(); completionLatch.countDown(); }, 200, TimeUnit.MILLISECONDS); - + scheduler.cancel(key); - + } catch (InterruptedException e) { Thread.currentThread().interrupt(); } - }).start(); + }); + workers[i].start(); } startLatch.countDown(); + for (Thread worker : workers) { + worker.join(); + } // Then boolean completed = completionLatch.await(3, TimeUnit.SECONDS); From c5f2709ae439f404a95f29a37209b7fac26d0113 Mon Sep 17 00:00:00 2001 From: Santhosh Date: Thu, 21 May 2026 22:21:43 +0530 Subject: [PATCH 3/3] Apply suggested fix to netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .../scheduler/HashedWheelTimeoutSchedulerTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java index f5c472d2..1bda9887 100644 --- a/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java +++ b/netty-socketio-core/src/test/java/com/socketio4j/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java @@ -16,6 +16,8 @@ */ package com.socketio4j.socketio.scheduler; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -575,11 +577,12 @@ void shouldHandleConcurrentTimeoutReplacement() throws InterruptedException { CountDownLatch completionLatch = new CountDownLatch(threadCount); AtomicInteger executionCount = new AtomicInteger(0); SchedulerKey sharedKey = new SchedulerKey(SchedulerKey.Type.PING, "shared-session"); + List threads = new ArrayList<>(threadCount); // When for (int i = 0; i < threadCount; i++) { final int threadId = i; - new Thread(() -> { + Thread thread = new Thread(() -> { try { startLatch.await(); // All threads try to schedule with the same key @@ -590,13 +593,18 @@ void shouldHandleConcurrentTimeoutReplacement() throws InterruptedException { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } - }).start(); + }); + threads.add(thread); + thread.start(); } startLatch.countDown(); // Then boolean completed = completionLatch.await(5, TimeUnit.SECONDS); + for (Thread thread : threads) { + thread.join(); + } // Due to replacement, the exact count depends on timing and implementation // We just verify that the test completes without hanging assertThat(executionCount.get()).isGreaterThanOrEqualTo(0);