@Test public void getUserIdentifierShouldReturnRemoteAddressForBridgeAcceptor() throws Exception { context.setImposteriser(ClassImposteriser.INSTANCE); final AbstractBridgeAcceptor<?, ?> service = context.mock(AbstractBridgeAcceptor.class, "service"); final InetSocketAddress address = new InetSocketAddress(InetAddress.getByAddress(new byte[]{127,0,0,1}), 2121); context.checking(new Expectations() { { oneOf(sessionEx).getService(); will(returnValue(service)); oneOf(sessionEx).getRemoteAddress(); will(returnValue(address)); oneOf(sessionEx).getLocalAddress(); will(returnValue(address)); } }); assertEquals("127.0.0.1:2121", LoggingUtils.getUserIdentifier(sessionEx)); }
static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); static String addSession(String message, IoSession session); static String getId(IoSession session); static void log(IoSession session, Throwable t); static void log(IoSession session, Logger logger, Throwable t); static void log(IoSession session, Logger logger, String message, Throwable t); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); static String addSession(String message, IoSession session); static String getId(IoSession session); static void log(IoSession session, Throwable t); static void log(IoSession session, Logger logger, Throwable t); static void log(IoSession session, Logger logger, String message, Throwable t); static final String NETWORK_CONNECTIVITY_ERROR_MESSAGE; static final String EARLY_TERMINATION_OF_IOSESSION_MESSAGE; }