Program: 79545
Project: 79545
Buggy source:
/** 
 * returns the jclouds Template which describes the image to be built, for the given config and compute service 
 */
public Template buildTemplate(ComputeService computeService,ConfigBag config){
  TemplateBuilder templateBuilder=(TemplateBuilder)config.get(TEMPLATE_BUILDER);
  if (templateBuilder == null) {
    templateBuilder=new PortableTemplateBuilder<PortableTemplateBuilder<?>>();
  }
 else {
    LOG.debug("String_Node_Str",new Object[]{templateBuilder,this,config.getDescription()});
  }
  if (templateBuilder instanceof PortableTemplateBuilder<?>) {
    if (((PortableTemplateBuilder<?>)templateBuilder).imageChooser() == null) {
      templateBuilder.imageChooser(getConfig(JcloudsLocationConfig.IMAGE_CHOOSER));
    }
 else {
    }
  }
 else {
    LOG.warn("String_Node_Str" + "String_Node_Str",config.getDescription());
  }
  if (!Strings.isEmpty(config.get(CLOUD_REGION_ID))) {
    templateBuilder.locationId(config.get(CLOUD_REGION_ID));
  }
  for (  Map.Entry<ConfigKey<?>,CustomizeTemplateBuilder> entry : SUPPORTED_TEMPLATE_BUILDER_PROPERTIES.entrySet()) {
    ConfigKey<?> name=entry.getKey();
    CustomizeTemplateBuilder code=entry.getValue();
    if (config.containsKey(name))     code.apply(templateBuilder,config,config.get(name));
  }
  if (templateBuilder instanceof PortableTemplateBuilder) {
    ((PortableTemplateBuilder<?>)templateBuilder).attachComputeService(computeService);
    if (truth(config.get(DEFAULT_IMAGE_ID))) {
      if (((PortableTemplateBuilder<?>)templateBuilder).isBlank()) {
        templateBuilder.imageId(config.get(DEFAULT_IMAGE_ID).toString());
      }
    }
  }
  for (  JcloudsLocationCustomizer customizer : getCustomizers(config)) {
    customizer.customize(this,computeService,templateBuilder);
  }
  Template template;
  try {
    template=templateBuilder.build();
    if (template == null)     throw new NullPointerException("String_Node_Str");
    LOG.debug("String_Node_Str" + this + "String_Node_Str"+ template+ "String_Node_Str"+ template.getImage()+ "String_Node_Str");
    if (template.getImage() == null)     throw new NullPointerException("String_Node_Str");
  }
 catch (  AuthorizationException e) {
    LOG.warn("String_Node_Str" + e + "String_Node_Str");
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ templateBuilder,e);
  }
catch (  Exception e) {
    try {
synchronized (this) {
        LOG.warn("String_Node_Str" + templateBuilder + "String_Node_Str"+ this+ "String_Node_Str"+ e);
        if (!listedAvailableTemplatesOnNoSuchTemplate) {
          listedAvailableTemplatesOnNoSuchTemplate=true;
          logAvailableTemplates(config);
        }
      }
    }
 catch (    Exception e2) {
      LOG.warn("String_Node_Str" + e2,e2);
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ templateBuilder,e);
    }
    throw new IllegalStateException("String_Node_Str" + templateBuilder + "String_Node_Str"+ this+ "String_Node_Str",e);
  }
  TemplateOptions options=template.getOptions();
  for (  Map.Entry<ConfigKey<?>,CustomizeTemplateOptions> entry : SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES.entrySet()) {
    ConfigKey<?> key=entry.getKey();
    CustomizeTemplateOptions code=entry.getValue();
    if (config.containsKey(key))     code.apply(options,config,config.get(key));
  }
  return template;
}

Fixed version (ground truth):
/** 
 * returns the jclouds Template which describes the image to be built, for the given config and compute service 
 */
public Template buildTemplate(ComputeService computeService,ConfigBag config){
  TemplateBuilder templateBuilder=(TemplateBuilder)config.get(TEMPLATE_BUILDER);
  if (templateBuilder == null) {
    templateBuilder=new PortableTemplateBuilder<PortableTemplateBuilder<?>>();
  }
 else {
    LOG.debug("String_Node_Str",new Object[]{templateBuilder,this,config.getDescription()});
  }
  if (templateBuilder instanceof PortableTemplateBuilder<?>) {
    if (((PortableTemplateBuilder<?>)templateBuilder).imageChooser() == null) {
      templateBuilder.imageChooser(getConfig(JcloudsLocationConfig.IMAGE_CHOOSER));
    }
 else {
    }
  }
 else {
    LOG.warn("String_Node_Str" + "String_Node_Str",config.getDescription());
  }
  if (!Strings.isEmpty(config.get(CLOUD_REGION_ID))) {
    templateBuilder.locationId(config.get(CLOUD_REGION_ID));
  }
  for (  Map.Entry<ConfigKey<?>,CustomizeTemplateBuilder> entry : SUPPORTED_TEMPLATE_BUILDER_PROPERTIES.entrySet()) {
    ConfigKey<?> name=entry.getKey();
    CustomizeTemplateBuilder code=entry.getValue();
    if (config.containsKey(name))     code.apply(templateBuilder,config,config.get(name));
  }
  if (templateBuilder instanceof PortableTemplateBuilder) {
    ((PortableTemplateBuilder<?>)templateBuilder).attachComputeService(computeService);
    if (truth(config.get(DEFAULT_IMAGE_ID))) {
      if (((PortableTemplateBuilder<?>)templateBuilder).isBlank()) {
        templateBuilder.imageId(config.get(DEFAULT_IMAGE_ID).toString());
      }
    }
  }
  for (  JcloudsLocationCustomizer customizer : getCustomizers(config)) {
    customizer.customize(this,computeService,templateBuilder);
  }
  Template template;
  try {
    template=templateBuilder.build();
    if (template == null)     throw new NullPointerException("String_Node_Str");
    LOG.debug("String_Node_Str" + this + "String_Node_Str"+ template+ "String_Node_Str"+ template.getImage()+ "String_Node_Str");
    if (template.getImage() == null)     throw new NullPointerException("String_Node_Str");
  }
 catch (  AuthorizationException e) {
    LOG.warn("String_Node_Str" + e + "String_Node_Str");
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ templateBuilder,e);
  }
catch (  Exception e) {
    try {
synchronized (this) {
        LOG.warn("String_Node_Str" + templateBuilder + "String_Node_Str"+ this+ "String_Node_Str"+ e);
        if (!listedAvailableTemplatesOnNoSuchTemplate) {
          listedAvailableTemplatesOnNoSuchTemplate=true;
          logAvailableTemplates(config);
        }
      }
    }
 catch (    Exception e2) {
      LOG.warn("String_Node_Str" + e2,e2);
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ templateBuilder+ "String_Node_Str"+ e,e);
    }
    throw new IllegalStateException("String_Node_Str" + templateBuilder + "String_Node_Str"+ this+ "String_Node_Str"+ "String_Node_Str"+ e,e);
  }
  TemplateOptions options=template.getOptions();
  for (  Map.Entry<ConfigKey<?>,CustomizeTemplateOptions> entry : SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES.entrySet()) {
    ConfigKey<?> key=entry.getKey();
    CustomizeTemplateOptions code=entry.getValue();
    if (config.containsKey(key))     code.apply(options,config,config.get(key));
  }
  return template;
}