Buggy code:
static ErrorInfo REASON_TOO_BIG = new ErrorInfo ( "Connection<seq2seq4repair_space>closed;<seq2seq4repair_space>message<seq2seq4repair_space>too<seq2seq4repair_space>large" , 40000 ) ; static ErrorInfo REASON_NEVER_CONNECTED = new ErrorInfo ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>establish<seq2seq4repair_space>connection" , 80002 ) ; static ErrorInfo REASON_TIMEDOUT = new ErrorInfo ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>establish<seq2seq4repair_space>connection" , 80014 ) ; public static class StateIndication { final ConnectionState state ; final ErrorInfo reason ; boolean useFallbackHost ; public StateIndication ( ConnectionState state , ErrorInfo reason ) { } } public static class StateInfo { public final ConnectionState state ; public final ErrorInfo defaultErrorInfo ; final boolean queueEvents ; final boolean sendEvents ; final boolean terminal ; final boolean retry ; final long timeout ; StateInfo ( ConnectionState state , boolean queueEvents , boolean sendEvents , boolean terminal , boolean retry , long timeout , ErrorInfo defaultErrorInfo ) { } } @ SuppressWarnings ( "serial" ) public static final HashMap < ConnectionState , ConnectionManager . StateInfo > states = new HashMap < ConnectionState , ConnectionManager . StateInfo > ( ) { } ; public ErrorInfo getStateErrorInfo ( ) { } public boolean isActive ( ) { } public ConnectionManager ( final AblyRealtime ably , Connection connection ) { } public String getHost ( ) { } public synchronized ConnectionManager . StateInfo getConnectionState ( ) { } private void setState ( ConnectionManager . StateIndication newState ) { } public void requestState ( ConnectionState state ) { } public synchronized void requestState ( ConnectionManager . StateIndication state ) { } synchronized void notifyState ( ITransport transport , ConnectionManager . StateIndication state ) { } synchronized void notifyState ( ConnectionManager . StateIndication state ) { } public void ping ( final CompletionListener listener ) { } void onMessage ( ProtocolMessage message ) { } private void onChannelMessage ( ProtocolMessage message ) { } private synchronized void onConnected ( ProtocolMessage message ) { } private synchronized void onDisconnected ( ProtocolMessage message ) { } private synchronized void onClosed ( ProtocolMessage message ) { } private synchronized void onError ( ProtocolMessage message ) { } private void onAck ( ProtocolMessage message ) { } private void onNack ( ProtocolMessage message ) { } private void onHeartbeat ( ProtocolMessage message ) { } private void handleStateRequest ( ) { } private void handleStateChange ( ConnectionManager . StateIndication stateChange ) { } private void setSuspendTime ( ) { } private ConnectionManager . StateIndication checkSuspend ( ConnectionManager . StateIndication stateChange ) { } private void tryWait ( long timeout ) { } public void run ( ) { } @ Override public void onTransportAvailable ( ITransport transport , TransportParams params ) { } @ Override public synchronized void onTransportUnavailable ( ITransport transport , TransportParams params , ErrorInfo reason ) { } private class ConnectParams extends TransportParams { private boolean fallback ; ConnectParams ( Options options , boolean fallback ) { } } private void connectImpl ( ConnectionManager . StateIndication request ) { } private void closeImpl ( ConnectionManager . StateIndication request ) { } protected boolean checkConnectivity ( ) { } public static class QueuedMessage { public final ProtocolMessage msg ; public CompletionListener listener ; private boolean isMerged ; public QueuedMessage ( ProtocolMessage msg , CompletionListener listener ) { } } public void send ( ProtocolMessage msg , boolean queueEvents , CompletionListener listener ) throws AblyException { } @ SuppressWarnings ( "unused" ) private void sendImpl ( ProtocolMessage message ) throws AblyException { } private void sendImpl ( ProtocolMessage message , CompletionListener listener ) throws AblyException { } private void sendImpl ( ConnectionManager . QueuedMessage msg ) throws AblyException { } private void sendQueuedMessages ( ) { } private void failQueuedMessages ( ErrorInfo reason ) { } private class PendingMessageQueue { private long startSerial = 0L ; private ArrayList < ConnectionManager . QueuedMessage > queue = new ArrayList < ConnectionManager . QueuedMessage > ( ) ; public synchronized void push ( ConnectionManager . QueuedMessage msg ) { } public void ack ( long msgSerial , int count , ErrorInfo reason ) { ConnectionManager . QueuedMessage [ ] ackMessages = null ; ConnectionManager . QueuedMessage [ ] nackMessages = null ; synchronized ( this ) { if ( msgSerial < ( startSerial ) ) { count -= ( ( int ) ( ( startSerial ) - msgSerial ) ) ; msgSerial = startSerial ; } if ( msgSerial > ( startSerial ) ) { int nCount = ( ( int ) ( msgSerial - ( startSerial ) ) ) ; List < ConnectionManager . QueuedMessage > nackList = queue . subList ( 0 , nCount ) ; nackMessages = nackList . toArray ( new ConnectionManager . QueuedMessage [ nCount ] ) ; nackList . clear ( ) ; startSerial = msgSerial ; } if ( msgSerial == ( startSerial ) ) { List < ConnectionManager . QueuedMessage > ackList = queue . subList ( 0 , count ) ; ackMessages = ackList . toArray ( new ConnectionManager . QueuedMessage [ count ] ) ; ackList . clear ( ) ; startSerial += count ; } } if ( nackMessages != null ) { if ( reason == null ) reason = new ErrorInfo ( "Unknown<seq2seq4repair_space>error" , 500 , 50000 ) ; for ( ConnectionManager . QueuedMessage msg : nackMessages ) { try { if ( ( msg . listener ) != null ) msg . listener . onError ( reason ) ; } catch ( Throwable t ) { Log . e ( ConnectionManager . TAG , "ack():<seq2seq4repair_space>listener<seq2seq4repair_space>exception" , t ) ; } } } if ( ackMessages != null ) { for ( ConnectionManager . QueuedMessage msg : ackMessages ) { try { if ( ( msg . listener ) != null ) <START_BUG> msg . listener . onError ( reason ) ; <END_BUG> } catch ( Throwable t ) { Log . e ( ConnectionManager . TAG , "ack():<seq2seq4repair_space>listener<seq2seq4repair_space>exception" , t ) ; } } } } public synchronized void nack ( long serial , int count , ErrorInfo reason ) { } } final AblyRealtime ably ; private final Options options ; private final Connection connection ; private final Factory factory ; private final List < ConnectionManager . QueuedMessage > queuedMessages ; private final ConnectionManager . PendingMessageQueue pendingMessages ; private final HashSet < Object > heartbeatWaiters = new HashSet < Object > ( ) ; private ConnectionManager . StateInfo state ; private ConnectionManager . StateIndication indicatedState ; private ConnectionManager . StateIndication requestedState ;

Fix:
msg . listener . onSuccess ( ) ;