You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sc...@apache.org on 2016/07/25 17:54:02 UTC

maven git commit: [MNG-5670] guard against ConcurrentModificationException [MNG-6053] guard against key without value

Repository: maven
Updated Branches:
  refs/heads/master 3d1117353 -> f848bc20f


[MNG-5670] guard against ConcurrentModificationException
[MNG-6053] guard against key without value


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/f848bc20
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/f848bc20
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/f848bc20

Branch: refs/heads/master
Commit: f848bc20f90ff25f5585f3f9515de65dfe12779a
Parents: 3d11173
Author: Christian Schulte <sc...@apache.org>
Authored: Mon Jul 25 19:53:27 2016 +0200
Committer: Christian Schulte <sc...@apache.org>
Committed: Mon Jul 25 19:53:27 2016 +0200

----------------------------------------------------------------------
 .../internal/MavenRepositorySystemUtils.java    | 28 ++++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f848bc20/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
index 17cbc6d..fa009f7 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
@@ -19,6 +19,9 @@ package org.apache.maven.repository.internal;
  * under the License.
  */
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.Properties;
 
 import org.eclipse.aether.DefaultRepositorySystemSession;
@@ -128,18 +131,27 @@ public final class MavenRepositorySystemUtils
         session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
 
         // MNG-5670 guard against ConcurrentModificationException
-        Properties sysProps = new Properties();
-        for ( String key : System.getProperties().stringPropertyNames() )
+        // MNG-6053 guard against key without value
+        final Properties systemProperties = new Properties();
+        // This relies on the fact that load/store are synchronized internally.
+        try ( final ByteArrayOutputStream out = new ByteArrayOutputStream() )
         {
-            Object value = System.getProperty( key );
-            // MNG-6053 guard against key without value
-            if ( value != null )
+            System.getProperties().store( out, null );
+            out.close();
+
+            try ( final ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() ) )
             {
-                sysProps.put( key, value );
+                systemProperties.load( in );
+                in.close();
             }
         }
-        session.setSystemProperties( sysProps );
-        session.setConfigProperties( sysProps );
+        catch ( final IOException e )
+        {
+            throw new AssertionError( "Unexpected IO error copying system properties." );
+        }
+
+        session.setSystemProperties( systemProperties );
+        session.setConfigProperties( systemProperties );
 
         return session;
     }