mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
[CORDA-2923] Prevent connection threads leaking on reconnect (#5313)
This commit is contained in:
parent
06e709f86b
commit
a204b50f5b
@ -91,10 +91,10 @@ class RPCStabilityTests {
|
|||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
val threadsAfter = waitUntilNumberOfThreadsStable(executor)
|
val threadsAfter = waitUntilNumberOfThreadsStable(executor)
|
||||||
// This is a less than check because threads from other tests may be shutting down while this test is running.
|
val newThreads = threadsAfter.keys.minus(threadsBefore.keys)
|
||||||
// This is therefore a "best effort" check. When this test is run on its own this should be a strict equality.
|
require(newThreads.isEmpty()) {
|
||||||
// In case of failure we output the threads along with their stacktraces to get an idea what was running at a time.
|
"Threads have leaked. New threads created: $newThreads (total before: ${threadsBefore.size}, total after: ${threadsAfter.size})"
|
||||||
require(threadsBefore.keys.size >= threadsAfter.keys.size) { "threadsBefore: $threadsBefore\nthreadsAfter: $threadsAfter" }
|
}
|
||||||
} finally {
|
} finally {
|
||||||
executor.shutdownNow()
|
executor.shutdownNow()
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,8 @@ class ReconnectingCordaRPCOps private constructor(
|
|||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun reconnectOnError(e: Throwable) {
|
fun reconnectOnError(e: Throwable) {
|
||||||
|
// Ensure any resources on this side are cleaned up before building a new connection
|
||||||
|
currentRPCConnection?.close()
|
||||||
currentState = CurrentState.DIED
|
currentState = CurrentState.DIED
|
||||||
//TODO - handle error cases
|
//TODO - handle error cases
|
||||||
log.error("Reconnecting to ${this.nodeHostAndPorts} due to error: ${e.message}")
|
log.error("Reconnecting to ${this.nodeHostAndPorts} due to error: ${e.message}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user