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 (apache#22501)

(cherry picked from commit d067efc)
(cherry picked from commit d23c77b)
freeznet authored and srinath-ctds committed May 16, 2024
1 parent d9dc63c commit 87c4df3
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -282,9 +282,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 {

0 comments on commit 87c4df3

Please sign in to comment.