Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 326268973 -> 353f559cf


[CXF-7083] Better handling of system property changes in plugins

# Conflicts:
#       
maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
#       
maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
#       
maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java


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

Branch: refs/heads/3.0.x-fixes
Commit: 8e4d8edbf8649e9caa0aeed1d57fcfc395469ae2
Parents: 3262689
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri Mar 31 13:22:04 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Mar 31 15:33:10 2017 -0400

----------------------------------------------------------------------
 .../cxf/maven_plugin/ClassLoaderSwitcher.java   | 15 ++++----------
 .../cxf/maven_plugin/ClassLoaderSwitcher.java   | 21 ++++++--------------
 .../common/ClassLoaderSwitcher.java             | 21 +++++++-------------
 3 files changed, 17 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8e4d8edb/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
----------------------------------------------------------------------
diff --git 
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
 
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
index b6fff97..9cf75e5 100644
--- 
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
+++ 
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
@@ -24,10 +24,9 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -44,7 +43,7 @@ public class ClassLoaderSwitcher {
 
     private Log log;
     private String origClassPath;
-    private Map<Object, Object> origProps;
+    private Properties origProps;
     private ClassLoader origContextClassloader;
 
     public ClassLoaderSwitcher(Log log) {
@@ -104,7 +103,7 @@ public class ClassLoaderSwitcher {
 
         log.debug("Classpath: " + urlList.toString());
 
-        origProps = new HashMap<Object, Object>(System.getProperties());
+        origProps = (Properties)System.getProperties().clone();
 
         origClassPath = System.getProperty("java.class.path");
 
@@ -126,13 +125,7 @@ public class ClassLoaderSwitcher {
         }
 
         if (origProps != null) {
-            Map<Object, Object> newProps = new HashMap<Object, 
Object>(System.getProperties());
-            for (Object o : newProps.keySet()) {
-                if (!origProps.containsKey(o)) {
-                    System.clearProperty(o.toString());
-                }
-            }
-            System.getProperties().putAll(origProps);
+            System.setProperties(origProps);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e4d8edb/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
----------------------------------------------------------------------
diff --git 
a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
 
b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
index 0f8ca2c..a759414 100644
--- 
a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
+++ 
b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
@@ -23,9 +23,8 @@ import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.CastUtils;
@@ -41,7 +40,7 @@ public class ClassLoaderSwitcher {
 
     private Log log;
     private String origClassPath;
-    private Map<Object, Object> origProps;
+    private Properties origProps;
     private ClassLoader origContextClassloader;
 
     public ClassLoaderSwitcher(Log log) {
@@ -97,8 +96,7 @@ public class ClassLoaderSwitcher {
 
         log.debug("Classpath: " + urlList.toString());
 
-        origProps = new HashMap<Object, Object>(System.getProperties());
-
+        origProps = (Properties)System.getProperties().clone();
         origClassPath = System.getProperty("java.class.path");
 
         Thread.currentThread().setContextClassLoader(loader);
@@ -114,18 +112,11 @@ public class ClassLoaderSwitcher {
             
Thread.currentThread().setContextClassLoader(origContextClassloader);
             origContextClassloader = null; // don't hold a reference.
         }
-        if (origClassPath != null) {
-            System.setProperty("java.class.path", origClassPath);
-        }
 
         if (origProps != null) {
-            Map<Object, Object> newProps = new HashMap<Object, 
Object>(System.getProperties());
-            for (Object o : newProps.keySet()) {
-                if (!origProps.containsKey(o)) {
-                    System.clearProperty(o.toString());
-                }
-            }
-            System.getProperties().putAll(origProps);
+            System.setProperties(origProps);
+        } else if (origClassPath != null) {
+            System.setProperty("java.class.path", origClassPath);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e4d8edb/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
----------------------------------------------------------------------
diff --git 
a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
 
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
index 21b13ef..4fc7a71 100644
--- 
a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
+++ 
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
@@ -24,10 +24,9 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -46,7 +45,7 @@ public class ClassLoaderSwitcher {
 
     private Log log;
     private String origClassPath;
-    private Map<Object, Object> origProps;
+    private Properties origProps;
     private ClassLoader origContextClassloader;
 
     public ClassLoaderSwitcher(Log log) {
@@ -106,7 +105,7 @@ public class ClassLoaderSwitcher {
 
         log.debug("Classpath: " + urlList.toString());
 
-        origProps = new HashMap<Object, Object>(System.getProperties());
+        origProps = (Properties)System.getProperties().clone();
 
         origClassPath = System.getProperty("java.class.path");
 
@@ -123,18 +122,12 @@ public class ClassLoaderSwitcher {
             
Thread.currentThread().setContextClassLoader(origContextClassloader);
             origContextClassloader = null; // don't hold a reference.
         }
-        if (origClassPath != null) {
-            System.setProperty("java.class.path", origClassPath);
-        }
+        
 
         if (origProps != null) {
-            Map<Object, Object> newProps = new HashMap<Object, 
Object>(System.getProperties());
-            for (Object o : newProps.keySet()) {
-                if (!origProps.containsKey(o)) {
-                    System.clearProperty(o.toString());
-                }
-            }
-            System.getProperties().putAll(origProps);
+            System.setProperties(origProps);
+        } else if (origClassPath != null) {
+            System.setProperty("java.class.path", origClassPath);
         }
     }
 }

Reply via email to