Program: 48067
Project: 48067
Buggy source:
/** 
 * Get translated version of a file depending on current locale. <p>The file's base path equals the component directory. The language definition is enclosed between the filename and the file ending plus a '.'.</p> <p>An example looks like this:<br/> <pre> I18n l = I18n.getTranslation("gui"); l.translationForFile("about", "html"); // this code in a german environment tries to load the following files until one is found // - openecard_i18n/gui/about_de_DE.html // - openecard_i18n/gui/about_de.html // - openecard_i18n/gui/about_C.html</pre> </p>
 * @param name Name part of the file
 * @param fileEnding File ending if available, null otherwise.
 * @return URL pointing to the translated, or default file.
 * @throws IOException Thrown in case no resource is available.
 */
public synchronized URL translationForFile(String name,String fileEnding) throws IOException {
  fileEnding=fileEnding != null ? ("String_Node_Str" + fileEnding) : "String_Node_Str";
  String mapKey=name + fileEnding;
  if (translatedFiles.containsKey(mapKey)) {
    URL url=translatedFiles.get(mapKey);
    if (url == null) {
      throw new IOException("String_Node_Str" + name + fileEnding+ "String_Node_Str");
    }
 else {
      return url;
    }
  }
  Locale locale=Locale.getDefault();
  String lang=locale.getLanguage();
  String country=locale.getCountry();
  String fnameBase="String_Node_Str" + component + "String_Node_Str"+ name;
  if (!lang.isEmpty() && !country.isEmpty()) {
    String fileName=fnameBase + "String_Node_Str" + lang+ "String_Node_Str"+ country+ fileEnding;
    URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
    if (url != null) {
      translatedFiles.put(mapKey,url);
      return url;
    }
  }
  if (!lang.isEmpty()) {
    String fileName=fnameBase + "String_Node_Str" + lang+ fileEnding;
    URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
    if (url != null) {
      translatedFiles.put(mapKey,url);
      return url;
    }
  }
  String fileName=fnameBase + "String_Node_Str" + fileEnding;
  URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
  if (url != null) {
    translatedFiles.put(mapKey,url);
    return url;
  }
  translatedFiles.put(mapKey,null);
  throw new IOException("String_Node_Str" + name + fileEnding+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get translated version of a file depending on current locale. <p>The file's base path equals the component directory. The language definition is enclosed between the filename and the file ending plus a '.'.</p> <p>An example looks like this:<br/> <pre> I18n l = I18n.getTranslation("gui"); l.translationForFile("about", "html"); // this code in a german environment tries to load the following files until one is found // - openecard_i18n/gui/about_de_DE.html // - openecard_i18n/gui/about_de.html // - openecard_i18n/gui/about_C.html</pre> </p>
 * @param name Name part of the file.
 * @param fileEnding File ending if available, null otherwise.
 * @return URL pointing to the translated, or default file.
 * @throws IOException Thrown in case no resource is available.
 */
@Nonnull public synchronized URL translationForFile(String name,String fileEnding) throws IOException {
  fileEnding=fileEnding != null ? ("String_Node_Str" + fileEnding) : "String_Node_Str";
  String mapKey=name + fileEnding;
  if (translatedFiles.containsKey(mapKey)) {
    URL url=translatedFiles.get(mapKey);
    if (url == null) {
      throw new IOException("String_Node_Str" + name + fileEnding+ "String_Node_Str");
    }
 else {
      return url;
    }
  }
  Locale locale=Locale.getDefault();
  String lang=locale.getLanguage();
  String country=locale.getCountry();
  String fnameBase="String_Node_Str" + component + "String_Node_Str"+ name;
  if (!lang.isEmpty() && !country.isEmpty()) {
    String fileName=fnameBase + "String_Node_Str" + lang+ "String_Node_Str"+ country+ fileEnding;
    URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
    if (url != null) {
      translatedFiles.put(mapKey,url);
      return url;
    }
  }
  if (!lang.isEmpty()) {
    String fileName=fnameBase + "String_Node_Str" + lang+ fileEnding;
    URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
    if (url != null) {
      translatedFiles.put(mapKey,url);
      return url;
    }
  }
  String fileName=fnameBase + "String_Node_Str" + fileEnding;
  URL url=FileUtils.resolveResourceAsURL(loaderReference,fileName);
  if (url != null) {
    translatedFiles.put(mapKey,url);
    return url;
  }
  translatedFiles.put(mapKey,null);
  throw new IOException("String_Node_Str" + name + fileEnding+ "String_Node_Str");
}