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:
parent
eaf7a28250
commit
24f8eac12a
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue