我对服务器的简单请求/响应有一个非常奇怪的例外。当我的网站仅由我使用时,我测试了它,响应的大小不应超过几千字节。
问题: 这是什么意思?我应该在哪里修复它?
的代码: 的
public class Peer implements WebSocketListener {
private org.eclipse.jetty.websocket.api.Session session;
public void sendResponse(Response response) {
try {
String stringifiedResponse = Utils.objectToJson(response); //just simple fasterxml mapping
if (stringifiedResponse.length() > 30000) {
LoggerFactory.getLogger(Peer.class).debug("Big Response = " + stringifiedResponse);
}
session.getRemote().sendString(stringifiedResponse); //BufferOverflowException!!!
} catch (IOException ex) {
// Do something!
}
}
public void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session) {
this.session = session;
this.session.getPolicy().setMaxTextMessageBufferSize(2097152);
this.session.getPolicy().setMaxBinaryMessageSize(2097152);
this.session.getPolicy().setMaxBinaryMessageBufferSize(2097152);
this.session.getPolicy().setInputBufferSize(2097151);
Engine.addPeer(this);
}
}
的堆栈跟踪: 的
java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.outgoingFrame(PerMessageDeflateExtension.java:229)
at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.outgoingFrame(ExtensionStack.java:273)
at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.uncheckedSendFrame(WebSocketRemoteEndpoint.java:297)
at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.blockingWrite(WebSocketRemoteEndpoint.java:97)
at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.sendString(WebSocketRemoteEndpoint.java:380)
at com.levi9.levirs.core.Peer.sendResponse(Peer.java:48)
at com.levi9.levirs.communication.user.UserRequestHandler$Login.handle(UserRequestHandler.java:42)
at com.levi9.levirs.core.Peer.onWebSocketText(Peer.java:33)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextMessage(JettyListenerEventDriver.java:127)
at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:64)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextFrame(JettyListenerEventDriver.java:121)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:169)
at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:302)
at org.eclipse.jetty.websocket.common.extensions.AbstractExtension.nextIncomingFrame(AbstractExtension.java:162)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.nextIncomingFrame(PerMessageDeflateExtension.java:281)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.incomingFrame(PerMessageDeflateExtension.java:159)
at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:204)
at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:223)
at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:260)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.read(AbstractWebSocketConnection.java:500)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:409)
at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
at java.lang.Thread.run(Thread.java:744)