Croway opened a new pull request, #1958:
URL: https://github.com/apache/camel-spring-boot/pull/1958

   Cherry-pick of #1932 onto `camel-spring-boot-4.18.x`.
   
   **Original PR:** #1932 — platform-http path variables follow the path Spring 
matched
   **JIRA:** [CAMEL-24577](https://issues.apache.org/jira/browse/CAMEL-24577)
   
   ### What it fixes
   
   `SpringBootPlatformHttpBinding` resolved the `{placeholder}` values of a 
`platform-http` consumer's
   path against `getRawPath(request)` — the undecoded request URI with the 
context path stripped off.
   Spring, however, dispatches the request against its own parsed 
`RequestPath`, whose segments are
   percent-decoded and have any matrix parameters removed. When the two 
disagreed, the header exposed
   to the route did not match what Spring actually matched: a request to 
`/greeting/%61dmin` was routed
   to the `admin` value but the header carried the raw `%61dmin`, and 
`/greeting/name;v=1` carried
   `name;v=1` instead of `name`.
   
   The fix evaluates the placeholders against the segments Spring matched, 
obtained via
   `ServletRequestPathUtils.parse(request)`, instead of the raw request path. 
This also brings the
   Spring MVC engine's behavior in line with the vertx platform-http engine, 
which already decodes path
   parameters. The path is parsed fresh rather than read from the `RequestPath` 
attribute Spring caches
   on the request, because the platform-http consumer services the request on 
its own executor and by
   the time it runs, Spring's dispatch may have already cleared that attribute 
— reading it back would
   make correctness depend on timing.
   
   `getRawPath()` itself is untouched, so `Exchange.HTTP_PATH` still reports 
the raw path, preserving the
   context-path handling from CAMEL-22116 and CAMEL-23191.
   
   ### Verification on this branch
   
   - The cherry-pick (`git cherry-pick -x`) applied with a clean auto-merge (no 
conflict markers) on top
     of this branch's current tip — despite the task brief's expectation that 
the CAMEL-24496 backport
     would already be on this branch and touching the same file, that backport 
(#1952) is still an open,
     unmerged PR at the time of this backport, so there was nothing to conflict 
with in `origin`'s actual
     history.
   - One of the two cherry-picked test files needed a fix to build on this 
branch, beyond a plain
     import/annotation adjustment:
     - `SpringBootPlatformHttpPathVariableTest.java` imported 
`org.apache.camel.test.spring.junit6.CamelSpringBootTest`,
       which doesn't exist on this Spring Boot 3 / JUnit 5 branch; switched to
       `org.apache.camel.test.spring.junit5.CamelSpringBootTest` to match this 
module's other tests.
     - `SpringBootPlatformHttpBindingPathVariableTest.java` called
       `consumer.service(request, response).get(20, TimeUnit.SECONDS)`. On 
`main`, `service()` returns a
       `CompletableFuture<Void>`, which supports `get(timeout, unit)`. On this 
branch, CAMEL-24380 changed
       `service()` to return a `WebAsyncTask<Void>` instead (to fix the 
platform-http timeout returning a
       Whitelabel Error Page), and `WebAsyncTask` has no such method. Adjusted 
the test to call
       `consumer.service(request, response).getCallable().call()` instead, 
which invokes the exact same
       `handleService()` code path synchronously; the test's assertions 
(response status and body content)
       are unchanged.
   - Ran `../../mvnw verify` in 
`components-starter/camel-platform-http-starter` (against the module built
     with its parent/`camel-version` temporarily repointed to the released 
4.18.4, since the branch's
     4.18.5-SNAPSHOT parent isn't published): 113 tests run, 1 failure —
     `SpringBootPlatformHttpRequestTimeoutTest.testGetAsync`. This is a 
pre-existing, unrelated failure on
     this branch tip (already flagged as such for this batch); it is unrelated 
to path/placeholder
     handling and not touched by this change.
   - `mvn install -pl components-starter/camel-platform-http-starter -am 
-DskipTests -Dfastinstall` built
     cleanly. The temporary parent/`camel-version` pom edits and any catalog 
regeneration artifacts were
     reverted before pushing; the pushed commit touches only the same files as 
the original PR.
   
   _Claude Code on behalf of Federico Mariani_
   


-- 
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]

Reply via email to