Program: 141892
Project: 141892
Buggy source:
/** 
 * @see io.netty.handler.codec.ByteToMessageCodec#decode(io.netty.channel.ChannelHandlerContext,io.netty.buffer.ByteBuf,java.util.List)
 */
@Override protected void decode(ChannelHandlerContext ctx,ByteBuf in,List<Object> out) throws Exception {
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str",in.toString(StandardCharsets.UTF_8));
  }
  int retryCount=0;
  Exception thrownException=null;
  byte[] data=new byte[in.readableBytes()];
  in.readBytes(data);
  while (retryCount < 2) {
    try {
      asyncInputFeeder.feedInput(data,0,data.length);
      int event=-1;
      while (isValidEvent(event=streamReader.next())) {
        if (streamReader.getDepth() == STANZA_ELEMENT_DEPTH - 1) {
          if (event == XMLStreamConstants.END_ELEMENT) {
            out.add(new KixmppStreamEnd());
          }
 else           if (event == XMLStreamConstants.START_ELEMENT) {
            StAXElementBuilder streamElementBuilder=new StAXElementBuilder(true);
            streamElementBuilder.process(streamReader);
            out.add(new KixmppStreamStart(null));
          }
        }
 else         if (streamReader.getDepth() >= STANZA_ELEMENT_DEPTH) {
          if (event == XMLStreamConstants.START_ELEMENT && streamReader.getDepth() == STANZA_ELEMENT_DEPTH) {
            elementBuilder=new StAXElementBuilder(true);
            elementBuilder.process(streamReader);
            Element element=elementBuilder.getElement();
            if ("String_Node_Str".equals(element.getQualifiedName())) {
              throw new RuntimeException("String_Node_Str");
            }
          }
 else           if (event == XMLStreamConstants.END_ELEMENT && streamReader.getDepth() == STANZA_ELEMENT_DEPTH) {
            elementBuilder.process(streamReader);
            Element element=elementBuilder.getElement();
            out.add(element);
          }
 else {
            elementBuilder.process(streamReader);
          }
        }
      }
      break;
    }
 catch (    Exception e) {
      retryCount++;
      thrownException=e;
      try {
        streamReader.close();
      }
  finally {
        streamReader=inputFactory.createAsyncXMLStreamReader();
        asyncInputFeeder=streamReader.getInputFeeder();
      }
    }
  }
  if (retryCount > 1) {
    throw thrownException;
  }
}

Fixed version (ground truth):
/** 
 * @see io.netty.handler.codec.ByteToMessageCodec#decode(io.netty.channel.ChannelHandlerContext,io.netty.buffer.ByteBuf,java.util.List)
 */
@Override protected void decode(ChannelHandlerContext ctx,ByteBuf in,List<Object> out) throws Exception {
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str",in.toString(StandardCharsets.UTF_8));
  }
  int retryCount=0;
  Exception thrownException=null;
  byte[] data=new byte[in.readableBytes()];
  in.readBytes(data);
  if (streamReader != null) {
    while (retryCount < 2) {
      try {
        asyncInputFeeder.feedInput(data,0,data.length);
        int event=-1;
        while (isValidEvent(event=streamReader.next())) {
          if (streamReader.getDepth() == STANZA_ELEMENT_DEPTH - 1) {
            if (event == XMLStreamConstants.END_ELEMENT) {
              out.add(new KixmppStreamEnd());
              asyncInputFeeder.endOfInput();
              streamReader.close();
              streamReader=null;
              asyncInputFeeder=null;
              break;
            }
 else             if (event == XMLStreamConstants.START_ELEMENT) {
              StAXElementBuilder streamElementBuilder=new StAXElementBuilder(true);
              streamElementBuilder.process(streamReader);
              out.add(new KixmppStreamStart(null));
            }
          }
 else           if (streamReader.getDepth() >= STANZA_ELEMENT_DEPTH) {
            if (event == XMLStreamConstants.START_ELEMENT && streamReader.getDepth() == STANZA_ELEMENT_DEPTH) {
              elementBuilder=new StAXElementBuilder(true);
              elementBuilder.process(streamReader);
              Element element=elementBuilder.getElement();
              if ("String_Node_Str".equals(element.getQualifiedName())) {
                throw new RuntimeException("String_Node_Str");
              }
            }
 else             if (event == XMLStreamConstants.END_ELEMENT && streamReader.getDepth() == STANZA_ELEMENT_DEPTH) {
              elementBuilder.process(streamReader);
              Element element=elementBuilder.getElement();
              out.add(element);
            }
 else {
              elementBuilder.process(streamReader);
            }
          }
        }
        break;
      }
 catch (      Exception e) {
        retryCount++;
        logger.info("String_Node_Str" + e.getMessage());
        thrownException=e;
        try {
          streamReader.close();
        }
  finally {
          streamReader=inputFactory.createAsyncXMLStreamReader();
          asyncInputFeeder=streamReader.getInputFeeder();
        }
      }
    }
    if (retryCount > 1) {
      throw thrownException;
    }
  }
}