mirror of
https://github.com/corda/corda.git
synced 2025-06-14 13:18:18 +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:
@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap
|
|||||||
/**
|
/**
|
||||||
* Cordapp provider and store. For querying CorDapps for their attachment and vice versa.
|
* 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 cordappConfigProvider: CordappConfigProvider,
|
||||||
private val attachmentStorage: AttachmentStorage) : SingletonSerializeAsToken(), CordappProviderInternal {
|
private val attachmentStorage: AttachmentStorage) : SingletonSerializeAsToken(), CordappProviderInternal {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -18,6 +18,7 @@ import net.corda.core.utilities.ProgressTracker
|
|||||||
import net.corda.core.utilities.Try
|
import net.corda.core.utilities.Try
|
||||||
import net.corda.core.utilities.debug
|
import net.corda.core.utilities.debug
|
||||||
import net.corda.core.utilities.trace
|
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.FlowAppAuditEvent
|
||||||
import net.corda.node.services.api.FlowPermissionAuditEvent
|
import net.corda.node.services.api.FlowPermissionAuditEvent
|
||||||
import net.corda.node.services.api.ServiceHubInternal
|
import net.corda.node.services.api.ServiceHubInternal
|
||||||
@ -219,6 +220,11 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
|||||||
logger.debug { "Calling flow: $logic" }
|
logger.debug { "Calling flow: $logic" }
|
||||||
val startTime = System.nanoTime()
|
val startTime = System.nanoTime()
|
||||||
val resultOrError = try {
|
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()
|
val result = logic.call()
|
||||||
suspend(FlowIORequest.WaitForSessionConfirmations, maySkipCheckpoint = true)
|
suspend(FlowIORequest.WaitForSessionConfirmations, maySkipCheckpoint = true)
|
||||||
Try.Success(result)
|
Try.Success(result)
|
||||||
|
Reference in New Issue
Block a user