< prev index next >
test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java
Print this page
@ rev 11405 : 8146015: JMXInterfaceBindingTest is failing intermittently for IPv6 addresses
| Reviewed-by: dfuchs, sspitsyn
o rev 11403 : 6425769: Allow specifying an address to bind JMX remote connector
| Reviewed-by: jbachorik, dfuchs
*** 128,147 ****
}
}
private static class JMXConnectorThread extends Thread {
! private final InetAddress addr;
private final int jmxPort;
private final int rmiPort;
private final boolean useSSL;
private final CountDownLatch latch;
private boolean failed;
private boolean jmxConnectWorked;
private boolean rmiConnectWorked;
! private JMXConnectorThread(InetAddress addr,
int jmxPort,
int rmiPort,
boolean useSSL,
CountDownLatch latch) {
this.addr = addr;
--- 128,147 ----
}
}
private static class JMXConnectorThread extends Thread {
! private final String addr;
private final int jmxPort;
private final int rmiPort;
private final boolean useSSL;
private final CountDownLatch latch;
private boolean failed;
private boolean jmxConnectWorked;
private boolean rmiConnectWorked;
! private JMXConnectorThread(String addr,
int jmxPort,
int rmiPort,
boolean useSSL,
CountDownLatch latch) {
this.addr = addr;
*** 161,175 ****
}
private void connect() throws IOException {
System.out.println(
"JMXConnectorThread: Attempting JMX connection on: "
! + addr.getHostAddress() + " on port " + jmxPort);
JMXServiceURL url;
try {
url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
! + addr.getHostAddress() + ":" + jmxPort + "/jmxrmi");
} catch (MalformedURLException e) {
throw new RuntimeException("Test failed.", e);
}
Map<String, Object> env = new HashMap<>();
if (useSSL) {
--- 161,175 ----
}
private void connect() throws IOException {
System.out.println(
"JMXConnectorThread: Attempting JMX connection on: "
! + addr + " on port " + jmxPort);
JMXServiceURL url;
try {
url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
! + addr + ":" + jmxPort + "/jmxrmi");
} catch (MalformedURLException e) {
throw new RuntimeException("Test failed.", e);
}
Map<String, Object> env = new HashMap<>();
if (useSSL) {
*** 198,208 ****
if (useSSL) {
((SSLSocket)rmiConnection).startHandshake();
}
System.out.println(
"JMXConnectorThread: connection to rmi socket worked host/port = "
! + addr.getHostAddress() + "/" + rmiPort);
rmiConnectWorked = true;
// Closing the channel without sending any data will cause an
// java.io.EOFException on the server endpoint. We don't care about this
// though, since we only want to test if we can connect.
rmiConnection.close();
--- 198,208 ----
if (useSSL) {
((SSLSocket)rmiConnection).startHandshake();
}
System.out.println(
"JMXConnectorThread: connection to rmi socket worked host/port = "
! + addr + "/" + rmiPort);
rmiConnectWorked = true;
// Closing the channel without sending any data will cause an
// java.io.EOFException on the server endpoint. We don't care about this
// though, since we only want to test if we can connect.
rmiConnection.close();
*** 222,241 ****
}
private static class MainThread extends Thread {
private static final int WAIT_FOR_JMX_AGENT_TIMEOUT_MS = 500;
! private final InetAddress bindAddress;
private final int jmxPort;
private final int rmiPort;
private final boolean useSSL;
private boolean terminated = false;
private boolean jmxAgentStarted = false;
private Exception excptn;
private MainThread(InetAddress bindAddress, int jmxPort, int rmiPort, boolean useSSL) {
! this.bindAddress = bindAddress;
this.jmxPort = jmxPort;
this.rmiPort = rmiPort;
this.useSSL = useSSL;
}
--- 222,241 ----
}
private static class MainThread extends Thread {
private static final int WAIT_FOR_JMX_AGENT_TIMEOUT_MS = 500;
! private final String addr;
private final int jmxPort;
private final int rmiPort;
private final boolean useSSL;
private boolean terminated = false;
private boolean jmxAgentStarted = false;
private Exception excptn;
private MainThread(InetAddress bindAddress, int jmxPort, int rmiPort, boolean useSSL) {
! this.addr = wrapAddress(bindAddress.getHostAddress());
this.jmxPort = jmxPort;
this.rmiPort = rmiPort;
this.useSSL = useSSL;
}
*** 257,267 ****
}
private void waitUntilReadyForConnections() {
CountDownLatch latch = new CountDownLatch(1);
JMXConnectorThread connectionTester = new JMXConnectorThread(
! bindAddress, jmxPort, rmiPort, useSSL, latch);
connectionTester.start();
boolean expired = false;
try {
expired = !latch.await(WAIT_FOR_JMX_AGENT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
System.out.println(
--- 257,267 ----
}
private void waitUntilReadyForConnections() {
CountDownLatch latch = new CountDownLatch(1);
JMXConnectorThread connectionTester = new JMXConnectorThread(
! addr, jmxPort, rmiPort, useSSL, latch);
connectionTester.start();
boolean expired = false;
try {
expired = !latch.await(WAIT_FOR_JMX_AGENT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
System.out.println(
*** 292,297 ****
--- 292,306 ----
private void rethrowException() throws RuntimeException {
throw new RuntimeException(excptn);
}
}
+ /**
+ * Will wrap IPv6 address in '[]'
+ */
+ static String wrapAddress(String address) {
+ if (address.contains(":")) {
+ return "[" + address + "]";
+ }
+ return address;
+ }
}
< prev index next >