asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject incubator-asterixdb-hyracks git commit: Fix Potential IllegalArgumentException
Date Mon, 22 Feb 2016 16:53:08 GMT
Repository: incubator-asterixdb-hyracks
Updated Branches:
  refs/heads/master 26a15f03b -> a549d4bf1


Fix Potential IllegalArgumentException

In the event multiple URLs were used for jar deployment,
an IllegalArgumentException would have been thrown.
Replaced problematic reflection call in favor of a sub-
class.

Change-Id: I7c9e1ec2c1541e7593dbc09dac52bfdc9e1cbec6
Reviewed-on: https://asterix-gerrit.ics.uci.edu/649
Reviewed-by: Till Westmann <tillw@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/commit/a549d4bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/tree/a549d4bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/diff/a549d4bf

Branch: refs/heads/master
Commit: a549d4bf18edd32bf1e48090a38b6bbaf99a574f
Parents: 26a15f0
Author: Michael Blow <michael.blow@couchbase.com>
Authored: Sat Feb 20 16:29:14 2016 -0500
Committer: Till Westmann <tillw@apache.org>
Committed: Mon Feb 22 08:47:40 2016 -0800

----------------------------------------------------------------------
 .../ClassLoaderJobSerializerDeserializer.java   | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/a549d4bf/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/deployment/ClassLoaderJobSerializerDeserializer.java
----------------------------------------------------------------------
diff --git a/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/deployment/ClassLoaderJobSerializerDeserializer.java
b/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/deployment/ClassLoaderJobSerializerDeserializer.java
index 60ff2d3..bcd90bd 100644
--- a/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/deployment/ClassLoaderJobSerializerDeserializer.java
+++ b/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/deployment/ClassLoaderJobSerializerDeserializer.java
@@ -20,7 +20,6 @@
 package org.apache.hyracks.control.common.deployment;
 
 import java.io.Serializable;
-import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Collections;
@@ -38,7 +37,7 @@ import org.apache.hyracks.api.util.JavaSerializationUtils;
  */
 public class ClassLoaderJobSerializerDeserializer implements IJobSerializerDeserializer {
 
-    private URLClassLoader classLoader;
+    private MutableURLClassLoader classLoader;
 
     @Override
     public Object deserialize(byte[] jsBytes) throws HyracksException {
@@ -76,13 +75,12 @@ public class ClassLoaderJobSerializerDeserializer implements IJobSerializerDeser
             if (classLoader == null) {
                 /** crate a new classloader */
                 URL[] urls = binaryURLs.toArray(new URL[binaryURLs.size()]);
-                classLoader = new URLClassLoader(urls, this.getClass().getClassLoader());
+                classLoader = new MutableURLClassLoader(urls, this.getClass().getClassLoader());
             } else {
                 /** add URLs to the existing classloader */
-                Object[] urls = binaryURLs.toArray(new URL[binaryURLs.size()]);
-                Method method = classLoader.getClass().getDeclaredMethod("addURL", new Class[]
{ URL.class });
-                method.setAccessible(true);
-                method.invoke(classLoader, urls);
+                for (URL url : binaryURLs) {
+                    classLoader.addURL(url);
+                }
             }
         } catch (Exception e) {
             throw new HyracksException(e);
@@ -107,4 +105,16 @@ public class ClassLoaderJobSerializerDeserializer implements IJobSerializerDeser
     public String toString() {
         return classLoader.toString();
     }
+
+    private static class MutableURLClassLoader extends URLClassLoader {
+
+        public MutableURLClassLoader(URL[] urls, ClassLoader classLoader) {
+            super(urls, classLoader);
+        }
+
+        @Override
+        protected void addURL(URL url) {
+            super.addURL(url);
+        }
+    }
 }


Mime
View raw message