src/java.management/share/classes/sun/management/Agent.java

Print this page

        

@@ -208,10 +208,12 @@
 
                 startDiscoveryService(configProps);
             } else {
                 throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
             }
+        } catch (JdpException e) {
+            error(e);
         } catch (AgentConfigurationError err) {
             error(err.getError(), err.getParams());
         }
     }
 

@@ -271,11 +273,11 @@
             error(e);
         }
     }
 
     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");
         String discoveryShouldStart = props.getProperty("com.sun.management.jmxremote.autodiscovery");
 

@@ -289,30 +291,30 @@
         }
         else{
             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");
             }
         }
 
         if (shouldStart) {
             // port and address are required arguments and have no default values
             InetAddress address;
             try {
                 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;
             if (discoveryPort != null) {
                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");
                }
             }
 
             // Rebuilding service URL to broadcast it
             String jmxremotePort = props.getProperty(JMXREMOTE_PORT);

@@ -328,17 +330,12 @@
                     : String.format(
                     "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", hostname, jmxremotePort);
 
             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);
-            }
-        }
     }
 
     public static Properties loadManagementProperties() {
         Properties props = new Properties();