Skip to content

Commit

Permalink
GEODE-3: remove dependency on management-agent.jar which is not inclu…
Browse files Browse the repository at this point in the history
…ded in java9 and later (#2478)

* this fix *launcher*IntegrationTests when running with java9
  • Loading branch information
jinmeiliao committed Sep 18, 2018
1 parent 3e28711 commit 238c73a
Showing 1 changed file with 3 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.apache.commons.lang.Validate.isTrue;
import static org.apache.commons.lang.Validate.notNull;

import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
Expand All @@ -33,8 +32,6 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

Expand Down Expand Up @@ -233,32 +230,9 @@ private JMXServiceURL getJMXServiceURL() throws AttachNotSupportedException, IOE
connectorAddress = agentProps.getProperty(PROPERTY_LOCAL_CONNECTOR_ADDRESS);

if (connectorAddress == null) {
// need to load the management-agent and get the address

String javaHome = vm.getSystemProperties().getProperty("java.home");

// assume java.home is JDK and look in JRE for agent
String managementAgentPath = javaHome + File.separator + "jre" + File.separator + "lib"
+ File.separator + "management-agent.jar";
File managementAgent = new File(managementAgentPath);
if (!managementAgent.exists()) {
// assume java.home is JRE and look in lib for agent
managementAgentPath =
javaHome + File.separator + "lib" + File.separator + "management-agent.jar";
managementAgent = new File(managementAgentPath);
if (!managementAgent.exists()) {
throw new IOException("JDK management agent not found");
}
}

// attempt to load the management agent
managementAgentPath = managementAgent.getCanonicalPath();
try {
vm.loadAgent(managementAgentPath, "com.sun.management.jmxremote");
} catch (AgentLoadException | AgentInitializationException e) {
throw new IOException(e);
}

// make sure the local management agent is started and this will ensure
// localConnectorAddress is present in the agent properties.
vm.startLocalManagementAgent();
// get the connector address
agentProps = vm.getAgentProperties();
connectorAddress = agentProps.getProperty(PROPERTY_LOCAL_CONNECTOR_ADDRESS);
Expand Down

0 comments on commit 238c73a

Please sign in to comment.