8057746: Cannot handle JdpException in JMX agent initialization.
Summary: Add special handling for JdpException
Reviewed-by: jbachorik
Contributed-by: Yasumasa Suenaga <yasuenag@gmail.com>
--- a/jdk/src/java.management/share/classes/sun/management/Agent.java Thu Sep 11 15:51:46 2014 +0100
+++ b/jdk/src/java.management/share/classes/sun/management/Agent.java Thu Sep 11 08:01:33 2014 -0700
@@ -210,6 +210,8 @@
} else {
throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
}
+ } catch (JdpException e) {
+ error(e);
} catch (AgentConfigurationError err) {
error(err.getError(), err.getParams());
}
@@ -273,7 +275,7 @@
}
private static void startDiscoveryService(Properties props)
- throws IOException {
+ throws IOException, JdpException {
// Start discovery service if requested
String discoveryPort = props.getProperty("com.sun.management.jdp.port");
String discoveryAddress = props.getProperty("com.sun.management.jdp.address");
@@ -291,7 +293,7 @@
try{
shouldStart = Boolean.parseBoolean(discoveryShouldStart);
} catch (NumberFormatException e) {
- throw new AgentConfigurationError("Couldn't parse autodiscovery argument");
+ throw new AgentConfigurationError(AGENT_EXCEPTION, "Couldn't parse autodiscovery argument");
}
}
@@ -302,7 +304,7 @@
address = (discoveryAddress == null) ?
InetAddress.getByName(JDP_DEFAULT_ADDRESS) : InetAddress.getByName(discoveryAddress);
} catch (UnknownHostException e) {
- throw new AgentConfigurationError("Unable to broadcast to requested address", e);
+ throw new AgentConfigurationError(AGENT_EXCEPTION, e, "Unable to broadcast to requested address");
}
int port = JDP_DEFAULT_PORT;
@@ -310,7 +312,7 @@
try {
port = Integer.parseInt(discoveryPort);
} catch (NumberFormatException e) {
- throw new AgentConfigurationError("Couldn't parse JDP port argument");
+ throw new AgentConfigurationError(AGENT_EXCEPTION, "Couldn't parse JDP port argument");
}
}
@@ -330,12 +332,7 @@
String instanceName = props.getProperty("com.sun.management.jdp.name");
- try{
- JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr);
- }
- catch(JdpException e){
- throw new AgentConfigurationError("Couldn't start JDP service", e);
- }
+ JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr);
}
}