Program: 24808
Project: 24808
Buggy source:
/** 
 * Marks all the terms within the given text. Typically used to mark terms within a meta-data field.
 * @param doc        document to get matching spans from
 * @param fieldName  name of the field to mark.
 * @param value      value of the field to mark
 * @return           Marked up text value.
 */
public String markField(SpanDocument doc,final String fieldName,final String value){
  try {
    final StringBuffer buf=new StringBuffer(value.length() * 2);
    TokenStream stream=analyzer.tokenStream(fieldName,new StringReader(value));
    stream=new StartEndStripper(stream);
    final WordIter wordIter=new BoundedWordIter(value,stream,chunkOverlap);
    doc.markField(fieldName,wordIter,maxContext,termMode,stopSet,new MarkCollector(){
      private MarkPos prevPos=null;
      private boolean inContext=false;
      private boolean inSpan=false;
      private int contextSize;
      private MarkPos contextStart;
      private void copyUpTo(      MarkPos pos){
        if (prevPos != null) {
          String toAdd=((BoundedMarkPos)prevPos).getTextTo(pos,inContext || inSpan);
          buf.append(toAdd);
          if (inContext)           contextSize+=toAdd.length();
        }
        prevPos=pos;
      }
      public void beginField(      MarkPos pos){
        prevPos=pos;
      }
      public void beginContext(      MarkPos pos,      Span span){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        buf.append(Integer.toString(span.rank + 1));
        buf.append("String_Node_Str");
        buf.append(Integer.toString((int)(span.score * 100)));
        buf.append("String_Node_Str");
        inContext=true;
        contextSize=0;
        contextStart=pos;
      }
      public void term(      MarkPos startPos,      MarkPos endPos,      String term){
        copyUpTo(startPos);
        String toAdd=startPos.getTextTo(endPos);
        buf.append("String_Node_Str");
        buf.append(toAdd);
        buf.append("String_Node_Str");
        if (inContext)         contextSize+=toAdd.length();
        prevPos=endPos;
      }
      public void beginSpan(      MarkPos pos,      Span span){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        buf.append(Integer.toString(span.rank + 1));
        buf.append("String_Node_Str");
        buf.append(Integer.toString((int)(span.score * 100)));
        buf.append("String_Node_Str");
        inSpan=true;
      }
      public void endSpan(      MarkPos pos){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        inSpan=false;
      }
      public void endContext(      MarkPos pos){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        if (contextSize > maxContext) {
          int posDiff=contextStart.countTextTo(pos);
        }
        inContext=false;
      }
      public void endField(      MarkPos pos){
        copyUpTo(pos);
      }
    }
);
    String strVal=buf.toString();
    return strVal;
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
catch (  BoundedMarkPos.UnmarkableException e) {
    return value;
  }
}

Fixed version (ground truth):
/** 
 * Marks all the terms within the given text. Typically used to mark terms within a meta-data field.
 * @param doc        document to get matching spans from
 * @param fieldName  name of the field to mark.
 * @param value      value of the field to mark
 * @return           Marked up text value.
 */
public String markField(SpanDocument doc,final String fieldName,final String value){
  try {
    final StringBuffer buf=new StringBuffer(value.length() * 2);
    TokenStream stream=analyzer.tokenStream(fieldName,new StringReader(value));
    stream=new StartEndStripper(stream);
    final WordIter wordIter=new BoundedWordIter(value,stream,chunkOverlap);
    doc.markField(fieldName,wordIter,maxContext,termMode,stopSet,new MarkCollector(){
      private MarkPos prevPos=null;
      private boolean inContext=false;
      private boolean inSpan=false;
      private int contextSize;
      private MarkPos contextStart;
      private void copyUpTo(      MarkPos pos){
        if (prevPos != null) {
          String toAdd=((BoundedMarkPos)prevPos).getTextTo(pos,inContext || inSpan);
          buf.append(toAdd);
          if (inContext)           contextSize+=toAdd.length();
        }
        prevPos=pos;
      }
      public void beginField(      MarkPos pos){
        prevPos=pos;
      }
      public void beginContext(      MarkPos pos,      Span span){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        buf.append(Integer.toString(span.rank + 1));
        buf.append("String_Node_Str");
        buf.append(Integer.toString((int)(span.score * 100)));
        buf.append("String_Node_Str");
        inContext=true;
        contextSize=0;
        contextStart=pos;
      }
      public void term(      MarkPos startPos,      MarkPos endPos,      String term){
        copyUpTo(startPos);
        String toAdd=startPos.getTextTo(endPos);
        buf.append("String_Node_Str");
        buf.append(toAdd);
        buf.append("String_Node_Str");
        if (inContext)         contextSize+=toAdd.length();
        prevPos=endPos;
      }
      public void beginSpan(      MarkPos pos,      Span span){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        if (!inContext) {
          buf.append("String_Node_Str");
          buf.append(Integer.toString(span.rank + 1));
          buf.append("String_Node_Str");
          buf.append(Integer.toString((int)(span.score * 100)));
          buf.append("String_Node_Str");
        }
        buf.append("String_Node_Str");
        inSpan=true;
      }
      public void endSpan(      MarkPos pos){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        inSpan=false;
      }
      public void endContext(      MarkPos pos){
        copyUpTo(pos);
        buf.append("String_Node_Str");
        if (contextSize > maxContext) {
          int posDiff=contextStart.countTextTo(pos);
        }
        inContext=false;
      }
      public void endField(      MarkPos pos){
        copyUpTo(pos);
      }
    }
);
    String strVal=buf.toString();
    return strVal;
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
catch (  BoundedMarkPos.UnmarkableException e) {
    return value;
  }
}