tomcat服务器调试过websocket后,再发送http请求后eclipse窗口弹出一个类class NioEndpoint
这个类标记出下面的方法throw new EOFException();控制台没有输出异常 。
private int fillReadBuffer(boolean block, ByteBuffer to) throws IOException {
int nRead;
NioChannel channel = getSocket();
if (block) {
Selector selector = null;
try {
selector = pool.get();
} catch (IOException x) {
// Ignore
}
try {
NioEndpoint.NioSocketWrapper att = (NioEndpoint.NioSocketWrapper) channel
.getAttachment();
if (att == null) {
throw new IOException("Key must be cancelled.");
}
nRead = pool.read(to, channel, selector, att.getReadTimeout());
} finally {
if (selector != null) {
pool.put(selector);
}
}
} else {
nRead = channel.read(to);
if (nRead == -1) {
throw new EOFException();
}
}
return nRead;
}
这段代码是Tomcat服务器的一个方法,用于填充读取缓冲区。当调用该方法时,它会检查是否需要阻塞,如果需要阻塞,则会使用一个选择器来等待数据可读,并在超时之后读取数据。如果不需要阻塞,则直接读取数据。
在这段代码中,如果使用阻塞方式读取数据,并且读取到的数据为-1(即已经到达流的末尾),则会抛出EOFException异常。这个异常可能会被上层代码捕获并处理。
根据你的描述,你在调试WebSocket之后发送了一个HTTP请求,然后Eclipse窗口弹出了一个NioEndpoint类的实例,其中包含了上述的方法。但是控制台没有输出异常。这可能是因为异常被捕获并处理了,或者异常被忽略了。具体原因需要查看调用该方法的上层代码。