Program: 13131
Project: 13131
Buggy source:
public void connect(String host,String username,String password){
  LoginToken loginToken=authService.getLoginToken(username,password);
  ConnectionConfiguration connectionConfig=createConnectionConfig(host,DEFAULT_PORT);
  XMPPTCPConnection authConnection=new XMPPTCPConnection(connectionConfig);
  try {
    addPacketLogging(authConnection,"String_Node_Str");
    authConnection.connect();
    authConnection.login(DEFAULT_XMPP_USER,DEFAULT_XMPP_PASSWORD,"String_Node_Str");
    authConnection.setFromMode(FromMode.USER);
    AuthRequest sessionRequest=createSessionRequest(loginToken);
    AuthReply oaResponse=sendOAPacket(authConnection,sessionRequest,AuthReply.class);
    authConnection.disconnect();
    connection=new XMPPTCPConnection(connectionConfig);
    addPacketLogging(connection,"String_Node_Str");
    connection.connect();
    connection.login(oaResponse.getUsername(),oaResponse.getPassword(),"String_Node_Str");
    connection.setFromMode(FromMode.USER);
    connection.addConnectionListener(new ConnectionListener(){
      @Override public void reconnectionSuccessful(){
        getCurrentActivity();
      }
      @Override public void connected(      XMPPConnection connection){
      }
      @Override public void authenticated(      XMPPConnection connection){
      }
      @Override public void connectionClosed(){
      }
      @Override public void connectionClosedOnError(      Exception e){
      }
      @Override public void reconnectingIn(      int seconds){
      }
      @Override public void reconnectionFailed(      Exception e){
      }
    }
);
    heartbeat=scheduler.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        try {
          if (!connection.isConnected()) {
            if (heartbeat != null) {
              heartbeat.cancel(false);
            }
            return;
          }
          sendPing();
        }
 catch (        Exception e) {
          logger.warn("String_Node_Str",e);
        }
      }
    }
,30,30,TimeUnit.SECONDS);
    monitorActivityChanges();
    getCurrentActivity();
  }
 catch (  XMPPException|SmackException|IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void connect(String host,String username,String password){
  LoginToken loginToken=authService.getLoginToken(username,password);
  ConnectionConfiguration connectionConfig=createConnectionConfig(host,DEFAULT_PORT);
  XMPPTCPConnection authConnection=new XMPPTCPConnection(connectionConfig);
  try {
    addPacketLogging(authConnection,"String_Node_Str");
    authConnection.connect();
    authConnection.login(DEFAULT_XMPP_USER,DEFAULT_XMPP_PASSWORD,"String_Node_Str");
    authConnection.setFromMode(FromMode.USER);
    AuthRequest sessionRequest=createSessionRequest(loginToken);
    AuthReply oaResponse=sendOAPacket(authConnection,sessionRequest,AuthReply.class);
    authConnection.disconnect();
    connection=new XMPPTCPConnection(connectionConfig);
    addPacketLogging(connection,"String_Node_Str");
    connection.connect();
    connection.login(oaResponse.getUsername(),oaResponse.getPassword(),"String_Node_Str");
    connection.setFromMode(FromMode.USER);
    connection.addConnectionListener(new ConnectionListener(){
      @Override public void reconnectionSuccessful(){
        getCurrentActivity();
      }
      @Override public void connected(      XMPPConnection connection){
      }
      @Override public void authenticated(      XMPPConnection connection){
      }
      @Override public void connectionClosed(){
      }
      @Override public void connectionClosedOnError(      Exception e){
      }
      @Override public void reconnectingIn(      int seconds){
      }
      @Override public void reconnectionFailed(      Exception e){
      }
    }
);
    heartbeat=scheduler.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        try {
          if (connection.isConnected()) {
            sendPing();
          }
        }
 catch (        Exception e) {
          logger.warn("String_Node_Str",e);
        }
      }
    }
,30,30,TimeUnit.SECONDS);
    monitorActivityChanges();
    getCurrentActivity();
  }
 catch (  XMPPException|SmackException|IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}