You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/07/12 08:41:46 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #10922: Explicitly set the Pulsar function classloader

eolivelli commented on a change in pull request #10922:
URL: https://github.com/apache/pulsar/pull/10922#discussion_r667730431



##########
File path: pulsar-client-api/src/main/java/org/apache/pulsar/client/internal/ReflectionUtils.java
##########
@@ -47,23 +62,17 @@
     }
 
     @SuppressWarnings("unchecked")
-    static <T> Class<T> newClassInstance(String className) {
-        try {
+    public static <T> Class<T> newClassInstance(String className) {
+        return (Class<T>) loadedClasses.computeIfAbsent(className, name -> {

Review comment:
       why do we need this cache ?
   the JVM is very good in dealing with Class.forName.
   

##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
##########
@@ -168,6 +169,7 @@ public JavaInstanceRunnable(InstanceConfig instanceConfig,
         this.collectorRegistry = collectorRegistry;
 
         this.instanceClassLoader = Thread.currentThread().getContextClassLoader();
+        ReflectionUtils.setClassLoader(instanceClassLoader);

Review comment:
       I believe that this will not fix the problems we have.
   
   Therefore I discovered this other bad problem about using AVRO (and JsonNode...)
   https://github.com/apache/pulsar/issues/11274
   
   basically now (2.8.0) you cannot use the org.apache.avro...GenericRecord returned by GenericRecord.getNativeObject()
   
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org