From 7a17c4e4534d209fe3a0335ed07136d98f2b3678 Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Fri, 30 Oct 2015 23:55:25 +0100 Subject: [PATCH] Fix formatting of contribution from PR#30. --- .../socket/jdk8/MuxServerSocketChannel.java | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/ice4j/socket/jdk8/MuxServerSocketChannel.java b/src/main/java/org/ice4j/socket/jdk8/MuxServerSocketChannel.java index d7ca3c8..f7702aa 100644 --- a/src/main/java/org/ice4j/socket/jdk8/MuxServerSocketChannel.java +++ b/src/main/java/org/ice4j/socket/jdk8/MuxServerSocketChannel.java @@ -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