NOTICK - Fix concurrency issue in flaky test (#6674)

* Fix concurrency issue in test; should be fixing flaky test
* Replace 'incrementAndGet' occurences with 'getAndIncrement'
This commit is contained in:
Kyriakos Tharrouniatis 2020-08-28 12:48:20 +01:00 committed by GitHub
parent d08b62da39
commit 90ab495798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -408,24 +408,24 @@ class CordaRPCClientReconnectionTest {
val completedCounter = AtomicInteger(0)
flowHandle0.returnValue.doOnComplete {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle1!!.returnValue.doOnComplete {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle0.returnValue.thenMatch({
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}, {})
flowHandle1.returnValue.thenMatch({
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}, {})
flowHandle0.returnValue.toCompletableFuture().thenApply {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle1.returnValue.toCompletableFuture().thenApply {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
node.stop()
@ -469,13 +469,13 @@ class CordaRPCClientReconnectionTest {
val clientId = UUID.randomUUID().toString()
val flowHandle = rpcOps.startFlowWithClientId(clientId, ::ThrowingFlow)
var erroredCounter = 0
val erroredCounter = AtomicInteger(0)
flowHandle.returnValue.doOnError {
erroredCounter++
erroredCounter.getAndIncrement()
}
flowHandle.returnValue.toCompletableFuture().exceptionally {
erroredCounter++
erroredCounter.getAndIncrement()
}
node.stop()
@ -489,7 +489,7 @@ class CordaRPCClientReconnectionTest {
}
sleep(1000)
assertEquals(2, erroredCounter)
assertEquals(2, erroredCounter.get())
assertThat(rpcOps.reconnectingRPCConnection.isClosed())
}
}