diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java index 856b8a563b5..409e07bfafc 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java @@ -162,8 +162,7 @@ public class FrameFlusher extends IteratingCallback break; } - if(entry.frame.isFin()) - messagesOut.increment(); + messagesOut.increment(); int batchSpace = batchBuffer == null?bufferSize:BufferUtil.space(batchBuffer); @@ -230,9 +229,16 @@ public class FrameFlusher extends IteratingCallback if (flush) { + int i = 0; + int bytes = 0; + ByteBuffer bufferArray[] = new ByteBuffer[buffers.size()]; for (ByteBuffer bb : buffers) - bytesOut.add(bb.limit() - bb.position()); - endPoint.write(this, buffers.toArray(new ByteBuffer[buffers.size()])); + { + bytes += bb.limit() - bb.position(); + bufferArray[i++] = bb; + } + bytesOut.add(bytes); + endPoint.write(this, bufferArray); buffers.clear(); } else diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java index 1a708075c47..ad48861a46b 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java @@ -402,8 +402,7 @@ public class WebSocketConnection extends AbstractConnection implements Connectio if (frame == null) break; - if (frame.isFin()) - messagesIn.increment(); + messagesIn.increment(); if (meetDemand()) onFrame(frame);