sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2633: Sqoop2: Allow to specify extra system classes for ConnectorClassLoader
Date Fri, 23 Oct 2015 20:14:34 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 21526151f -> 6f113c094


SQOOP-2633: Sqoop2: Allow to specify extra system classes for ConnectorClassLoader

(Dian Fu via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: 6f113c094f4cd956f089641ddc1e47012f63edec
Parents: 2152615
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Fri Oct 23 13:14:10 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Fri Oct 23 13:14:10 2015 -0700

----------------------------------------------------------------------
 .../apache/sqoop/utils/ConnectorClassLoader.java | 19 ++++++++++++++-----
 .../sqoop/utils/TestConnectorClassLoader.java    |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/6f113c09/common/src/main/java/org/apache/sqoop/utils/ConnectorClassLoader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/utils/ConnectorClassLoader.java b/common/src/main/java/org/apache/sqoop/utils/ConnectorClassLoader.java
index 69e972d..4c42a78 100644
--- a/common/src/main/java/org/apache/sqoop/utils/ConnectorClassLoader.java
+++ b/common/src/main/java/org/apache/sqoop/utils/ConnectorClassLoader.java
@@ -85,7 +85,7 @@ public class ConnectorClassLoader extends URLClassLoader {
   private final List<String> systemClasses;
 
   public ConnectorClassLoader(URL[] urls, ClassLoader parent,
-      List<String> systemClasses) {
+      List<String> systemClasses, boolean overrideDefaultSystemClasses) {
     super(urls, parent);
     if (LOG.isDebugEnabled()) {
       LOG.debug("urls: " + Arrays.toString(urls));
@@ -96,15 +96,24 @@ public class ConnectorClassLoader extends URLClassLoader {
       throw new IllegalArgumentException("No parent classloader!");
     }
     // if the caller-specified system classes are null or empty, use the default
-    this.systemClasses = (systemClasses == null || systemClasses.isEmpty()) ?
-        Arrays.asList(SYSTEM_CLASSES_DEFAULT.split("\\s*,\\s*")) :
-        systemClasses;
+    this.systemClasses = new ArrayList<String>();
+    if (systemClasses != null && !systemClasses.isEmpty()) {
+      this.systemClasses.addAll(systemClasses);
+    }
+    if (!overrideDefaultSystemClasses || this.systemClasses.isEmpty()) {
+      this.systemClasses.addAll(Arrays.asList(SYSTEM_CLASSES_DEFAULT.split("\\s*,\\s*")));
+    }
     LOG.info("system classes: " + this.systemClasses);
   }
 
   public ConnectorClassLoader(String classpath, ClassLoader parent,
       List<String> systemClasses) throws MalformedURLException {
-    this(constructUrlsFromClasspath(classpath), parent, systemClasses);
+    this(constructUrlsFromClasspath(classpath), parent, systemClasses, true);
+  }
+
+  public ConnectorClassLoader(String classpath, ClassLoader parent,
+      List<String> systemClasses, boolean overrideDefaultSystemClasses) throws MalformedURLException
{
+    this(constructUrlsFromClasspath(classpath), parent, systemClasses, overrideDefaultSystemClasses);
   }
 
   static URL[] constructUrlsFromClasspath(String classpath)

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6f113c09/common/src/test/java/org/apache/sqoop/utils/TestConnectorClassLoader.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/utils/TestConnectorClassLoader.java b/common/src/test/java/org/apache/sqoop/utils/TestConnectorClassLoader.java
index 442be4d..1ec1bb4 100644
--- a/common/src/test/java/org/apache/sqoop/utils/TestConnectorClassLoader.java
+++ b/common/src/test/java/org/apache/sqoop/utils/TestConnectorClassLoader.java
@@ -126,7 +126,7 @@ public class TestConnectorClassLoader {
 
     ClassLoader currentClassLoader = getClass().getClassLoader();
     ClassLoader connectorClassloader = new ConnectorClassLoader(
-        new URL[] { testJar }, currentClassLoader, null);
+        new URL[] { testJar }, currentClassLoader, null, false);
 
     assertNull(currentClassLoader.getResourceAsStream("resource.txt"),
         "Resource should be null for current classloader");


Mime
View raw message