Skip to content

Commit

Permalink
Merge pull request #2208 from jplag/feature/wsl-networking-fix
Browse files Browse the repository at this point in the history
Ensure that IPv4 network stack is preferred.
  • Loading branch information
tsaglam authored Feb 26, 2025
2 parents 0ddf389 + e29dbea commit 719cb3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/src/main/java/de/jplag/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ private String getWritableFileName() throws CliException {
}

public static void main(String[] args) {
// This needs to be executed before any other code, as it changes the default behavior of the JVM for network
// connections.
System.setProperty("java.net.preferIPv4Stack", "true");

CLI cli = new CLI(args);
if (cli.executeCliAndHandleErrors()) {
System.exit(1);
Expand Down
2 changes: 0 additions & 2 deletions cli/src/main/java/de/jplag/cli/server/ReportViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public int start() throws IOException {
throw new IllegalStateException("Server already started");
}

System.setProperty("java.net.preferIPv4Stack", "true");

int currentPort = this.port;
int remainingLookups = MAX_PORT_LOOKUPS;
BindException lastException = new BindException("Could not create server. Probably due to no free port found.");
Expand Down

0 comments on commit 719cb3c

Please sign in to comment.