Skip to content

Commit 4733eea

Browse files
committed
[grid] Retaining to increase the reference count once and then close the ws properly.
This helps to close the VNC stream properly. Does not affect any of the CDP ws commands (since they do not go through this path).
1 parent 5385a15 commit 4733eea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

java/server/src/org/openqa/selenium/netty/server/WebSocketUpgradeHandler.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ private void handleHttpRequest(ChannelHandlerContext ctx, HttpRequest req) {
157157

158158
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
159159
if (frame instanceof CloseWebSocketFrame) {
160-
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
160+
CloseWebSocketFrame close = (CloseWebSocketFrame) frame.retain();
161+
handshaker.close(ctx.channel(), close);
161162
// Pass on to the rest of the channel
162-
ctx.fireChannelRead(frame);
163+
ctx.fireChannelRead(close);
163164
} else if (frame instanceof PingWebSocketFrame) {
164165
ctx.write(new PongWebSocketFrame(frame.isFinalFragment(), frame.rsv(), frame.content()));
165166
} else if (frame instanceof ContinuationWebSocketFrame) {
@@ -170,8 +171,8 @@ private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame fram
170171
// Allow the rest of the pipeline to deal with this.
171172
ctx.fireChannelRead(frame);
172173
} else {
173-
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
174-
.getName()));
174+
throw new UnsupportedOperationException(
175+
String.format("%s frame types not supported", frame.getClass().getName()));
175176
}
176177
}
177178

0 commit comments

Comments
 (0)