8306806: JMX agent with JDP enabled won't start when PerfData is disabled

Reviewed-by: dholmes, cjplummer
This commit is contained in:
Kevin Walls 2023-05-16 08:28:53 +00:00
parent c2ef302468
commit 0790f704fd

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,6 +35,7 @@ import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.nio.BufferUnderflowException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
@ -499,12 +500,17 @@ public class Agent {
}
// Get service URL to broadcast it
Map<String,String> remoteProps = ConnectorAddressLink.importRemoteFrom(0);
String jmxUrlStr = remoteProps.get("sun.management.JMXConnectorServer.0.remoteAddress");
String instanceName = props.getProperty("com.sun.management.jdp.name");
JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr);
Map<String,String> remoteProps = null;
try {
remoteProps = ConnectorAddressLink.importRemoteFrom(0);
} catch (BufferUnderflowException bue) {
warning(AGENT_EXCEPTION, "JDP not starting, PerfData not available");
}
if (remoteProps != null) {
String jmxUrlStr = remoteProps.get("sun.management.JMXConnectorServer.0.remoteAddress");
String instanceName = props.getProperty("com.sun.management.jdp.name");
JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr);
}
}
}