Skip to content

Commit

Permalink
[fix][fn]make sure the classloader for ContextImpl is `functionClassL…
Browse files Browse the repository at this point in the history
…oader` in different runtimes (#22501)

(cherry picked from commit d067efc)
  • Loading branch information
freeznet authored and lhotari committed May 14, 2024
1 parent db43414 commit d23c77b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,15 @@ private synchronized void setup() throws Exception {
ContextImpl setupContext() throws PulsarClientException {
Logger instanceLog = LoggerFactory.getILoggerFactory().getLogger(
"function-" + instanceConfig.getFunctionDetails().getName());
return new ContextImpl(instanceConfig, instanceLog, client, secretsProvider,
ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(functionClassLoader);
return new ContextImpl(instanceConfig, instanceLog, client, secretsProvider,
collectorRegistry, metricsLabels, this.componentType, this.stats, stateManager,
pulsarAdmin, clientBuilder);
} finally {
Thread.currentThread().setContextClassLoader(clsLoader);
}
}

public interface AsyncResultConsumer {
Expand Down

0 comments on commit d23c77b

Please sign in to comment.