You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "nao-it (via GitHub)" <gi...@apache.org> on 2026/09/25 12:21:37 UTC

[PR] IGNITE-29072 Fix tests using Thread.suspend() for JDK 21 [ignite]

nao-it opened a new pull request, #13619:
URL: https://github.com/apache/ignite/pull/13619

   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see tab `PR Check` at [TC.Bot - Instance 1](https://tcbot2.sbt-ignite-dev.ru/prs.html) or [TC.Bot - Instance 2](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-29072 Fix tests using Thread.suspend() for JDK 21 [ignite]

Posted by "wernerdv (via GitHub)" <gi...@apache.org>.
wernerdv commented on code in PR #13619:
URL: https://github.com/apache/ignite/pull/13619#discussion_r4153433959


##########
modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java:
##########
@@ -53,9 +56,98 @@ public class TestTcpDiscoverySpi extends TcpDiscoverySpi implements IgniteDiscov
     /** */
     private IgniteDiscoverySpiInternalListener internalLsnr;
 
+    /** Latch released on {@link #unfreeze()}, {@code null} if the discovery I/O is not frozen. */
+    private volatile CountDownLatch freezeLatch;
+
+    /**
+     * Freezes the discovery I/O of this node: every socket read and write blocks until {@link #unfreeze()} is called.
+     * The node keeps accepting TCP connections. Emulates a node whose threads hang, e.g. at a long GC pause.
+     */
+    public synchronized void freeze() {
+        if (freezeLatch == null)
+            freezeLatch = new CountDownLatch(1);
+    }
+
+    /** Releases the discovery I/O frozen by {@link #freeze()}. */
+    public synchronized void unfreeze() {
+        if (freezeLatch != null) {
+            freezeLatch.countDown();
+
+            freezeLatch = null;
+        }
+    }
+
+    /**
+     * Blocks while the discovery I/O is frozen.
+     *
+     * @throws InterruptedIOException If interrupted.
+     */
+    private void awaitUnfrozen() throws InterruptedIOException {
+        CountDownLatch latch = freezeLatch;
+
+        if (latch == null)
+            return;
+
+        try {
+            latch.await();
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+
+            throw new InterruptedIOException("Interrupted while discovery I/O is frozen.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void write(TcpDiscoveryIoSession ses, byte[] data, long timeout) throws IOException,
+        IgniteCheckedException {
+        awaitUnfrozen();
+
+        super.write(ses, data, timeout);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void writeReceipt(TcpDiscoveryIoSession ses, int res, long timeout) throws IOException,
+        IgniteCheckedException {

Review Comment:
   ```suggestion
       @Override protected void writeReceipt(TcpDiscoveryIoSession ses, int res, long timeout) throws IOException, IgniteCheckedException {
   ```



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-29072 Fix tests using Thread.suspend() for JDK 21 [ignite]

Posted by "wernerdv (via GitHub)" <gi...@apache.org>.
wernerdv merged PR #13619:
URL: https://github.com/apache/ignite/pull/13619


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-29072 Fix tests using Thread.suspend() for JDK 21 [ignite]

Posted by "wernerdv (via GitHub)" <gi...@apache.org>.
wernerdv commented on code in PR #13619:
URL: https://github.com/apache/ignite/pull/13619#discussion_r4153439210


##########
modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java:
##########
@@ -53,9 +56,98 @@ public class TestTcpDiscoverySpi extends TcpDiscoverySpi implements IgniteDiscov
     /** */
     private IgniteDiscoverySpiInternalListener internalLsnr;
 
+    /** Latch released on {@link #unfreeze()}, {@code null} if the discovery I/O is not frozen. */
+    private volatile CountDownLatch freezeLatch;
+
+    /**
+     * Freezes the discovery I/O of this node: every socket read and write blocks until {@link #unfreeze()} is called.
+     * The node keeps accepting TCP connections. Emulates a node whose threads hang, e.g. at a long GC pause.
+     */
+    public synchronized void freeze() {
+        if (freezeLatch == null)
+            freezeLatch = new CountDownLatch(1);
+    }
+
+    /** Releases the discovery I/O frozen by {@link #freeze()}. */
+    public synchronized void unfreeze() {
+        if (freezeLatch != null) {
+            freezeLatch.countDown();
+
+            freezeLatch = null;
+        }
+    }
+
+    /**
+     * Blocks while the discovery I/O is frozen.
+     *
+     * @throws InterruptedIOException If interrupted.
+     */
+    private void awaitUnfrozen() throws InterruptedIOException {
+        CountDownLatch latch = freezeLatch;
+
+        if (latch == null)
+            return;
+
+        try {
+            latch.await();
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+
+            throw new InterruptedIOException("Interrupted while discovery I/O is frozen.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void write(TcpDiscoveryIoSession ses, byte[] data, long timeout) throws IOException,
+        IgniteCheckedException {
+        awaitUnfrozen();
+
+        super.write(ses, data, timeout);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void writeReceipt(TcpDiscoveryIoSession ses, int res, long timeout) throws IOException,
+        IgniteCheckedException {
+        awaitUnfrozen();
+
+        super.writeReceipt(ses, res, timeout);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected <T extends Message> T readMessage(
+            TcpDiscoveryIoSession ses,
+            long timeout) throws IOException,
+        IgniteCheckedException {

Review Comment:
   ```suggestion
           TcpDiscoveryIoSession ses,
           long timeout
       ) throws IOException, IgniteCheckedException {
   ```



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-29072 Fix tests using Thread.suspend() for JDK 21 [ignite]

Posted by "wernerdv (via GitHub)" <gi...@apache.org>.
wernerdv commented on code in PR #13619:
URL: https://github.com/apache/ignite/pull/13619#discussion_r4153430577


##########
modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java:
##########
@@ -53,9 +56,98 @@ public class TestTcpDiscoverySpi extends TcpDiscoverySpi implements IgniteDiscov
     /** */
     private IgniteDiscoverySpiInternalListener internalLsnr;
 
+    /** Latch released on {@link #unfreeze()}, {@code null} if the discovery I/O is not frozen. */
+    private volatile CountDownLatch freezeLatch;
+
+    /**
+     * Freezes the discovery I/O of this node: every socket read and write blocks until {@link #unfreeze()} is called.
+     * The node keeps accepting TCP connections. Emulates a node whose threads hang, e.g. at a long GC pause.
+     */
+    public synchronized void freeze() {
+        if (freezeLatch == null)
+            freezeLatch = new CountDownLatch(1);
+    }
+
+    /** Releases the discovery I/O frozen by {@link #freeze()}. */
+    public synchronized void unfreeze() {
+        if (freezeLatch != null) {
+            freezeLatch.countDown();
+
+            freezeLatch = null;
+        }
+    }
+
+    /**
+     * Blocks while the discovery I/O is frozen.
+     *
+     * @throws InterruptedIOException If interrupted.
+     */
+    private void awaitUnfrozen() throws InterruptedIOException {
+        CountDownLatch latch = freezeLatch;
+
+        if (latch == null)
+            return;
+
+        try {
+            latch.await();
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+
+            throw new InterruptedIOException("Interrupted while discovery I/O is frozen.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void write(TcpDiscoveryIoSession ses, byte[] data, long timeout) throws IOException,
+        IgniteCheckedException {

Review Comment:
   ```suggestion
       @Override protected void write(TcpDiscoveryIoSession ses, byte[] data, long timeout) throws IOException, IgniteCheckedException {
   ```



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org