mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
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:
parent
87faf35ecb
commit
68feb1c35f
@ -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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user