private void returnConnection ( Channel c ) { switch ( state ) { case SHUTTING_DOWN : case SHUTDOWN : closeConnection ( c ) ; break ; case RUNNING : case HEALTH_CHECKING : default : if ( inProgressMap . containsKey ( c ) ) { logger . error ( "Channel returned to pool while still in use. id: {}" , c . hashCode ( ) ) ; } else { if ( c . isOpen ( ) ) { logger . debug ( "Channel id:{} returned to pool" , c . hashCode ( ) ) ; c . closeFuture ( ) . removeListener ( inProgressCloseListener ) ; c . closeFuture ( ) . addListener ( inAvailableCloseListener ) ; available . offerFirst ( new ChannelWithIdleTime ( c ) ) ; } else { logger . debug ( "Closed channel id:{} returned to pool; discarding" , c . hashCode ( ) ) ; } logger . debug ( "Released pool permit" ) ; permits . release ( ) ; } } }
Return a Netty channel .