Skip to content

Commit f857156

Browse files
committed
Fix NPE on WebSocket close, close AsyncHttpClient#1366
Motivation: We always try to release buffered frames when WebSocket gets closed. But the buffer might be null at this time (no frame was buffered or they were handled once WebSocket was open). We currently crash with NPE. Modification: Check for null frame buffer when trying to release. Result: No more NPE
1 parent b594a85 commit f857156

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client/src/main/java/org/asynchttpclient/netty/ws/NettyWebSocket.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ public void bufferFrame(WebSocketFrame frame) {
8181
}
8282

8383
private void releaseBufferedFrames() {
84-
for (WebSocketFrame frame : bufferedFrames) {
85-
frame.release();
84+
if (bufferedFrames != null) {
85+
for (WebSocketFrame frame : bufferedFrames) {
86+
frame.release();
87+
}
8688
}
8789
}
8890

0 commit comments

Comments
 (0)