Source:
<code>public JmxAgent9(JmxConfig config) throws IOException { Integer existingRegistryPort = Integer.getInteger(JMX_REGISTRY_PORT); Integer existingServerPort = Integer.getInteger(JMX_SERVER_PORT); <START> if ((existingRegistryPort != null) && (config.getRmiRegistryPort() != null) && <END> (!existingRegistryPort.equals(config.getRmiRegistryPort()))) { throw new RuntimeException(format("System property [%s] value [%s] does match configured RMI registry port [%s]", JMX_REGISTRY_PORT, existingRegistryPort, config.getRmiRegistryPort())); } if ((existingServerPort != null) && (config.getRmiServerPort() != null) && (!existingServerPort.equals(config.getRmiServerPort()))) { throw new RuntimeException(format("System property [%s] value [%s] does match configured RMI server port [%s]", JMX_SERVER_PORT, existingServerPort, config.getRmiServerPort())); } int registryPort; if (existingRegistryPort != null) { registryPort = existingRegistryPort; } else if (config.getRmiRegistryPort() == null) { registryPort = NetUtils.findUnusedPort(); } else { registryPort = config.getRmiRegistryPort(); } int serverPort = 0; if (existingServerPort != null) { serverPort = existingServerPort; } else if (config.getRmiServerPort() != null) { serverPort = config.getRmiServerPort(); } JMXServiceURL jmxUrl = new JMXServiceURL("rmi", null, registryPort); HostAndPort address = HostAndPort.fromParts(jmxUrl.getHost(), jmxUrl.getPort()); if (existingRegistryPort == null) { startJmxAgent(registryPort, serverPort); log.info("JMX agent started and listening on %s", address); } else { log.info("JMX agent already running and listening on %s", address); } this.url = new JMXServiceURL(format("service:jmx:rmi:/ }</code><technical_language>parentheses this harder read, IMO</technical_language>

Target:
public JmxAgent9(JmxConfig config) throws IOException { int registryPort; Integer existingRegistryPort = Integer.getInteger(JMX_REGISTRY_PORT); Integer configuredRegistryPort = config.getRmiRegistryPort(); if (existingRegistryPort != null) { if (configuredRegistryPort != null && !existingRegistryPort.equals(configuredRegistryPort)) { throw new RuntimeException(format( "System property '%s=%s' does match configured RMI registry port %s", JMX_REGISTRY_PORT, existingRegistryPort, configuredRegistryPort)); } if (existingRegistryPort.equals(0)) { throw new RuntimeException(format( "JMX agent already running on an unknown port (system property '%s' is 0)", JMX_REGISTRY_PORT)); } registryPort = existingRegistryPort; } else if (configuredRegistryPort != null) { registryPort = configuredRegistryPort; } else { registryPort = NetUtils.findUnusedPort(); } int serverPort = 0; Integer existingServerPort = Integer.getInteger(JMX_SERVER_PORT); Integer configuredServerPort = config.getRmiServerPort(); if (!Objects.equals(existingServerPort, configuredServerPort)) { throw new RuntimeException(format( "System property '%s=%s' does match configured RMI server port %s", JMX_SERVER_PORT, existingServerPort, configuredServerPort)); } if (configuredServerPort != null && !configuredServerPort.equals(0)) { serverPort = configuredServerPort; } JMXServiceURL jmxUrl = new JMXServiceURL("rmi", null, registryPort); HostAndPort address = HostAndPort.fromParts(jmxUrl.getHost(), jmxUrl.getPort()); if (existingRegistryPort == null) { startJmxAgent(registryPort, serverPort); log.info("JMX agent started and listening on %s", address); } else { log.info("JMX agent already running and listening on %s", address); } this.url = new JMXServiceURL(format("service:jmx:rmi:/ }