Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 5639e679f -> b0ad4130d


[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/2d04ee0c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2d04ee0c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2d04ee0c

Branch: refs/heads/3.1.x-fixes
Commit: 2d04ee0c4b6b55772d5746b8f58f6386d264c00b
Parents: 5639e67
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:31:28 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/2d04ee0c/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 a8a3fae..6d4442a 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) {
@@ -105,7 +104,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");
 
@@ -127,13 +126,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/2d04ee0c/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 d411616..f3cb6e3 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) {
@@ -98,8 +97,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);
@@ -115,18 +113,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/2d04ee0c/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 9485fbd..75241bb 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) {
@@ -107,7 +106,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");
 
@@ -124,18 +123,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