mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-10-23 21:44:41 +00:00
NTCP: Catch unchecked BufferOverflowException on read() call, unknown cause
reported 2x by: postman
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user