brooklyn-dev mailing list archives

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


ASF GitHub Bot commented on BROOKLYN-130:

GitHub user mattunderscorechampion reopened a pull request:

    Release ports acquired when checking available

    Fixes issue [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 correctPortRelease

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

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 <>
Date:   2015-01-27T17:20:51Z

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

commit 5004bfee4c1ad6f98f3a61b9f697022ef59de70f
Author: Matt Champion <>
Date:   2015-01-27T20:40:30Z

    Ensure that the datagram socket is created in an unbound state

commit 34439f4a2ac0c13781a8485c4d6d308fb744de47
Author: Matt Champion <>
Date:   2015-01-27T20:43:58Z

    Removed unnecessary double checking of free port

commit f673e19910eaf160b2ba1c93e0d6a0d23a265f27
Author: Matt Champion <>
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:
>             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: 
> Address already in use
> 	at Method)
> 	at
> 	at
> 	at<init>(
> 	at<init>(
> 	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(
> 	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(
> 	at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(
> 	at sun.rmi.transport.tcp.TCPTransport.listen(
> 	at sun.rmi.transport.tcp.TCPTransport.exportObject(
> 	at sun.rmi.transport.tcp.TCPEndpoint.exportObject(
> 	at sun.rmi.transport.LiveRef.exportObject(
> 	at sun.rmi.server.UnicastServerRef.exportObject(
> 	at sun.rmi.registry.RegistryImpl.setup(
> 	at sun.rmi.registry.RegistryImpl.<init>(
> 	at java.rmi.registry.LocateRegistry.createRegistry(
> 	at
> 	at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(
> 	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(
> 	at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(
> 	at com.sun.jmx.mbeanserver.PerInterface.invoke(
> 	at com.sun.jmx.mbeanserver.MBeanSupport.invoke(
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(
> 	at
> 	at com.sun.proxy.$Proxy41.start(Unknown Source)
> 	at brooklyn.test.JmxService.<init>(
> 	at brooklyn.test.JmxService.<init>(
> 	at brooklyn.event.feed.jmx.JmxFeedTest.setUp(
> 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

View raw message