Program: 17931
Project: 17931
Buggy source:
private WriteableSynonymMap createSynonymMap(){
  return new WriteableExplicitSynonymMap(){
    @Override public void populateMap(    List<String> rules){
      HashSet<String> hs=new HashSet<String>();
      for (      String rule : rules) {
        List<String> mapping=StrUtils.splitSmart(rule,"String_Node_Str",false);
        if (mapping.size() != 2) {
          log.error("String_Node_Str" + rule);
          continue;
        }
        String key=mapping.get(0).trim().replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
        hs.clear();
        hs.add(key);
        for (        String val : splitValues(mapping.get(1))) {
          add(val,hs);
        }
      }
    }
    @Override public void add(    String origName,    Set<String> values){
      Set<String> masterSet=null;
      for (      String key : values) {
        if (containsKey(key)) {
          masterSet=get(key);
          break;
        }
      }
      if (masterSet == null) {
        masterSet=new LinkedHashSet<String>();
      }
      masterSet.add(origName);
      for (      String key : values) {
        put(key,masterSet);
      }
    }
    @Override public String formatEntry(    String key,    Set<String> values){
      List<String> rows=new ArrayList<String>();
      boolean hadApostrophe=false;
      String[] nameParts=carefullySplitName(key,true);
      if (nameParts.length > 1) {
        String[][] otherNames=new String[values.size()][];
        int n=0;
        for (        String name : values) {
          if (name.contains("String_Node_Str"))           hadApostrophe=true;
          otherNames[n++]=carefullySplitName(name,false);
        }
        int cycle=0;
        do {
          for (n=0; n < nameParts.length; n++) {
            StringBuffer out=new StringBuffer();
            if (cycle > 0 && n == 0)             continue;
            out.append(join(nameParts,n));
            out.append("String_Node_Str");
            boolean notFirst=false;
            for (            String[] other : otherNames) {
              if (notFirst)               out.append("String_Node_Str");
              out.append(join(other,n));
              notFirst=true;
            }
            rows.add(out.toString());
          }
          cycle++;
        }
 while (shortened(nameParts,otherNames));
      }
      StringBuffer toReturn=new StringBuffer();
      for (      String row : rows) {
        if (hadApostrophe || hasNonAscii(row)) {
          toReturn.append(row);
          toReturn.append("String_Node_Str");
        }
      }
      return toReturn.toString();
    }
    private boolean hasNonAscii(    String s){
      for (      char c : s.toCharArray()) {
        if ((int)c > 128) {
          return true;
        }
      }
      return false;
    }
    private String join(    String[] name,    int v){
      StringBuffer out=new StringBuffer();
      boolean notFirst=false;
      for (int i=0; i <= v; i++) {
        if (notFirst)         out.append("String_Node_Str");
        out.append(name[i]);
        notFirst=true;
      }
      return out.toString();
    }
    private boolean shortened(    String[] nameParts,    String[][] otherNames){
      for (int i=nameParts.length - 1; i > 0; i--) {
        if (nameParts[i].length() > 1) {
          nameParts[i]=nameParts[i].substring(0,1);
          for (          String[] other : otherNames) {
            if (other[i] == null || other[i].length() < 2)             return false;
            other[i]=other[i].substring(0,1);
          }
          return true;
        }
      }
      return false;
    }
    private String[] carefullySplitName(    String name,    boolean keepApostrophe){
      name=name.replaceAll("String_Node_Str","String_Node_Str");
      name=AuthorUtils.normalizeAuthor(name,keepApostrophe);
      String[] out=new String[0];
      String[] twoParts=name.split("String_Node_Str");
      if (twoParts.length > 1) {
        String[] names=twoParts[1].trim().split("String_Node_Str");
        out=new String[names.length + 1];
        out[0]=twoParts[0] + "String_Node_Str";
        int x=1;
        for (        String r : names) {
          out[x]=names[x - 1];
          x++;
        }
      }
      return out;
    }
  }
;
}

Fixed version (ground truth):
private WriteableSynonymMap createSynonymMap(){
  return new WriteableExplicitSynonymMap(){
    @Override public void populateMap(    List<String> rules){
      HashSet<String> hs=new HashSet<String>();
      for (      String rule : rules) {
        List<String> mapping=StrUtils.splitSmart(rule,"String_Node_Str",false);
        if (mapping.size() != 2) {
          log.error("String_Node_Str" + rule);
          continue;
        }
        String key=mapping.get(0).trim().replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
        hs.clear();
        hs.add(key);
        for (        String val : splitValues(mapping.get(1))) {
          add(val,hs);
        }
      }
    }
    @Override public void add(    String origName,    Set<String> values){
      Set<String> masterSet=null;
      for (      String key : values) {
        if (containsKey(key)) {
          masterSet=get(key);
          break;
        }
      }
      if (masterSet == null) {
        masterSet=new LinkedHashSet<String>();
      }
      masterSet.add(origName);
      for (      String key : values) {
        put(key,masterSet);
      }
    }
    @Override public String formatEntry(    String key,    Set<String> values){
      List<String> rows=new ArrayList<String>();
      boolean hadApostrophe=false;
      String[] nameParts=carefullySplitName(key,true);
      if (nameParts.length > 1) {
        String[][] otherNames=new String[values.size()][];
        int n=0;
        for (        String name : values) {
          if (name.contains("String_Node_Str"))           hadApostrophe=true;
          otherNames[n++]=carefullySplitName(name,false);
        }
        int cycle=0;
        do {
          for (n=0; n < nameParts.length; n++) {
            StringBuffer out=new StringBuffer();
            if (cycle > 0 && n == 0)             continue;
            out.append(join(nameParts,n));
            out.append("String_Node_Str");
            boolean notFirst=false;
            for (            String[] other : otherNames) {
              if (notFirst)               out.append("String_Node_Str");
              out.append(join(other,n));
              notFirst=true;
            }
            rows.add(out.toString());
          }
          cycle++;
        }
 while (shortened(nameParts,otherNames));
      }
      StringBuffer toReturn=new StringBuffer();
      for (      String row : rows) {
        if (hadApostrophe || hasNonAscii(row)) {
          toReturn.append(row);
          toReturn.append("String_Node_Str");
        }
      }
      return toReturn.toString();
    }
    private boolean hasNonAscii(    String s){
      for (      char c : s.toCharArray()) {
        if ((int)c > 128) {
          return true;
        }
      }
      return false;
    }
    private String join(    String[] name,    int v){
      StringBuffer out=new StringBuffer();
      boolean notFirst=false;
      for (int i=0; i <= v && i < out.length(); i++) {
        if (notFirst)         out.append("String_Node_Str");
        out.append(name[i]);
        notFirst=true;
      }
      return out.toString();
    }
    private boolean shortened(    String[] nameParts,    String[][] otherNames){
      for (int i=nameParts.length - 1; i > 0; i--) {
        if (nameParts[i].length() > 1) {
          nameParts[i]=nameParts[i].substring(0,1);
          for (          String[] other : otherNames) {
            if (other[i] == null || other[i].length() < 2)             return false;
            other[i]=other[i].substring(0,1);
          }
          return true;
        }
      }
      return false;
    }
    private String[] carefullySplitName(    String name,    boolean keepApostrophe){
      name=name.replaceAll("String_Node_Str","String_Node_Str");
      name=AuthorUtils.normalizeAuthor(name,keepApostrophe);
      String[] out=new String[0];
      String[] twoParts=name.split("String_Node_Str");
      if (twoParts.length > 1) {
        String[] names=twoParts[1].trim().split("String_Node_Str");
        out=new String[names.length + 1];
        out[0]=twoParts[0] + "String_Node_Str";
        int x=1;
        for (        String r : names) {
          out[x]=names[x - 1];
          x++;
        }
      }
      return out;
    }
  }
;
}