Skip to content

Conversation

lachlan-roberts
Copy link
Contributor

Fixes #12818 and #13225

If a close WebSocketConnection.onClose event happens during fillAndParse() then the network buffer is nulled out while it is still in use potentially causing NPE.

This fixes this issue by introducing a new atomic state so that onClosed() serializes the close actions with fillAndParse().

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
sbordet
sbordet previously approved these changes Jun 24, 2025
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit.

@@ -429,6 +464,28 @@ public void cancelDemand()

private void fillAndParse()
{
boolean doClose = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to just close like above.

gregw
gregw previously approved these changes Jun 25, 2025
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a niggle

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
@lachlan-roberts lachlan-roberts dismissed stale reviews from gregw and sbordet via 9dda144 June 25, 2025 05:42
@lachlan-roberts lachlan-roberts requested review from gregw and sbordet June 25, 2025 06:24
gregw
gregw previously approved these changes Jun 25, 2025
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this

…n/java/org/eclipse/jetty/websocket/core/WebSocketConnection.java

Co-authored-by: Greg Wilkins <gregw@webtide.com>
@lachlan-roberts lachlan-roberts merged commit b25c83c into jetty-12.0.x Jun 26, 2025
10 checks passed
@lachlan-roberts lachlan-roberts deleted the jetty-12.0.x-12818-WebSocketConnectionNPE branch June 26, 2025 00:34
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Jetty 12.0.23 - FROZEN Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
3 participants