Repository navigation
Conversation
Follow the Restlet API conventions used by the RPC extensions: constructors, getter and void setter pairs, and a start/stop lifecycle instead of a fluent builder. - Remove WebSocketClient.Builder, builder() and create(). Settings are now configured with setters on a new WebSocketClient(). - Add start(), stop() and isStarted(). close() stops the client, which can be started again. connect() starts a stopped client, like Restlet.handle(). - Reject setting changes while the client is started. The extension is unreleased, so the builder is removed rather than deprecated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
This was referenced Oct 30, 2026
Open
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The public API migration lacks a breaking-change entry, and the same-instance stop/reconfigure/reconnect lifecycle lacks integration-test coverage.
2 open issues
What changed in this PR
This PR replaces the experimental WebSocket client’s builder API with constructor-based configuration and setters, aligning it with the Restlet RPC extensions.
Changes:
- Adds getters and setters, with configuration changes blocked while the client is started.
- Introduces a restartable lifecycle and automatic startup on connection.
- Migrates existing tests and adds configuration validation and lifecycle-state checks.
| File | Description |
|---|---|
org.restlet.ext.websocket/src/test/java/org/restlet/ext/websocket/WebSocketTestCase.java |
Updates shared client setup to use setters. |
org.restlet.ext.websocket/src/test/java/org/restlet/ext/websocket/WebSocketSessionTestCase.java |
Migrates client usage and adds settings and lifecycle assertions. |
org.restlet.ext.websocket/src/test/java/org/restlet/ext/websocket/WebSocketCompressionTestCase.java |
Migrates compression and frame-limit tests to setters. |
org.restlet.ext.websocket/src/main/java/org/restlet/ext/websocket/WebSocketClient.java |
Replaces the builder with configurable, restartable client lifecycle methods. |
Review effort: Balanced
| private NettyWebSocketConnector connector; | ||
|
|
||
| /** Constructor using the default settings. */ | ||
| public WebSocketClient() {} |
| public synchronized void stop() { | ||
| if (connector != null) { | ||
| connector.close(); | ||
| connector = null; |
Also describe the setter-based configuration and restartable lifecycle of WebSocketClient in the changes log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
WebSocketClientin the experimentalorg.restlet.ext.websocketextension was configured through a fluentBuilder. This PR switches it to the Restlet API conventions used by the RPC extensions (MCP, gRPC, Smithy): a constructor, getter andvoidsetter pairs, and astart()/stop()lifecycle.Changes
WebSocketClient.Builder,builder()andcreate(). Each setting is now a getter/setter pair:SslContext,ConnectTimeout,IdleTimeout,MaxMessageSize,MaxFrameSize,CompressionandHostnameVerification.start(),stop()andisStarted().start()creates the I/O threads andstop()releases them.close()callsstop(), and a stopped client can be started again.connect()starts a stopped client, likeRestlet.handle().IllegalStateException.getMaxFrameSize()returns the maximum message size until a frame size is set, the same default as before.The extension has not been released yet, so the builder is removed rather than deprecated.
Testing
builderValidatesSettingstoclientValidatesSettingsand addedsettingsAreFixedWhileStarted.mvn -pl org.restlet.ext.websocket verifypasses locally: 28 tests, no failures.Not in this PR
The client still creates its own Netty event loop instead of borrowing one from the application's connector. That is a separate, larger change.
🤖 Generated with Claude Code