JDK-8234484 : Add ability to configure third port for remote JMX
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 8u231,15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-11-14
  • Updated: 2022-12-19
  • Resolved: 2020-01-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15 Other
15 b07Fixed openjdk8u372Fixed
Related Reports
CSR :  
Sub Tasks
JDK-8248353 :  
Description
A DESCRIPTION OF THE PROBLEM :
It is possible to configure two of the three ports for JMX with com.sun.management.jmxremote.port and com.sun.management.jmxremote.rmi.port. However, there is no way to configure the third port. This can cause problems if the randomly assigned port conflicts with another service that has not yet acquired its port.



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk8u-dev/pull/213 Date: 2022-12-16 17:39:35 +0000
16-12-2022

Corresponding CSR: https://bugs.openjdk.java.net/browse/JDK-8237631
22-01-2020

[~alanb] I am preparing a retroactive CSR. Will reply the reviewing thread when finished. Thanks
22-01-2020

[~lcable] This change adds a new supported interface so a CSR should be created too.
22-01-2020

added release-note label to indicate need for this addition to be mentioned in the release notes for 15...
22-01-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/dff4792e3206 User: fyang Date: 2020-01-21 15:36:29 +0000
21-01-2020

Reviewing thread: https://mail.openjdk.java.net/pipermail/jmx-dev/2020-January/001183.html
08-01-2020

Hi Larry, Thanks for checking that patch. I will prepare a webrev and send it to: https://mail.openjdk.java.net/pipermail/jmx-dev/
07-01-2020

[~fyang] this looks good to me! thanks for developing this solution.
06-01-2020

Hi Larry, We witnessed the same problem. Currently, we have a patch which provides a way to configure the third port on the command line. Is that a good way to go? Patch: diff -r bb0a7975b31d src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java --- a/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java Tue Dec 24 09:38:41 2019 +0000 +++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java Fri Dec 27 17:44:58 2019 +0000 @@ -55,6 +55,8 @@ "agent.err.invalid.jmxremote.port"; public static final String INVALID_JMXREMOTE_RMI_PORT = "agent.err.invalid.jmxremote.rmi.port"; + public static final String INVALID_JMXLOCAL_PORT = + "agent.err.invalid.jmxlocal.port"; public static final String PASSWORD_FILE_NOT_SET = "agent.err.password.file.notset"; public static final String PASSWORD_FILE_NOT_READABLE = diff -r bb0a7975b31d src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java --- a/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Tue Dec 24 09:38:41 2019 +0000 +++ b/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Fri Dec 27 17:44:58 2019 +0000 @@ -116,6 +116,8 @@ "com.sun.management.jmxremote.host"; public static final String RMI_PORT = "com.sun.management.jmxremote.rmi.port"; + public static final String LOCAL_PORT = + "com.sun.management.jmxlocal.port"; public static final String CONFIG_FILE_NAME = "com.sun.management.config.file"; public static final String USE_LOCAL_ONLY = @@ -539,9 +541,24 @@ localhost = "127.0.0.1"; } + // User can specify a port to be used to start Local Connector Server, + // if port is not specified random one will be allocated. + int localPort = 0; + String localPortStr = System.getProperty(PropertyNames.LOCAL_PORT); + try { + if (localPortStr != null) { + localPort = Integer.parseInt(localPortStr); + } + } catch (NumberFormatException x) { + throw new AgentConfigurationError(INVALID_JMXLOCAL_PORT, x, localPortStr); + } + if (localPort < 0) { + throw new AgentConfigurationError(INVALID_JMXLOCAL_PORT, localPortStr); + } + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try { - JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0); + JMXServiceURL url = new JMXServiceURL("rmi", localhost, localPort); // Do we accept connections from local interfaces only? Properties props = Agent.getManagementProperties(); if (props == null) {
30-12-2019

I believe that the 3rd port mentioned is that of the localhost rmi server, but this needs to be confirmed and any potential fix evaluated based upon the functionality available for setting that separate from the JMX usage thereof
22-11-2019

I believe the "3rd" port being referred to in the above bug may be the port of the local RMI server registry on localhost/127.0.0.1 this needs further investigation.
22-11-2019