mirror of
https://github.com/corda/corda.git
synced 2025-04-07 19:34:41 +00:00
CORDA-2344 Set contextClassloader on the flow threads. (#4437)
* CORDA-2344 Set contextClassloader on the flow threads. * CORDA-2344 Set contextClassloader on the flow threads.
This commit is contained in:
parent
3efbad34cc
commit
3c13c07c09
@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
/**
|
||||
* Cordapp provider and store. For querying CorDapps for their attachment and vice versa.
|
||||
*/
|
||||
open class CordappProviderImpl(private val cordappLoader: CordappLoader,
|
||||
open class CordappProviderImpl(val cordappLoader: CordappLoader,
|
||||
private val cordappConfigProvider: CordappConfigProvider,
|
||||
private val attachmentStorage: AttachmentStorage) : SingletonSerializeAsToken(), CordappProviderInternal {
|
||||
companion object {
|
||||
|
@ -18,6 +18,7 @@ import net.corda.core.utilities.ProgressTracker
|
||||
import net.corda.core.utilities.Try
|
||||
import net.corda.core.utilities.debug
|
||||
import net.corda.core.utilities.trace
|
||||
import net.corda.node.internal.cordapp.CordappProviderImpl
|
||||
import net.corda.node.services.api.FlowAppAuditEvent
|
||||
import net.corda.node.services.api.FlowPermissionAuditEvent
|
||||
import net.corda.node.services.api.ServiceHubInternal
|
||||
@ -219,6 +220,11 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
logger.debug { "Calling flow: $logic" }
|
||||
val startTime = System.nanoTime()
|
||||
val resultOrError = try {
|
||||
|
||||
// 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 result = logic.call()
|
||||
suspend(FlowIORequest.WaitForSessionConfirmations, maySkipCheckpoint = true)
|
||||
Try.Success(result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user