[
https://issues.apache.org/jira/browse/QPID-4062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13294358#comment-13294358
]
Philip Harvey commented on QPID-4062:
-------------------------------------
In case anyone is wondering why this hack is really necessary, I've attached a
test program illustrating that closing the socket used by the RMI Registry is
inherently asynchronous (unlike closing a plain old ServerSocket, if my tests
are to be believed).
In the attached jar, run class com.philharveyonline.SocketPlay, and notice that
it sometimes complains that the port is not free after the socket has seemingly
been closed.
The program is managing the socket using LocateRegistry.createRegistry /
UnicastRemoteObject.unexportObject. If you edit the code to use SocketHelper
instead of RmiSocketHelper, the socket is managed using straightforward new
ServerSocket / socket.close calls. In this case, it never complains about the
port not being freed up.
> Java system tests sometimes fail due to JMX port already initialised
> --------------------------------------------------------------------
>
> Key: QPID-4062
> URL: https://issues.apache.org/jira/browse/QPID-4062
> Project: Qpid
> Issue Type: Bug
> Components: Java Tests
> Affects Versions: 0.16
> Reporter: Philip Harvey
> Assignee: Rob Godfrey
> Priority: Minor
> Fix For: 0.17
>
> Attachments:
> 0001-QPID-4062-when-shutting-down-broker-at-end-of-test-w.patch,
> socketPlay.jar
>
>
> I'm often seeing errors such as this:
> {noformat}
> java.rmi.server.ExportException: Port already in use: 18999; nested exception
> is:
> java.net.BindException: Address already in use
> at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)
> at
> sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)
> at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
> at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
> at
> sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
> at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
> at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:68)
> at
> java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:222)
> at
> org.apache.qpid.server.management.JMXManagedObjectRegistry.start(JMXManagedObjectRegistry.java:215)
> at
> org.apache.qpid.server.registry.ApplicationRegistry.initialise(ApplicationRegistry.java:311)
> at
> org.apache.qpid.server.registry.ApplicationRegistry.initialise(ApplicationRegistry.java:202)
> at org.apache.qpid.server.Broker.startupImpl(Broker.java:123)
> at org.apache.qpid.server.Broker.startup(Broker.java:97)
> at
> org.apache.qpid.test.utils.QpidBrokerTestCase.startBroker(QpidBrokerTestCase.java:394)
> at
> org.apache.qpid.test.utils.QpidBrokerTestCase.startBroker(QpidBrokerTestCase.java:354)
> at
> org.apache.qpid.test.utils.QpidBrokerTestCase.startBroker(QpidBrokerTestCase.java:349)
> at
> org.apache.qpid.test.utils.QpidBrokerTestCase.setUp(QpidBrokerTestCase.java:295)
> at
> org.apache.qpid.management.jmx.MessageStatisticsTestCase.setUp(MessageStatisticsTestCase.java:61)
> at
> org.apache.qpid.test.utils.QpidBrokerTestCase.runBare(QpidBrokerTestCase.java:237)
> at org.apache.qpid.test.utils.QpidTestCase.run(QpidTestCase.java:139)
> Caused by: java.net.BindException: Address already in use
> at java.net.PlainSocketImpl.socketBind(Native Method)
> at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
> at java.net.ServerSocket.bind(ServerSocket.java:319)
> at java.net.ServerSocket.<init>(ServerSocket.java:185)
> at java.net.ServerSocket.<init>(ServerSocket.java:97)
> at
> sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:27)
> at
> sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:333)
> at
> sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:649)
> at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:299)
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]