From d2568b9077a821d1f5fb591d7997a8f88a7912ae Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Mon, 24 Feb 2020 09:36:16 +0000 Subject: [PATCH] NOTICK: Fix potential infinite loop when a SecurityManager is installed. (#5993) --- .../net/corda/testing/driver/SharedMemoryIncremental.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/node-driver/src/main/java/net/corda/testing/driver/SharedMemoryIncremental.java b/testing/node-driver/src/main/java/net/corda/testing/driver/SharedMemoryIncremental.java index fe0d957499..a3ca4e8aef 100644 --- a/testing/node-driver/src/main/java/net/corda/testing/driver/SharedMemoryIncremental.java +++ b/testing/node-driver/src/main/java/net/corda/testing/driver/SharedMemoryIncremental.java @@ -86,7 +86,10 @@ class SharedMemoryIncremental extends PortAllocation { private boolean isLocalPortAvailable(Long portToTest) { try (ServerSocket serverSocket = new ServerSocket(Math.toIntExact(portToTest))) { - } catch (Exception e) { + } catch (IOException e) { + // Don't catch anything other than IOException here in case we + // accidentally create an infinite loop. For example, installing + // a SecurityManager could throw AccessControlException. return false; } return true;