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/01/18 14:36:18 UTC
[maven-surefire] 04/04: [SUREFIRE-1981] Upgrade Apache maven-shared-utils to Version 3.3.4
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch ext-libs
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 9365aa01c8afc9cc0360e4e2d725fb262808930a
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Tue Jan 18 15:34:28 2022 +0100
[SUREFIRE-1981] Upgrade Apache maven-shared-utils to Version 3.3.4
---
.../booterclient/DefaultForkConfiguration.java | 52 +++++++++-------
.../output/ThreadedStreamConsumer.java | 3 +-
.../surefire/report/StatelessXmlReporter.java | 71 +++++++++-------------
pom.xml | 7 ++-
4 files changed, 65 insertions(+), 68 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
index a2c38b8..138e7f3 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
@@ -28,6 +28,7 @@ import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.extensions.ForkNodeFactory;
import org.apache.maven.surefire.api.util.internal.ImmutableMap;
+import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -133,35 +134,42 @@ public abstract class DefaultForkConfiguration
@Nonnull File dumpLogDirectory )
throws SurefireBooterForkException
{
- OutputStreamFlushableCommandline cli =
- new OutputStreamFlushableCommandline( getExcludedEnvironmentVariables() );
+ try
+ {
+ OutputStreamFlushableCommandline cli =
+ new OutputStreamFlushableCommandline( getExcludedEnvironmentVariables() );
- cli.setWorkingDirectory( getWorkingDirectory( forkNumber ).getAbsolutePath() );
+ cli.setWorkingDirectory( getWorkingDirectory( forkNumber ).getAbsolutePath() );
- for ( Entry<String, String> entry : getEnvironmentVariables().entrySet() )
- {
- String value = entry.getValue();
- cli.addEnvironment( entry.getKey(), value == null ? "" : value );
- }
+ for ( Entry<String, String> entry : getEnvironmentVariables().entrySet() )
+ {
+ String value = entry.getValue();
+ cli.addEnvironment( entry.getKey(), value == null ? "" : value );
+ }
- cli.setExecutable( getJdkForTests().getJvmExecutable().getAbsolutePath() );
+ cli.setExecutable( getJdkForTests().getJvmExecutable().getAbsolutePath() );
- String jvmArgLine = newJvmArgLine( forkNumber );
- if ( !jvmArgLine.isEmpty() )
- {
- cli.createArg()
- .setLine( jvmArgLine );
- }
+ String jvmArgLine = newJvmArgLine( forkNumber );
+ if ( !jvmArgLine.isEmpty() )
+ {
+ cli.createArg()
+ .setLine( jvmArgLine );
+ }
- if ( getDebugLine() != null && !getDebugLine().isEmpty() )
- {
- cli.createArg()
- .setLine( getDebugLine() );
- }
+ if ( getDebugLine() != null && !getDebugLine().isEmpty() )
+ {
+ cli.createArg()
+ .setLine( getDebugLine() );
+ }
- resolveClasspath( cli, findStartClass( config ), config, dumpLogDirectory );
+ resolveClasspath( cli, findStartClass( config ), config, dumpLogDirectory );
- return cli;
+ return cli;
+ }
+ catch ( CommandLineException e )
+ {
+ throw new SurefireBooterForkException( e.getLocalizedMessage(), e );
+ }
}
protected ConsoleLogger getLogger()
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index 10920c5..742aad2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -21,7 +21,6 @@ package org.apache.maven.plugin.surefire.booterclient.output;
import org.apache.maven.surefire.api.event.Event;
import org.apache.maven.surefire.extensions.EventHandler;
-import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
import javax.annotation.Nonnull;
import java.io.Closeable;
@@ -69,7 +68,7 @@ public final class ThreadedStreamConsumer
/**
* Calls {@link ForkClient#handleEvent(Event)} which may throw any {@link RuntimeException}.<br>
* Even if {@link ForkClient} is not fault-tolerant, this method MUST be fault-tolerant and thus the
- * try-catch block must be inside of the loop which prevents from loosing events from {@link StreamConsumer}.
+ * try-catch block must be inside of the loop which prevents from loosing events from {@link EventHandler}.
* <br>
* If {@link org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter#writeTestOutput} throws
* {@link java.io.IOException} and then {@code target.consumeLine()} throws any RuntimeException, this method
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 7c24fe2..5431069 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -23,7 +23,6 @@ import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpS
import org.apache.maven.surefire.shared.utils.xml.PrettyPrintXMLWriter;
import org.apache.maven.surefire.shared.utils.xml.XMLWriter;
import org.apache.maven.surefire.extensions.StatelessReportEventListener;
-import org.apache.maven.surefire.api.report.ReporterException;
import org.apache.maven.surefire.api.report.SafeThrowable;
import java.io.BufferedOutputStream;
@@ -135,8 +134,10 @@ public class StatelessXmlReporter
Map<String, Map<String, List<WrappedReportEntry>>> classMethodStatistics =
arrangeMethodStatistics( testSetReportEntry, testSetStats );
- OutputStream outputStream = getOutputStream( testSetReportEntry );
- try ( OutputStreamWriter fw = getWriter( outputStream ) )
+ // The Java Language Spec:
+ // "Note that the close methods of resources are called in the opposite order of their creation."
+ try ( OutputStream outputStream = getOutputStream( testSetReportEntry );
+ OutputStreamWriter fw = getWriter( outputStream ) )
{
XMLWriter ppw = new PrettyPrintXMLWriter( fw );
ppw.setEncoding( UTF_8.name() );
@@ -155,7 +156,7 @@ public class StatelessXmlReporter
ppw.endElement(); // TestSuite
}
- catch ( Exception e )
+ catch ( IOException e )
{
// It's not a test error.
// This method must be sail-safe and errors are in a dump log.
@@ -201,6 +202,7 @@ public class StatelessXmlReporter
private void serializeTestClass( OutputStream outputStream, OutputStreamWriter fw, XMLWriter ppw,
List<WrappedReportEntry> methodEntries )
+ throws IOException
{
if ( rerunFailingTestsCount > 0 )
{
@@ -216,6 +218,7 @@ public class StatelessXmlReporter
private void serializeTestClassWithoutRerun( OutputStream outputStream, OutputStreamWriter fw, XMLWriter ppw,
List<WrappedReportEntry> methodEntries )
+ throws IOException
{
for ( WrappedReportEntry methodEntry : methodEntries )
{
@@ -232,6 +235,7 @@ public class StatelessXmlReporter
private void serializeTestClassWithRerun( OutputStream outputStream, OutputStreamWriter fw, XMLWriter ppw,
List<WrappedReportEntry> methodEntries )
+ throws IOException
{
WrappedReportEntry firstMethodEntry = methodEntries.get( 0 );
switch ( getTestResultType( methodEntries ) )
@@ -339,6 +343,7 @@ public class StatelessXmlReporter
}
private OutputStream getOutputStream( WrappedReportEntry testSetReportEntry )
+ throws IOException
{
File reportFile = getReportFile( testSetReportEntry );
@@ -346,15 +351,7 @@ public class StatelessXmlReporter
//noinspection ResultOfMethodCallIgnored
reportDir.mkdirs();
-
- try
- {
- return new BufferedOutputStream( new FileOutputStream( reportFile ), 64 * 1024 );
- }
- catch ( Exception e )
- {
- throw new ReporterException( "When writing report", e );
- }
+ return new BufferedOutputStream( new FileOutputStream( reportFile ), 64 * 1024 );
}
private static OutputStreamWriter getWriter( OutputStream fos )
@@ -370,6 +367,7 @@ public class StatelessXmlReporter
}
private void startTestElement( XMLWriter ppw, WrappedReportEntry report )
+ throws IOException
{
ppw.startElement( "testcase" );
String name = phrasedMethodName ? report.getReportName() : report.getName();
@@ -391,6 +389,7 @@ public class StatelessXmlReporter
}
private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats )
+ throws IOException
{
ppw.startElement( "testsuite" );
@@ -421,6 +420,7 @@ public class StatelessXmlReporter
private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
WrappedReportEntry report, boolean trimStackTrace, OutputStream fw,
String testErrorType, boolean createOutErrElementsInside )
+ throws IOException
{
ppw.startElement( testErrorType );
@@ -478,6 +478,7 @@ public class StatelessXmlReporter
// Create system-out and system-err elements
private static void createOutErrElements( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
WrappedReportEntry report, OutputStream fw )
+ throws IOException
{
EncodingOutputStream eos = new EncodingOutputStream( fw );
addOutputStreamElement( outputStreamWriter, eos, ppw, report.getStdout(), "system-out" );
@@ -488,24 +489,17 @@ public class StatelessXmlReporter
EncodingOutputStream eos, XMLWriter xmlWriter,
Utf8RecodingDeferredFileOutputStream utf8RecodingDeferredFileOutputStream,
String name )
+ throws IOException
{
if ( utf8RecodingDeferredFileOutputStream != null && utf8RecodingDeferredFileOutputStream.getByteCount() > 0 )
{
xmlWriter.startElement( name );
-
- try
- {
- xmlWriter.writeText( "" ); // Cheat sax to emit element
- outputStreamWriter.flush();
- eos.getUnderlying().write( ByteConstantsHolder.CDATA_START_BYTES ); // emit cdata
- utf8RecodingDeferredFileOutputStream.writeTo( eos );
- eos.getUnderlying().write( ByteConstantsHolder.CDATA_END_BYTES );
- eos.flush();
- }
- catch ( IOException e )
- {
- throw new ReporterException( "When writing xml report stdout/stderr", e );
- }
+ xmlWriter.writeText( "" ); // Cheat sax to emit element
+ outputStreamWriter.flush();
+ eos.getUnderlying().write( ByteConstantsHolder.CDATA_START_BYTES ); // emit cdata
+ utf8RecodingDeferredFileOutputStream.writeTo( eos );
+ eos.getUnderlying().write( ByteConstantsHolder.CDATA_END_BYTES );
+ eos.flush();
xmlWriter.endElement();
}
}
@@ -517,6 +511,7 @@ public class StatelessXmlReporter
* @param xmlWriter The test suite to report to
*/
private static void showProperties( XMLWriter xmlWriter, Map<String, String> systemProperties )
+ throws IOException
{
xmlWriter.startElement( "properties" );
for ( final Entry<String, String> entry : systemProperties.entrySet() )
@@ -559,6 +554,7 @@ public class StatelessXmlReporter
*/
private static void extraEscapeElementValue( String message, OutputStreamWriter outputStreamWriter,
XMLWriter xmlWriter, OutputStream fw )
+ throws IOException
{
// Someday convert to xml 1.1 which handles everything but 0 inside string
if ( containsEscapesIllegalXml10( message ) )
@@ -567,20 +563,13 @@ public class StatelessXmlReporter
}
else
{
- try
- {
- EncodingOutputStream eos = new EncodingOutputStream( fw );
- xmlWriter.writeText( "" ); // Cheat sax to emit element
- outputStreamWriter.flush();
- eos.getUnderlying().write( ByteConstantsHolder.CDATA_START_BYTES );
- eos.write( message.getBytes( UTF_8 ) );
- eos.getUnderlying().write( ByteConstantsHolder.CDATA_END_BYTES );
- eos.flush();
- }
- catch ( IOException e )
- {
- throw new ReporterException( "When writing xml element", e );
- }
+ EncodingOutputStream eos = new EncodingOutputStream( fw );
+ xmlWriter.writeText( "" ); // Cheat sax to emit element
+ outputStreamWriter.flush();
+ eos.getUnderlying().write( ByteConstantsHolder.CDATA_START_BYTES );
+ eos.write( message.getBytes( UTF_8 ) );
+ eos.getUnderlying().write( ByteConstantsHolder.CDATA_END_BYTES );
+ eos.flush();
}
}
diff --git a/pom.xml b/pom.xml
index d6f4b30..15d933c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,8 +95,8 @@
<doxiaVersion>1.11.1</doxiaVersion>
<doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
<plexus-java-version>1.1.0</plexus-java-version>
- <!-- maven-shared-utils:3.2.0+ another behavior - broke Surefire performance - end of subprocess notification not arrived in ForkStarter -->
- <mavenSharedUtilsVersion>3.1.0</mavenSharedUtilsVersion>
+ <!-- maven-shared-utils:3.3.4 uses org.fusesource.jansi:jansi:2.2.0 -->
+ <mavenSharedUtilsVersion>3.3.4</mavenSharedUtilsVersion>
<powermockVersion>2.0.9</powermockVersion>
<mavenPluginToolsVersion>3.6.2</mavenPluginToolsVersion>
<jacocoVersion>0.8.7</jacocoVersion>
@@ -257,9 +257,10 @@
<version>2.33</version>
</dependency>
<dependency>
+ <!-- used in the unit tests and maven-shared-utils:3.3.4 -->
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
- <version>1.13</version>
+ <version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>