Program: 12415
Project: 12415
Buggy source:
private Integer doSend() throws Exception {
  if (message == null) {
    return 0;
  }
  List<String> clients=message.getClients();
  if (clients == null || clients.size() == 0) {
    logger.error("String_Node_Str",message);
    if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
      message.setStatusId(PayloadStatus.Failed);
      message.setTotalUsers(0);
      PayloadServiceImpl.instance.add(message);
    }
 else {
      message.setStatusId(PayloadStatus.Failed);
      message.setTotalUsers(0);
      PayloadServiceImpl.instance.updateSendStatus(message);
    }
    return 0;
  }
  if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
    message.setStatusId(PayloadStatus.Pending);
    message.setTotalUsers(0);
    PayloadServiceImpl.instance.add(message);
  }
  logger.info("String_Node_Str",clients.size());
  for (int i=0; i < clients.size(); i++) {
    String client=clients.get(i);
    Client cc=ClientServiceImpl.instance.findByUserId(client);
    if (cc == null) {
      logger.error("String_Node_Str",client);
      if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
        message.setStatus(client,new PushStatus(PushStatus.NoClient));
      }
      continue;
    }
    message.setBadge(cc.getBadge() + 1);
    Connection c=ConnectionKeeper.get(product.getAppKey(),client);
    if (c != null) {
      if (c.getStatusId() == ClientStatus.Online) {
        c.send(message);
        message.setStatus(client,new PushStatus(PushStatus.TcpSent));
      }
 else {
        sendMessageToOfflineClient(client,cc);
      }
    }
 else {
      sendMessageToOfflineClient(client,cc);
    }
  }
  PayloadServiceImpl.instance.updateSendStatus(message);
  return clients.size();
}

Fixed version (ground truth):
private Integer doSend() throws Exception {
  if (message == null) {
    return 0;
  }
  List<String> clients=message.getClients();
  if (clients == null || clients.size() == 0) {
    logger.error("String_Node_Str",message);
    if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
      message.setStatusId(PayloadStatus.Failed);
      message.setTotalUsers(0);
      PayloadServiceImpl.instance.add(message);
    }
 else {
      message.setStatusId(PayloadStatus.Failed);
      message.setTotalUsers(0);
      PayloadServiceImpl.instance.updateSendStatus(message);
    }
    return 0;
  }
  if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
    message.setStatusId(PayloadStatus.Pending);
    message.setTotalUsers(0);
    PayloadServiceImpl.instance.add(message);
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str",message.getId(),clients.size());
  }
  for (int i=0; i < clients.size(); i++) {
    String client=clients.get(i);
    Client cc=ClientServiceImpl.instance.findByUserId(client);
    if (cc == null) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str",message.getId(),client);
      }
      if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
        message.setStatus(client,new PushStatus(PushStatus.WaitOnline));
      }
 else {
        message.setStatus(client,new PushStatus(PushStatus.NoClient));
      }
      continue;
    }
    message.setBadge(cc.getBadge() + 1);
    Connection c=ConnectionKeeper.get(product.getAppKey(),client);
    if (c != null) {
      if (c.getStatusId() == ClientStatus.Online) {
        c.send(message);
        message.setStatus(client,new PushStatus(PushStatus.TcpSent));
      }
 else {
        sendMessageToOfflineClient(client,cc);
      }
    }
 else {
      sendMessageToOfflineClient(client,cc);
    }
  }
  PayloadServiceImpl.instance.updateSendStatus(message);
  return clients.size();
}