Skip to content

fix: let WebSocketClient borrow a client created without a context - #1607

Open
jlouvel wants to merge 1 commit into
fix/websocket-client-shared-event-loopfrom
fix/websocket-borrow-client-without-context
Open

jlouvel wants to merge 1 commit into
fix/websocket-client-shared-event-loopfrom
fix/websocket-borrow-client-without-context

Conversation

@jlouvel

@jlouvel jlouvel commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1599.

Stacked on #1568 (itself on #1566). Merge those first; this PR's base then moves to 3.0. It could also be folded into #1568.

Summary

WebSocketClient.setClient found the borrowed client's NettyClientHelper through the org.restlet.engine.helper context attribute. A client created with new Client(Protocol.HTTP) has no context, so it couldn't be borrowed, and the error didn't say what to change.

  • Client.getHelper() is now public, documented as an engine extension point for extensions that share the connector's resources. It was private, and it doesn't depend on a context.
  • WebSocketClient uses client.getHelper(). The context requirement is removed from the setClient Javadoc and from the error message, which now reads "The borrowed client must use the Netty HTTP connector".

Server keeps its helper private. It could get the same accessor later if an extension needs it.

Testing

  • New WebSocketSharedEventLoopTestCase.acceptsAClientWithoutContext: a started new Client(Protocol.HTTP) is borrowed and serves a session. The existing tests still reject unstarted clients and clients without a Netty HTTP connector.
  • org.restlet.ext.websocket tests pass locally: 33 tests. SpotBugs and the full core suite couldn't run locally because the machine was short of memory; CI runs them.

🤖 Generated with Claude Code

WebSocketClient.setClient found the borrowed client's NettyClientHelper
through the "org.restlet.engine.helper" context attribute, so a client
created with new Client(Protocol.HTTP), which has no context, couldn't
be borrowed.

Client.getHelper() is now public, as an engine extension point, and the
WebSocket client uses it. The context requirement is removed from the
setClient Javadoc and the error message.

Fixes #1599.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant