Skip to content

Commit b86af76

Browse files
SougandhSjukzi
authored andcommitted
Fix for VM not connected in JDI tests
1 parent 5c87527 commit b86af76

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

org.eclipse.jdt.debug.jdi.tests/tests/org/eclipse/debug/jdi/tests/AbstractJDITest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.File;
1717
import java.io.IOException;
1818
import java.io.InputStream;
19+
import java.net.ServerSocket;
1920
import java.net.URISyntaxException;
2021
import java.util.Iterator;
2122
import java.util.List;
@@ -1205,7 +1206,16 @@ public void shutDownTarget() {
12051206
// We want subsequent connections to use different ports, unless a
12061207
// VM exec sting is given.
12071208
if (fVmCmd == null) {
1208-
fBackEndPort += 2;
1209+
ServerSocket socket;
1210+
try {
1211+
socket = new ServerSocket(0);
1212+
int availablePort = socket.getLocalPort();
1213+
socket.close(); //Available but always initialized
1214+
fBackEndPort = availablePort;
1215+
} catch (IOException e) {
1216+
fBackEndPort +=2;
1217+
1218+
}
12091219
}
12101220
}
12111221
/**

0 commit comments

Comments
 (0)