This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 9aba86e0ad37 CAMEL-26141: camel-atmosphere-websocket - fix query 
parameter without a value and the useStreaming description (#28913)
9aba86e0ad37 is described below

commit 9aba86e0ad37413df5fccd77a926fabd165153c7
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 2 20:43:10 2026 +0100

    CAMEL-26141: camel-atmosphere-websocket - fix query parameter without a 
value and the useStreaming description (#28913)
    
    … a value and the useStreaming description
    
    The consumer split each query parameter on = and read the second part, so a
    request with ?foo or ?foo= failed with ArrayIndexOutOfBoundsException (HTTP 
500).
    It now splits with a limit of 2, uses an empty value when there is none, 
keeps
    an = inside a value, and skips empty parameters (&&).
    
    The useStreaming option said it streams sent data, but only the consumer 
uses it,
    to receive text as a Reader and binary as an InputStream. The description 
now says so.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../catalog/components/atmosphere-websocket.json   |  2 +-
 .../atmosphere/websocket/atmosphere-websocket.json |  2 +-
 .../atmosphere/websocket/WebsocketConsumer.java    | 10 ++--
 .../atmosphere/websocket/WebsocketEndpoint.java    |  3 +-
 .../websocket/WebsocketQueryParameterTest.java     | 63 ++++++++++++++++++++++
 .../AtmosphereWebsocketEndpointBuilderFactory.java | 30 ++++++++---
 6 files changed, 98 insertions(+), 12 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/atmosphere-websocket.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/atmosphere-websocket.json
index c5200281fada..fec5e4d3c4f4 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/atmosphere-websocket.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/atmosphere-websocket.json
@@ -56,7 +56,7 @@
     "disableStreamCache": { "index": 2, "kind": "parameter", "displayName": 
"Disable Stream Cache", "group": "common", "label": "common", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Determines whether or not the raw input stream is cached or not. The Camel 
consumer (camel-servlet, camel-jetty etc.) will by default cache the input 
stream to support reading it multiple times to [...]
     "sendToAll": { "index": 3, "kind": "parameter", "displayName": "Send To 
All", "group": "common", "label": "", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "description": "Whether to send to all 
(broadcast) or send to a single receiver." },
     "transferException": { "index": 4, "kind": "parameter", "displayName": 
"Transfer Exception", "group": "common", "label": "common", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "security": "insecure:serialization", "defaultValue": 
false, "description": "If enabled and an Exchange failed processing on the 
consumer side, and if the caused Exception was send back serialized in the 
response as a application\/x-java- [...]
-    "useStreaming": { "index": 5, "kind": "parameter", "displayName": "Use 
Streaming", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To enable streaming to 
send data as multiple text fragments." },
+    "useStreaming": { "index": 5, "kind": "parameter", "displayName": "Use 
Streaming", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the consumer 
receives messages as a stream: a text message as a java.io.Reader and a binary 
message as a java.io.InputStream, instead of a String or a byte array. The 
producer does not use this option." },
     "headerFilterStrategy": { "index": 6, "kind": "parameter", "displayName": 
"Header Filter Strategy", "group": "common (advanced)", "label": 
"common,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom HeaderFilterStrategy to 
filter header to and from Camel message." },
     "httpBinding": { "index": 7, "kind": "parameter", "displayName": "Http 
Binding", "group": "common (advanced)", "label": "common,advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.http.common.HttpBinding", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom HttpBinding to control 
the mapping between Camel message and HttpClient." },
     "async": { "index": 8, "kind": "parameter", "displayName": "Async", 
"group": "consumer", "label": "consumer", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "description": "Configure the consumer to work in 
async mode" },
diff --git 
a/components/camel-atmosphere-websocket/src/generated/resources/META-INF/org/apache/camel/component/atmosphere/websocket/atmosphere-websocket.json
 
b/components/camel-atmosphere-websocket/src/generated/resources/META-INF/org/apache/camel/component/atmosphere/websocket/atmosphere-websocket.json
index c5200281fada..fec5e4d3c4f4 100644
--- 
a/components/camel-atmosphere-websocket/src/generated/resources/META-INF/org/apache/camel/component/atmosphere/websocket/atmosphere-websocket.json
+++ 
b/components/camel-atmosphere-websocket/src/generated/resources/META-INF/org/apache/camel/component/atmosphere/websocket/atmosphere-websocket.json
@@ -56,7 +56,7 @@
     "disableStreamCache": { "index": 2, "kind": "parameter", "displayName": 
"Disable Stream Cache", "group": "common", "label": "common", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Determines whether or not the raw input stream is cached or not. The Camel 
consumer (camel-servlet, camel-jetty etc.) will by default cache the input 
stream to support reading it multiple times to [...]
     "sendToAll": { "index": 3, "kind": "parameter", "displayName": "Send To 
All", "group": "common", "label": "", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "description": "Whether to send to all 
(broadcast) or send to a single receiver." },
     "transferException": { "index": 4, "kind": "parameter", "displayName": 
"Transfer Exception", "group": "common", "label": "common", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "security": "insecure:serialization", "defaultValue": 
false, "description": "If enabled and an Exchange failed processing on the 
consumer side, and if the caused Exception was send back serialized in the 
response as a application\/x-java- [...]
-    "useStreaming": { "index": 5, "kind": "parameter", "displayName": "Use 
Streaming", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To enable streaming to 
send data as multiple text fragments." },
+    "useStreaming": { "index": 5, "kind": "parameter", "displayName": "Use 
Streaming", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the consumer 
receives messages as a stream: a text message as a java.io.Reader and a binary 
message as a java.io.InputStream, instead of a String or a byte array. The 
producer does not use this option." },
     "headerFilterStrategy": { "index": 6, "kind": "parameter", "displayName": 
"Header Filter Strategy", "group": "common (advanced)", "label": 
"common,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom HeaderFilterStrategy to 
filter header to and from Camel message." },
     "httpBinding": { "index": 7, "kind": "parameter", "displayName": "Http 
Binding", "group": "common (advanced)", "label": "common,advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.http.common.HttpBinding", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom HttpBinding to control 
the mapping between Camel message and HttpClient." },
     "async": { "index": 8, "kind": "parameter", "displayName": "Async", 
"group": "consumer", "label": "consumer", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "description": "Configure the consumer to work in 
async mode" },
diff --git 
a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketConsumer.java
 
b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketConsumer.java
index 628c46c4f450..2042987b35cb 100644
--- 
a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketConsumer.java
+++ 
b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketConsumer.java
@@ -134,13 +134,17 @@ public class WebsocketConsumer extends ServletConsumer {
         return enableEventsResending;
     }
 
-    private Map<String, String> getQueryMap(String query) {
+    static Map<String, String> getQueryMap(String query) {
         Map<String, String> map = new HashMap<>();
         if (query != null) {
             String[] params = query.split("&");
             for (String param : params) {
-                String[] nameval = param.split("=");
-                map.put(nameval[0], nameval[1]);
+                if (param.isEmpty()) {
+                    continue;
+                }
+                // a parameter without a value (?foo or ?foo=) gets an empty 
value, and a value may contain =
+                String[] nameval = param.split("=", 2);
+                map.put(nameval[0], nameval.length > 1 ? nameval[1] : "");
             }
         }
         return map;
diff --git 
a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
 
b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
index 0d68cdb777e5..6da654dc1a23 100644
--- 
a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
+++ 
b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
@@ -122,7 +122,8 @@ public class WebsocketEndpoint extends ServletEndpoint {
     }
 
     /**
-     * To enable streaming to send data as multiple text fragments.
+     * Whether the consumer receives messages as a stream: a text message as a 
java.io.Reader and a binary message as a
+     * java.io.InputStream, instead of a String or a byte array. The producer 
does not use this option.
      */
     public void setUseStreaming(boolean useStreaming) {
         this.useStreaming = useStreaming;
diff --git 
a/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketQueryParameterTest.java
 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketQueryParameterTest.java
new file mode 100644
index 000000000000..f769aaeb99ae
--- /dev/null
+++ 
b/components/camel-atmosphere-websocket/src/test/java/org/apache/camel/component/atmosphere/websocket/WebsocketQueryParameterTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.atmosphere.websocket;
+
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class WebsocketQueryParameterTest extends 
WebsocketCamelRouterWithInitParamTestSupport {
+
+    @Test
+    void testRequestWithParameterWithoutValue() throws Exception {
+        try (HttpClient client = HttpClient.newHttpClient()) {
+            HttpRequest request = 
HttpRequest.newBuilder(URI.create("http://localhost:"; + PORT + 
"/hola?flag")).build();
+            HttpResponse<String> response = client.send(request, 
HttpResponse.BodyHandlers.ofString());
+
+            assertEquals(200, response.statusCode());
+        }
+    }
+
+    @Test
+    void testQueryMap() {
+        Map<String, String> map = 
WebsocketConsumer.getQueryMap("flag&empty=&&eq=a=b&param=value");
+
+        assertEquals(Map.of("flag", "", "empty", "", "eq", "a=b", "param", 
"value"), map);
+    }
+
+    @Test
+    void testQueryMapNoQuery() {
+        assertTrue(WebsocketConsumer.getQueryMap(null).isEmpty());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("atmosphere-websocket:///hola").to("mock:result");
+            }
+        };
+    }
+}
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AtmosphereWebsocketEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AtmosphereWebsocketEndpointBuilderFactory.java
index 940eaa386fd5..9e94046109d8 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AtmosphereWebsocketEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AtmosphereWebsocketEndpointBuilderFactory.java
@@ -212,7 +212,10 @@ public interface AtmosphereWebsocketEndpointBuilderFactory 
{
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -227,7 +230,10 @@ public interface AtmosphereWebsocketEndpointBuilderFactory 
{
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 
@@ -1058,7 +1064,10 @@ public interface 
AtmosphereWebsocketEndpointBuilderFactory {
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -1073,7 +1082,10 @@ public interface 
AtmosphereWebsocketEndpointBuilderFactory {
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 
@@ -1425,7 +1437,10 @@ public interface 
AtmosphereWebsocketEndpointBuilderFactory {
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -1440,7 +1455,10 @@ public interface 
AtmosphereWebsocketEndpointBuilderFactory {
             return this;
         }
         /**
-         * To enable streaming to send data as multiple text fragments.
+         * Whether the consumer receives messages as a stream: a text message 
as
+         * a java.io.Reader and a binary message as a java.io.InputStream,
+         * instead of a String or a byte array. The producer does not use this
+         * option.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 

Reply via email to