Croway commented on code in PR #27210:
URL: https://github.com/apache/camel/pull/27210#discussion_r4156021844
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/WebSocketCliConnectorTransport.java:
##########
@@ -661,75 +694,52 @@ private static boolean isLoopback(String host) {
}
/**
- * One WebSocket connection, and what has been sent on it.
+ * One WebSocket connection, and what has been sent on it. The callbacks
come from the client, on any thread.
*/
- private final class Connection implements WebSocket.Listener {
+ private final class Connection implements CliWebSocketClient.Listener {
- private WebSocket ws;
- private final StringBuilder partial = new StringBuilder();
- private final long openedAt = System.currentTimeMillis();
+ // set on the scheduler thread, before the connection is used
+ private CliWebSocketClient.Channel channel;
+ private boolean lost;
+ private long openedAt = System.currentTimeMillis();
private volatile long lastSeen = openedAt;
private boolean helloSent;
private long lastTraceUid;
private long lastReceiveUid;
private final Map<String, String> lastSent = new HashMap<>();
@Override
- public void onOpen(WebSocket webSocket) {
- this.ws = webSocket;
- webSocket.request(1);
- execute(() -> opened(this));
- }
-
- @Override
- public CompletionStage<?> onText(WebSocket webSocket, CharSequence
data, boolean last) {
+ public void onText(String text) {
Review Comment:
_Claude Code on behalf of Croway_
Good catch, thanks. Fixed in a72fa1b8e5d0 with the second option: frames
received before the connection is reported open are kept (up to 64, as the
pending actions) and handled once `opened` runs, after the `hello`. Dropping
them would lose a `stop` silently, since no result can be sent yet. Frames of a
connection that is already gone are no longer run, as their result cannot be
sent either.
`runsActionsReceivedBeforeTheClientReportsTheConnectionOpen` covers it with
a client that delivers an action and reports the connection open 500 ms later:
it fails without the change (the result was dropped) and passes with it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]