NSAmelchev commented on code in PR #13501:
URL: https://github.com/apache/ignite/pull/13501#discussion_r3822839861


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java:
##########
@@ -133,6 +134,65 @@ public void testTimeouts() throws Exception {
         }
     }
 
+    /**
+     * Tests that non-blocking cancellation doesn't wait for a running task 
holding the task monitor and prevents
+     * subsequent executions.
+     *
+     * @throws Exception If test failed.
+     */
+    @Test
+    public void testNonBlockingCancel() throws Exception {
+        ReentrantLock sslLock = new ReentrantLock();

Review Comment:
   Done.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java:
##########
@@ -133,6 +134,65 @@ public void testTimeouts() throws Exception {
         }
     }
 
+    /**
+     * Tests that non-blocking cancellation doesn't wait for a running task 
holding the task monitor and prevents
+     * subsequent executions.
+     *
+     * @throws Exception If test failed.
+     */
+    @Test
+    public void testNonBlockingCancel() throws Exception {
+        ReentrantLock sslLock = new ReentrantLock();
+        CountDownLatch lockAcquired = new CountDownLatch(1);
+        CountDownLatch taskStarted = new CountDownLatch(1);
+        AtomicInteger taskCallCnt = new AtomicInteger();
+
+        GridTimeoutProcessor.CancelableTask task = ctx.timeout().schedule(() 
-> {
+            taskCallCnt.incrementAndGet();
+
+            taskStarted.countDown();
+
+            sslLock.lock();
+
+            try {
+                // No-op.
+            }
+            finally {
+                sslLock.unlock();
+            }
+        }, 60_000, 1_000);
+
+        IgniteInternalFuture<?> cancelFut = GridTestUtils.runAsync(() -> {
+            // Emulates the NIO worker cancelling the handshake timeout under 
the SSL handler lock.
+            sslLock.lock();
+
+            try {
+                lockAcquired.countDown();
+
+                taskStarted.await();
+
+                task.cancel();
+            }
+            finally {
+                sslLock.unlock();
+            }
+        }, "test-cancel-thread");
+
+        assertTrue(lockAcquired.await(10_000, MILLISECONDS));
+
+        IgniteInternalFuture<?> timeoutFut = 
GridTestUtils.runAsync(task::onTimeout, "test-timeout-thread");

Review Comment:
   Done.



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