Program: 116325
Project: 116325
Buggy source:
@Override public void buildTemplate(){
  IaasProvider iaasInfo=getIaasProvider();
  if (iaasInfo.getComputeService() == null) {
    String msg="String_Node_Str" + iaasInfo.getName();
    log.fatal(msg);
    throw new CloudControllerException(msg);
  }
  TemplateBuilder templateBuilder=iaasInfo.getComputeService().templateBuilder();
  templateBuilder.imageId(iaasInfo.getImage());
  if (iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
    Set<? extends Location> locations=iaasInfo.getComputeService().listAssignableLocations();
    for (    Location location : locations) {
      if (location.getId().equals(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE))) {
        templateBuilder.locationId(location.getId());
        log.info("String_Node_Str" + iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) + "String_Node_Str"+ location.getId());
        break;
      }
    }
  }
  if (iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE) != null) {
    templateBuilder.hardwareId(iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE));
  }
  Template template=templateBuilder.build();
  boolean blockUntilRunning=Boolean.parseBoolean(iaasInfo.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP));
  template.getOptions().as(TemplateOptions.class).blockUntilRunning(blockUntilRunning);
  template.getOptions().as(TemplateOptions.class).inboundPorts(new int[]{});
  if (iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUP_IDS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).securityGroupIds(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUP_IDS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.NETWORK_IDS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).networks(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.NETWORK_IDS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.USER_NAME) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).account(iaasInfo.getProperty(CloudControllerConstants.USER_NAME));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.DOMAIN_ID) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).domainId(iaasInfo.getProperty(CloudControllerConstants.DOMAIN_ID));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).keyPair(iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.TAGS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).tags(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.TAGS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.DISK_OFFERING) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).diskOfferingId(iaasInfo.getProperty(CloudControllerConstants.DISK_OFFERING));
  }
  iaasInfo.setTemplate(template);
}

Fixed version (ground truth):
@Override public void buildTemplate(){
  IaasProvider iaasInfo=getIaasProvider();
  if (iaasInfo.getComputeService() == null) {
    String msg="String_Node_Str" + iaasInfo.getName();
    log.error(msg);
    throw new CloudControllerException(msg);
  }
  TemplateBuilder templateBuilder=iaasInfo.getComputeService().templateBuilder();
  templateBuilder.imageId(iaasInfo.getImage());
  if (iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
    Set<? extends Location> locations=iaasInfo.getComputeService().listAssignableLocations();
    for (    Location location : locations) {
      if (location.getId().equals(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE))) {
        templateBuilder.locationId(location.getId());
        log.info("String_Node_Str" + iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) + "String_Node_Str"+ location.getId());
        break;
      }
    }
  }
  if (iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE) != null) {
    templateBuilder.hardwareId(iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE));
  }
  Template template=templateBuilder.build();
  boolean blockUntilRunning=Boolean.parseBoolean(iaasInfo.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP));
  template.getOptions().as(TemplateOptions.class).blockUntilRunning(blockUntilRunning);
  template.getOptions().as(TemplateOptions.class).inboundPorts(new int[]{});
  if (iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUP_IDS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).securityGroupIds(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUP_IDS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.NETWORK_IDS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).networks(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.NETWORK_IDS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.USER_NAME) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).account(iaasInfo.getProperty(CloudControllerConstants.USER_NAME));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.DOMAIN_ID) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).domainId(iaasInfo.getProperty(CloudControllerConstants.DOMAIN_ID));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).keyPair(iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.TAGS) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).tags(Arrays.asList(iaasInfo.getProperty(CloudControllerConstants.TAGS).split(CloudControllerConstants.ENTRY_SEPARATOR)));
  }
  if (iaasInfo.getProperty(CloudControllerConstants.DISK_OFFERING) != null) {
    template.getOptions().as(CloudStackTemplateOptions.class).diskOfferingId(iaasInfo.getProperty(CloudControllerConstants.DISK_OFFERING));
  }
  iaasInfo.setTemplate(template);
}