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.
This commit is contained in:
Dan Newton 2020-01-24 16:34:29 +00:00 committed by Rick Parker
parent 4f1777adb4
commit ecc3b5e330
2 changed files with 5 additions and 5 deletions

View File

@ -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<List<StateMachineInfo>, StateMachineUpdate> {

View File

@ -102,7 +102,7 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging,
* statemachine.
*/
val flowPatients = HashMap<StateMachineRunId, FlowMedicalHistory>()
val treatableSessionInits = HashMap<UUID, InternalSessionInitRecord>()
val treatableSessionInits = HashMap<StateMachineRunId, InternalSessionInitRecord>()
val recordsPublisher = PublishSubject.create<MedicalRecord>()
})
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,