diff --git a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java index 175c736e420..d80f36b6793 100644 --- a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java +++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java @@ -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 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 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); + } } }