Skip to content

Commit

Permalink
Fix for VM not connected in JDI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SougandhS authored and jukzi committed Sep 26, 2024
1 parent 5c87527 commit b86af76
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

}
}
}
/**
Expand Down

0 comments on commit b86af76

Please sign in to comment.