Program: 4223
Project: 4223
Buggy source:
public int read(ByteBuffer dst) throws IOException {
  int transferred=0;
  if (readOutgoing != null && readOutgoing.position() > 0) {
    transferred+=BufferUtils.transfer(readOutgoing,dst);
  }
  while (true) {
    if (!dst.hasRemaining() && engine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
      LOG.debug("String_Node_Str");
      return transferred;
    }
    int read=-1;
    while (readIncoming.hasRemaining() && (read=readSink.read(readIncoming)) > 0)     ;
    if (read == -1 && readIncoming.position() == 0) {
      LOG.debug("String_Node_Str");
      return -1;
    }
    if (readIncoming.position() == 0)     return 0;
    readIncoming.flip();
    SSLEngineResult result=engine.unwrap(readIncoming,dst);
    transferred+=result.bytesProduced();
    SSLEngineResult.Status status=result.getStatus();
    if (status == Status.BUFFER_OVERFLOW) {
      if (readOutgoing == null)       readOutgoing=ByteBuffer.allocate(engine.getSession().getPacketBufferSize());
      result=engine.unwrap(readIncoming,readOutgoing);
      status=result.getStatus();
      if (status == Status.BUFFER_OVERFLOW)       throw new IllegalStateException("String_Node_Str");
      transferred+=BufferUtils.transfer(readOutgoing,dst);
    }
    if (readIncoming.hasRemaining()) {
      readDataLeft=true;
      readIncoming.compact();
    }
 else {
      readDataLeft=false;
      readIncoming.clear();
    }
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + result);
    if (status == Status.BUFFER_UNDERFLOW)     return transferred;
    if (status == Status.CLOSED) {
      if (transferred == 0)       return -1;
 else       return transferred;
    }
    if (!processHandshakeResult(true,false,result.getHandshakeStatus()))     return transferred;
  }
}

Fixed version (ground truth):
public int read(ByteBuffer dst) throws IOException {
  int transferred=0;
  if (readOutgoing != null && readOutgoing.position() > 0) {
    transferred+=BufferUtils.transfer(readOutgoing,dst);
  }
  while (true) {
    if (!dst.hasRemaining() && engine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
      LOG.debug("String_Node_Str");
      return transferred;
    }
    int read=-1;
    while (readIncoming.hasRemaining() && (read=readSink.read(readIncoming)) > 0)     ;
    if (read == -1 && readIncoming.position() == 0) {
      LOG.debug("String_Node_Str");
      return -1;
    }
    if (readIncoming.position() == 0) {
      LOG.debug("String_Node_Str");
      return 0;
    }
    readIncoming.flip();
    SSLEngineResult result=engine.unwrap(readIncoming,dst);
    transferred+=result.bytesProduced();
    SSLEngineResult.Status status=result.getStatus();
    if (status == Status.BUFFER_OVERFLOW) {
      if (readOutgoing == null)       readOutgoing=ByteBuffer.allocate(engine.getSession().getPacketBufferSize());
      result=engine.unwrap(readIncoming,readOutgoing);
      status=result.getStatus();
      if (status == Status.BUFFER_OVERFLOW)       throw new IllegalStateException("String_Node_Str");
      transferred+=BufferUtils.transfer(readOutgoing,dst);
    }
    if (readIncoming.hasRemaining()) {
      readDataLeft=true;
      readIncoming.compact();
    }
 else {
      readDataLeft=false;
      readIncoming.clear();
    }
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + result);
    if (status == Status.BUFFER_UNDERFLOW)     return transferred;
    if (status == Status.CLOSED) {
      if (transferred == 0)       return -1;
 else       return transferred;
    }
    if (!processHandshakeResult(true,false,result.getHandshakeStatus()))     return transferred;
  }
}