Skip to content

Commit

Permalink
Merge pull request #2951 from mikezhang1234567890/attach
Browse files Browse the repository at this point in the history
Save local connector address in Attach API code
  • Loading branch information
pshipton authored Sep 25, 2018
2 parents b72aff7 + a0f34a7 commit cf45f6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ static Properties getAgentProperties() {
"sun.jvm.flags", //$NON-NLS-1$
"sun.java.command" //$NON-NLS-1$
};
Attachment.saveLocalConnectorAddress();
//If we don't have a local connector address, just continue and get the others
Properties agentProperties = new Properties();
for (String pName: agentPropertyNames) {
String pValue = com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties().getProperty(pName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ private static String startLocalAgent() throws IbmAttachOperationFailedException
throw new IbmAttachOperationFailedException("startLocalManagementAgent error starting agent:" + e.getClass() + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}

String addr = saveLocalConnectorAddress();
if (Objects.isNull(addr)) {
throw new IbmAttachOperationFailedException("startLocalManagementAgent: " + LOCAL_CONNECTOR_ADDRESS + " not defined"); //$NON-NLS-1$ //$NON-NLS-2$
}
return addr;
}

static String saveLocalConnectorAddress() {
Properties systemProperties = com.ibm.oti.vm.VM.getVMLangAccess().internalGetProperties();
String addr;
synchronized (systemProperties) {
Expand All @@ -419,9 +427,9 @@ private static String startLocalAgent() throws IbmAttachOperationFailedException
}
}
if (Objects.isNull(addr)) {
/* startLocalAgent() should have set the property. */
/* property should be set at this point */
IPC.logMessage(LOCAL_CONNECTOR_ADDRESS + " not set"); //$NON-NLS-1$
throw new IbmAttachOperationFailedException("startLocalManagementAgent: " + LOCAL_CONNECTOR_ADDRESS + " not defined"); //$NON-NLS-1$ //$NON-NLS-2$
return null;
}
IPC.logMessage(LOCAL_CONNECTOR_ADDRESS + "=", addr); //$NON-NLS-1$
return addr;
Expand Down

0 comments on commit cf45f6e

Please sign in to comment.