This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.18.x by this push:
new b5c8a8878583 CAMEL-23698: camel-util - Do not append trailing ? to URI
when query string is empty (#23797) (#23801)
b5c8a8878583 is described below
commit b5c8a887858347bc42a475c94bc5c2e35fac6efe
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jun 5 23:17:38 2026 +0200
CAMEL-23698: camel-util - Do not append trailing ? to URI when query string
is empty (#23797) (#23801)
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude <[email protected]>
---
.../src/main/java/org/apache/camel/util/URISupport.java | 2 +-
.../src/test/java/org/apache/camel/util/URISupportTest.java | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git
a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
index beaec95280f8..05610ddb1520 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
@@ -443,7 +443,7 @@ public final class URISupport {
if (before != null) {
s = before;
}
- if (query != null) {
+ if (query != null && !query.isEmpty()) {
s = s + "?" + query;
}
if (!s.contains("#") && uri.getFragment() != null) {
diff --git
a/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
b/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
index b1e6d73c6295..48f908ba55d8 100644
--- a/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
+++ b/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
@@ -185,6 +185,14 @@ public class URISupportTest {
assertEquals("smtp://localhost?utm_campaign=launch#fragmentOne",
resultUri.toString());
}
+ @Test
+ public void testCreateURIWithQueryEmptyQueryString() throws Exception {
+ URI uri = new URI("https://api.example.com/users/myuser/repos");
+ URI resultUri = URISupport.createURIWithQuery(uri, "");
+ assertNotNull(resultUri);
+ assertEquals("https://api.example.com/users/myuser/repos",
resultUri.toString());
+ }
+
@Test
public void testNormalizeEndpointWithEqualSignInParameter() throws
Exception {
String out =
URISupport.normalizeUri("jms:queue:foo?selector=somekey='somevalue'&foo=bar");