vignesh-manel opened a new pull request, #28767:
URL: https://github.com/apache/camel/pull/28767

   # Description
   
   Fixes [CAMEL-26131](https://issues.apache.org/jira/browse/CAMEL-26131).
   
   **1. The geolocation of one query was used by every later query.** For a 
location of `current` (or no location), `WeatherQuery.getQuery` ran the 
geolocation and wrote the lat/lon onto the endpoint's shared 
`WeatherConfiguration`. Any later query on the endpoint then took the "lat and 
lon are set" branch first.
   
   It is worse than the ticket describes. `WeatherEndpoint.createProducer` 
builds the default query with `getQuery()`, so on an endpoint **without** 
`location` the geolocation already ran when the producer was created. The 
`CamelWeatherLocation` header of the very first message was then ignored. 
Reproduced with a fake `GeoLocationProvider` (lat 2, lon 1) and a recording 
HTTP client:
   
   | endpoint | header | requested before | requested now |
   |---|---|---|---|
   | no `location` | `Paris` | `lat=2&lon=1` | `q=Paris` |
   | no `location` | none | `lat=2&lon=1` | `lat=2&lon=1` |
   | `location=Madrid` | `current` | `lat=2&lon=1` | `lat=2&lon=1` |
   | `location=Madrid` | `Paris` (next) | `lat=2&lon=1` | `q=Paris` |
   | `location=Madrid` | none | `q=Madrid` | `q=Madrid` |
   
   The lat/lon are now local variables of `getQuery` and are passed to 
`createContext`, so the `find?` context for a geolocation with `cnt` is chosen 
as before. Nothing writes to the configuration any more. The `lat` / `lon` 
options set on an endpoint are still used before the location, as documented.
   
   **2. The error of a non-200 response named the wrong URI.** It printed the 
endpoint's default `query`, not the `uri` that was called (the one built from 
the header). It now prints `uri`, like the empty-response error just below it.
   
   Tests: the new `WeatherProducerLocationHeaderTest` has 3 tests, with no 
network. It uses the fake geolocation and a Mockito `CloseableHttpClient` bound 
with `#geo` / `#http`, and covers the first and the fourth row of the table 
above and the error message. All 3 failed before the fix, for example 
`expected: <[q=Paris, lat=2&lon=1]> but was: <[lat=2&lon=1, lat=2&lon=1]>`.
   
   `WeatherQueryTest` (15 tests of the query building) only runs with 
`-Denable.weather.tests=true`, so CI does not run it. I ran it locally with 
that flag and all 15 pass with the fix.
   
   Not changed: the geolocation call when a producer for an endpoint without 
`location` is created. That is existing behaviour for the default query.
   
   Upgrade guide: a short entry in 4.24, before the camel-gson/camel-jsonb 
entry.
   
   Local: `mvn clean install -Psourcecheck` in `components/camel-weather`, unit 
tests green (4 run, 15 skipped by the flag above); the 8 ITs are skipped 
without an API key. No generated files changed.
   
   _Claude Code on behalf of vignesh-manel_
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   - [x] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes. (Run in the module with 
`-Psourcecheck`, not from the root; no generated files changed. CI checks the 
rest.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   🤖 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]

Reply via email to