davsclaus opened a new pull request, #28913: URL: https://github.com/apache/camel/pull/28913
Fixes [CAMEL-26141](https://issues.apache.org/jira/browse/CAMEL-26141). ### 1. A query parameter without a value fails with ArrayIndexOutOfBoundsException `WebsocketConsumer.getQueryMap` split each parameter on `=` and read `nameval[1]`. A request such as `/hola?flag` or `/hola?flag=` threw `ArrayIndexOutOfBoundsException` in `service()`, and the servlet answered HTTP 500. Confirmed with a plain HTTP GET against the test Jetty: `?a=b` gives 200, `?flag` gives 500. Change: split with a limit of 2 and use an empty value when there is no `=`. On the same lines: a value that contains `=` (`?eq=a=b`) is kept whole (it was cut to `a`), and an empty parameter (`&&`) is skipped (it also threw). Tests: new `WebsocketQueryParameterTest`. It sends `GET /hola?flag` and expects 200, and checks the parsed map for `flag&empty=&&eq=a=b¶m=value`. Both tests failed before the fix (500 and `ArrayIndexOutOfBoundsException`). `getQueryMap` is now package-private static so the test can call it. ### 2. useStreaming is documented for sending, but only the consumer uses it The description said "To enable streaming to send data as multiple text fragments". The producer never reads the option. The consumer uses it to pick `WebsocketStreamHandler`, which hands a text message over as a `Reader` and a binary message as an `InputStream`. Change: the description now says that, and that the producer does not use it. Regenerated the component JSON, the catalog copy and the endpoint DSL. No behaviour change. ### Not changed - `useStreaming` keeps its `common` group. Labelling it `consumer` would move the Endpoint DSL method to the consumer builder and break code that sets it on a common builder. - Query values are still not URL-decoded. That is a separate behaviour change. ### Found while testing (not fixed here) - With the embedded Jetty in the tests, the WebSocket upgrade goes through Atmosphere's JSR 356 endpoint, not `service()`. The query parameters of the upgrade request never reach the open event's headers. The existing `WebsocketRoute1WithInitParamTest.testPassParametersWebsocketOnOpen` passes only because its asserts run inside a processor and the error is swallowed (the test log shows `"param1" is null`). - `queryMap` is one field on the consumer, shared by all connections. Concurrent connections can see each other's parameters. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
