Program: 57059
Project: 57059
Buggy source:
/** 
 * Add the required Javascript files and the FontAwesome CDN link.
 * @param root The UIViewRoot of the JSF tree.
 * @param context The current FacesContext
 * @param isProduction This flag can be used to deliver different version of the JS library, optimized for debugging or production.
 */
private void addJavascript(UIViewRoot root,FacesContext context,boolean isProduction){
  Application app=context.getApplication();
  ResourceHandler rh=app.getResourceHandler();
  String theme=null;
  theme=context.getExternalContext().getInitParameter(C.P_USETHEME);
  if (isFontAwesomeComponentUsedAndRemoveIt() || (theme != null && theme.equals(C.TRUE))) {
    Resource themeResource=rh.createResource(C.BSF_CSS_TBSTHEME,C.BSF_LIBRARY);
    if (themeResource == null) {
      throw new FacesException("String_Node_Str" + C.BSF_CSS_TBSTHEME + "String_Node_Str"+ C.BSF_LIBRARY+ "String_Node_Str");
    }
 else {
      UIOutput output=new UIOutput();
      output.setRendererType("String_Node_Str");
      output.getAttributes().put("String_Node_Str",C.BSF_CSS_TBSTHEME);
      output.getAttributes().put("String_Node_Str",C.BSF_LIBRARY);
      output.getAttributes().put("String_Node_Str","String_Node_Str");
      root.addComponentResource(context,output,"String_Node_Str");
    }
  }
  UIComponent header=findHeader(root);
  boolean useCDNImportForFontAwesome=(null == header) || (null == header.getFacet("String_Node_Str"));
  if (useCDNImportForFontAwesome) {
    String useCDN=FacesContext.getCurrentInstance().getExternalContext().getInitParameter("String_Node_Str");
    if (null != useCDN)     if (useCDN.equalsIgnoreCase("String_Node_Str") || useCDN.equals("String_Node_Str"))     useCDNImportForFontAwesome=false;
  }
  boolean loadJQuery=true;
  List<UIComponent> availableResources=root.getComponentResources(context,"String_Node_Str");
  for (  UIComponent ava : availableResources) {
    String name=(String)ava.getAttributes().get("String_Node_Str");
    if (null != name) {
      name=name.toLowerCase();
      if ((name.contains("String_Node_Str") || name.contains("String_Node_Str")) && name.endsWith("String_Node_Str"))       useCDNImportForFontAwesome=false;
      if (name.contains("String_Node_Str") && name.endsWith("String_Node_Str")) {
      }
 else       if (name.contains("String_Node_Str") && name.endsWith("String_Node_Str")) {
        loadJQuery=false;
      }
    }
  }
  if (useCDNImportForFontAwesome) {
    InternalFALink output=new InternalFALink();
    output.getAttributes().put("String_Node_Str",C.FONTAWESOME_CDN_URL);
    root.addComponentResource(context,output,"String_Node_Str");
  }
  Map<String,Object> viewMap=root.getViewMap();
  @SuppressWarnings("String_Node_Str") Map<String,String> resourceMap=(Map<String,String>)viewMap.get(RESOURCE_KEY);
  if (null != resourceMap) {
    if (loadJQuery) {
      boolean needsJQuery=false;
      for (      Entry<String,String> entry : resourceMap.entrySet()) {
        String file=entry.getValue();
        if ("String_Node_Str".equals(file)) {
          needsJQuery=true;
        }
      }
      if (needsJQuery) {
        UIOutput output=new UIOutput();
        output.setRendererType("String_Node_Str");
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        output.getAttributes().put("String_Node_Str",C.BSF_LIBRARY);
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        root.addComponentResource(context,output,"String_Node_Str");
      }
    }
    for (    Entry<String,String> entry : resourceMap.entrySet()) {
      String file=entry.getValue();
      String library=entry.getKey().substring(0,entry.getKey().length() - file.length() - 1);
      if (!"String_Node_Str".equals(file)) {
        UIOutput output=new UIOutput();
        output.setRendererType("String_Node_Str");
        output.getAttributes().put("String_Node_Str",file);
        output.getAttributes().put("String_Node_Str",library);
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        root.addComponentResource(context,output,"String_Node_Str");
      }
    }
  }
  enforceCorrectLoadOrder(root,context);
{
    InternalIE8CompatiblityLinks output=new InternalIE8CompatiblityLinks();
    root.addComponentResource(context,output,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Add the required Javascript files and the FontAwesome CDN link.
 * @param root The UIViewRoot of the JSF tree.
 * @param context The current FacesContext
 * @param isProduction This flag can be used to deliver different version of the JS library, optimized for debugging or production.
 */
private void addJavascript(UIViewRoot root,FacesContext context,boolean isProduction){
  Application app=context.getApplication();
  ResourceHandler rh=app.getResourceHandler();
  String theme=null;
  theme=context.getExternalContext().getInitParameter(C.P_USETHEME);
  if (isFontAwesomeComponentUsedAndRemoveIt() || (theme != null && theme.equals(C.TRUE))) {
    Resource themeResource=rh.createResource(C.BSF_CSS_TBSTHEME,C.BSF_LIBRARY);
    if (themeResource == null) {
      throw new FacesException("String_Node_Str" + C.BSF_CSS_TBSTHEME + "String_Node_Str"+ C.BSF_LIBRARY+ "String_Node_Str");
    }
 else {
      UIOutput output=new UIOutput();
      output.setRendererType("String_Node_Str");
      output.getAttributes().put("String_Node_Str",C.BSF_CSS_TBSTHEME);
      output.getAttributes().put("String_Node_Str",C.BSF_LIBRARY);
      output.getAttributes().put("String_Node_Str","String_Node_Str");
      addResourceIfNecessary(root,context,output);
    }
  }
  UIComponent header=findHeader(root);
  boolean useCDNImportForFontAwesome=(null == header) || (null == header.getFacet("String_Node_Str"));
  if (useCDNImportForFontAwesome) {
    String useCDN=FacesContext.getCurrentInstance().getExternalContext().getInitParameter("String_Node_Str");
    if (null != useCDN)     if (useCDN.equalsIgnoreCase("String_Node_Str") || useCDN.equals("String_Node_Str"))     useCDNImportForFontAwesome=false;
  }
  boolean loadJQuery=true;
  List<UIComponent> availableResources=root.getComponentResources(context,"String_Node_Str");
  for (  UIComponent ava : availableResources) {
    String name=(String)ava.getAttributes().get("String_Node_Str");
    if (null != name) {
      name=name.toLowerCase();
      if ((name.contains("String_Node_Str") || name.contains("String_Node_Str")) && name.endsWith("String_Node_Str"))       useCDNImportForFontAwesome=false;
      if (name.contains("String_Node_Str") && name.endsWith("String_Node_Str")) {
      }
 else       if (name.contains("String_Node_Str") && name.endsWith("String_Node_Str")) {
        loadJQuery=false;
      }
    }
  }
  if (useCDNImportForFontAwesome) {
    InternalFALink output=new InternalFALink();
    output.getAttributes().put("String_Node_Str",C.FONTAWESOME_CDN_URL);
    addResourceIfNecessary(root,context,output);
  }
  Map<String,Object> viewMap=root.getViewMap();
  @SuppressWarnings("String_Node_Str") Map<String,String> resourceMap=(Map<String,String>)viewMap.get(RESOURCE_KEY);
  if (null != resourceMap) {
    if (loadJQuery) {
      boolean needsJQuery=false;
      for (      Entry<String,String> entry : resourceMap.entrySet()) {
        String file=entry.getValue();
        if ("String_Node_Str".equals(file)) {
          needsJQuery=true;
        }
      }
      if (needsJQuery) {
        UIOutput output=new UIOutput();
        output.setRendererType("String_Node_Str");
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        output.getAttributes().put("String_Node_Str",C.BSF_LIBRARY);
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        addResourceIfNecessary(root,context,output);
      }
    }
    for (    Entry<String,String> entry : resourceMap.entrySet()) {
      String file=entry.getValue();
      String library=entry.getKey().substring(0,entry.getKey().length() - file.length() - 1);
      if (!"String_Node_Str".equals(file)) {
        UIOutput output=new UIOutput();
        output.setRendererType("String_Node_Str");
        output.getAttributes().put("String_Node_Str",file);
        output.getAttributes().put("String_Node_Str",library);
        output.getAttributes().put("String_Node_Str","String_Node_Str");
        addResourceIfNecessary(root,context,output);
      }
    }
  }
  enforceCorrectLoadOrder(root,context);
{
    InternalIE8CompatiblityLinks output=new InternalIE8CompatiblityLinks();
    addResourceIfNecessary(root,context,output);
  }
}