Program: 5250
Project: 5250
Buggy source:
/** 
 * reads characters until the requested string is found, or buffers are exhausted.
 * @throws CharacterCodingException
 */
private boolean readString(StringReadRequest request) throws CharacterCodingException {
  String delimiter=request.getDelimiter();
  StringBuilder builder=request.getBuf();
  int fromIndex=Math.max(0,builder.length() - delimiter.length());
  List<ByteBuffer> databufs=new ArrayList<ByteBuffer>();
  String retVal=null;
  CharsetDecoder decoder=request.getCharset().newDecoder();
  CharBuffer charBuf=CharBuffer.allocate(this.getBytesPerRead());
  for (  ByteBuffer buf : this.databuffers) {
    if (retVal != null) {
      databufs.add(buf);
    }
 else {
      decoder.decode(buf,charBuf,false);
      charBuf.flip();
      log.info(charBuf.toString());
      request.getBuf().append(charBuf);
      charBuf.clear();
      if (request.getBuf().length() > request.getDelimiter().length() + fromIndex) {
        int found=builder.indexOf(delimiter,fromIndex);
        if (found != -1) {
          String val=builder.toString();
          log.info(val);
          retVal=val.substring(0,found);
          String remaining=val.substring(found + delimiter.length());
          log.info(remaining);
          ByteBuffer remainingAsBuf=this.getBuffer().put(remaining.getBytes(request.getCharset()));
          remainingAsBuf.flip();
          databufs.add(remainingAsBuf);
        }
 else {
          fromIndex+=delimiter.length();
        }
      }
      if (buf.hasRemaining()) {
        databufs.add(buf);
        if (retVal == null) {
          throw new CharacterCodingException();
        }
      }
 else {
        this.returnBuffer(buf);
      }
    }
  }
  this.databuffers=databufs;
  if (retVal != null) {
    log.info("String_Node_Str");
    log.info(retVal);
    request.getCallback().stringResult(retVal);
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * reads characters until the requested string is found, or buffers are exhausted.
 * @throws CharacterCodingException
 */
private boolean readString(StringReadRequest request) throws CharacterCodingException {
  String delimiter=request.getDelimiter();
  StringBuilder builder=request.getBuf();
  int fromIndex=Math.max(0,builder.length() - delimiter.length());
  List<ByteBuffer> databufs=new ArrayList<ByteBuffer>();
  String retVal=null;
  CharsetDecoder decoder=request.getCharset().newDecoder();
  CharBuffer charBuf=CharBuffer.allocate(this.getBytesPerRead());
  for (  ByteBuffer buf : this.databuffers) {
    if (retVal != null) {
      databufs.add(buf);
    }
 else {
      decoder.decode(buf,charBuf,false);
      charBuf.flip();
      request.getBuf().append(charBuf);
      charBuf.clear();
      if (request.getBuf().length() > request.getDelimiter().length() + fromIndex) {
        int found=builder.indexOf(delimiter,fromIndex);
        if (found != -1) {
          String val=builder.toString();
          retVal=val.substring(0,found);
          String remaining=val.substring(found + delimiter.length());
          ByteBuffer remainingAsBuf=this.getBuffer().put(remaining.getBytes(request.getCharset()));
          remainingAsBuf.flip();
          databufs.add(remainingAsBuf);
        }
 else {
          fromIndex+=delimiter.length();
        }
      }
      if (buf.hasRemaining()) {
        databufs.add(buf);
        if (retVal == null) {
          throw new CharacterCodingException();
        }
      }
 else {
        this.returnBuffer(buf);
      }
    }
  }
  this.databuffers=databufs;
  if (retVal != null) {
    this.callbacks.poll();
    request.getCallback().stringResult(retVal);
    return true;
  }
  return false;
}