Skip to content

Commit a5d287f

Browse files
Copilotmarci4
andcommitted
Address code review: Remove unused import and add documentation
Co-authored-by: marci4 <13464940+marci4@users.noreply.github.com>
1 parent 2d5f930 commit a5d287f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/org/java_websocket/drafts/Draft_6455.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.time.format.DateTimeFormatter;
3636
import java.util.ArrayList;
3737
import java.util.Collections;
38-
import java.util.LinkedList;
3938
import java.util.List;
4039
import java.util.Locale;
4140
import org.java_websocket.WebSocketImpl;

src/main/java/org/java_websocket/util/ByteBufferUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
public class ByteBufferUtils {
3434

3535
/**
36-
* Shared empty ByteBuffer to avoid repeated allocations
36+
* Shared empty ByteBuffer to avoid repeated allocations.
37+
* Safe to share because it has zero capacity and duplicate() provides independent position/limit state.
3738
*/
3839
private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.allocate(0);
3940

@@ -70,9 +71,10 @@ public static int transferByteBuffer(ByteBuffer source, ByteBuffer dest) {
7071
}
7172

7273
/**
73-
* Get a ByteBuffer with zero capacity
74+
* Get a ByteBuffer with zero capacity. Returns a duplicate of a shared empty buffer
75+
* for efficiency - each duplicate has independent position/limit/mark state.
7476
*
75-
* @return empty ByteBuffer
77+
* @return empty ByteBuffer with zero capacity
7678
*/
7779
public static ByteBuffer getEmptyByteBuffer() {
7880
return EMPTY_BYTE_BUFFER.duplicate();

0 commit comments

Comments
 (0)