You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/02/01 13:34:50 UTC

[maven-surefire] 01/01: InterruptedIOException and cause:InterruptedException have the same purpose and should be caught

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

tibordigana pushed a commit to branch InterruptedIOException
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit cd005c294dc42d6924356e3952700775f703de15
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Tue Feb 1 14:33:19 2022 +0100

    InterruptedIOException and cause:InterruptedException have the same purpose and should be caught
---
 .../main/java/org/apache/maven/surefire/booter/CommandReader.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 5509095..609327c 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -33,6 +33,7 @@ import org.apache.maven.surefire.api.testset.TestSetFailedException;
 
 import java.io.EOFException;
 import java.io.IOException;
+import java.io.InterruptedIOException;
 import java.nio.channels.ClosedChannelException;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -393,8 +394,9 @@ public final class CommandReader implements CommandChainReader
             catch ( IOException e )
             {
                 CommandReader.this.state.set( TERMINATED );
-                // If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
-                if ( !( e.getCause() instanceof InterruptedException ) )
+                // If #stop() method is called, reader thread is interrupted
+                // and exception is InterruptedIOException or its cause is InterruptedException.
+                if ( !( e instanceof InterruptedIOException || e.getCause() instanceof InterruptedException ) )
                 {
                     String msg = "[SUREFIRE] std/in stream corrupted";
                     DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );