@Test public void testWithoutInetSocketAddressSocketServerChannel() throws Exception { when(serverSocketChannel.remoteAddress()).thenReturn(null); val result = subject.extractRemoteAddressAndPort(serverSocketChannel); assertTrue(result == null); }
@Nullable public String extractRemoteAddressAndPort(Channel channel) { if (channel instanceof ServerSocketChannel) { val inetSocketAddress = ((ServerSocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else if (channel instanceof SocketChannel) { val inetSocketAddress = ((SocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else { return null; } }
SocketAddressHelper { @Nullable public String extractRemoteAddressAndPort(Channel channel) { if (channel instanceof ServerSocketChannel) { val inetSocketAddress = ((ServerSocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else if (channel instanceof SocketChannel) { val inetSocketAddress = ((SocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else { return null; } } }
SocketAddressHelper { @Nullable public String extractRemoteAddressAndPort(Channel channel) { if (channel instanceof ServerSocketChannel) { val inetSocketAddress = ((ServerSocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else if (channel instanceof SocketChannel) { val inetSocketAddress = ((SocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else { return null; } }  }
SocketAddressHelper { @Nullable public String extractRemoteAddressAndPort(Channel channel) { if (channel instanceof ServerSocketChannel) { val inetSocketAddress = ((ServerSocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else if (channel instanceof SocketChannel) { val inetSocketAddress = ((SocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else { return null; } }  @Nullable String extractRemoteAddressAndPort(Channel channel); }
SocketAddressHelper { @Nullable public String extractRemoteAddressAndPort(Channel channel) { if (channel instanceof ServerSocketChannel) { val inetSocketAddress = ((ServerSocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else if (channel instanceof SocketChannel) { val inetSocketAddress = ((SocketChannel) channel).remoteAddress(); return computeAddressAndPort(inetSocketAddress); } else { return null; } }  @Nullable String extractRemoteAddressAndPort(Channel channel);  }