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;
/**
* 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;
static {
try {
ANY_LOCAL_ADDRESS = InetAddress.getByName("::");
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
static
{
try
{
ANY_LOCAL_ADDRESS = InetAddress.getByName("::");
}
catch (UnknownHostException e)
{
throw new RuntimeException(e);
}
}
/**
@ -515,21 +521,29 @@ public class MuxServerSocketChannel
{
aLocalAddr = null;
}
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 (!matches && aLocalAddr instanceof InetSocketAddress && localAddr instanceof InetSocketAddress)
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 (!matches
&& aLocalAddr instanceof InetSocketAddress
&& localAddr instanceof InetSocketAddress)
{
InetSocketAddress aLocalInetAddr = (InetSocketAddress) aLocalAddr;
InetSocketAddress localInetAddr = (InetSocketAddress) localAddr;
matches =
aLocalInetAddr.getAddress().equals(ANY_LOCAL_ADDRESS) &&
aLocalInetAddr.getPort() == localInetAddr.getPort();
InetSocketAddress aLocalInetAddr
= (InetSocketAddress) aLocalAddr;
InetSocketAddress localInetAddr
= (InetSocketAddress) localAddr;
matches = aLocalInetAddr.getAddress()
.equals(ANY_LOCAL_ADDRESS)
&& aLocalInetAddr.getPort()
== localInetAddr.getPort();
}
if (matches)
if (matches)
{
channel = aChannel;
// The whole idea of using (1) a List for