Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #7086 - fix issues when calling websocket demand #7088

Merged
merged 5 commits into from
Nov 16, 2021

Conversation

lachlan-roberts
Copy link
Contributor

Closes #7086

If the call to CoreSession.demand(1) throws then the callback will be completed for success and failure. This seems to be the most likely cause for what we are seeing in #7086, and I have been able to reproduce the same error stack trace in a test.

  • Do not throw from demand() if the session state is not input open.
  • Fix bug where demand was not called when there was a null message sink.

// Can send/receive binary message successfully.
ByteBuffer binaryMessage = BufferUtil.toBuffer("hello world");
session.getBasicRemote().sendBinary(binaryMessage);
assertThat(BINARY_MESSAGES.poll(5, TimeUnit.SECONDS), is(binaryMessage));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is so confusing. That is(binaryMessage) actually calls equals() is so weird. Why not using assertEquals()?

Also, why binaryMessage is not consumed after sendBinary()?!? This seems like a bug, I wonder how the test is passing?

Copy link
Contributor Author

@lachlan-roberts lachlan-roberts Nov 12, 2021

Choose a reason for hiding this comment

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

This is so confusing. That is(binaryMessage) actually calls equals() is so weird. Why not using assertEquals()?

I don't see this as confusing, this pattern is frequently used in other tests.

Also, why binaryMessage is not consumed after sendBinary()?!? This seems like a bug, I wonder how the test is passing?

This was an intentional change that was made. See issue #4341. @gregw has previously said that sending a frame should not modify the position/limit of the original buffer.

@sbordet sbordet self-requested a review November 12, 2021 10:15
@lachlan-roberts lachlan-roberts merged commit 6bfab6e into jetty-10.0.x Nov 16, 2021
@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-7086-WebSocketMessageSinks branch November 16, 2021 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocket: java.lang.IllegalStateException: already released RetainableByteBuffer
2 participants