Program: 41811
Project: 41811
Buggy source:
private boolean readNextExcerpt(@NotNull SocketChannel sc){
  try {
    if (closed)     return false;
    if (readBuffer.remaining() < (scFirst ? TcpUtil.HEADER_SIZE : 4)) {
      if (readBuffer.remaining() == 0)       readBuffer.clear();
 else       readBuffer.compact();
      int minSize=scFirst ? 8 + 4 + 8 : 4 + 8;
      while (readBuffer.position() < minSize) {
        if (sc.read(readBuffer) < 0) {
          sc.close();
          return false;
        }
      }
      readBuffer.flip();
    }
    if (scFirst) {
      long scIndex=readBuffer.getLong();
      if (scIndex != chronicle.size())       throw new StreamCorruptedException("String_Node_Str" + chronicle.size() + "String_Node_Str"+ scIndex);
      scFirst=false;
    }
    int size=readBuffer.getInt();
switch (size) {
case InProcessChronicleSource.IN_SYNC_LEN:
      return false;
case InProcessChronicleSource.PADDED_LEN:
    excerpt.addPaddedEntry();
  return true;
default :
break;
}
if (size > 128 << 20 || size < 0) throw new StreamCorruptedException("String_Node_Str" + size);
excerpt.startExcerpt(size);
long remaining=size;
int limit=readBuffer.limit();
int size2=(int)Math.min(readBuffer.remaining(),remaining);
remaining-=size2;
readBuffer.limit(readBuffer.position() + size2);
excerpt.write(readBuffer);
readBuffer.limit(limit);
while (remaining > 0) {
readBuffer.clear();
int size3=(int)Math.min(readBuffer.capacity(),remaining);
readBuffer.limit(size3);
if (sc.read(readBuffer) < 0) throw new EOFException();
readBuffer.flip();
remaining-=readBuffer.remaining();
excerpt.write(readBuffer);
}
excerpt.finish();
}
 catch (IOException e) {
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE,"String_Node_Str" + address + "String_Node_Str",e);
 else if (logger.isLoggable(Level.INFO)) logger.log(Level.INFO,"String_Node_Str" + address + "String_Node_Str"+ e);
try {
sc.close();
}
 catch (IOException ignored) {
}
}
return true;
}

Fixed version (ground truth):
private boolean readNextExcerpt(@NotNull SocketChannel sc){
  try {
    if (closed)     return false;
    if (readBuffer.remaining() < (scFirst ? TcpUtil.HEADER_SIZE : 4)) {
      if (readBuffer.remaining() == 0)       readBuffer.clear();
 else       readBuffer.compact();
      int minSize=scFirst ? 8 + 4 + 8 : 4 + 8;
      while (readBuffer.position() < minSize) {
        if (sc.read(readBuffer) < 0) {
          sc.close();
          return false;
        }
      }
      readBuffer.flip();
    }
    if (scFirst) {
      long scIndex=readBuffer.getLong();
      if (scIndex != chronicle.size())       throw new StreamCorruptedException("String_Node_Str" + chronicle.size() + "String_Node_Str"+ scIndex);
      scFirst=false;
    }
    int size=readBuffer.getInt();
switch (size) {
case InProcessChronicleSource.IN_SYNC_LEN:
      return false;
case InProcessChronicleSource.PADDED_LEN:
    excerpt.startExcerpt(chronicle.config().dataBlockSize() - 1);
  return true;
default :
break;
}
if (size > 128 << 20 || size < 0) throw new StreamCorruptedException("String_Node_Str" + size);
excerpt.startExcerpt(size);
long remaining=size;
int limit=readBuffer.limit();
int size2=(int)Math.min(readBuffer.remaining(),remaining);
remaining-=size2;
readBuffer.limit(readBuffer.position() + size2);
excerpt.write(readBuffer);
readBuffer.limit(limit);
while (remaining > 0) {
readBuffer.clear();
int size3=(int)Math.min(readBuffer.capacity(),remaining);
readBuffer.limit(size3);
if (sc.read(readBuffer) < 0) throw new EOFException();
readBuffer.flip();
remaining-=readBuffer.remaining();
excerpt.write(readBuffer);
}
excerpt.finish();
}
 catch (IOException e) {
if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE,"String_Node_Str" + address + "String_Node_Str",e);
 else if (logger.isLoggable(Level.INFO)) logger.log(Level.INFO,"String_Node_Str" + address + "String_Node_Str"+ e);
try {
sc.close();
}
 catch (IOException ignored) {
}
}
return true;
}