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 2020/04/27 19:22:38 UTC

[maven-surefire] branch master updated: [SUREFIRE-1782] Configured Environment Variables do not take effect unless also added to excludedEnvironmentVariables

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1c54882  [SUREFIRE-1782] Configured Environment Variables do not take effect unless also added to excludedEnvironmentVariables
1c54882 is described below

commit 1c548824703dca398e200d25214cbf9743257c70
Author: akomakom <ak...@users.noreply.github.com>
AuthorDate: Mon Apr 27 15:22:29 2020 -0400

    [SUREFIRE-1782] Configured Environment Variables do not take effect unless also added to excludedEnvironmentVariables
---
 .../lazytestprovider/OutputStreamFlushableCommandline.java  | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
index 7f14c54..b54e185 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
@@ -21,7 +21,9 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Properties;
+import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedDeque;
 
 import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
@@ -40,6 +42,7 @@ public class OutputStreamFlushableCommandline
     implements FlushReceiverProvider
 {
     private final Collection<String> excludedEnvironmentVariables;
+    private final Set<String> addedEnvironmentVariables;
     private volatile FlushReceiver flushReceiver;
 
     /**
@@ -53,17 +56,25 @@ public class OutputStreamFlushableCommandline
     public OutputStreamFlushableCommandline( String[] excludedEnvironmentVariables )
     {
         this.excludedEnvironmentVariables = new ConcurrentLinkedDeque<>();
+        addedEnvironmentVariables = new HashSet<>();
         Collections.addAll( this.excludedEnvironmentVariables, excludedEnvironmentVariables );
     }
 
     @Override
+    public void addEnvironment( String name, String value )
+    {
+        super.addEnvironment( name, value );
+        addedEnvironmentVariables.add( name );
+    }
+
+    @Override
     public final void addSystemEnvironment()
     {
         Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
 
         for ( String key : systemEnvVars.stringPropertyNames() )
         {
-            if ( !excludedEnvironmentVariables.contains( key ) )
+            if ( !addedEnvironmentVariables.contains( key ) && !excludedEnvironmentVariables.contains( key ) )
             {
                 addEnvironment( key, systemEnvVars.getProperty( key ) );
             }