public final void tryToOfferChannelToPool(Channel channel, AsyncHandler<?> asyncHandler, boolean keepAlive, Object partitionKey) { if (channel.isActive() && keepAlive) { LOGGER.debug("Adding key: {} for channel {}", partitionKey, channel); Channels.setDiscard(channel); try { asyncHandler.onConnectionOffer(channel); } catch (Exception e) { LOGGER.error("onConnectionOffer crashed", e); } if (!channelPool.offer(channel, partitionKey)) { // rejected by pool closeChannel(channel); } } else { // not offered closeChannel(channel); } }