Fix formatting of contribution from PR#30.

This commit is contained in:
Ingo Bauersachs 2015-10-30 23:55:25 +01:00
parent bfa3b487d1
commit 7a17c4e453

View File

@ -57,15 +57,21 @@ public class MuxServerSocketChannel
= MuxServerSocketChannelFactory.SOCKET_CHANNEL_READ_TIMEOUT; = MuxServerSocketChannelFactory.SOCKET_CHANNEL_READ_TIMEOUT;
/** /**
* Reference to 0.0.0.0 IPv4 or 0::0 IPv6 address for "wildcard" matching purposes * Reference to 0.0.0.0 IPv4 or 0::0 IPv6 address for "wildcard" matching
* purposes.
*/ */
private static final InetAddress ANY_LOCAL_ADDRESS; private static final InetAddress ANY_LOCAL_ADDRESS;
static {
try { static
ANY_LOCAL_ADDRESS = InetAddress.getByName("::"); {
} catch (UnknownHostException e) { try
throw new RuntimeException(e); {
} ANY_LOCAL_ADDRESS = InetAddress.getByName("::");
}
catch (UnknownHostException e)
{
throw new RuntimeException(e);
}
} }
/** /**
@ -516,20 +522,28 @@ public class MuxServerSocketChannel
aLocalAddr = null; aLocalAddr = null;
} }
boolean matches = aLocalAddr != null && aLocalAddr.equals(localAddr); boolean matches = aLocalAddr != null
&& aLocalAddr.equals(localAddr);
// if not the same address, let's see if the cached one is an "anyLocalAddress" and if so let's consider it a match // if not the same address, let's see if the cached one
if (!matches && aLocalAddr instanceof InetSocketAddress && localAddr instanceof InetSocketAddress) // is an "anyLocalAddress" and if so let's consider it
// a match
if (!matches
&& aLocalAddr instanceof InetSocketAddress
&& localAddr instanceof InetSocketAddress)
{ {
InetSocketAddress aLocalInetAddr = (InetSocketAddress) aLocalAddr; InetSocketAddress aLocalInetAddr
InetSocketAddress localInetAddr = (InetSocketAddress) localAddr; = (InetSocketAddress) aLocalAddr;
InetSocketAddress localInetAddr
= (InetSocketAddress) localAddr;
matches = matches = aLocalInetAddr.getAddress()
aLocalInetAddr.getAddress().equals(ANY_LOCAL_ADDRESS) && .equals(ANY_LOCAL_ADDRESS)
aLocalInetAddr.getPort() == localInetAddr.getPort(); && aLocalInetAddr.getPort()
== localInetAddr.getPort();
} }
if (matches) if (matches)
{ {
channel = aChannel; channel = aChannel;
// The whole idea of using (1) a List for // The whole idea of using (1) a List for