JDK-8048050 : Agent NullPointerException when rmi.port in use
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 7u51
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-06-19
  • Updated: 2015-09-29
  • Resolved: 2015-01-14
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 7 JDK 8 JDK 9
7u80 b05Fixed 8u60Fixed 9Fixed
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
3.11.0-17-generic #31-Ubuntu SMP Mon Feb 3 21:52:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
If the com.sun.management.jmxremote.rmi.port option is provided it will give a NPE if already in use by a different JVM.  Its expected to fail but should provide an appropriate exception.

REGRESSION.  Last worked in version 1.0

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run two instances in different JVMs at same time with the following options:

-Dcom.sun.management.jmxremote.port=2222 -Dcom.sun.management.jmxremote.rmi.port=2223 -Dcom.sun.management.jmxremote.authenticate=false


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error given port already in use like when jmxremote.port is:

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 2223
ACTUAL -
Error: Exception thrown by the agent : java.lang.NullPointerException


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error: Exception thrown by the agent : java.lang.NullPointerException


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Test {
	public static void main(String[] args) throws Exception {
		    Thread.sleep(100000);
	}
}
---------- END SOURCE ----------


Comments
Then we trying to start JMXConnectorServer (see method exportMBeanServer of class sun.management.jmxremote.ConnectorBootstrap on already used port it cause IOException. Call of connServer.getAddress().toString() in the exception handler cause NullPointerException because connServer.getAddress() returns null. I see possible fixes: 1. Provide url.toString() if connServer.getAddress() is null 2. Check is port already in use or not. And if it is in use, provide "port already in use".
14-11-2014

The regression introduced by JDK-7110104
12-11-2014