You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Nipun (JIRA)" <ji...@apache.org> on 2015/06/18 10:07:00 UTC

[jira] [Created] (DIRMINA-1014) SocketAcceptor doesn't unbind correctly

Nipun created DIRMINA-1014:
------------------------------

             Summary: SocketAcceptor doesn't unbind correctly
                 Key: DIRMINA-1014
                 URL: https://issues.apache.org/jira/browse/DIRMINA-1014
             Project: MINA
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.9
         Environment: Ubuntu 12.04.5 x64
Oracle JDK 1.6.0_45
Mina 2.0.9
            Reporter: Nipun


When the AbstractIoAcceptor binds a socket, it adds an entry to the "boundAddresses" set to keep track of that socket.

In my case, I am passing a SocketAddress initialized with a specific port, and "null" for host (I want to listen on that port on the local machine). This InetSocketAddress instance has an Inet4Address in it when created.

When the Acceptor is given this v4 SocketAddress to bind, it creates a ServerSocketChannel, and then calls ServerSocketChannel.socket().getLocalSocketAddress() to retrieve a SocketAddress. This is the value that is then put in the "boundAddresses" collection.

The problem is that the ServerSocketChannel.socket().getLocalSocketAddress() returns a SocketAddress with an Inet6Address value in it, even though the SocketAcceptor.bind() was given a v4 address. So when I try to unbind that socket (using the same v4 address I used to do the bind() call), it fails because the "boundAddresses" set has the v6 version in it, and the "Inet6Address.equals(Inet4Address) is false".

Basically:
1. I call NioSocketAcceptor.bind() on a v4 SocketAddress
2. A ServerSocketChannel is created for that v4 address.
3. The ServerSocketChannel.socket().getLocalSocketAddress() is called, which returns a v6 SocketAddress (which is the equivalent of the v4 SocketAddress given)
4. NioSocketAcceptor puts the v6 address in its "boundAddresses" list.
5. When I ask to unbind the same v4 address, it fails because the "boundAddresses" list only contains a v6 address.

This was not the case in Mina 1.x. In v1.x version, the SocketAddress passed to the bind() method could be used to also unbind.



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