Source:
public InMemoryConnectionStore(final int capacity, final long threshold, final SessionCache sessionCache) { this.connections = new LeastRecentlyUsedCache<>(capacity, threshold); this.connections.setEvictingOnReadAccess(false); this.connections.setUpdatingOnReadAccess(false); this.connectionsByEstablishedSession = new ConcurrentHashMap<>(); this.connectionsByAddress = new ConcurrentHashMap<>(); this.sessionCache = sessionCache; this.cidLength = DEFAULT_CID_LENGTH; if (sessionCache != null) { connections.addEvictionListener(new LeastRecentlyUsedCache.EvictionListener<Connection>() { @Override public void onEviction(final Connection staleConnection) { Runnable remove = new Runnable() { @Override public void run() { Handshaker handshaker = staleConnection.getOngoingHandshake(); if (handshaker != null) { handshaker.handshakeFailed(new RuntimeException("Evicted!")); } synchronized (InMemoryConnectionStore.this) { removeFromAddressConnections(staleConnection); removeFromEstablishedSessions(staleConnection); removeSessionFromCache(staleConnection); } } }; if (staleConnection.isExecuting()) { staleConnection.getExecutor().execute(remove); } else { remove.run(); } } }); if (sessionCache instanceof ClientSessionCache) { ClientSessionCache clientCache = (ClientSessionCache) sessionCache; LOG.debug("resume client sessions {}", clientCache); for (InetSocketAddress peer : clientCache) { SessionTicket ticket = clientCache.getSessionTicket(peer); SessionId id = clientCache.getSessionIdentity(peer); if (ticket != null && id != null) { Connection connection = new Connection(ticket, id); connection.setResumptionRequired(true); ConnectionId connectionId = newConnectionId(); if (connectionId != null) { connection.setConnectionId(connectionId); connections.put(connectionId, connection); connectionsByAddress.put(peer, connection); LOG.debug("resume {}", peer, id); } } } } } LOG.info("Created new InMemoryConnectionStore [capacity: {}, connection expiration threshold: {}s]", capacity, threshold); }

Target:
public InMemoryConnectionStore(final int capacity, final long threshold, final SessionCache sessionCache) { this.connections = new LeastRecentlyUsedCache<>(capacity, threshold); this.connections.setEvictingOnReadAccess(false); this.connections.setUpdatingOnReadAccess(false); this.connectionsByEstablishedSession = new ConcurrentHashMap<>(); this.connectionsByAddress = new ConcurrentHashMap<>(); this.sessionCache = sessionCache; int bits = Integer.SIZE - Integer.numberOfLeadingZeros(capacity); this.cidLength = ((bits + 7)/ 8) + DEFAULT_EXTRA_CID_LENGTH; if (sessionCache != null) { connections.addEvictionListener(new LeastRecentlyUsedCache.EvictionListener<Connection>() { @Override public void onEviction(final Connection staleConnection) { Runnable remove = new Runnable() { @Override public void run() { Handshaker handshaker = staleConnection.getOngoingHandshake(); if (handshaker != null) { handshaker.handshakeFailed(new RuntimeException("Evicted!")); } synchronized (InMemoryConnectionStore.this) { removeFromAddressConnections(staleConnection); removeFromEstablishedSessions(staleConnection); removeSessionFromCache(staleConnection); } } }; if (staleConnection.isExecuting()) { staleConnection.getExecutor().execute(remove); } else { remove.run(); } } }); if (sessionCache instanceof ClientSessionCache) { ClientSessionCache clientCache = (ClientSessionCache) sessionCache; LOG.debug("resume client sessions {}", clientCache); for (InetSocketAddress peer : clientCache) { SessionTicket ticket = clientCache.getSessionTicket(peer); SessionId id = clientCache.getSessionIdentity(peer); if (ticket != null && id != null) { Connection connection = new Connection(ticket, id); ConnectionId connectionId = newConnectionId(); if (connectionId != null) { connection.setConnectionId(connectionId); connection.setPeerAddress(peer); connections.put(connectionId, connection); connectionsByAddress.put(peer, connection); LOG.debug("resume {}", peer, id); } else { LOG.info("drop session {}, could not allocated cid!", peer, id); } } } } } LOG.info("Created new InMemoryConnectionStore [capacity: {}, connection expiration threshold: {}s]", capacity, threshold); }