From b86af76897c08ff5d7ca0ce330c07ffb05980603 Mon Sep 17 00:00:00 2001 From: sougandhs Date: Wed, 25 Sep 2024 20:00:27 +0530 Subject: [PATCH] Fix for VM not connected in JDI tests --- .../org/eclipse/debug/jdi/tests/AbstractJDITest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.debug.jdi.tests/tests/org/eclipse/debug/jdi/tests/AbstractJDITest.java b/org.eclipse.jdt.debug.jdi.tests/tests/org/eclipse/debug/jdi/tests/AbstractJDITest.java index fc5ab70450..bef7e5ebd1 100644 --- a/org.eclipse.jdt.debug.jdi.tests/tests/org/eclipse/debug/jdi/tests/AbstractJDITest.java +++ b/org.eclipse.jdt.debug.jdi.tests/tests/org/eclipse/debug/jdi/tests/AbstractJDITest.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.ServerSocket; import java.net.URISyntaxException; import java.util.Iterator; import java.util.List; @@ -1205,7 +1206,16 @@ public void shutDownTarget() { // We want subsequent connections to use different ports, unless a // VM exec sting is given. if (fVmCmd == null) { - fBackEndPort += 2; + ServerSocket socket; + try { + socket = new ServerSocket(0); + int availablePort = socket.getLocalPort(); + socket.close(); //Available but always initialized + fBackEndPort = availablePort; + } catch (IOException e) { + fBackEndPort +=2; + + } } } /**