From 5736a8e09fd104f7a94fa214630854ed7e1c41fa Mon Sep 17 00:00:00 2001 From: James Higgs <45565019+JamesHR3@users.noreply.github.com> Date: Tue, 23 Jul 2019 09:05:56 +0100 Subject: [PATCH] [CORDA-2923] Revert previous test fix and workaround other test failures (#5319) * Revert "[CORDA-2923] Prevent connection threads leaking on reconnect (#5313)" This reverts commit a204b50f5b05942208659570742af79cac48328d. * [CORDA-2923] Move CordaRPCClientReconnectionTest to prevent test failures --- .../kotlin/net/corda/client/rpc/RPCStabilityTests.kt | 8 ++++---- .../CordaRPCClientReconnectionTest.kt | 5 ++++- .../corda/client/rpc/internal/ReconnectingCordaRPCOps.kt | 2 -- 3 files changed, 8 insertions(+), 7 deletions(-) rename client/rpc/src/integration-test/kotlin/net/corda/client/{rpc => rpcreconnect}/CordaRPCClientReconnectionTest.kt (97%) diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt index 6397a27458..752d6e7196 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt @@ -91,10 +91,10 @@ class RPCStabilityTests { block() } val threadsAfter = waitUntilNumberOfThreadsStable(executor) - val newThreads = threadsAfter.keys.minus(threadsBefore.keys) - require(newThreads.isEmpty()) { - "Threads have leaked. New threads created: $newThreads (total before: ${threadsBefore.size}, total after: ${threadsAfter.size})" - } + // This is a less than check because threads from other tests may be shutting down while this test is running. + // This is therefore a "best effort" check. When this test is run on its own this should be a strict equality. + // In case of failure we output the threads along with their stacktraces to get an idea what was running at a time. + require(threadsBefore.keys.size >= threadsAfter.keys.size) { "threadsBefore: $threadsBefore\nthreadsAfter: $threadsAfter" } } finally { executor.shutdownNow() } diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientReconnectionTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpcreconnect/CordaRPCClientReconnectionTest.kt similarity index 97% rename from client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientReconnectionTest.kt rename to client/rpc/src/integration-test/kotlin/net/corda/client/rpcreconnect/CordaRPCClientReconnectionTest.kt index 8536f0a8f1..88cc2d1857 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientReconnectionTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpcreconnect/CordaRPCClientReconnectionTest.kt @@ -1,5 +1,8 @@ -package net.corda.client.rpc +package net.corda.client.rpcreconnect +import net.corda.client.rpc.CordaRPCClient +import net.corda.client.rpc.CordaRPCClientConfiguration +import net.corda.client.rpc.CordaRPCClientTest import net.corda.client.rpc.internal.ReconnectingCordaRPCOps import net.corda.core.messaging.startTrackedFlow import net.corda.core.utilities.NetworkHostAndPort diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/ReconnectingCordaRPCOps.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/ReconnectingCordaRPCOps.kt index 2d47dfe640..a4f1f9212c 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/ReconnectingCordaRPCOps.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/ReconnectingCordaRPCOps.kt @@ -157,8 +157,6 @@ class ReconnectingCordaRPCOps private constructor( */ @Synchronized fun reconnectOnError(e: Throwable) { - // Ensure any resources on this side are cleaned up before building a new connection - currentRPCConnection?.close() currentState = CurrentState.DIED //TODO - handle error cases log.error("Reconnecting to ${this.nodeHostAndPorts} due to error: ${e.message}")