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 2021/05/08 21:34:13 UTC

[maven-surefire] 02/02: [SUREFIRE-1913] system properties should be restored after the in-process tests have been executed

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

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

commit 190b5ff3c31cd21f21c386df55f3f9625fc33811
Author: tibordigana <ti...@gmail.com>
AuthorDate: Sat May 8 23:33:46 2021 +0200

    [SUREFIRE-1913] system properties should be restored after the in-process tests have been executed
---
 .../maven/plugin/surefire/AbstractSurefireMojo.java      | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index d95c6a5..5109fde 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -1302,11 +1302,19 @@ public abstract class AbstractSurefireMojo
 
         if ( isNotForking() )
         {
-            createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
+            Properties originalSystemProperties = (Properties) System.getProperties().clone();
+            try
+            {
+                createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
 
-            InPluginVMSurefireStarter surefireStarter = createInprocessStarter( provider, classLoaderConfiguration,
-                    runOrderParameters, scanResult, platform, testClasspathWrapper );
-            return surefireStarter.runSuitesInProcess( scanResult );
+                InPluginVMSurefireStarter surefireStarter = createInprocessStarter( provider, classLoaderConfiguration,
+                        runOrderParameters, scanResult, platform, testClasspathWrapper );
+                return surefireStarter.runSuitesInProcess( scanResult );
+            }
+            finally
+            {
+                System.setProperties( originalSystemProperties );
+            }
         }
         else
         {