Skip to content

Commit

Permalink
Take debugHost into account when checking debug port
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Nov 9, 2021
1 parent 3c17fdf commit 454407e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.net.InetAddress;
import java.net.Socket;
import java.net.URI;
import java.net.UnknownHostException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -354,7 +355,7 @@ protected void prepare() throws Exception {
// make sure the debug port is not used, we don't want to just fail if something else is using it
// we don't check this on restarts, as the previous process is still running
if (debugPortOk == null) {
try (Socket socket = new Socket(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), port)) {
try (Socket socket = new Socket(getInetAddress(debugHost), port)) {
error("Port " + port + " in use, not starting in debug mode");
debugPortOk = false;
} catch (IOException e) {
Expand Down Expand Up @@ -456,6 +457,13 @@ protected void prepare() throws Exception {
}
}

private InetAddress getInetAddress(String host) throws UnknownHostException {
if (host.equals("localhost")) {
return InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 });
}
return InetAddress.getByName(host);
}

public Collection<Path> watchedBuildFiles() {
return buildFiles;
}
Expand Down

0 comments on commit 454407e

Please sign in to comment.