CAMEL-23698: Do not append trailing ? to URI when query string is empty#23797
Merged
Conversation
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
|
…string is empty Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
b171cf8 to
106aa9e
Compare
davsclaus
commented
Jun 5, 2026
Contributor
Author
davsclaus
left a comment
There was a problem hiding this comment.
Reviewed — looks good to merge.
- The
!query.isEmpty()guard oncreateURIWithQuery()is the right fix. The original null-only check (from 2011) never handled empty strings, butcamel-rest-openapican produce them when all optional query params are unset. - Checked all 6 production callers (
URISupport,ResourceHelper,HttpProducer,HttpHelper,NettyHttpHelper,UndertowHelper) — none rely on appending a bare?for empty queries. They all benefit from this fix. - Test coverage is appropriate: the new test complements the existing null and non-empty cases.
- No regression risk.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
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
URISupport.createURIWithQuery()to not append a bare?when the query string is emptycamel-rest-openapiproduces a REST call from an OpenAPI spec with optional query parameters that are not set, the URL ended with a trailing?(e.g.,/users/myuser/repos?instead of/users/myuser/repos)/resourceand/resource?differently, so this can cause issuesRoot Cause
URISupport.createURIWithQuery()checkedif (query != null)before appending?+ query, but did not check if the query string was empty. Changed toif (query != null && !query.isEmpty()).Test plan
testCreateURIWithQueryEmptyQueryStringinURISupportTestverifying no trailing?is appended for empty query stringsURISupportTesttests pass (null query and non-empty query cases)Claude Code on behalf of Claus Ibsen