Buggy code:
public class NSServer implements NIOEventListener { private static final Logger LOG = LoggerFactory . getLogger ( NSServer . class . getName ( ) ) ; private static final long SELECT_TIMEOUT = 50 ; private static final int BYTEBUFFER_SIZE = 512 ; private NIOServer nioServer ; private Map < Integer , Session > connectedUserSessions ; private Map < String , Command > enabledCommands ; private Map < String , List < Session > > globalFollowers ; private void __loadEnabledCommands ( ) { } public int run ( ) { } @ Override public void onAcceptableEvent ( Selector selector , SocketChannel socket ) throws IOException { } @ Override public int onReadableEvent ( Selector selector , SocketChannel socket ) throws IOException { } @ Override public int onWritableEvent ( Selector selector , SocketChannel socket ) throws IOException { } @ Override public void onTimeoutEvent ( Selector selector ) throws IOException { } @ Override public void onFinalize ( Selector selector ) throws IOException { final Instant currentInstant = Instant . now ( ) ; for ( Session usrSess : this . connectedUserSessions . values ( ) ) { final String [ ] payload = usrSess . getNextPayload ( ) ; if ( payload != null ) { if ( NSServer . LOG . isTraceEnabled ( ) ) { String methodName = payload [ 0 ] ; if ( ( ( payload . length ) > 1 ) && ( ( ( methodName . compareTo ( "user_cmd" ) ) == 0 ) || ( ( methodName . compareTo ( "cmd" ) ) == 0 ) ) ) { methodName += String . format ( "::%s" , payload [ 1 ] ) ; } NSServer . LOG . trace ( "Client<seq2seq4repair_space>from<seq2seq4repair_space>{}<seq2seq4repair_space>call<seq2seq4repair_space>the<seq2seq4repair_space>method<seq2seq4repair_space>\"{}\"" , String . format ( "%s<seq2seq4repair_space>(%s)" , usrSess . network . address , ( ( usrSess . user . login ) == null ? "<not_authenticated>" : usrSess . user . login ) ) , methodName ) ; } final Command cmd = this . enabledCommands . get ( payload [ 0 ] ) ; if ( cmd != null ) { if ( cmd . canExecute ( usrSess . stageLevel ) ) { final int minArgs = cmd . getMinimalArgsCountNeeded ( ) ; final int maxArgs = cmd . getMaximalArgsCountNeeded ( ) ; if ( ( ( payload . length ) >= minArgs ) && ( ( maxArgs == ( - 1 ) ) || ( ( payload . length ) <= maxArgs ) ) ) { try { cmd . execute ( payload , usrSess , this . connectedUserSessions . values ( ) , this . globalFollowers ) ; } catch ( Exception e ) { NSServer . LOG . error ( "Something<seq2seq4repair_space>goes<seq2seq4repair_space>wrong<seq2seq4repair_space>during<seq2seq4repair_space>the<seq2seq4repair_space>command<seq2seq4repair_space>execution!" , e ) ; usrSess . outputBuffer . add ( "rep<seq2seq4repair_space>500<seq2seq4repair_space>--<seq2seq4repair_space>internal<seq2seq4repair_space>error\n" ) ; } } else { if ( minArgs == maxArgs ) { usrSess . outputBuffer . add ( String . format ( "rep<seq2seq4repair_space>003<seq2seq4repair_space>--<seq2seq4repair_space>cmd<seq2seq4repair_space>bad<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>arguments<seq2seq4repair_space>%d<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>%d\n" , payload . length , minArgs ) ) ; } else if ( maxArgs == ( - 1 ) ) { usrSess . outputBuffer . add ( String . format ( "rep<seq2seq4repair_space>003<seq2seq4repair_space>--<seq2seq4repair_space>cmd<seq2seq4repair_space>bad<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>arguments<seq2seq4repair_space>%d<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>at<seq2seq4repair_space>least<seq2seq4repair_space>%d\n" , payload . length , minArgs ) ) ; } else { usrSess . outputBuffer . add ( String . format ( "rep<seq2seq4repair_space>003<seq2seq4repair_space>--<seq2seq4repair_space>cmd<seq2seq4repair_space>bad<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>arguments<seq2seq4repair_space>%d<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>between<seq2seq4repair_space>%d<seq2seq4repair_space>and<seq2seq4repair_space>%d\n" , payload . length , minArgs , maxArgs ) ) ; } } } else { if ( ( cmd . getType ( ) ) == ( CmdType . AUTHENTICATION ) ) { usrSess . outputBuffer . add ( "rep<seq2seq4repair_space>008<seq2seq4repair_space>--<seq2seq4repair_space>agent<seq2seq4repair_space>already<seq2seq4repair_space>log\n" ) ; } else { usrSess . outputBuffer . add ( "rep<seq2seq4repair_space>403<seq2seq4repair_space>--<seq2seq4repair_space>forbidden\n" ) ; } } } else { usrSess . outputBuffer . add ( "rep<seq2seq4repair_space>001<seq2seq4repair_space>--<seq2seq4repair_space>no<seq2seq4repair_space>such<seq2seq4repair_space>cmd\n" ) ; } usrSess . network . registerWriteEvent ( ) ; } if ( ( ( ( usrSess . disconnectReason ) != null ) && ( ( usrSess . network . socket ) != null ) ) && ( usrSess . outputBuffer . isEmpty ( ) ) ) { this . nioServer . addToDisconnect ( usrSess . network . socket , usrSess . disconnectReason ) ; } else { final Instant lastSockActivity = this . nioServer . getInactivityTTL ( usrSess . network . socket ) ; <START_BUG> if ( ( ( lastSockActivity != null ) && ( currentInstant . isAfter ( lastSockActivity . plusMillis ( ( ( Settings . socketTTL ) * 700 ) ) ) ) ) && ( usrSess . lastPingSent . isBefore ( currentInstant ) ) ) { <END_BUG> usrSess . outputBuffer . add ( String . format ( "ping<seq2seq4repair_space>%d\n" , lastSockActivity . plusSeconds ( socketTTL ) . minusSeconds ( currentInstant . getEpochSecond ( ) ) . getEpochSecond ( ) ) ) ; usrSess . network . registerWriteEvent ( ) ; usrSess . lastPingSent = currentInstant . plusMillis ( ( ( Settings . socketTTL ) * 800 ) ) ; } } } } @ Override public void onDisconnected ( SocketChannel socket , DisconnectReason discoReason ) throws IOException { } }

Fix:
if ( ( ( lastSockActivity != null ) && ( currentInstant . isAfter ( lastSockActivity . plusMillis ( ( ( Settings . socketTTL ) * 750 ) ) ) ) ) && ( usrSess . lastPingSent . isBefore ( currentInstant ) ) ) {