brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-130) Available port detection does not release ports
Date Wed, 28 Jan 2015 11:24:35 GMT

    [ https://issues.apache.org/jira/browse/BROOKLYN-130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295025#comment-14295025
] 

ASF GitHub Bot commented on BROOKLYN-130:
-----------------------------------------

GitHub user mattunderscorechampion reopened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/480

    Release ports acquired when checking available

    Fixes issue [BROOKLYN-130](https://issues.apache.org/jira/browse/BROOKLYN-130). Ensures
that the setReuseAddress is called before the port is bound. Removes the attempt to connect
to the port before binding it as unnecessary. Corrected off by one error in loop so that port
is not incremented beyond MAX_PORT_NUMBER.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/pushtechnology/incubator-brooklyn correctPortRelease

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/480.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #480
    
----
commit 0b5a77d4f3f8b4e5c1975d67c9cfddbab8a629eb
Author: Matt Champion <mattunderscorechampion@gmail.com>
Date:   2015-01-27T17:20:51Z

    Bind the socket after setting SO_REUSEADDR to true, behaviour is undefined the other way
around

commit 5004bfee4c1ad6f98f3a61b9f697022ef59de70f
Author: Matt Champion <mattunderscorechampion@gmail.com>
Date:   2015-01-27T20:40:30Z

    Ensure that the datagram socket is created in an unbound state

commit 34439f4a2ac0c13781a8485c4d6d308fb744de47
Author: Matt Champion <mattunderscorechampion@gmail.com>
Date:   2015-01-27T20:43:58Z

    Removed unnecessary double checking of free port

commit f673e19910eaf160b2ba1c93e0d6a0d23a265f27
Author: Matt Champion <mattunderscorechampion@gmail.com>
Date:   2015-01-27T20:58:43Z

    Fixed off by one error. After MAX_PORT_NUMBER comparison port is incremented and checked.
If not in valid range isPortAvailable throws an exception which is less descriptive than the
one in nextAvailablePort.

----


> Available port detection does not release ports
> -----------------------------------------------
>
>                 Key: BROOKLYN-130
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-130
>             Project: Brooklyn
>          Issue Type: Bug
>    Affects Versions: 0.7.0-M2
>            Reporter: Matthew Champion
>            Priority: Minor
>
> While build Brooklyn I have encountered an exception in one of the tests.
> java.rmi.server.ExportException: Port already in use: 40127; nested exception is: 
> 	java.net.BindException: Address already in use
> 	at java.net.PlainSocketImpl.socketBind(Native Method)
> 	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
> 	at java.net.ServerSocket.bind(ServerSocket.java:376)
> 	at java.net.ServerSocket.<init>(ServerSocket.java:237)
> 	at java.net.ServerSocket.<init>(ServerSocket.java:128)
> 	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:45)
> 	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:349)
> 	at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:667)
> 	at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:317)
> 	at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:236)
> 	at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411)
> 	at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
> 	at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:207)
> 	at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:122)
> 	at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:108)
> 	at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203)
> 	at mx4j.tools.naming.NamingService.start(NamingService.java:67)
> 	at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:111)
> 	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:45)
> 	at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235)
> 	at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
> 	at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)
> 	at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:305)
> 	at com.sun.proxy.$Proxy41.start(Unknown Source)
> 	at brooklyn.test.JmxService.<init>(JmxService.java:106)
> 	at brooklyn.test.JmxService.<init>(JmxService.java:80)
> 	at brooklyn.event.feed.jmx.JmxFeedTest.setUp(JmxFeedTest.java:140)
> The port 40127 is being returned by LocalhostMachineProvisioningLocation.obtainPort(..)
which calls through several layers to Networking.isPortAvailable(..). This checks if the port
is free but appears not to release the port. This appears to be related to socket.setReuseAddress(..)
being called after binding the socket. The documentation requires it to be called before.
> Also an off by one error in Networking.nextAvailablePort(). The last value it passes
to Networking.isPortAvailable(..) is MAX_PORT_NUMBER + 1.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message