Program: 185135
Project: 185135
Buggy source:
public void populateFontMappings(Map documentFontNames,org.docx4j.wml.Fonts fonts) throws Exception {
  List<Fonts.Font> fontList=fonts.getFont();
  Map<String,Fonts.Font> fontsInFontTable=new HashMap<String,Fonts.Font>();
  for (  Fonts.Font font : fontList) {
    fontsInFontTable.put(normalise(font.getName()),font);
  }
  log.info("String_Node_Str");
  Iterator documentFontIterator=documentFontNames.entrySet().iterator();
  while (documentFontIterator.hasNext()) {
    Map.Entry pairs=(Map.Entry)documentFontIterator.next();
    if (pairs.getKey() == null) {
      log.info("String_Node_Str");
      pairs=(Map.Entry)documentFontIterator.next();
    }
    String fontName=(String)pairs.getKey();
    log.info("String_Node_Str" + fontName);
    String normalisedFontName=normalise(fontName);
    if (fontMappings.get(normalisedFontName) != null) {
      continue;
    }
    boolean foundAwtMapping=false;
    boolean foundPdfMapping=false;
    FontMapping fm=new FontMapping();
    fm.setMicrosoftFontName(normalisedFontName);
    org.docx4j.wml.FontPanose panose=null;
    Fonts.Font font=fontsInFontTable.get(normalisedFontName);
    if (font == null) {
      log.error("String_Node_Str" + normalisedFontName + "String_Node_Str");
    }
 else {
      panose=font.getPanose1();
    }
    org.apache.fop.fonts.Panose fopPanose=null;
    if (panose != null && panose.getVal() != null) {
      fopPanose=new org.apache.fop.fonts.Panose(panose.getVal());
      System.out.println("String_Node_Str" + fopPanose.toString());
    }
 else {
      System.out.println("String_Node_Str");
    }
    if (System.getProperty("String_Node_Str").toUpperCase().indexOf("String_Node_Str") > -1) {
    }
    if (physicalFontMap.get(normalise(fontName)) != null) {
      System.out.println(fontName + "String_Node_Str");
      foundPdfMapping=true;
      fm.setPdfSubstituteFont(normalise(fontName));
      fm.setPdfEmbeddedFile(((EmbedFontInfo)physicalFontMap.get(normalise(fontName))).getEmbedFile());
      EmbedFontInfo nfontInfo=((EmbedFontInfo)physicalFontMap.get(normalise(fontName)));
      if (nfontInfo.getPanose() == null) {
        System.out.println("String_Node_Str");
      }
 else       if (fopPanose != null) {
        long pd=fopPanose.difference(nfontInfo.getPanose().getPanoseArray());
        System.out.println("String_Node_Str" + pd);
      }
      continue;
    }
    String panoseKey=null;
    if (fopPanose != null) {
      if (!org.apache.fop.fonts.Panose.validPanose(panose.getVal())) {
        System.out.println("String_Node_Str");
      }
      System.out.println("String_Node_Str" + fopPanose);
      Iterator it=physicalFontMap.entrySet().iterator();
      long bestPanoseMatchValue=-1;
      String matchingPanoseString=null;
      while (it.hasNext()) {
        Map.Entry mapPairs=(Map.Entry)it.next();
        EmbedFontInfo fontInfo=(EmbedFontInfo)mapPairs.getValue();
        if (fontInfo.getPanose() == null) {
          continue;
        }
        long panoseMatchValue=fopPanose.difference(fontInfo.getPanose().getPanoseArray());
        if (bestPanoseMatchValue == -1 || panoseMatchValue < bestPanoseMatchValue) {
          bestPanoseMatchValue=panoseMatchValue;
          matchingPanoseString=fontInfo.getPanose().toString();
          panoseKey=(String)mapPairs.getKey();
          if (bestPanoseMatchValue == 0) {
            continue;
          }
        }
 else {
        }
      }
      if (panoseKey != null && bestPanoseMatchValue < org.apache.fop.fonts.Panose.MATCH_THRESHOLD) {
        log.info("String_Node_Str" + panoseKey + "String_Node_Str"+ matchingPanoseString+ "String_Node_Str"+ bestPanoseMatchValue);
        log.debug(fontName + "String_Node_Str" + ((EmbedFontInfo)physicalFontMap.get(panoseKey)).getEmbedFile());
        fm.setPdfSubstituteFont(panoseKey);
        fm.setPdfEmbeddedFile(((EmbedFontInfo)physicalFontMap.get(panoseKey)).getEmbedFile());
        FontSubstitutions.Replace rtmp=(FontSubstitutions.Replace)replaceMap.get(normalise(fontName));
        if (rtmp != null && rtmp.getSubstFonts() != null) {
          if (rtmp.getSubstFonts().contains(panoseKey)) {
            System.out.println("String_Node_Str");
          }
 else {
            System.out.println("String_Node_Str");
          }
        }
        continue;
      }
    }
 else {
      System.out.println("String_Node_Str");
    }
    log.debug("String_Node_Str");
    FontSubstitutions.Replace replacement=(FontSubstitutions.Replace)replaceMap.get(normalise(fontName));
    if (replacement != null) {
      String[] tokens=replacement.getSubstFonts().split("String_Node_Str");
      if (!foundPdfMapping) {
        for (int x=0; x < tokens.length; x++) {
          if (physicalFontMap.get(tokens[x]) != null) {
            EmbedFontInfo embedFontInfo=(EmbedFontInfo)physicalFontMap.get(tokens[x]);
            String physicalFontFile=embedFontInfo.getEmbedFile();
            log.debug("String_Node_Str" + fontName + "String_Node_Str"+ physicalFontFile);
            foundPdfMapping=true;
            fm.setPdfSubstituteFont(tokens[x]);
            fm.setPdfEmbeddedFile(physicalFontFile);
            if (embedFontInfo.getPanose() == null) {
              System.out.println("String_Node_Str");
            }
 else             if (fopPanose != null) {
              long pd=fopPanose.difference(embedFontInfo.getPanose().getPanoseArray());
              if (pd >= org.apache.fop.fonts.Panose.MATCH_THRESHOLD) {
                log.debug("String_Node_Str" + pd);
              }
 else {
                log.error("String_Node_Str" + pd);
              }
            }
            break;
          }
 else {
          }
        }
      }
      for (int x=0; x < tokens.length; x++) {
        if (awtFontFamilyNames.get(tokens[x]) != null) {
          log.debug("String_Node_Str" + tokens[x]);
          fm.setAwtSubstituteFont(tokens[x]);
          foundAwtMapping=true;
          break;
        }
 else {
        }
      }
      if (!foundAwtMapping) {
        log.debug("String_Node_Str" + fontName + "String_Node_Str"+ replacement.getSubstFonts());
      }
      if (!foundPdfMapping) {
        log.debug("String_Node_Str" + fontName + "String_Node_Str"+ replacement.getSubstFonts());
      }
    }
 else {
      System.out.println("String_Node_Str" + fontName);
    }
    fontMappings.put(normalisedFontName,fm);
    log.info("String_Node_Str" + normalisedFontName);
  }
}

Fixed version (ground truth):
public void populateFontMappings(Map documentFontNames,org.docx4j.wml.Fonts fonts) throws Exception {
  List<Fonts.Font> fontList=fonts.getFont();
  Map<String,Fonts.Font> fontsInFontTable=new HashMap<String,Fonts.Font>();
  for (  Fonts.Font font : fontList) {
    fontsInFontTable.put(normalise(font.getName()),font);
  }
  log.info("String_Node_Str");
  Iterator documentFontIterator=documentFontNames.entrySet().iterator();
  while (documentFontIterator.hasNext()) {
    Map.Entry pairs=(Map.Entry)documentFontIterator.next();
    if (pairs.getKey() == null) {
      log.info("String_Node_Str");
      pairs=(Map.Entry)documentFontIterator.next();
    }
    String fontName=(String)pairs.getKey();
    log.info("String_Node_Str" + fontName);
    String normalisedFontName=normalise(fontName);
    if (fontMappings.get(normalisedFontName) != null) {
      continue;
    }
    boolean foundAwtMapping=false;
    boolean foundPdfMapping=false;
    FontMapping fm=new FontMapping();
    fm.setMicrosoftFontName(normalisedFontName);
    org.docx4j.wml.FontPanose panose=null;
    Fonts.Font font=fontsInFontTable.get(normalisedFontName);
    if (font == null) {
      log.error("String_Node_Str" + normalisedFontName + "String_Node_Str");
    }
 else {
      panose=font.getPanose1();
    }
    org.apache.fop.fonts.Panose fopPanose=null;
    if (panose != null && panose.getVal() != null) {
      fopPanose=new org.apache.fop.fonts.Panose(panose.getVal());
      System.out.println("String_Node_Str" + fopPanose.toString());
    }
 else {
      System.out.println("String_Node_Str");
    }
    if (System.getProperty("String_Node_Str").toUpperCase().indexOf("String_Node_Str") > -1) {
    }
    if (physicalFontMap.get(normalise(fontName)) != null) {
      System.out.println(fontName + "String_Node_Str");
      foundPdfMapping=true;
      fm.setPdfSubstituteFont(normalise(fontName));
      fm.setPdfEmbeddedFile(((EmbedFontInfo)physicalFontMap.get(normalise(fontName))).getEmbedFile());
      EmbedFontInfo nfontInfo=((EmbedFontInfo)physicalFontMap.get(normalise(fontName)));
      if (nfontInfo.getPanose() == null) {
        System.out.println("String_Node_Str");
      }
 else       if (fopPanose != null) {
        long pd=fopPanose.difference(nfontInfo.getPanose().getPanoseArray());
        System.out.println("String_Node_Str" + pd);
      }
      fontMappings.put(normalisedFontName,fm);
      log.info("String_Node_Str" + normalisedFontName);
      continue;
    }
    String panoseKey=null;
    if (fopPanose != null) {
      if (!org.apache.fop.fonts.Panose.validPanose(panose.getVal())) {
        System.out.println("String_Node_Str");
      }
      System.out.println("String_Node_Str" + fopPanose);
      Iterator it=physicalFontMap.entrySet().iterator();
      long bestPanoseMatchValue=-1;
      String matchingPanoseString=null;
      while (it.hasNext()) {
        Map.Entry mapPairs=(Map.Entry)it.next();
        EmbedFontInfo fontInfo=(EmbedFontInfo)mapPairs.getValue();
        if (fontInfo.getPanose() == null) {
          continue;
        }
        long panoseMatchValue=fopPanose.difference(fontInfo.getPanose().getPanoseArray());
        if (bestPanoseMatchValue == -1 || panoseMatchValue < bestPanoseMatchValue) {
          bestPanoseMatchValue=panoseMatchValue;
          matchingPanoseString=fontInfo.getPanose().toString();
          panoseKey=(String)mapPairs.getKey();
          if (bestPanoseMatchValue == 0) {
            continue;
          }
        }
 else {
        }
      }
      if (panoseKey != null && bestPanoseMatchValue < org.apache.fop.fonts.Panose.MATCH_THRESHOLD) {
        log.info("String_Node_Str" + panoseKey + "String_Node_Str"+ matchingPanoseString+ "String_Node_Str"+ bestPanoseMatchValue);
        log.debug(fontName + "String_Node_Str" + ((EmbedFontInfo)physicalFontMap.get(panoseKey)).getEmbedFile());
        fm.setPdfSubstituteFont(panoseKey);
        fm.setPdfEmbeddedFile(((EmbedFontInfo)physicalFontMap.get(panoseKey)).getEmbedFile());
        FontSubstitutions.Replace rtmp=(FontSubstitutions.Replace)replaceMap.get(normalise(fontName));
        if (rtmp != null && rtmp.getSubstFonts() != null) {
          if (rtmp.getSubstFonts().contains(panoseKey)) {
            System.out.println("String_Node_Str");
          }
 else {
            System.out.println("String_Node_Str");
          }
        }
        fontMappings.put(normalisedFontName,fm);
        log.info("String_Node_Str" + normalisedFontName);
        continue;
      }
    }
 else {
      System.out.println("String_Node_Str");
    }
    log.debug("String_Node_Str");
    FontSubstitutions.Replace replacement=(FontSubstitutions.Replace)replaceMap.get(normalise(fontName));
    if (replacement != null) {
      String[] tokens=replacement.getSubstFonts().split("String_Node_Str");
      if (!foundPdfMapping) {
        for (int x=0; x < tokens.length; x++) {
          if (physicalFontMap.get(tokens[x]) != null) {
            EmbedFontInfo embedFontInfo=(EmbedFontInfo)physicalFontMap.get(tokens[x]);
            String physicalFontFile=embedFontInfo.getEmbedFile();
            log.debug("String_Node_Str" + fontName + "String_Node_Str"+ physicalFontFile);
            foundPdfMapping=true;
            fm.setPdfSubstituteFont(tokens[x]);
            fm.setPdfEmbeddedFile(physicalFontFile);
            if (embedFontInfo.getPanose() == null) {
              System.out.println("String_Node_Str");
            }
 else             if (fopPanose != null) {
              long pd=fopPanose.difference(embedFontInfo.getPanose().getPanoseArray());
              if (pd >= org.apache.fop.fonts.Panose.MATCH_THRESHOLD) {
                log.debug("String_Node_Str" + pd);
              }
 else {
                log.error("String_Node_Str" + pd);
              }
            }
            break;
          }
 else {
          }
        }
      }
      for (int x=0; x < tokens.length; x++) {
        if (awtFontFamilyNames.get(tokens[x]) != null) {
          log.debug("String_Node_Str" + tokens[x]);
          fm.setAwtSubstituteFont(tokens[x]);
          foundAwtMapping=true;
          break;
        }
 else {
        }
      }
      if (!foundAwtMapping) {
        log.debug("String_Node_Str" + fontName + "String_Node_Str"+ replacement.getSubstFonts());
      }
      if (!foundPdfMapping) {
        log.debug("String_Node_Str" + fontName + "String_Node_Str"+ replacement.getSubstFonts());
      }
    }
 else {
      System.out.println("String_Node_Str" + fontName);
    }
    fontMappings.put(normalisedFontName,fm);
    log.info("String_Node_Str" + normalisedFontName);
  }
}