Program: 12468
Project: 12468
Buggy source:
private Integer doSend() throws Exception {
  if (message == null) {
    this.progress.incrFailed();
    return 0;
  }
  if (message.getClients() == null || message.getClients().size() == 0) {
    this.progress.incrFailed();
    logger.error("String_Node_Str",message);
    return 0;
  }
  SentProgress thisProg=new SentProgress(message.getClients().size());
  for (  String client : message.getClients()) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str",client,message);
    }
    Connection c=ConnectionKeeper.get(product.getAppKey(),client);
    if (c != null) {
      c.send(thisProg,message);
    }
 else {
      Client cc=ClientServiceImpl.instance.findByUserId(client);
      if (cc == null) {
        logger.error("String_Node_Str" + client);
        thisProg.incrFailed();
        if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
          thisProg.incrFailed();
          message.addFailedClient(cc.getUserId(),new PushError(PushError.NoClient));
        }
 else {
          thisProg.incrSuccess();
        }
        continue;
      }
      if (!cc.isDevice(ClientType.iOS)) {
        logger.error("String_Node_Str" + client);
        thisProg.incrFailed();
        message.addFailedClient(cc.getUserId(),new PushError(PushError.NoConnections));
        continue;
      }
      if (StringUtils.isBlank(cc.getDeviceToken())) {
        logger.error("String_Node_Str" + client);
        if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
          thisProg.incrFailed();
          message.addFailedClient(cc.getUserId(),new PushError(PushError.NoDevivceToken));
        }
 else {
          thisProg.incrSuccess();
        }
        continue;
      }
      if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.APNS_VALUE) {
        APNSKeeper.push(thisProg,this.product,cc,message);
      }
 else       if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
        thisProg.incrFailed();
        message.addFailedClient(cc.getUserId(),new PushError(PushError.WaitOnline));
      }
 else {
        thisProg.incrSuccess();
      }
    }
  }
  try {
    thisProg.getCountDownLatch().await(message.getClients().size() * 5,TimeUnit.SECONDS);
  }
 catch (  InterruptedException e) {
    logger.error(e.getMessage(),e);
  }
  logger.info("String_Node_Str" + message.getId() + "String_Node_Str"+ thisProg);
  int total=thisProg.getSuccess().get();
  if (total > 0) {
    MetricBuilder.pushMeter.mark(total);
    MetricBuilder.pushSingleMeter.mark(total);
  }
  try {
    if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
      message.setTotalUsers(total);
      message.setSentDate(new Date().getTime() / 1000);
      message.setStatusId(PayloadStatus.Sent);
      PayloadServiceImpl.instance.saveAfterSent(message);
    }
 else {
      PayloadServiceImpl.instance.updateSendStatus(message,total);
    }
  }
 catch (  Exception e) {
    logger.error(e.getMessage(),e);
  }
  this.progress.incrSuccess();
  return total;
}

Fixed version (ground truth):
private Integer doSend() throws Exception {
  if (message == null) {
    this.progress.incrFailed();
    return 0;
  }
  if (message.getClients() == null || message.getClients().size() == 0) {
    this.progress.incrFailed();
    logger.error("String_Node_Str",message);
    return 0;
  }
  SentProgress thisProg=new SentProgress(message.getClients().size());
  for (  String client : message.getClients()) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str",client,message);
    }
    Connection c=ConnectionKeeper.get(product.getAppKey(),client);
    if (c != null) {
      c.send(thisProg,message);
    }
 else {
      Client cc=ClientServiceImpl.instance.findByUserId(client);
      if (cc == null) {
        logger.error("String_Node_Str" + client);
        thisProg.incrFailed();
        if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
          thisProg.incrFailed();
          message.addFailedClient(client,new PushError(PushError.NoClient));
        }
 else {
          thisProg.incrSuccess();
        }
        continue;
      }
      if (!cc.isDevice(ClientType.iOS)) {
        logger.error("String_Node_Str" + client);
        thisProg.incrFailed();
        message.addFailedClient(cc.getUserId(),new PushError(PushError.NoConnections));
        continue;
      }
      if (StringUtils.isBlank(cc.getDeviceToken())) {
        logger.error("String_Node_Str" + client);
        if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
          thisProg.incrFailed();
          message.addFailedClient(cc.getUserId(),new PushError(PushError.NoDevivceToken));
        }
 else {
          thisProg.incrSuccess();
        }
        continue;
      }
      if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.APNS_VALUE) {
        APNSKeeper.push(thisProg,this.product,cc,message);
      }
 else       if (message.getOfflineMode().intValue() == PBAPNSMessage.OfflineModes.SendAfterOnline_VALUE) {
        thisProg.incrFailed();
        message.addFailedClient(cc.getUserId(),new PushError(PushError.WaitOnline));
      }
 else {
        thisProg.incrSuccess();
      }
    }
  }
  try {
    thisProg.getCountDownLatch().await(message.getClients().size() * 5,TimeUnit.SECONDS);
  }
 catch (  InterruptedException e) {
    logger.error(e.getMessage(),e);
  }
  logger.info("String_Node_Str" + message.getId() + "String_Node_Str"+ thisProg);
  int total=thisProg.getSuccess().get();
  if (total > 0) {
    MetricBuilder.pushMeter.mark(total);
    MetricBuilder.pushSingleMeter.mark(total);
  }
  try {
    if (message.getStatusId().intValue() == PayloadStatus.Pending0) {
      message.setTotalUsers(total);
      message.setSentDate(new Date().getTime() / 1000);
      message.setStatusId(PayloadStatus.Sent);
      PayloadServiceImpl.instance.saveAfterSent(message);
    }
 else {
      PayloadServiceImpl.instance.updateSendStatus(message,total);
    }
  }
 catch (  Exception e) {
    logger.error(e.getMessage(),e);
  }
  this.progress.incrSuccess();
  return total;
}