Skip to content

Conversation

lachlan-roberts
Copy link
Contributor

Closes #13525

I'm not sure if this will actually fix #13525, but it cleans up some of the usage around the WebSocketComponents lifecycle and tests that the WebSocketComponents is actually started when executing the test.

I think it is most likely that the RejectedExecutionException is resulting from a WebSocketComponents which has not been started yet.

…ndlerOnMessageBinaryStreamTest

Signed-off-by: Lachlan Roberts <[email protected]>
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.

When you are having lifecycle start/stop order issues, the solution is never to start doing explicit start calls to sub components. Build a correct containment tree and let the infrastructure code do its work. I.e. follow the pattern rather than fight it. Don't try to work around it, adopt it fully!

components = new WebSocketComponents();
container = new DummyContainer(components);
components.start();
container.start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Starting both should not be required. Just start the container

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we want to do this.

Because in the non-test usage we have the WebSocketComponents managed by the server lifecycle so it can be shared between multiple WebSocket containers. For example if both Jakarta and Jetty websocket containers were used, or WebSocketContainers with different EE versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Jetty's component mechanism can handle this. If the components are managed by the server, then it will be started by server and the auto beans in the containers will be unmanaged.

Embrace the pattern!

{
LifeCycle.stop(components);
LifeCycle.stop(container);
LifeCycle.stop(components);
Copy link
Contributor

Choose a reason for hiding this comment

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

just stop the container

public DummyContainer(WebSocketComponents components)
{
super(new WebSocketComponents());
super(components);
Copy link
Contributor

Choose a reason for hiding this comment

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

The super constructor should installBean(components), but it does not

Comment on lines +39 to +41
container = new DummyContainer(components);
components.start();
container.start();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@sbordet sbordet moved this to 👀 In review in Jetty 12.1.3 Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Flakey test: JakartaWebSocketFrameHandler.OnMessageBinaryStreamTest
2 participants