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/03 22:40:51 UTC
[maven-surefire] branch InterruptedIOException updated (d0ccc1d -> d180c78)
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a change to branch InterruptedIOException
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.
from d0ccc1d build fix
new 6d19a9a more tests
new d180c78 blocking TCP session writes
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/maven/surefire/booter/PpidChecker.java | 12 +--
...refireMasterProcessChannelProcessorFactory.java | 2 +-
.../maven/surefire/booter/PpidCheckerTest.java | 95 ++++++++++++++++++++++
3 files changed, 103 insertions(+), 6 deletions(-)
[maven-surefire] 01/02: more tests
Posted by ti...@apache.org.
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 6d19a9ad12a8c4cfe601ab65f5ba4a9e188e7e1f
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Thu Feb 3 23:39:37 2022 +0100
more tests
---
.../apache/maven/surefire/booter/PpidChecker.java | 12 +--
.../maven/surefire/booter/PpidCheckerTest.java | 95 ++++++++++++++++++++++
2 files changed, 102 insertions(+), 5 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index 244331f..1fb8a30 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -24,6 +24,7 @@ import org.apache.maven.surefire.api.booter.DumpErrorSingleton;
import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
+import java.io.InterruptedIOException;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
@@ -382,7 +383,7 @@ final class PpidChecker
* This implementation is taylor made without using any Thread.
* It's easy to destroy Process from other Thread.
*/
- private abstract class ProcessInfoConsumer
+ abstract class ProcessInfoConsumer
{
private final String charset;
@@ -437,11 +438,9 @@ final class PpidChecker
}
catch ( Exception e )
{
- if ( !( e instanceof InterruptedException ) && !( e.getCause() instanceof InterruptedException ) )
+ if ( !( e instanceof InterruptedException || e instanceof InterruptedIOException
+ || e.getCause() instanceof InterruptedException ) )
{
- //noinspection ResultOfMethodCallIgnored
- Thread.interrupted();
-
DumpErrorSingleton.getSingleton()
.dumpText( out.toString() );
@@ -449,6 +448,9 @@ final class PpidChecker
.dumpException( e );
}
+ //noinspection ResultOfMethodCallIgnored
+ Thread.interrupted();
+
return ERR_PROCESS_INFO;
}
finally
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
index 396cb1a..c5d916e 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
@@ -27,11 +27,15 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
+import javax.annotation.Nonnull;
import java.io.File;
+import java.io.IOException;
+import java.io.InterruptedIOException;
import java.lang.management.ManagementFactory;
import java.util.Random;
import java.util.regex.Matcher;
+import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.file.Files.readAllBytes;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_UNIX;
@@ -230,6 +234,97 @@ public class PpidCheckerTest
}
@Test
+ public void shouldStartedProcessThrowInterruptedException() throws Exception
+ {
+ String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim();
+ DumpErrorSingleton.getSingleton().init( reportsDir, dumpFileName );
+
+ PpidChecker checker = new PpidChecker( expectedPid );
+
+ PpidChecker.ProcessInfoConsumer consumer = checker.new ProcessInfoConsumer( US_ASCII.name() )
+ {
+ @Nonnull
+ @Override
+ ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo )
+ throws Exception
+ {
+ throw new InterruptedException();
+ }
+ };
+
+ String[] cmd =
+ IS_OS_WINDOWS
+ ? new String[]{"CMD", "/A", "/X", "/C", "dir"}
+ : new String[]{"/bin/sh", "-c", "ls"};
+
+ assertThat( consumer.execute( cmd ).isError() ).isTrue();
+ assertThat( new File( reportsDir, dumpFileName + ".dump" ) ).doesNotExist();
+ }
+
+ @Test
+ public void shouldStartedProcessThrowInterruptedIOException() throws Exception
+ {
+ String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim();
+ DumpErrorSingleton.getSingleton().init( reportsDir, dumpFileName );
+
+ PpidChecker checker = new PpidChecker( expectedPid );
+
+ PpidChecker.ProcessInfoConsumer consumer = checker.new ProcessInfoConsumer( US_ASCII.name() )
+ {
+ @Nonnull
+ @Override
+ ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo )
+ throws Exception
+ {
+ throw new InterruptedIOException();
+ }
+ };
+
+ String[] cmd =
+ IS_OS_WINDOWS
+ ? new String[]{"CMD", "/A", "/X", "/C", "dir"}
+ : new String[]{"/bin/sh", "-c", "ls"};
+
+ assertThat( consumer.execute( cmd ).isError() ).isTrue();
+ assertThat( new File( reportsDir, dumpFileName + ".dump" ) ).doesNotExist();
+ }
+
+ @Test
+ public void shouldStartedProcessThrowIOException() throws Exception
+ {
+ String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim();
+ DumpErrorSingleton.getSingleton().init( reportsDir, dumpFileName );
+
+ PpidChecker checker = new PpidChecker( expectedPid );
+
+ PpidChecker.ProcessInfoConsumer consumer = checker.new ProcessInfoConsumer( US_ASCII.name() )
+ {
+ @Nonnull
+ @Override
+ ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo )
+ throws Exception
+ {
+ throw new IOException( "wrong command" );
+ }
+ };
+
+ String[] cmd =
+ IS_OS_WINDOWS
+ ? new String[]{"CMD", "/A", "/X", "/C", "dir"}
+ : new String[]{"/bin/sh", "-c", "ls"};
+
+ assertThat( consumer.execute( cmd ).isError() ).isTrue();
+
+ File dumpFile = new File( reportsDir, dumpFileName + ".dump" );
+
+ String error = new String( readAllBytes( dumpFile.toPath() ) );
+
+ assertThat( error )
+ .contains( IOException.class.getName() )
+ .contains( "wrong command" );
+ }
+
+ @Test
public void shouldNotFindSuchPID()
{
PpidChecker checker = new PpidChecker( "1000000" );
[maven-surefire] 02/02: blocking TCP session writes
Posted by ti...@apache.org.
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 d180c787e658e960de2cd4e1064e34166e6ef393
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Thu Feb 3 23:40:28 2022 +0100
blocking TCP session writes
---
.../booter/spi/SurefireMasterProcessChannelProcessorFactory.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/SurefireMasterProcessChannelProcessorFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/SurefireMasterProcessChannelProcessorFactory.java
index 6232209..a2c4487 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/SurefireMasterProcessChannelProcessorFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/SurefireMasterProcessChannelProcessorFactory.java
@@ -86,7 +86,7 @@ public class SurefireMasterProcessChannelProcessorFactory
if ( sessionId != null )
{
ByteBuffer buff = ByteBuffer.wrap( sessionId.getBytes( US_ASCII ) );
- clientSocketChannel.write( buff );
+ clientSocketChannel.write( buff ).get();
}
}
catch ( URISyntaxException | InterruptedException e )