Buggy code:
public class TcpChannelHub implements Closeable , View { public static final int HEATBEAT_PING_PERIOD = Integer . getInteger ( "heartbeat.ping.period" , 5000 ) ; public static final int HEATBEAT_TIMEOUT_PERIOD = Integer . getInteger ( "heartbeat.timeout" , 20000 ) ; public static final int SIZE_OF_SIZE = 4 ; private static final Logger LOG = LoggerFactory . getLogger ( TcpChannelHub . class ) ; @ NotNull private final SocketAddressSupplier socketAddressSupplier ; public final long timeoutMs ; @ NotNull protected final String name ; private final Set < Long > preventSubscribeUponReconnect = new ConcurrentSkipListSet < > ( ) ; protected final int tcpBufferSize ; final Wire outWire ; final Wire inWire ; private final ReentrantLock outBytesLock = new ReentrantLock ( ) ; @ NotNull private final AtomicLong transactionID = new AtomicLong ( 0 ) ; @ NotNull private final SessionProvider sessionProvider ; @ NotNull private final TcpChannelHub . TcpSocketConsumer tcpSocketConsumer ; @ NotNull private final EventLoop eventLoop ; @ NotNull private final Function < Bytes , Wire > wire ; private final Wire handShakingWire ; private long largestChunkSoFar = 0 ; @ Nullable private volatile SocketChannel clientChannel ; private volatile boolean closed ; private CountDownLatch receivedClosedAcknowledgement = new CountDownLatch ( 1 ) ; private long limitOfLast = 0 ; public TcpChannelHub ( @ NotNull final SessionProvider sessionProvider , @ NotNull final EventLoop eventLoop , @ NotNull final Function < Bytes , Wire > wire , @ NotNull final String name , @ NotNull final SocketAddressSupplier socketAddressSupplier ) { } private void clear ( @ NotNull final Wire wire ) { } static void logToStandardOutMessageReceived ( @ NotNull Wire wire ) { } static void logToStandardOutMessageReceivedInERROR ( @ NotNull Wire wire ) { } @ Nullable SocketChannel openSocketChannel ( ) throws IOException { } public void preventSubscribeUponReconnect ( long tid ) { } @ NotNull @ Override public String toString ( ) { } private void onDisconnected ( ) { } private void onConnected ( ) { } public void subscribe ( @ NotNull final AsyncSubscription asyncSubscription ) { } public void subscribe ( @ NotNull final AsyncSubscription asyncSubscription , boolean tryLock ) { } public void unsubscribe ( final long tid ) { } @ NotNull public ReentrantLock outBytesLock ( ) { } private synchronized void doHandShaking ( @ NotNull SocketChannel socketChannel ) throws IOException { } @ Nullable private SessionDetails sessionDetails ( ) { } protected synchronized void closeSocket ( ) { } public boolean isOpen ( ) { } public void close ( ) { } private void sendCloseMessage ( ) { } public long nextUniqueTransaction ( long timeMs ) { long id = timeMs ; for ( ; ; ) { long old = transactionID . get ( ) ; <START_BUG> if ( old == id ) <END_BUG> id = old + 1 ; if ( transactionID . compareAndSet ( old , id ) ) break ; } return id ; } public void writeSocket ( @ NotNull final WireOut wire ) { } public Wire proxyReply ( long timeoutTime , final long tid ) throws ConnectionDroppedException { } private void writeSocket1 ( @ NotNull WireOut outWire , long timeoutTime , @ NotNull SocketChannel socketChannel ) throws IOException { } private void logToStandardOutMessageSent ( @ NotNull WireOut wire , @ NotNull ByteBuffer outBuffer ) { } private void updateLargestChunkSoFarSize ( @ NotNull ByteBuffer outBuffer ) { } public Wire outWire ( ) { } void reflectServerHeartbeatMessage ( @ NotNull ValueIn valueIn ) { } public long writeMetaDataStartTime ( long startTime , @ NotNull Wire wire , String csp , long cid ) { } public void writeMetaDataForKnownTID ( long tid , @ NotNull Wire wire , @ Nullable String csp , long cid ) { } public void writeAsyncHeader ( @ NotNull Wire wire , String csp , long cid ) { } public boolean lock ( @ NotNull TcpChannelHub . Task r ) { } public boolean lock ( @ NotNull TcpChannelHub . Task r , boolean tryLock ) { } public void checkConnection ( ) throws InterruptedException { } public interface Task { void run ( ) { } } private class TcpSocketConsumer implements EventHandler { @ NotNull private final ExecutorService executorService ; @ NotNull private final Map < Long , Object > map = new ConcurrentHashMap < > ( ) ; private final Map < Long , Object > omap = new ConcurrentHashMap < > ( ) ; long lastheartbeatSentTime = 0 ; private Function < Bytes , Wire > wireFunction ; private long tid ; @ NotNull private ThreadLocal < Wire > syncInWireThreadLocal = ThreadLocal . withInitial ( ( ) -> wire . apply ( elasticByteBuffer ( ) ) ) ; private Bytes serverHeartBeatHandler = Bytes . elasticByteBuffer ( ) ; private volatile long lastTimeMessageReceived = Time . currentTimeMillis ( ) ; private volatile boolean isShutdown ; @ Nullable private volatile Throwable shutdownHere = null ; private TcpSocketConsumer ( @ NotNull final Function < Bytes , Wire > wireFunction ) { } private void reconnect ( ) { } @ SuppressWarnings ( "SynchronizationOnLocalVariableOrMethodParameter" ) public void onConnectionClosed ( ) { } @ NotNull @ Override public HandlerPriority priority ( ) { } Wire syncBlockingReadSocket ( final long timeoutTimeMs , long tid ) throws InterruptedException , TimeoutException , ConnectionDroppedException { } private void put ( long tid , Object bytes ) { } void subscribe ( @ NotNull final AsyncSubscription asyncSubscription , boolean tryLock ) { } public void unsubscribe ( long tid ) { } @ NotNull private ExecutorService start ( ) { } public void checkNotShutdown ( ) { } private void running ( ) { } private boolean isShutdown ( ) { } private long size ( int header ) { } private boolean processData ( final long tid , final boolean isReady , final int header , final int messageSize , @ NotNull Wire inWire ) throws IOException , InterruptedException { } private void processServerSystemMessage ( final int header , final int messageSize ) throws IOException { }

Fix:
if ( old >= id )