freeznet commented on code in PR #22501:
URL: https://github.com/apache/pulsar/pull/22501#discussion_r1566619911


##########
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java:
##########
@@ -283,13 +283,17 @@ ContextImpl setupContext() throws PulsarClientException {
         Logger instanceLog = LoggerFactory.getILoggerFactory().getLogger(
                 "function-" + instanceConfig.getFunctionDetails().getName());
         Thread currentThread = Thread.currentThread();
+        ClassLoader clsLoader = currentThread.getContextClassLoader();
         Consumer<Throwable> fatalHandler = throwable -> {
             this.deathException = throwable;
             currentThread.interrupt();
         };
-        return new ContextImpl(instanceConfig, instanceLog, client, 
secretsProvider,
-                collectorRegistry, metricsLabels, this.componentType, 
this.stats, stateManager,
-                pulsarAdmin, clientBuilder, fatalHandler);
+        Thread.currentThread().setContextClassLoader(functionClassLoader);
+        ContextImpl contextImpl = new ContextImpl(instanceConfig, instanceLog, 
client, secretsProvider,
+            collectorRegistry, metricsLabels, this.componentType, this.stats, 
stateManager,
+            pulsarAdmin, clientBuilder, fatalHandler);
+        Thread.currentThread().setContextClassLoader(clsLoader);
+        return contextImpl;

Review Comment:
   thanks, addressed in the latest commit



-- 
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-unsubscr...@pulsar.apache.org

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

Reply via email to