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

David Holmes david.holmes at oracle.com
Thu Apr 13 01:18:22 UTC 2017


Adding back runtime

On 13/04/2017 11:15 AM, David Holmes wrote:
> Hi Shafi,
>
> On 12/04/2017 10:14 PM, Shafi Ahmad wrote:
>> 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.
>
> I don't think this is the best way to fix this. You are basically
> extracting the other exception's stacktrace into a string and then using
> that string to print out (and some of the output seems to be doubled up).
>
> Instead of:
>
>  456         } catch (AgentConfigurationError e) {
>  457             error(e.getError(), e.getParams());
>
> the error(e) variant could be called, which can then extract any
> additional info needed from an AgentConfigurationError, print it and
> then call printStackTrace, which will print the ACE stack plus the stack
> of any exception set as a cause.
>
> Overall the exception management in this code looks like it predate the
> existence of an "exception cause" and should probably be updated to
> utilize that more effectively.
>
> Thanks,
> David
> -----
>
>> 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 hotspot-runtime-dev mailing list