mirror of
https://github.com/corda/corda.git
synced 2025-06-20 08:03:53 +00:00
Some integration tests seem to be getting exceptions that suggest the ArtemisMQ session has been closed down already. Looking at the client code it is clear two threads can call stop and interfere with each other. Therefore this fixes the running flag logic.
This commit is contained in:
@ -252,12 +252,16 @@ class ArtemisMessagingClient(directory: Path,
|
|||||||
// Ignore it: this can happen if the server has gone away before we do.
|
// Ignore it: this can happen if the server has gone away before we do.
|
||||||
}
|
}
|
||||||
consumer = null
|
consumer = null
|
||||||
running
|
val prevRunning = running
|
||||||
|
running = false
|
||||||
|
prevRunning
|
||||||
}
|
}
|
||||||
if (running && !executor.isOnThread) {
|
if (running && !executor.isOnThread) {
|
||||||
// Wait for the main loop to notice the consumer has gone and finish up.
|
// Wait for the main loop to notice the consumer has gone and finish up.
|
||||||
shutdownLatch.await()
|
shutdownLatch.await()
|
||||||
}
|
}
|
||||||
|
// Only first caller to gets running true to protect against double stop, which seems to happen in some integration tests.
|
||||||
|
if (running) {
|
||||||
state.locked {
|
state.locked {
|
||||||
producer?.close()
|
producer?.close()
|
||||||
producer = null
|
producer = null
|
||||||
@ -268,6 +272,7 @@ class ArtemisMessagingClient(directory: Path,
|
|||||||
clientFactory = null
|
clientFactory = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun send(message: Message, target: MessageRecipients) {
|
override fun send(message: Message, target: MessageRecipients) {
|
||||||
val queueName = toQueueName(target)
|
val queueName = toQueueName(target)
|
||||||
|
Reference in New Issue
Block a user