[jdk10] RFR for 'JDK-8177721: Improve diagnostics in sun.management.Agent#startAgent()

Shafi Ahmad shafi.s.ahmad at oracle.com
Wed Apr 12 12:14:35 UTC 2017


Hi,

Please review the trivial code change for the fix of 'JDK-8177721: Improve diagnostics in sun.management.Agent#startAgent()' to jdk10.

Summary:
In method exportMBeanServer of sun/management/jmxremote/ConnectorBootstrap.java, we wrap IOException in AgentConfigurationError.
But in jdk/internal/agent/Agent.java this exception is caught and the wrapped exception is ignored. 
We just prints the error message and not the stack trace and ignores the wrapped exception.

With the current code, we are getting message without the stack trace that caused this failure:

STDERR:
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 2; nested exception is: 
	java.net.BindException: Permission denied (Bind failed)

We should fix this code to print information about the original exception as well.

jdk10 bug: https://bugs.openjdk.java.net/browse/JDK-8177721
webrev link: http://cr.openjdk.java.net/~shshahma/8177721/webrev.00/

I have unit tested the code change with the existing test case by doing below change in test case: 

diff -r 3696d4c26897 test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java
--- a/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Tue Apr 11 11:24:12 2017 +0200
+++ b/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Wed Apr 12 02:51:01 2017 -0700
@@ -36,7 +36,7 @@
  * @run build JvmstatCountersTest
  * @run main/othervm/timeout=600 -XX:+UsePerfData JvmstatCountersTest 1
  * @run main/othervm/timeout=600 -XX:+UsePerfData -Dcom.sun.management.jmxremote JvmstatCountersTest 2
- * @run main/othervm/timeout=600 -XX:+UsePerfData -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3
+ * @run main/othervm/timeout=600 -XX:+UsePerfData -Dcom.sun.management.jmxremote.port=2 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3 
  * @run main/othervm/timeout=600 -XX:+UsePerfData JvmstatCountersTest 4
  */


We are getting  below error message with the fix for the above modified test case:

STDERR:
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 2; nested exception is: 
	java.net.BindException: Permission denied (Bind failed)
jdk.internal.agent.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 2; nested exception is: 
	java.net.BindException: Permission denied (Bind failed)
	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:481)
	at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:452)
	at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:626)
Caused by: java.rmi.server.ExportException: Port already in use: 2; nested exception is: 
	java.net.BindException: Permission denied (Bind failed)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:340)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:248)
	at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411)
	at java.rmi/sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
	at java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:232)
	at java.rmi/sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:202)
	at java.rmi/sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:187)
	at jdk.management.agent/sun.management.jmxremote.SingleEntryRegistry.<init>(SingleEntryRegistry.java:48)
	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:817)
	at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:469)
	... 2 more
Caused by: java.net.BindException: Permission denied (Bind failed)
	at java.base/java.net.PlainSocketImpl.socketBind(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:437)
	at java.base/java.net.ServerSocket.bind(ServerSocket.java:381)
	at java.base/java.net.ServerSocket.<init>(ServerSocket.java:243)
	at java.base/java.net.ServerSocket.<init>(ServerSocket.java:135)
	at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createServerSocket(TCPDirectSocketFactory.java:45)
	at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:666)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:329)
	... 11 more

I have run the jprt testset core and results are fine.

Regards,
Shafi


More information about the serviceability-dev mailing list