nus-yam/ex-repair huggingface dataset:
Program: 60295
Project: 60295
Buggy source:
public GeoQuery<T> geoWithin(String key,Polygon polygon){
  DBObject geometry=new BasicDBObject();
  geometry.put(Operator.GEOMETRY,MapperUtil.toDBObject(polygon));
  append(key,Operator.GEO_WITHIN,geometry);
  return this;
}

Fixed version (ground truth):
public GeoQuery<T> geoWithin(String key,Polygon polygon){
  DBObject geometry=new BasicDBObject();
  geometry.put(Operator.GEOMETRY,MapperUtil.toDBObject(polygon,true));
  append(key,Operator.GEO_WITHIN,geometry);
  return this;
}
Program: 60296
Project: 60296
Buggy source:
@Override public void init(ServletConfig config) throws ServletException {
  super.init(config);
  String p=config.getInitParameter("String_Node_Str");
  password=StringUtil.encodeMD5(p);
  allowBucket=config.getInitParameter("String_Node_Str");
  forbidBucket=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(allowBucket) && !StringUtil.isEmpty(forbidBucket)) {
    throw new ServletException("String_Node_Str");
  }
  String md5=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(md5)) {
    contentMD5=Boolean.getBoolean(md5);
  }
}

Fixed version (ground truth):
@Override public void init(ServletConfig config) throws ServletException {
  super.init(config);
  String p=config.getInitParameter("String_Node_Str");
  password=StringUtil.encodeMD5(p);
  allowBucket=config.getInitParameter("String_Node_Str");
  forbidBucket=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(allowBucket) && !StringUtil.isEmpty(forbidBucket)) {
    throw new ServletException("String_Node_Str");
  }
  String md5=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(md5)) {
    contentMD5=Boolean.valueOf(md5);
  }
}
Program: 60300
Project: 60300
Buggy source:
/** 
 * Update the value of the field to a specified value if the specified value is less than the current value of the field. If the field does not exists, this operation sets the field to the specified value. 
 * @param key the field's name
 * @param value the specified value
 * @return 
 */
public BuguUpdater<T> min(String id,String key,Object value){
  append(Operator.MIN,key,value);
  return this;
}

Fixed version (ground truth):
/** 
 * Update the value of the field to a specified value if the specified value is less than the current value of the field. If the field does not exists, this operation sets the field to the specified value. 
 * @param key the field's name
 * @param value the specified value
 * @return 
 */
public BuguUpdater<T> min(String key,Object value){
  append(Operator.MIN,key,value);
  return this;
}
Program: 60301
Project: 60301
Buggy source:
/** 
 * Remove the last element from the array/list/set field
 * @param key the field's name
 * @return 
 */
public BuguUpdater<T> popLast(String id,String key){
  append(Operator.POP,key,1);
  return this;
}

Fixed version (ground truth):
/** 
 * Remove the last element from the array/list/set field
 * @param key the field's name
 * @return 
 */
public BuguUpdater<T> popLast(String key){
  append(Operator.POP,key,1);
  return this;
}
Program: 60302
Project: 60302
Buggy source:
/** 
 * Performs a bitwise update of a field
 * @param key the field's name
 * @param value the bitwise value
 * @param bitwise the enum type of bitwise operation: AND,OR,XOR
 * @return 
 */
public BuguUpdater<T> bitwise(String id,String key,int value,Bitwise bitwise){
  DBObject logic=new BasicDBObject(checkBitwise(bitwise),value);
  append(Operator.BIT,key,logic);
  return this;
}

Fixed version (ground truth):
/** 
 * Performs a bitwise update of a field
 * @param key the field's name
 * @param value the bitwise value
 * @param bitwise the enum type of bitwise operation: AND,OR,XOR
 * @return 
 */
public BuguUpdater<T> bitwise(String key,int value,Bitwise bitwise){
  DBObject logic=new BasicDBObject(checkBitwise(bitwise),value);
  append(Operator.BIT,key,logic);
  return this;
}
Program: 60303
Project: 60303
Buggy source:
/** 
 * Remove the first element from the array/list/set field
 * @param key the field's name
 * @return 
 */
public BuguUpdater<T> popFirst(String id,String key){
  append(Operator.POP,key,-1);
  return this;
}

Fixed version (ground truth):
/** 
 * Remove the first element from the array/list/set field
 * @param key the field's name
 * @return 
 */
public BuguUpdater<T> popFirst(String key){
  append(Operator.POP,key,-1);
  return this;
}
Program: 60306
Project: 60306
Buggy source:
private void moveCollectionElement(List list,Collection collection){
  ParameterizedType paramType=(ParameterizedType)field.getGenericType();
  Type[] types=paramType.getActualTypeArguments();
  Class actualType=(Class)types[0];
  if (DataType.isShortObject(actualType)) {
    for (    Object o : list) {
      collection.add(Short.valueOf(o.toString()));
    }
  }
 else   if (DataType.isByteObject(actualType)) {
    for (    Object o : list) {
      collection.add(Byte.valueOf(o.toString()));
    }
  }
 else   if (DataType.isFloatObject(actualType)) {
    for (    Object o : list) {
      collection.add(Float.valueOf(o.toString()));
    }
  }
 else   if (DataType.isCharObject(actualType)) {
    for (    Object o : list) {
      collection.add(o.toString().charAt(0));
    }
  }
 else {
    for (    Object o : list) {
      collection.add(o);
    }
  }
}

Fixed version (ground truth):
private void moveCollectionElement(Class actualType,List list,Collection collection){
  if (DataType.isShortObject(actualType)) {
    for (    Object o : list) {
      collection.add(Short.valueOf(o.toString()));
    }
  }
 else   if (DataType.isByteObject(actualType)) {
    for (    Object o : list) {
      collection.add(Byte.valueOf(o.toString()));
    }
  }
 else   if (DataType.isFloatObject(actualType)) {
    for (    Object o : list) {
      collection.add(Float.valueOf(o.toString()));
    }
  }
 else   if (DataType.isCharObject(actualType)) {
    for (    Object o : list) {
      collection.add(o.toString().charAt(0));
    }
  }
 else {
    for (    Object o : list) {
      collection.add(o);
    }
  }
}
Program: 60307
Project: 60307
Buggy source:
private void parseInlineTemplate(Snippet body){
  List<SnippetPart> parts=body.getParts();
  int bodyEnd=parts.size();
  for (int i=bodyEnd - 1; i >= 0; i--) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      SnippetTag tag=(SnippetTag)part;
      if (tag.getTag().equals("String_Node_Str")) {
        bodyEnd=i;
      }
 else       if (tag.getTag().startsWith("String_Node_Str")) {
        bodyEnd=i;
      }
 else       if (tag.getTag().equals("String_Node_Str")) {
        Snippet inlineSnippet=new Snippet(parts,i + 1,bodyEnd);
        inlineSnippet.setOrigin(body.getOrigin());
        List<SnippetPart> inlineParts=inlineSnippet.getParts();
        LoopTag.smartTrimSnippetParts(inlineParts,false);
        this.template=inlineSnippet;
        for (int j=bodyEnd - 1; j >= i; j--) {
          parts.remove(j);
        }
        return;
      }
    }
  }
}

Fixed version (ground truth):
private void parseInlineTemplate(Snippet body){
  List<SnippetPart> parts=body.getParts();
  int bodyEnd=parts.size();
  int eatUntil=bodyEnd;
  for (int i=bodyEnd - 1; i >= 0; i--) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      SnippetTag tag=(SnippetTag)part;
      if (tag.getTag().equals("String_Node_Str")) {
        bodyEnd=i;
        eatUntil=i + 1;
      }
 else       if (tag.getTag().startsWith("String_Node_Str")) {
        bodyEnd=i;
        eatUntil=i;
      }
 else       if (tag.getTag().equals("String_Node_Str")) {
        Snippet inlineSnippet=new Snippet(parts,i + 1,bodyEnd);
        inlineSnippet.setOrigin(body.getOrigin());
        List<SnippetPart> inlineParts=inlineSnippet.getParts();
        LoopTag.smartTrimSnippetParts(inlineParts,false);
        this.template=inlineSnippet;
        for (int j=eatUntil - 1; j >= i; j--) {
          parts.remove(j);
        }
        return;
      }
    }
  }
}
Program: 60308
Project: 60308
Buggy source:
private String parseCond(String params){
  if (params == null)   return null;
  int exprPos=params.indexOf("String_Node_Str") + 1;
  int openParenPos=params.indexOf("String_Node_Str",exprPos);
  if (openParenPos > -1 && params.substring(exprPos,openParenPos).trim().length() == 0) {
    int closeParenPos=params.lastIndexOf("String_Node_Str");
    if (closeParenPos > openParenPos) {
      String test=params.substring(openParenPos + 1,closeParenPos);
      return test;
    }
  }
  return params.substring(exprPos);
}

Fixed version (ground truth):
private String parseCond(String params){
  if (params == null)   return null;
  int exprPos=params.indexOf("String_Node_Str") + 1;
  int openParenPos=params.indexOf("String_Node_Str",exprPos);
  if (openParenPos > -1 && params.substring(exprPos,openParenPos).trim().length() == 0) {
    int closeParenPos=params.lastIndexOf("String_Node_Str");
    if (closeParenPos > openParenPos) {
      String test=params.substring(openParenPos + 1,closeParenPos);
      return test;
    }
 else {
      String test=params.substring(openParenPos + 1);
      return test;
    }
  }
  return params.substring(exprPos);
}
Program: 60309
Project: 60309
Buggy source:
private int skipModifiers(String test){
  char[] chars=test.toCharArray();
  int i=0;
  for (; i < chars.length; i++) {
    char c=chars[i];
    if (Character.isJavaIdentifierPart(c))     continue;
    if (c == '|' || c == ':' || c == '.')     continue;
    if (c == '(') {
      i=FilterArgs.nextUnescapedDelim("String_Node_Str",test,i + 1);
      continue;
    }
    if (c == '/') {
      i=RegexFilter.nextRegexDelim(test,i + 1);
      continue;
    }
    break;
  }
  return i;
}

Fixed version (ground truth):
private int skipModifiers(String test){
  char[] chars=test.toCharArray();
  int i=0;
  for (; i < chars.length; i++) {
    char c=chars[i];
    if (Character.isJavaIdentifierPart(c))     continue;
    if (c == '|' || c == ':' || c == '.')     continue;
    if (c == '(') {
      i=FilterArgs.nextUnescapedDelim("String_Node_Str",test,i + 1);
      if (i < 0) {
        return chars.length;
      }
      continue;
    }
    if (c == '/') {
      i=RegexFilter.nextRegexDelim(test,i + 1);
      if (i < 0) {
        return chars.length;
      }
      continue;
    }
    break;
  }
  return i;
}
Program: 60310
Project: 60310
Buggy source:
public String toString(){
  if (simpleText != null)   return simpleText;
  if (parts == null)   return null;
  StringBuilder sb=new StringBuilder();
  if (origin != null) {
    sb.append("String_Node_Str");
    sb.append(origin);
    sb.append("String_Node_Str");
  }
  for (  SnippetPart part : parts) {
    sb.append(part.toString());
  }
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  return _toString(true);
}
Program: 60311
Project: 60311
Buggy source:
public Object applyFilter(Chunk chunk,Object object,String[] args){
  String stringifiedObject=(object == null) ? null : object.toString();
  return transformText(chunk,stringifiedObject,args);
}

Fixed version (ground truth):
public Object applyFilter(Chunk chunk,Object object,String[] args){
  String stringifiedObject=null;
  if (object != null) {
    if (object instanceof com.x5.template.Snippet) {
      stringifiedObject=((com.x5.template.Snippet)object).toSimpleString();
    }
 else {
      stringifiedObject=object.toString();
    }
  }
  return transformText(chunk,stringifiedObject,args);
}
Program: 60312
Project: 60312
Buggy source:
private void parseAttributes(String params){
  Map<String,Object> opts=_parseAttributes(params);
  if (opts == null)   return;
  this.options=opts;
  String dataVar=(String)opts.get("String_Node_Str");
  fetchData(dataVar);
  this.rowTemplate=(String)opts.get("String_Node_Str");
  this.emptyTemplate=(String)opts.get("String_Node_Str");
}

Fixed version (ground truth):
private void parseAttributes(String params){
  Map<String,Object> opts=_parseAttributes(params);
  if (opts == null)   return;
  this.options=opts;
  this.rowTemplate=(String)opts.get("String_Node_Str");
  this.emptyTemplate=(String)opts.get("String_Node_Str");
}
Program: 60313
Project: 60313
Buggy source:
private void parseFnParams(String params){
  int endOfParams=params.length();
  if (params.endsWith("String_Node_Str"))   endOfParams--;
  params=params.substring("String_Node_Str".length(),endOfParams);
  String[] args=params.split("String_Node_Str");
  if (args != null && args.length >= 2) {
    String dataVar=args[0];
    fetchData(dataVar);
    this.rowTemplate=args[1];
    if (args.length > 2) {
      this.emptyTemplate=args[2];
    }
 else {
      this.emptyTemplate=null;
    }
  }
}

Fixed version (ground truth):
private void parseFnParams(String params){
  int endOfParams=params.length();
  if (params.endsWith("String_Node_Str"))   endOfParams--;
  params=params.substring("String_Node_Str".length(),endOfParams);
  String[] args=params.split("String_Node_Str");
  if (args != null && args.length >= 2) {
    String dataVar=args[0];
    if (options == null)     options=new HashMap<String,Object>();
    options.put("String_Node_Str",dataVar);
    this.rowTemplate=args[1];
    if (args.length > 2) {
      this.emptyTemplate=args[2];
    }
 else {
      this.emptyTemplate=null;
    }
  }
}
Program: 60314
Project: 60314
Buggy source:
private void parseEZParams(String paramString){
  String[] params=paramString.split("String_Node_Str");
  String dataVar=params[2];
  fetchData(dataVar);
  this.options=_parseAttributes(paramString);
  if (options == null)   options=new HashMap<String,Object>();
  options.put("String_Node_Str",dataVar);
  if (params.length > 3) {
    if (params[3].equals("String_Node_Str")) {
      String loopVarPrefix=params[4];
      if (loopVarPrefix != null) {
        if (loopVarPrefix.startsWith("String_Node_Str") || loopVarPrefix.startsWith("String_Node_Str")) {
          loopVarPrefix=loopVarPrefix.substring(1);
        }
        if (loopVarPrefix.contains("String_Node_Str")) {
          String[] labels=loopVarPrefix.split("String_Node_Str");
          String valuePrefix=labels[1];
          if (valuePrefix.startsWith("String_Node_Str") || valuePrefix.startsWith("String_Node_Str")) {
            valuePrefix=valuePrefix.substring(1);
          }
          options.put("String_Node_Str",labels[0]);
          options.put("String_Node_Str",valuePrefix);
        }
        options.put("String_Node_Str",loopVarPrefix);
      }
    }
  }
}

Fixed version (ground truth):
private void parseEZParams(String paramString){
  String[] params=paramString.split("String_Node_Str");
  String dataVar=params[2];
  this.options=_parseAttributes(paramString);
  if (options == null)   options=new HashMap<String,Object>();
  options.put("String_Node_Str",dataVar);
  if (params.length > 3) {
    if (params[3].equals("String_Node_Str")) {
      String loopVarPrefix=params[4];
      if (loopVarPrefix != null) {
        if (loopVarPrefix.startsWith("String_Node_Str") || loopVarPrefix.startsWith("String_Node_Str")) {
          loopVarPrefix=loopVarPrefix.substring(1);
        }
        if (loopVarPrefix.contains("String_Node_Str")) {
          String[] labels=loopVarPrefix.split("String_Node_Str");
          String valuePrefix=labels[1];
          if (valuePrefix.startsWith("String_Node_Str") || valuePrefix.startsWith("String_Node_Str")) {
            valuePrefix=valuePrefix.substring(1);
          }
          options.put("String_Node_Str",labels[0]);
          options.put("String_Node_Str",valuePrefix);
        }
        options.put("String_Node_Str",loopVarPrefix);
      }
    }
  }
}
Program: 60316
Project: 60316
Buggy source:
@Override public void renderBlock(Writer out,Chunk context,String origin,int depth) throws IOException {
  if (dividerSnippet != null && !options.containsKey("String_Node_Str")) {
    options.put("String_Node_Str",dividerSnippet);
  }
  this.chunk=context;
  TableData data=null;
  if (options != null) {
    data=fetchData((String)options.get("String_Node_Str"));
  }
  cookLoopToPrinter(out,context,origin,true,depth,data);
}

Fixed version (ground truth):
@Override public void renderBlock(Writer out,Chunk context,String origin,int depth) throws IOException {
  if (dividerSnippet != null && !options.containsKey("String_Node_Str")) {
    options.put("String_Node_Str",dividerSnippet);
  }
  this.chunk=context;
  TableData data=null;
  if (options != null) {
    data=fetchData((String)options.get("String_Node_Str"),origin);
  }
  cookLoopToPrinter(out,context,origin,true,depth,data);
}
Program: 60317
Project: 60317
Buggy source:
private boolean isLiteralClose(String template,char magicChar,int tagStart,int i){
  if (magicChar == '^') {
    if (tagStart == i - 2) {
      return true;
    }
  }
 else   if (magicChar == '~') {
    if (tagStart == i - 3 && template.charAt(i - 1) == '.') {
      return true;
    }
 else     if (tagStart == i - 11 && template.substring(tagStart + 3,i).equals("String_Node_Str")) {
      return true;
    }
  }
 else   if (tagStart == i - 9 && magicChar == '/') {
    if (template.substring(tagStart + 1,i).equals("String_Node_Str")) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean isLiteralClose(String template,char magicChar,int tagStart,int i){
  if (magicChar == '.' && i - tagStart > 8) {
    if (template.charAt(tagStart + 1) == '%') {
      int exprEnd=i - 1;
      if (template.charAt(exprEnd) == '%')       exprEnd--;
      String expr=template.substring(tagStart + 2,exprEnd).trim();
      if (expr.equals("String_Node_Str") || expr.equals("String_Node_Str")) {
        return true;
      }
    }
  }
 else   if (magicChar == '^') {
    if (tagStart == i - 2) {
      return true;
    }
  }
 else   if (magicChar == '~') {
    if (tagStart == i - 3 && template.charAt(i - 1) == '.') {
      return true;
    }
 else     if (tagStart == i - 11 && template.substring(tagStart + 3,i).equals("String_Node_Str")) {
      return true;
    }
  }
 else   if (tagStart == i - 9 && magicChar == '/') {
    if (template.substring(tagStart + 1,i).equals("String_Node_Str")) {
      return true;
    }
  }
  return false;
}
Program: 60318
Project: 60318
Buggy source:
public void render(Writer out,Chunk rules,String origin,int depth) throws IOException {
  if (depthCheckFails(depth,out))   return;
  Object tagValue=null;
  if (path == null)   init();
  tagValue=rules.resolveTagValue(this,depth,origin);
  if (tagValue == null) {
    out.append(super.snippetText);
  }
 else   if (tagValue instanceof Snippet) {
    ((Snippet)tagValue).render(out,rules,depth);
  }
 else   if (tagValue instanceof String) {
    Snippet compiled=Snippet.getSnippet((String)tagValue);
    compiled.render(out,rules,depth + 1);
  }
 else {
    rules.explodeToPrinter(out,tagValue,depth + 1);
  }
}

Fixed version (ground truth):
public void render(Writer out,Chunk rules,String origin,int depth) throws IOException {
  if (depthCheckFails(depth,out))   return;
  Object tagValue=null;
  if (path == null)   init();
  tagValue=rules.resolveTagValue(this,depth,origin);
  if (tagValue == null) {
    out.append(super.snippetText);
  }
 else   if (tagValue instanceof Snippet) {
    ((Snippet)tagValue).render(out,rules,depth);
  }
 else   if (tagValue instanceof String) {
    Snippet compiled=Snippet.getSnippet((String)tagValue,origin);
    compiled.render(out,rules,depth + 1);
  }
 else {
    rules.explodeToPrinter(out,tagValue,depth + 1);
  }
}
Program: 60319
Project: 60319
Buggy source:
public static StringBuilder expandShorthand(String name,StringBuilder template){
  if (template.indexOf("String_Node_Str") > -1 || template.indexOf("String_Node_Str") > -1)   return null;
  Matcher m=SUPER_TAG.matcher(template);
  if (m.find())   return null;
  String fullRef=name;
  if (fullRef != null) {
    int dotPos=fullRef.indexOf('.');
    if (dotPos > 0)     fullRef=name.substring(0,dotPos);
  }
  int cursor=template.indexOf("String_Node_Str");
  while (cursor > -1) {
    if (template.length() == cursor + 1)     return template;
    char afterBrace=template.charAt(cursor + 1);
    if (afterBrace == '%') {
      cursor++;
      while (cursor + 1 < template.length() && Character.isWhitespace(template.charAt(cursor + 1))) {
        cursor++;
      }
      afterBrace=template.charAt(cursor + 1);
      if (Snippet.MAGIC_CHARS.indexOf(afterBrace) < 0) {
        template.replace(cursor + 1,cursor + 1,"String_Node_Str");
        afterBrace='~';
      }
    }
    if (afterBrace == '^' || afterBrace == '.') {
      int afterLiteralBlock=skipLiterals(template,cursor);
      if (afterLiteralBlock == cursor) {
        template.replace(cursor + 1,cursor + 2,"String_Node_Str");
      }
 else {
        cursor=afterLiteralBlock;
      }
    }
 else     if (afterBrace == '/') {
      template.replace(cursor + 1,cursor + 2,"String_Node_Str");
    }
 else     if (afterBrace == '*') {
      cursor=expandShorthandMacro(template,fullRef,cursor);
    }
 else {
      cursor+=2;
    }
    if (cursor > -1)     cursor=template.indexOf("String_Node_Str",cursor);
  }
  return template;
}

Fixed version (ground truth):
public static StringBuilder expandShorthand(String name,StringBuilder template){
  if (template.indexOf("String_Node_Str") > -1 || template.indexOf("String_Node_Str") > -1)   return null;
  Matcher m=SUPER_TAG.matcher(template);
  if (m.find())   return null;
  int cursor=template.indexOf("String_Node_Str");
  while (cursor > -1) {
    if (template.length() == cursor + 1)     return template;
    char afterBrace=template.charAt(cursor + 1);
    if (afterBrace == '^' || afterBrace == '.' || afterBrace == '%') {
      int afterLiteralBlock=skipLiterals(template,cursor);
      if (afterLiteralBlock != cursor) {
        cursor=afterLiteralBlock;
      }
 else {
        if (afterBrace != '%') {
          template.replace(cursor + 1,cursor + 2,"String_Node_Str");
        }
 else {
          int exprStart=cursor + 2;
          while (exprStart < template.length() && Character.isWhitespace(template.charAt(exprStart))) {
            exprStart++;
          }
          afterBrace=template.charAt(exprStart);
          if (Snippet.MAGIC_CHARS.indexOf(afterBrace) < 0) {
            template.replace(exprStart,exprStart,"String_Node_Str");
            afterBrace='~';
          }
        }
        cursor+=2;
      }
    }
 else     if (afterBrace == '/') {
      template.replace(cursor + 1,cursor + 2,"String_Node_Str");
    }
 else {
      cursor+=2;
    }
    if (cursor > -1)     cursor=template.indexOf("String_Node_Str",cursor);
  }
  return template;
}
Program: 60320
Project: 60320
Buggy source:
private String getLiteralLines(int litBegin,String firstLine,BufferedReader brTemp,StringBuilder sbTemp) throws IOException {
  int litEnd=firstLine.indexOf(LITERAL_END,litBegin + 2);
  int endMarkerLen=LITERAL_END.length();
  int litEndLong=firstLine.indexOf(LITERAL_END_LONGHAND,litBegin + 2);
  if (litEndLong > -1 && (litEnd < 0 || litEndLong < litEnd)) {
    litEnd=litEndLong;
    endMarkerLen=LITERAL_END_LONGHAND.length();
  }
  if (litEnd > -1) {
    litEnd+=endMarkerLen;
    sbTemp.append(firstLine.substring(0,litEnd));
    return firstLine.substring(litEnd);
  }
 else {
    sbTemp.append(firstLine);
    sbTemp.append("String_Node_Str");
    String line=null;
    while (brTemp.ready()) {
      line=brTemp.readLine();
      if (line == null)       break;
      litEnd=line.indexOf(LITERAL_END);
      litEndLong=line.indexOf(LITERAL_END_LONGHAND);
      if (litEndLong > -1 && (litEnd < 0 || litEndLong < litEnd)) {
        litEnd=litEndLong;
        endMarkerLen=LITERAL_END_LONGHAND.length();
      }
      if (litEnd > -1) {
        litEnd+=endMarkerLen;
        sbTemp.append(line.substring(0,litEnd));
        return line.substring(litEnd);
      }
      sbTemp.append(line);
      sbTemp.append("String_Node_Str");
    }
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
private String getLiteralLines(int litBegin,String firstLine,BufferedReader brTemp,StringBuilder sbTemp) throws IOException {
  Matcher m=LITERAL_CLOSE.matcher(firstLine);
  if (m.find(litBegin + 2)) {
    int litEnd=m.end();
    sbTemp.append(firstLine.substring(0,litEnd));
    return firstLine.substring(litEnd);
  }
 else {
    sbTemp.append(firstLine);
    sbTemp.append("String_Node_Str");
    String line=null;
    while (brTemp.ready()) {
      line=brTemp.readLine();
      if (line == null)       break;
      m.reset(line);
      if (m.find()) {
        int litEnd=m.end();
        sbTemp.append(line.substring(0,litEnd));
        return line.substring(litEnd);
      }
      sbTemp.append(line);
      sbTemp.append("String_Node_Str");
    }
    return "String_Node_Str";
  }
}
Program: 60321
Project: 60321
Buggy source:
private static int skipLiterals(StringBuilder template,int cursor){
  int wall=template.length();
  int shortLen=LITERAL_SHORTHAND.length();
  int scanStart=cursor;
  if (cursor + shortLen <= wall && template.substring(cursor,cursor + shortLen).equals(LITERAL_SHORTHAND)) {
    scanStart=cursor + shortLen;
  }
 else {
    int longLen=LITERAL_START2.length();
    if (cursor + longLen <= wall && template.substring(cursor,cursor + longLen).equals(LITERAL_START2)) {
      scanStart=cursor + longLen;
    }
 else {
      longLen=LITERAL_START.length();
      if (cursor + longLen <= wall && template.substring(cursor,cursor + longLen).equals(LITERAL_START)) {
        scanStart=cursor + longLen;
      }
    }
  }
  if (scanStart > cursor) {
    int tail=template.indexOf(LITERAL_END,scanStart);
    int longTail=template.indexOf(LITERAL_END_LONGHAND,scanStart);
    tail=(tail < 0) ? longTail : (longTail < 0) ? tail : Math.min(tail,longTail);
    if (tail < 0) {
      return wall;
    }
 else {
      return tail + (tail == longTail ? LITERAL_END_LONGHAND.length() : LITERAL_END.length());
    }
  }
 else {
    return cursor;
  }
}

Fixed version (ground truth):
private static int skipLiterals(StringBuilder template,int cursor){
  int scanStart=cursor;
  Matcher m=LITERAL_OPEN_HERE.matcher(template);
  if (m.find(scanStart)) {
    scanStart=m.end();
  }
  if (scanStart > cursor) {
    m=LITERAL_CLOSE.matcher(template);
    if (m.find(scanStart)) {
      return m.end();
    }
 else {
      return template.length();
    }
  }
 else {
    return cursor;
  }
}
Program: 60322
Project: 60322
Buggy source:
public static int findLiteralMarker(String text,int startAt){
  int literalPos=text.indexOf(LITERAL_START,startAt);
  int literal2Pos=text.indexOf(LITERAL_START2,startAt);
  int litPos=text.indexOf(LITERAL_SHORTHAND,startAt);
  int[] pos=new int[]{literalPos,literal2Pos,litPos};
  int firstEncounter=-1;
  for (int i=0; i < 3; i++) {
    int p=pos[i];
    if (p > -1) {
      if (firstEncounter < 0) {
        firstEncounter=p;
      }
 else {
        firstEncounter=Math.min(firstEncounter,p);
      }
    }
  }
  return firstEncounter;
}

Fixed version (ground truth):
public static int findLiteralMarker(String text,int startAt){
  Matcher m=LITERAL_OPEN_ANYWHERE.matcher(text);
  if (m.find(startAt)) {
    return m.start();
  }
 else {
    return -1;
  }
}
Program: 60323
Project: 60323
Buggy source:
public String transformText(Chunk chunk,String text,String[] args){
  String templateName;
  if (args != null && args.length > 0) {
    templateName=args[0];
    templateName=BlockTag.qualifyTemplateRef(chunk.getTemplateOrigin(),templateName);
  }
 else {
    return null;
  }
  if (chunk == null)   return null;
  ContentSource theme=chunk.getTemplateSet();
  if (theme == null)   return null;
  Snippet filterBody=theme.getSnippet(templateName);
  if (filterBody == null) {
    return null;
  }
  Chunk miniMacro=new Chunk();
  miniMacro.append(filterBody);
  miniMacro.setOrDelete("String_Node_Str",text);
  return miniMacro.toString();
}

Fixed version (ground truth):
public String transformText(Chunk chunk,String text,String[] args){
  String templateName;
  if (args != null && args.length > 0) {
    templateName=args[0];
    if (chunk != null) {
      templateName=BlockTag.qualifyTemplateRef(chunk.getTemplateOrigin(),templateName);
    }
  }
 else {
    return null;
  }
  if (chunk == null)   return null;
  ContentSource theme=chunk.getTemplateSet();
  if (theme == null)   return null;
  Snippet filterBody=theme.getSnippet(templateName);
  if (filterBody == null) {
    return null;
  }
  Chunk miniMacro=new Chunk();
  miniMacro.append(filterBody);
  miniMacro.setOrDelete("String_Node_Str",text);
  return miniMacro.toString();
}
Program: 60326
Project: 60326
Buggy source:
private static String parseRegexEscapes(String str){
  if (str == null)   return str;
  char[] strArr=str.toCharArray();
  boolean escape=false;
  StringBuilder buf=new StringBuilder();
  for (int i=0; i < strArr.length; ++i) {
    if (escape) {
      if (strArr[i] == 'b') {
        buf.append('\b');
      }
 else       if (strArr[i] == 't') {
        buf.append('\t');
      }
 else       if (strArr[i] == 'n') {
        buf.append('\n');
      }
 else       if (strArr[i] == 'r') {
        buf.append('\r');
      }
 else       if (strArr[i] == 'f') {
        buf.append('\f');
      }
 else       if (strArr[i] == 'U') {
        buf.append("String_Node_Str");
      }
 else       if (strArr[i] == 'L') {
        buf.append("String_Node_Str");
      }
 else       if (strArr[i] == 'u') {
        int utf=Integer.parseInt(str.substring(i + 1,i + 5),16);
        buf.append((char)utf);
        i+=4;
      }
 else       if (Character.isDigit(strArr[i])) {
        int j=0;
        for (j=1; (j < 2) && (i + j < strArr.length); ++j) {
          if (!Character.isDigit(strArr[i + j]))           break;
        }
        int octal=Integer.parseInt(str.substring(i,i + j),8);
        buf.append((char)octal);
        i+=j - 1;
      }
 else {
        buf.append(strArr[i]);
      }
      escape=false;
    }
 else     if (strArr[i] == '\\') {
      escape=true;
    }
 else {
      buf.append(strArr[i]);
    }
  }
  return buf.toString();
}

Fixed version (ground truth):
public static String parseRegexEscapes(String str){
  if (str == null)   return str;
  char[] strArr=str.toCharArray();
  boolean escape=false;
  StringBuilder buf=new StringBuilder();
  for (int i=0; i < strArr.length; ++i) {
    if (escape) {
      if (strArr[i] == 'b') {
        buf.append('\b');
      }
 else       if (strArr[i] == 't') {
        buf.append('\t');
      }
 else       if (strArr[i] == 'n') {
        buf.append('\n');
      }
 else       if (strArr[i] == 'r') {
        buf.append('\r');
      }
 else       if (strArr[i] == 'f') {
        buf.append('\f');
      }
 else       if (strArr[i] == 'U') {
        buf.append("String_Node_Str");
      }
 else       if (strArr[i] == 'L') {
        buf.append("String_Node_Str");
      }
 else       if (strArr[i] == 'u') {
        if (i + 4 < strArr.length) {
          int utf=Integer.parseInt(str.substring(i + 1,i + 5),16);
          buf.append((char)utf);
          i+=4;
        }
 else {
          buf.append('\\');
          buf.append(strArr[i]);
        }
      }
 else       if (Character.isDigit(strArr[i])) {
        int j=0;
        for (j=1; (j < 2) && (i + j < strArr.length); ++j) {
          if (!Character.isDigit(strArr[i + j]))           break;
        }
        int octal=Integer.parseInt(str.substring(i,i + j),8);
        buf.append((char)octal);
        i+=j - 1;
      }
 else {
        buf.append(strArr[i]);
      }
      escape=false;
    }
 else     if (strArr[i] == '\\') {
      escape=true;
    }
 else {
      buf.append(strArr[i]);
    }
  }
  return buf.toString();
}
Program: 60327
Project: 60327
Buggy source:
private Chunk makeChildChunk(){
  if (chunkFactory == null) {
    Chunk child=new Chunk();
    child.setLocale(this.localeCode);
    return child;
  }
 else {
    return chunkFactory.makeChunk();
  }
}

Fixed version (ground truth):
private Chunk makeChildChunk(){
  Chunk child=chunkFactory == null ? new Chunk() : chunkFactory.makeChunk();
  child.setLocale(this.localeCode);
  return child;
}
Program: 60328
Project: 60328
Buggy source:
public static String processFormatString(String string,String[] args,Chunk context,HashMap<String,String> translations){
  if (string == null)   return null;
  String xlated=string;
  if (translations != null && translations.containsKey(string)) {
    xlated=translations.get(string);
  }
  if (!xlated.contains("String_Node_Str") || args == null || context == null) {
    return xlated;
  }
  Object[] values=new String[args.length];
  for (int i=0; i < args.length; i++) {
    String tagName=args[i];
    if (tagName.startsWith("String_Node_Str") || tagName.startsWith("String_Node_Str")) {
      Object val=context.get(tagName.substring(1));
      String valString=(val == null ? "String_Node_Str" : val.toString());
      values[i]=valString;
    }
 else {
      values[i]=tagName;
    }
  }
  try {
    return String.format(xlated,values);
  }
 catch (  IllegalFormatException e) {
    return xlated;
  }
}

Fixed version (ground truth):
public static String processFormatString(String string,String[] args,Chunk context,HashMap<String,String> translations){
  if (string == null)   return null;
  String xlated=string;
  if (translations != null && translations.containsKey(string)) {
    xlated=translations.get(string);
  }
  if (args == null || context == null || !xlated.contains("String_Node_Str")) {
    return xlated;
  }
  Object[] values=new String[args.length];
  for (int i=0; i < args.length; i++) {
    String tagName=args[i];
    if (tagName.startsWith("String_Node_Str") || tagName.startsWith("String_Node_Str")) {
      Object val=context.get(tagName.substring(1));
      String valString=(val == null ? "String_Node_Str" : val.toString());
      values[i]=valString;
    }
 else {
      values[i]=tagName;
    }
  }
  try {
    return String.format(xlated,values);
  }
 catch (  IllegalFormatException e) {
    return xlated;
  }
}
Program: 60330
Project: 60330
Buggy source:
public static Snippet getSnippet(String template){
  long timestamp=System.currentTimeMillis();
  if (++gcCounter % gcInterval == 0) {
    pruneCache(timestamp);
  }
  Snippet s=snippetCache.get(template);
  if (s != null) {
    cacheAge.put(template,timestamp);
    return s;
  }
 else {
    s=new Snippet(template);
    snippetCache.put(template,s);
    cacheAge.put(template,timestamp);
    return s;
  }
}

Fixed version (ground truth):
public static Snippet getSnippet(String template){
  if (Snippet.useCache) {
    return getSnippetFromCache(template);
  }
 else {
    return new Snippet(template);
  }
}
Program: 60331
Project: 60331
Buggy source:
@Override public String transformText(Chunk chunk,String text,String[] args){
  return markForTranslation(text);
}

Fixed version (ground truth):
@Override public String transformText(Chunk context,String text,String[] args){
  if (text == null)   return null;
  if (context == null)   return text;
  ChunkLocale translator=context.getLocale();
  if (translator == null)   return text;
  return translator.translate(text,null,context);
}
Program: 60332
Project: 60332
Buggy source:
public static String magicBraces(Chunk context,String output){
  char firstChar=output.charAt(0);
  if (firstChar == '~' || firstChar == '+') {
    if (context == null || context.isConforming()) {
      return "String_Node_Str" + output + "String_Node_Str";
    }
 else {
      String tagOpen=context.makeTag("String_Node_Str");
      tagOpen=RegexFilter.applyRegex(tagOpen,"String_Node_Str");
      String tag=context.makeTag(output);
      tag=Chunk.findAndReplace(tag,tagOpen + '~',tagOpen);
      tag=Chunk.findAndReplace(tag,tagOpen + '+',TemplateSet.INCLUDE_SHORTHAND);
      return tag;
    }
  }
 else   if (firstChar == '^') {
    if (context == null) {
      return TemplateSet.DEFAULT_TAG_START + '.' + output.substring(1)+ TemplateSet.DEFAULT_TAG_END;
    }
 else {
      return context.makeTag('.' + output.substring(1));
    }
  }
 else {
    return output;
  }
}

Fixed version (ground truth):
public static String magicBraces(Chunk context,String output){
  if (output == null || output.length() == 0)   return output;
  char firstChar=output.charAt(0);
  if (firstChar == '~' || firstChar == '+') {
    if (context == null || context.isConforming()) {
      return "String_Node_Str" + output + "String_Node_Str";
    }
 else {
      String tagOpen=context.makeTag("String_Node_Str");
      tagOpen=RegexFilter.applyRegex(tagOpen,"String_Node_Str");
      String tag=context.makeTag(output);
      tag=Chunk.findAndReplace(tag,tagOpen + '~',tagOpen);
      tag=Chunk.findAndReplace(tag,tagOpen + '+',TemplateSet.INCLUDE_SHORTHAND);
      return tag;
    }
  }
 else   if (firstChar == '^') {
    if (context == null) {
      return TemplateSet.DEFAULT_TAG_START + '.' + output.substring(1)+ TemplateSet.DEFAULT_TAG_END;
    }
 else {
      return context.makeTag('.' + output.substring(1));
    }
  }
 else {
    return output;
  }
}
Program: 60333
Project: 60333
Buggy source:
private static String applyMatchTransform(Chunk context,String text,String[] args){
  if (args == null)   return text;
  if (args.length == 1 && args[0] != null && args[0].length() == 0) {
    return text;
  }
  for (int i=1; i < args.length; i+=2) {
    if (i + 1 >= args.length)     return text;
    String test=args[i];
    String value=args[i + 1];
    if (test.equals("String_Node_Str")) {
      return TextFilter.magicBraces(context,value);
    }
    int patternStart=test.indexOf('/') + 1;
    int patternEnd=test.lastIndexOf('/');
    if (patternStart < 0 || patternStart == patternEnd)     return text;
    boolean ignoreCase=false;
    boolean multiLine=false;
    boolean dotAll=false;
    String pattern=test.substring(patternStart,patternEnd);
    for (int c=test.length() - 1; c > patternEnd; c--) {
      char option=test.charAt(c);
      if (option == 'i')       ignoreCase=true;
      if (option == 'm')       multiLine=true;
      if (option == 's')       dotAll=true;
    }
    if (multiLine)     pattern="String_Node_Str" + pattern;
    if (ignoreCase)     pattern="String_Node_Str" + pattern;
    if (dotAll)     pattern="String_Node_Str" + pattern;
    Pattern p=Pattern.compile(pattern);
    Matcher m=p.matcher(text);
    if (m.find()) {
      return TextFilter.magicBraces(context,value);
    }
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
private static String applyMatchTransform(Chunk context,String text,String[] args){
  if (args == null)   return text;
  if (args.length == 1 && args[0] != null && args[0].length() == 0) {
    return text;
  }
  for (int i=1; i < args.length; i+=2) {
    if (i + 1 >= args.length)     return text;
    String test=args[i];
    String value=args[i + 1];
    if (test.equals("String_Node_Str")) {
      return TextFilter.magicBraces(context,value);
    }
    if (text == null)     continue;
    int patternStart=test.indexOf('/') + 1;
    int patternEnd=test.lastIndexOf('/');
    if (patternStart < 0 || patternStart == patternEnd)     return text;
    boolean ignoreCase=false;
    boolean multiLine=false;
    boolean dotAll=false;
    String pattern=test.substring(patternStart,patternEnd);
    for (int c=test.length() - 1; c > patternEnd; c--) {
      char option=test.charAt(c);
      if (option == 'i')       ignoreCase=true;
      if (option == 'm')       multiLine=true;
      if (option == 's')       dotAll=true;
    }
    if (multiLine)     pattern="String_Node_Str" + pattern;
    if (ignoreCase)     pattern="String_Node_Str" + pattern;
    if (dotAll)     pattern="String_Node_Str" + pattern;
    Pattern p=Pattern.compile(pattern);
    Matcher m=p.matcher(text);
    if (m.find()) {
      return TextFilter.magicBraces(context,value);
    }
  }
  return "String_Node_Str";
}
Program: 60334
Project: 60334
Buggy source:
private static String[] parseArgs(String filter,boolean splitOnComma){
  int quote1=filter.indexOf("String_Node_Str");
  int quote2;
  boolean isQuoted=true;
  if (quote1 < 0) {
    quote2=filter.lastIndexOf("String_Node_Str");
    if (quote2 < 0)     return null;
    isQuoted=false;
  }
 else {
    quote2=filter.indexOf("String_Node_Str",quote1 + 1);
    if (quote2 < 0)     quote2=filter.length();
  }
  String arg0=filter.substring(quote1 + 1,quote2);
  String arg1=null;
  if (isQuoted) {
    int quote3=filter.indexOf("String_Node_Str",quote2 + 1);
    if (quote3 > 0) {
      int quote4=filter.indexOf("String_Node_Str",quote3 + 1);
      if (quote4 > 0) {
        arg1=filter.substring(quote3 + 1,quote4);
      }
    }
  }
  if (arg1 != null) {
    return new String[]{filter,arg0,arg1};
  }
 else   if (isQuoted || !splitOnComma || arg0.indexOf("String_Node_Str") < 0) {
    return new String[]{arg0};
  }
 else {
    return parseCommaDelimitedArgs(arg0);
  }
}

Fixed version (ground truth):
private static String[] parseArgs(String filter,boolean splitOnComma){
  int quote1=filter.indexOf("String_Node_Str");
  int quote2;
  boolean isQuoted=true;
  if (quote1 < 0 || filter.substring(0,quote1).trim().length() > 0) {
    quote1=-1;
    quote2=filter.lastIndexOf("String_Node_Str");
    if (quote2 < 0)     return null;
    isQuoted=false;
  }
 else {
    quote2=filter.indexOf("String_Node_Str",quote1 + 1);
    if (quote2 < 0)     quote2=filter.length();
  }
  String arg0=filter.substring(quote1 + 1,quote2);
  String arg1=null;
  if (isQuoted) {
    int quote3=filter.indexOf("String_Node_Str",quote2 + 1);
    if (quote3 > 0) {
      int quote4=filter.indexOf("String_Node_Str",quote3 + 1);
      if (quote4 > 0) {
        arg1=filter.substring(quote3 + 1,quote4);
      }
    }
  }
  if (arg1 != null) {
    return new String[]{filter,arg0,arg1};
  }
 else   if (isQuoted || !splitOnComma || arg0.indexOf("String_Node_Str") < 0) {
    return new String[]{arg0};
  }
 else {
    return parseCommaDelimitedArgs(arg0);
  }
}
Program: 60335
Project: 60335
Buggy source:
private static String selected(Chunk context,String text,String[] args,String token){
  if (args == null)   return token;
  String testValue=args[1];
  if (args.length > 2 && args[2] != null) {
    token=args[2];
  }
  if (testValue.charAt(0) == '~') {
    String xlation=testValue + "String_Node_Str" + RegexFilter.escapeRegex(text)+ "String_Node_Str"+ token+ "String_Node_Str";
    return TextFilter.magicBraces(context,xlation);
  }
  if (text.equals(testValue)) {
    return token;
  }
 else {
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
private static String selected(Chunk context,String text,String[] args,String token){
  if (args == null)   return token;
  String testValue=args[0];
  if (args.length > 1)   testValue=args[1];
  if (args.length > 2)   token=args[2];
  if (testValue.charAt(0) == '~') {
    String xlation=testValue + "String_Node_Str" + RegexFilter.escapeRegex(text)+ "String_Node_Str"+ token+ "String_Node_Str";
    return TextFilter.magicBraces(context,xlation);
  }
  if (text.equals(testValue)) {
    return token;
  }
 else {
    return "String_Node_Str";
  }
}
Program: 60336
Project: 60336
Buggy source:
private int findMatchingDefEnd(List<SnippetPart> parts,int startAt){
  int allTheRest=parts.size();
  for (int i=startAt; i < allTheRest; i++) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      String tagText=((SnippetTag)part).getTag();
      int eqPos=tagText.indexOf('=');
      if (eqPos < 0)       continue;
      if (tagText.length() == 1)       return i;
      if (tagText.contains("String_Node_Str")) {
        char[] tagChars=tagText.toCharArray();
        for (int x=0; x < eqPos; x++) {
          char c=tagChars[x];
          if (c == '.' || c == '|' || c == ':' || c == '(') {
            continue;
          }
        }
        return i;
      }
    }
  }
  return allTheRest;
}

Fixed version (ground truth):
private int findMatchingDefEnd(List<SnippetPart> parts,int startAt){
  int allTheRest=parts.size();
  for (int i=startAt; i < allTheRest; i++) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      String tagText=((SnippetTag)part).getTag();
      int eqPos=tagText.indexOf('=');
      if (eqPos < 0)       continue;
      if (tagText.length() == 1)       return i;
      char[] tagChars=tagText.toCharArray();
      char c='=';
      for (int x=0; x < eqPos; x++) {
        c=tagChars[x];
        if (c == '.' || c == '|' || c == ':' || c == '(') {
          c=0;
          break;
        }
      }
      if (c == 0) {
        continue;
      }
 else {
        return i;
      }
    }
  }
  return allTheRest;
}
Program: 60337
Project: 60337
Buggy source:
private void parseDefs(Snippet body){
  List<SnippetPart> parts=body.getParts();
  for (int i=0; i < parts.size(); i++) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      String tagText=((SnippetTag)part).getTag();
      if (tagText.trim().endsWith("String_Node_Str")) {
        int j=findMatchingDefEnd(parts,i + 1);
        Snippet def=new Snippet(parts,i + 1,j);
        String varName=tagText.substring(0,tagText.length() - 1);
        saveDef(varName,def);
        SnippetPart partJ=parts.get(j);
        if (partJ.getText().equals("String_Node_Str")) {
          i=j + 1;
        }
 else {
          i=j;
        }
      }
 else {
        String[] simpleDef=getSimpleDef(tagText);
        if (simpleDef != null) {
          saveDef(simpleDef[0],simpleDef[1]);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void parseDefs(Snippet body){
  List<SnippetPart> parts=body.getParts();
  for (int i=0; i < parts.size(); i++) {
    SnippetPart part=parts.get(i);
    if (part.isTag()) {
      String tagText=((SnippetTag)part).getTag();
      if (tagText.trim().endsWith("String_Node_Str")) {
        int j=findMatchingDefEnd(parts,i + 1);
        Snippet def=new Snippet(parts,i + 1,j);
        String varName=tagText.substring(0,tagText.length() - 1);
        saveDef(varName,def);
        i=j;
        if (j < parts.size()) {
          SnippetPart partJ=parts.get(j);
          if (partJ.getText().equals("String_Node_Str")) {
            i=j + 1;
          }
        }
      }
 else {
        String[] simpleDef=getSimpleDef(tagText);
        if (simpleDef != null) {
          saveDef(simpleDef[0],simpleDef[1]);
        }
      }
    }
  }
}
Program: 60339
Project: 60339
Buggy source:
public String toString(){
  if (simpleText != null)   return simpleText;
  if (parts == null)   return null;
  StringBuilder sb=new StringBuilder();
  for (  SnippetPart part : parts) {
    sb.append(part.getText());
  }
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  if (simpleText != null)   return simpleText;
  if (parts == null)   return null;
  StringBuilder sb=new StringBuilder();
  for (  SnippetPart part : parts) {
    sb.append(part.toString());
  }
  return sb.toString();
}
Program: 60340
Project: 60340
Buggy source:
/** 
 * Makes a template "factory" which reads in template files from the file system in the templatePath folder.  Caches for refreshMins. Uses "extensions" for the default file extension (do not include dot).
 * @param templatePath folder where template files are located.
 * @param extensions appends dot plus this String to a template name stub to find template files.
 * @param refreshMins returns template from cache unless this many minutes have passed.
 */
public TemplateSet(String templatePath,String extension,int refreshMins){
  if (templatePath != null) {
    char lastChar=templatePath.charAt(templatePath.length() - 1);
    char fs=System.getProperty("String_Node_Str").charAt(0);
    if (lastChar != '\\' && lastChar != '/' && lastChar != fs) {
      templatePath+=fs;
    }
    this.templatePath=templatePath;
  }
  this.dirtyInterval=refreshMins;
  this.defaultExtension=extension;
}

Fixed version (ground truth):
/** 
 * Makes a template "factory" which reads in template files from the file system in the templatePath folder.  Caches for refreshMins. Uses "extensions" for the default file extension (do not include dot).
 * @param templatePath folder where template files are located.
 * @param extensions appends dot plus this String to a template name stub to find template files.
 * @param refreshMins returns template from cache unless this many minutes have passed.
 */
public TemplateSet(String templatePath,String extension,int refreshMins){
  if (templatePath != null) {
    char lastChar=templatePath.charAt(templatePath.length() - 1);
    char fs=System.getProperty("String_Node_Str").charAt(0);
    if (lastChar != '\\' && lastChar != '/' && lastChar != fs) {
      templatePath+=fs;
    }
    this.templatePath=templatePath;
  }
  this.dirtyInterval=refreshMins;
  this.defaultExtension=(extension == null ? DEFAULT_EXTENSION : extension);
}