Buggy code:
PeerNode toSendAckOnly = null ; PeerNode toSendHandshake = null ; long t = Long . MAX_VALUE ; if ( lowestUrgentSendTime <= now ) { toSendPacket = urgentSendPeers . get ( localRandom . nextInt ( urgentSendPeers . size ( ) ) ) ; t = lowestUrgentSendTime ; } else if ( lowestFullPacketSendTime < ( Long . MAX_VALUE ) ) { toSendPacket = urgentFullPacketPeers . get ( localRandom . nextInt ( urgentFullPacketPeers . size ( ) ) ) ; t = lowestFullPacketSendTime ; } else if ( lowestAckTime <= now ) { toSendAckOnly = ackPeers . get ( localRandom . nextInt ( ackPeers . size ( ) ) ) ; t = lowestAckTime ; } if ( ( lowestHandshakeTime <= now ) && ( t > lowestHandshakeTime ) ) { toSendHandshake = handshakePeers . get ( localRandom . nextInt ( handshakePeers . size ( ) ) ) ; toSendPacket = null ; toSendAckOnly = null ; } if ( toSendPacket != null ) { try { if ( toSendPacket . maybeSendPacket ( now , false ) ) { nextActionTime = now ; } } catch ( BlockedTooLongException e ) { Logger . error ( this , ( ( ( ( ( ( ( ( "Waited<seq2seq4repair_space>too<seq2seq4repair_space>long:<seq2seq4repair_space>" + ( TimeUtil . formatTime ( e . delta ) ) ) + "<seq2seq4repair_space>to<seq2seq4repair_space>allocate<seq2seq4repair_space>a<seq2seq4repair_space>packet<seq2seq4repair_space>number<seq2seq4repair_space>to<seq2seq4repair_space>send<seq2seq4repair_space>to<seq2seq4repair_space>" ) + toSendPacket ) + "<seq2seq4repair_space>:<seq2seq4repair_space>" ) + "(new<seq2seq4repair_space>packet<seq2seq4repair_space>format)" ) + "<seq2seq4repair_space>(version<seq2seq4repair_space>" ) + ( toSendPacket . getVersionNumber ( ) ) ) + ")<seq2seq4repair_space>-<seq2seq4repair_space>DISCONNECTING!" ) ) ; toSendPacket . forceDisconnect ( ) ; } } else if ( toSendAckOnly != null ) { try { if ( toSendAckOnly . maybeSendPacket ( now , true ) ) { nextActionTime = now ; } } catch ( BlockedTooLongException e ) { Logger . error ( this , ( ( ( ( ( ( ( ( "Waited<seq2seq4repair_space>too<seq2seq4repair_space>long:<seq2seq4repair_space>" + ( TimeUtil . formatTime ( e . delta ) ) ) + "<seq2seq4repair_space>to<seq2seq4repair_space>allocate<seq2seq4repair_space>a<seq2seq4repair_space>packet<seq2seq4repair_space>number<seq2seq4repair_space>to<seq2seq4repair_space>send<seq2seq4repair_space>to<seq2seq4repair_space>" ) + toSendAckOnly ) + "<seq2seq4repair_space>:<seq2seq4repair_space>" ) + "(new<seq2seq4repair_space>packet<seq2seq4repair_space>format)" ) + "<seq2seq4repair_space>(version<seq2seq4repair_space>" ) + ( toSendAckOnly . getVersionNumber ( ) ) ) + ")<seq2seq4repair_space>-<seq2seq4repair_space>DISCONNECTING!" ) ) ; toSendAckOnly . forceDisconnect ( ) ; } } if ( toSendHandshake != null ) { long beforeHandshakeTime = System . currentTimeMillis ( ) ; toSendHandshake . getOutgoingMangler ( ) . sendHandshake ( toSendHandshake , false ) ; long afterHandshakeTime = System . currentTimeMillis ( ) ; if ( ( afterHandshakeTime - beforeHandshakeTime ) > ( TimeUnit . SECONDS . toMillis ( 2 ) ) ) Logger . error ( this , ( ( ( "afterHandshakeTime<seq2seq4repair_space>is<seq2seq4repair_space>more<seq2seq4repair_space>than<seq2seq4repair_space>2<seq2seq4repair_space>seconds<seq2seq4repair_space>past<seq2seq4repair_space>beforeHandshakeTime<seq2seq4repair_space>(" + ( afterHandshakeTime - beforeHandshakeTime ) ) + ")<seq2seq4repair_space>in<seq2seq4repair_space>PacketSender<seq2seq4repair_space>working<seq2seq4repair_space>with<seq2seq4repair_space>" ) + ( toSendHandshake . userToString ( ) ) ) ) ; } nextActionTime = Math . min ( nextActionTime , lowestUrgentSendTime ) ; nextActionTime = Math . min ( nextActionTime , lowestFullPacketSendTime ) ; nextActionTime = Math . min ( nextActionTime , lowestAckTime ) ; nextActionTime = Math . min ( nextActionTime , lowestHandshakeTime ) ; OpennetManager om = node . getOpennet ( ) ; if ( ( om != null ) && ( ( node . getUptime ( ) ) > ( TimeUnit . SECONDS . toMillis ( 30 ) ) ) ) { OpennetPeerNode [ ] peers = om . getOldPeers ( ) ; for ( OpennetPeerNode pn : peers ) { long lastConnected = pn . timeLastConnected ( now ) ; if ( lastConnected <= 0 ) Logger . error ( this , ( "Last<seq2seq4repair_space>connected<seq2seq4repair_space>is<seq2seq4repair_space>zero<seq2seq4repair_space>or<seq2seq4repair_space>negative<seq2seq4repair_space>for<seq2seq4repair_space>old-opennet-peer<seq2seq4repair_space>" + pn ) ) ; if ( ( now - lastConnected ) > ( OpennetManager . MAX_TIME_ON_OLD_OPENNET_PEERS ) ) { om . purgeOldOpennetPeer ( pn ) ; if ( PacketSender . logMINOR ) Logger . minor ( this , ( ( ( "Removing<seq2seq4repair_space>old<seq2seq4repair_space>opennet<seq2seq4repair_space>peer<seq2seq4repair_space>(too<seq2seq4repair_space>old):<seq2seq4repair_space>" + pn ) + "<seq2seq4repair_space>age<seq2seq4repair_space>is<seq2seq4repair_space>" ) + ( TimeUtil . formatTime ( ( now - lastConnected ) ) ) ) ) ; continue ; } if ( pn . isConnected ( ) ) continue ; if ( pn . noContactDetails ( ) ) { pn . startARKFetcher ( ) ; continue ; } <START_BUG> if ( pn . shouldSendHandshake ( ) ) { <END_BUG> long beforeHandshakeTime = System . currentTimeMillis ( ) ; pn . getOutgoingMangler ( ) . sendHandshake ( pn , true ) ; long afterHandshakeTime = System . currentTimeMillis ( ) ; if ( ( afterHandshakeTime - beforeHandshakeTime ) > ( TimeUnit . SECONDS . toMillis ( 2 ) ) ) Logger . error ( this , ( ( ( "afterHandshakeTime<seq2seq4repair_space>is<seq2seq4repair_space>more<seq2seq4repair_space>than<seq2seq4repair_space>2<seq2seq4repair_space>seconds<seq2seq4repair_space>past<seq2seq4repair_space>beforeHandshakeTime<seq2seq4repair_space>(" + ( afterHandshakeTime - beforeHandshakeTime ) ) + ")<seq2seq4repair_space>in<seq2seq4repair_space>PacketSender<seq2seq4repair_space>working<seq2seq4repair_space>with<seq2seq4repair_space>" ) + ( pn . userToString ( ) ) ) ) ; } } } long oldNow = now ; now = System . currentTimeMillis ( ) ; if ( ( now - oldNow ) > ( TimeUnit . SECONDS . toMillis ( 10 ) ) ) Logger . error ( this , ( ( "now<seq2seq4repair_space>is<seq2seq4repair_space>more<seq2seq4repair_space>than<seq2seq4repair_space>10<seq2seq4repair_space>seconds<seq2seq4repair_space>past<seq2seq4repair_space>oldNow<seq2seq4repair_space>(" + ( now - oldNow ) ) + ")<seq2seq4repair_space>in<seq2seq4repair_space>PacketSender" ) ) ; long sleepTime = nextActionTime - now ; sleepTime = Math . min ( sleepTime , PacketSender . MAX_COALESCING_DELAY ) ; if ( ( now - ( node . startupTime ) ) > ( TimeUnit . MINUTES . toMillis ( 5 ) ) ) if ( ( now - ( lastReceivedPacketFromAnyNode ) ) > ( Node . ALARM_TIME ) ) { Logger . error ( this , ( ( "Have<seq2seq4repair_space>not<seq2seq4repair_space>received<seq2seq4repair_space>any<seq2seq4repair_space>packets<seq2seq4repair_space>from<seq2seq4repair_space>any<seq2seq4repair_space>node<seq2seq4repair_space>in<seq2seq4repair_space>last<seq2seq4repair_space>" + ( TimeUnit . SECONDS . convert ( ALARM_TIME , TimeUnit . MILLISECONDS ) ) ) + "<seq2seq4repair_space>seconds" ) ) ; lastReportedNoPackets = now ; } if ( sleepTime > 0 ) { try { if ( PacketSender . logMINOR ) Logger . minor ( this , ( "Sleeping<seq2seq4repair_space>for<seq2seq4repair_space>" + sleepTime ) ) ; synchronized ( this ) { wait ( sleepTime ) ; } } catch ( InterruptedException e ) { } } else { if ( PacketSender . logDEBUG ) Logger . debug ( this , ( ( "Next<seq2seq4repair_space>urgent<seq2seq4repair_space>time<seq2seq4repair_space>is<seq2seq4repair_space>" + ( now - nextActionTime ) ) + "ms<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>past" ) ) ; } } void wakeUp ( ) { }

Fix:
if ( pn . shouldSendHandshake ( true ) ) {