pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] srkukarni commented on a change in pull request #3865: Classloader choice for validating Source/Sink
Date Wed, 20 Mar 2019 05:01:49 GMT
srkukarni commented on a change in pull request #3865: Classloader choice for validating Source/Sink
URL: https://github.com/apache/pulsar/pull/3865#discussion_r267186297
 
 

 ##########
 File path: pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SinkConfigUtils.java
 ##########
 @@ -288,14 +290,35 @@ public static ExtractedSinkDetails validate(SinkConfig sinkConfig,
Path archiveP
         }
 
         String sinkClassName;
-        ClassLoader classLoader;
+        final Class<?> typeArg;
+        final ClassLoader classLoader;
         if (!isEmpty(sinkConfig.getClassName())) {
             sinkClassName = sinkConfig.getClassName();
+            // We really don't know if we should use nar class loader or regular classloader
+            ClassLoader jarClassLoader = null;
+            ClassLoader narClassLoader = null;
             try {
-                classLoader = Utils.extractClassLoader(archivePath, functionPkgUrl, uploadedInputStreamAsFile);
+                jarClassLoader = Utils.extractClassLoader(archivePath, functionPkgUrl, uploadedInputStreamAsFile);
             } catch (Exception e) {
-                throw new IllegalArgumentException("Invalid Sink Jar");
             }
+            try {
+                narClassLoader = Utils.extractNarClassLoader(archivePath, functionPkgUrl,
uploadedInputStreamAsFile);
+            } catch (Exception e) {
+            }
+            if (jarClassLoader == null && narClassLoader == null) {
+                throw new IllegalArgumentException("Invalid Sink Package");
+            }
+            Class<?> typArg;
+            ClassLoader clsLoader;
+            try {
+                typArg = getSinkType(sinkClassName, narClassLoader);
+                clsLoader = narClassLoader;
+            } catch (Exception e) {
+                typArg = getSinkType(sinkClassName, jarClassLoader);
+                clsLoader = jarClassLoader;
+            }
+            typeArg = typArg;
 
 Review comment:
   renamed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message