Skip to content

Commit

Permalink
8030616: sun/management/jmxremote/bootstrap/RmiBootstrapTest fails in…
Browse files Browse the repository at this point in the history
…termittently with cannot find a free port

Reviewed-by: sspitsyn, msheppar
  • Loading branch information
jaikiran committed Oct 21, 2022
1 parent b35922b commit 8b010e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.BindException;
import java.net.InetAddress;
import java.nio.file.Path;
import java.rmi.server.ExportException;

Expand Down Expand Up @@ -521,6 +522,7 @@ public void testCommunication(JMXServiceURL url) throws IOException {
**/
private String testConfiguration(File file) throws IOException, InterruptedException {

final String loopback = InetAddress.getLoopbackAddress().getHostAddress();
for (int i = 0; i < MAX_GET_FREE_PORT_TRIES; i++) {
try {
int port = jdk.test.lib.Utils.getFreePort();
Expand All @@ -536,9 +538,12 @@ private String testConfiguration(File file) throws IOException, InterruptedExcep
final String config = (path == null) ? "Default config file" : path;

System.out.println("***");
System.out.println("*** Testing configuration (port=" + port + "): " + path);
System.out.println("*** Testing configuration (host= " + loopback
+ " port=" + port + "): " + path);
System.out.println("***");

System.setProperty("com.sun.management.jmxremote.host", loopback);
System.setProperty("java.rmi.server.hostname", loopback);
System.setProperty("com.sun.management.jmxremote.port", Integer.toString(port));
if (path != null) {
System.setProperty("com.sun.management.config.file", path);
Expand Down
2 changes: 1 addition & 1 deletion test/lib/jdk/test/lib/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public static List<InetAddress> getAddressesWithSymbolicAndNumericScopes() {
}

/**
* Returns the free port on the local host.
* Returns the free port on the loopback address.
*
* @return The port number
* @throws IOException if an I/O error occurs when opening the socket
Expand Down

1 comment on commit 8b010e0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.