Program: 188600
Project: 188600
Buggy source:
public static List<SupportedMetadataTypeBundle> retrieveSupportedMetadata(User user,IndexedAIP aip,Locale locale) throws GenericException {
  Messages messages=RodaCoreFactory.getI18NMessages(locale);
  List<String> types=RodaUtils.copyList(RodaCoreFactory.getRodaConfiguration().getList(RodaConstants.UI_BROWSER_METADATA_DESCRIPTIVE_TYPES));
  List<SupportedMetadataTypeBundle> supportedMetadata=new ArrayList<>();
  if (types != null) {
    for (    String id : types) {
      String type=id;
      String version=null;
      if (id.contains(RodaConstants.METADATA_VERSION_SEPARATOR)) {
        version=id.substring(id.lastIndexOf(RodaConstants.METADATA_VERSION_SEPARATOR) + 1,id.length());
        type=id.substring(0,id.lastIndexOf(RodaConstants.METADATA_VERSION_SEPARATOR));
      }
      String key=RodaConstants.I18N_UI_BROWSE_METADATA_DESCRIPTIVE_TYPE_PREFIX + id;
      if (version != null) {
        key+="String_Node_Str" + version;
      }
      String label=messages.getTranslation(key,id);
      InputStream templateStream=RodaCoreFactory.getConfigurationFileAsStream(RodaConstants.METADATA_TEMPLATE_FOLDER + "String_Node_Str" + ((version != null) ? id + RodaConstants.METADATA_VERSION_SEPARATOR + version : id)+ RodaConstants.METADATA_TEMPLATE_EXTENSION);
      String template=null;
      Set<MetadataValue> values=null;
      if (templateStream != null) {
        try {
          template=IOUtils.toString(templateStream,RodaConstants.DEFAULT_ENCODING);
          values=ServerTools.transform(template);
          for (          MetadataValue mv : values) {
            String generator=mv.get("String_Node_Str");
            if (generator != null && generator.length() > 0) {
              String value=ServerTools.autoGenerateValue(aip,user,generator);
              if (value != null) {
                mv.set("String_Node_Str",value);
              }
            }
            String labels=mv.get("String_Node_Str");
            String labelI18N=mv.get("String_Node_Str");
            if (labels != null && labelI18N != null) {
              Map<String,String> labelsMaps=JsonUtils.getMapFromJson(labels);
              try {
                labelsMaps.put(locale.toString(),RodaCoreFactory.getI18NMessages(locale).getTranslation(labelI18N));
              }
 catch (              MissingResourceException e) {
                LOGGER.debug("String_Node_Str",labelI18N);
              }
              labels=JsonUtils.getJsonFromObject(labelsMaps);
              mv.set("String_Node_Str",labels);
            }
            String i18nPrefix=mv.get("String_Node_Str");
            if (i18nPrefix != null) {
              try {
                Map<String,String> terms=messages.getTranslations(i18nPrefix,String.class,false);
                Map<String,Map<String,String>> i18nMap=new HashMap<String,Map<String,String>>();
                for (                Map.Entry<String,String> entry : terms.entrySet()) {
                  Map<String,String> term=new HashMap<String,String>();
                  term.put(locale.toString(),entry.getValue());
                  i18nMap.put(entry.getKey().replace(i18nPrefix + "String_Node_Str","String_Node_Str"),term);
                }
                mv.set("String_Node_Str",JsonUtils.getJsonFromObject(i18nMap));
              }
 catch (              MissingResourceException e) {
                LOGGER.error(e.getMessage(),e);
              }
            }
          }
        }
 catch (        IOException e) {
          LOGGER.error("String_Node_Str",e);
        }
      }
      supportedMetadata.add(new SupportedMetadataTypeBundle(id,type,version,label,template,values));
    }
  }
  return supportedMetadata;
}

Fixed version (ground truth):
public static List<SupportedMetadataTypeBundle> retrieveSupportedMetadata(User user,IndexedAIP aip,Locale locale) throws GenericException {
  LOGGER.error("String_Node_Str");
  Messages messages=RodaCoreFactory.getI18NMessages(locale);
  List<String> types=RodaUtils.copyList(RodaCoreFactory.getRodaConfiguration().getList(RodaConstants.UI_BROWSER_METADATA_DESCRIPTIVE_TYPES));
  List<SupportedMetadataTypeBundle> supportedMetadata=new ArrayList<>();
  if (types != null) {
    for (    String id : types) {
      String type=id;
      String version=null;
      if (id.contains(RodaConstants.METADATA_VERSION_SEPARATOR)) {
        version=id.substring(id.lastIndexOf(RodaConstants.METADATA_VERSION_SEPARATOR) + 1,id.length());
        type=id.substring(0,id.lastIndexOf(RodaConstants.METADATA_VERSION_SEPARATOR));
      }
      String key=RodaConstants.I18N_UI_BROWSE_METADATA_DESCRIPTIVE_TYPE_PREFIX + type;
      if (version != null) {
        key+=RodaConstants.METADATA_VERSION_SEPARATOR + version;
      }
      String label=messages.getTranslation(key,type);
      InputStream templateStream=RodaCoreFactory.getConfigurationFileAsStream(RodaConstants.METADATA_TEMPLATE_FOLDER + "String_Node_Str" + ((version != null) ? type + RodaConstants.METADATA_VERSION_SEPARATOR + version : type)+ RodaConstants.METADATA_TEMPLATE_EXTENSION);
      String template=null;
      Set<MetadataValue> values=null;
      if (templateStream != null) {
        try {
          template=IOUtils.toString(templateStream,RodaConstants.DEFAULT_ENCODING);
          values=ServerTools.transform(template);
          for (          MetadataValue mv : values) {
            String generator=mv.get("String_Node_Str");
            if (generator != null && generator.length() > 0) {
              String value=ServerTools.autoGenerateValue(aip,user,generator);
              if (value != null) {
                mv.set("String_Node_Str",value);
              }
            }
            String labels=mv.get("String_Node_Str");
            String labelI18N=mv.get("String_Node_Str");
            if (labels != null && labelI18N != null) {
              Map<String,String> labelsMaps=JsonUtils.getMapFromJson(labels);
              try {
                labelsMaps.put(locale.toString(),RodaCoreFactory.getI18NMessages(locale).getTranslation(labelI18N));
              }
 catch (              MissingResourceException e) {
                LOGGER.debug("String_Node_Str",labelI18N);
              }
              labels=JsonUtils.getJsonFromObject(labelsMaps);
              mv.set("String_Node_Str",labels);
            }
            String i18nPrefix=mv.get("String_Node_Str");
            if (i18nPrefix != null) {
              try {
                Map<String,String> terms=messages.getTranslations(i18nPrefix,String.class,false);
                Map<String,Map<String,String>> i18nMap=new HashMap<String,Map<String,String>>();
                for (                Map.Entry<String,String> entry : terms.entrySet()) {
                  Map<String,String> term=new HashMap<String,String>();
                  term.put(locale.toString(),entry.getValue());
                  i18nMap.put(entry.getKey().replace(i18nPrefix + "String_Node_Str","String_Node_Str"),term);
                }
                mv.set("String_Node_Str",JsonUtils.getJsonFromObject(i18nMap));
              }
 catch (              MissingResourceException e) {
                LOGGER.error(e.getMessage(),e);
              }
            }
          }
        }
 catch (        IOException e) {
          LOGGER.error("String_Node_Str",e);
        }
      }
      supportedMetadata.add(new SupportedMetadataTypeBundle(id,type,version,label,template,values));
    }
  }
  return supportedMetadata;
}