Improve ByteBuffer copy method
This commit improves JettyWebSocketHandlerAdapter::copyByteBuffer so that it allocates a buffer large enough for the remaining bytes contained in the source, instead of allocating one with the capacity of the source. Closes gh-31857
This commit is contained in:
@@ -118,8 +118,9 @@ public class JettyWebSocketHandlerAdapter {
|
||||
}
|
||||
|
||||
private static ByteBuffer copyByteBuffer(ByteBuffer src) {
|
||||
ByteBuffer dest = ByteBuffer.allocate(src.capacity());
|
||||
dest.put(0, src, 0, src.remaining());
|
||||
ByteBuffer dest = ByteBuffer.allocate(src.remaining());
|
||||
dest.put(src);
|
||||
dest.flip();
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user