CORDA-3932 Correct race condition in FlowVersioningTest (#6536)

Correct race condition in FlowVersioningTest where the last message is read (and the session close can be triggered)
before one side has finished reading metadata from the session.
This commit is contained in:
Ross Nicoll 2020-07-31 08:32:20 +01:00 committed by GitHub
parent 87faf35ecb
commit 68feb1c35f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,13 +33,19 @@ class FlowVersioningTest : NodeBasedTest() {
private class PretendInitiatingCoreFlow(val initiatedParty: Party) : FlowLogic<Pair<Int, Int>>() { private class PretendInitiatingCoreFlow(val initiatedParty: Party) : FlowLogic<Pair<Int, Int>>() {
@Suspendable @Suspendable
override fun call(): Pair<Int, Int> { override fun call(): Pair<Int, Int> {
// Execute receive() outside of the Pair constructor to avoid Kotlin/Quasar instrumentation bug.
val session = initiateFlow(initiatedParty) val session = initiateFlow(initiatedParty)
val alicePlatformVersionAccordingToBob = session.receive<Int>().unwrap { it } return try {
return Pair( // Get counterparty flow info before we receive Alice's data, to ensure the flow is still open
alicePlatformVersionAccordingToBob, val bobPlatformVersionAccordingToAlice = session.getCounterpartyFlowInfo().flowVersion
session.getCounterpartyFlowInfo().flowVersion // Execute receive() outside of the Pair constructor to avoid Kotlin/Quasar instrumentation bug.
) val alicePlatformVersionAccordingToBob = session.receive<Int>().unwrap { it }
Pair(
alicePlatformVersionAccordingToBob,
bobPlatformVersionAccordingToAlice
)
} finally {
session.close()
}
} }
} }