Program: 107429
Project: 107429
Buggy source:
@Override @DB public String uploadCertificate(UploadCustomCertificateCmd cmd) throws ServerApiException {
  try {
    CertificateVO cert=_certDao.listAll().get(0);
    if (cert.getUpdated().equals("String_Node_Str")) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str");
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str");
    }
    String certificatePath=cmd.getPath();
    CertificateVO lockedCert=_certDao.acquire(cert.getId());
    Long certVOId=_certDao.persistCustomCertToDb(certificatePath,lockedCert);
    if (certVOId != null && certVOId != 0) {
      List<ConsoleProxyVO> cpList=_consoleProxyDao.listAll();
      if (cpList.size() == 0) {
        throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR,"String_Node_Str");
      }
      List<HostVO> cpHosts=_hostDao.listByType(com.cloud.host.Host.Type.ConsoleProxy);
      if (cpHosts.size() == 0) {
        throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR,"String_Node_Str");
      }
      Map<String,Long> hostNameToHostIdMap=new HashMap<String,Long>();
      List<Long> updatedCpIdList=new ArrayList<Long>();
      for (      HostVO cpHost : cpHosts) {
        hostNameToHostIdMap.put(cpHost.getName(),cpHost.getId());
      }
      for (      ConsoleProxyVO cp : cpList) {
        Long cpHostId=hostNameToHostIdMap.get(cp.getName());
        UpdateCertificateCommand certCmd=new UpdateCertificateCommand(_certDao.findById(certVOId).getCertificate());
        try {
          Answer updateCertAns=_agentMgr.send(cpHostId,certCmd);
          if (updateCertAns.getResult() == true) {
            long eventId=saveScheduledEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_PROXY_REBOOT,"String_Node_Str" + cp.getId());
            _consoleProxyMgr.rebootProxy(cp.getId(),eventId);
            if (s_logger.isDebugEnabled())             s_logger.debug("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId);
            updatedCpIdList.add(cp.getId());
          }
        }
 catch (        AgentUnavailableException e) {
          s_logger.warn("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId,e);
        }
catch (        OperationTimedoutException e) {
          s_logger.warn("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId,e);
        }
      }
      _certDao.release(lockedCert.getId());
      return ("String_Node_Str" + updatedCpIdList.size() + "String_Node_Str"+ cpList.size()+ "String_Node_Str");
    }
 else {
      return null;
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
@Override @DB public String uploadCertificate(UploadCustomCertificateCmd cmd) throws ServerApiException {
  try {
    CertificateVO cert=_certDao.listAll().get(0);
    if (cert.getUpdated().equals("String_Node_Str")) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str");
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str");
    }
    String certificatePath=cmd.getPath();
    CertificateVO lockedCert=_certDao.acquire(cert.getId());
    Long certVOId=_certDao.persistCustomCertToDb(certificatePath,lockedCert);
    if (certVOId != null && certVOId != 0) {
      List<ConsoleProxyVO> cpList=_consoleProxyDao.listAll();
      if (cpList.size() == 0) {
        throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR,"String_Node_Str");
      }
      List<HostVO> cpHosts=_hostDao.listByType(com.cloud.host.Host.Type.ConsoleProxy);
      if (cpHosts.size() == 0) {
        throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR,"String_Node_Str");
      }
      Map<String,Long> hostNameToHostIdMap=new HashMap<String,Long>();
      List<Long> updatedCpIdList=new ArrayList<Long>();
      for (      HostVO cpHost : cpHosts) {
        hostNameToHostIdMap.put(cpHost.getName(),cpHost.getId());
      }
      for (      ConsoleProxyVO cp : cpList) {
        Long cpHostId=hostNameToHostIdMap.get(cp.getName());
        UpdateCertificateCommand certCmd=new UpdateCertificateCommand(_certDao.findById(certVOId).getCertificate(),false);
        try {
          Answer updateCertAns=_agentMgr.send(cpHostId,certCmd);
          if (updateCertAns.getResult() == true) {
            long eventId=saveScheduledEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_PROXY_REBOOT,"String_Node_Str" + cp.getId());
            _consoleProxyMgr.rebootProxy(cp.getId(),eventId);
            if (s_logger.isDebugEnabled())             s_logger.debug("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId);
            updatedCpIdList.add(cp.getId());
          }
        }
 catch (        AgentUnavailableException e) {
          s_logger.warn("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId,e);
        }
catch (        OperationTimedoutException e) {
          s_logger.warn("String_Node_Str" + cp.getId() + "String_Node_Str"+ cpHostId,e);
        }
      }
      _certDao.release(lockedCert.getId());
      return ("String_Node_Str" + updatedCpIdList.size() + "String_Node_Str"+ cpList.size()+ "String_Node_Str");
    }
 else {
      return null;
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str");
  }
  return null;
}