From 99faeaf667bf6041f31bc49c3c44b6f23d3f391c Mon Sep 17 00:00:00 2001 From: Adel El-Beik Date: Wed, 13 Mar 2024 11:01:41 +0000 Subject: [PATCH] ENT-11620: Set the thread context class loader so all fibres involved in a flow has the thread context class loader set to the app class loader. --- .../corda/node/services/statemachine/FlowStateMachineImpl.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt index 551023cd81..56a983cf3d 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt @@ -320,6 +320,9 @@ class FlowStateMachineImpl(override val id: StateMachineRunId, } private fun openThreadLocalWormhole() { + // This sets the Cordapp classloader on the contextClassLoader of the current thread. + // Needed because in previous versions of the finance app we used Thread.contextClassLoader to resolve services defined in cordapps. + Thread.currentThread().contextClassLoader = (serviceHub.cordappProvider as CordappProviderImpl).cordappLoader.appClassLoader val threadLocal = transientValues.database.hikariPoolThreadLocal if (threadLocal != null) { val valueFromThread = swappedOutThreadLocalValue(threadLocal)