From ecc3b5e33004e5a0192a8f001c86a2511c8bd27a Mon Sep 17 00:00:00 2001 From: Dan Newton Date: Fri, 24 Jan 2020 16:34:29 +0000 Subject: [PATCH] CORDA-3554 Use `flowId` from `ExternalMessageEvent` when failing to init sessions (#5890) Use `flowId` from `ExternalMessageEvent` when failing to init sessions instead of generating a new random UUID. The a `flowId` is generated and stored inside the event after the state machine work that done previously. --- .../kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt | 2 +- .../node/services/statemachine/StaffedFlowHospital.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt index 5405964ee1..402d6ee368 100644 --- a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt +++ b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt @@ -167,7 +167,7 @@ internal class CordaRPCOpsImpl( return snapshot } - override fun killFlow(id: StateMachineRunId): Boolean = if (smm.killFlow(id)) true else smm.flowHospital.dropSessionInit(id.uuid) + override fun killFlow(id: StateMachineRunId): Boolean = if (smm.killFlow(id)) true else smm.flowHospital.dropSessionInit(id) override fun stateMachinesFeed(): DataFeed, StateMachineUpdate> { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt index 623ea0bd20..dbaeb0e586 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt @@ -102,7 +102,7 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging, * statemachine. */ val flowPatients = HashMap() - val treatableSessionInits = HashMap() + val treatableSessionInits = HashMap() val recordsPublisher = PublishSubject.create() }) private val secureRandom = newSecureRandom() @@ -111,8 +111,8 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging, * The node was unable to initiate the [InitialSessionMessage] from [sender]. */ fun sessionInitErrored(sessionMessage: InitialSessionMessage, sender: Party, event: ExternalEvent.ExternalMessageEvent, error: Throwable) { + val id = event.flowId val time = clock.instant() - val id = UUID.randomUUID() val outcome = if (error is SessionRejectException.UnknownClass) { // We probably don't have the CorDapp installed so let's pause the message in the hopes that the CorDapp is // installed on restart, at which point the message will be able proceed as normal. If not then it will need @@ -154,7 +154,7 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging, * to send back the relevant session error to the initiator party and acknowledge its receipt from the message broker * so that it never gets redelivered. */ - fun dropSessionInit(id: UUID): Boolean { + fun dropSessionInit(id: StateMachineRunId): Boolean { val (sessionMessage, event, publicRecord) = mutex.locked { treatableSessionInits.remove(id) ?: return false } @@ -339,7 +339,7 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging, override val outcome: Outcome) : MedicalRecord() /** Medical record for a session initiation that was unsuccessful. */ - data class SessionInit(val id: UUID, + data class SessionInit(val id: StateMachineRunId, override val time: Instant, override val outcome: Outcome, val initiatorFlowClassName: String,