NTCP: Catch unchecked BufferOverflowException on read() call, unknown cause

reported 2x by: postman
This commit is contained in:
zzz committed 2026-08-05 16:06:08 -04:00
1 parent 316f0bc1e3
commit ab715a94a7
1 file changed
+11
@@ -6,6 +6,7 @@ import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.Buffer;
import java.nio.BufferOverflowException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
@@ -782,6 +783,16 @@ class EventPumper implements Runnable {
clearInterest(key, SelectionKey.OP_READ);
if (_log.shouldLog(Log.WARN))
_log.warn("error reading on " + con, nyce);
} catch (BufferOverflowException boe) {
// Rare unchecked exception on read() call, unknown cause
// Not even listed on SocketChannel.read() javadoc
// Do not release the buf, maybe it was in the pool twice?
// We assume this is fatal for the con so we close it.
clearInterest(key, SelectionKey.OP_READ);
con.close();
_context.statManager().addRateData("ntcp.readError", 1);
if (_log.shouldWarn())
_log.warn("error reading on " + con, boe);
}
}