davsclaus opened a new pull request, #29104:
URL: https://github.com/apache/camel/pull/29104

   Fixes [CAMEL-26264](https://issues.apache.org/jira/browse/CAMEL-26264).
   
   ### 1. event FIRE with no body fails with a NullPointerException
   
   `ConsulEventProducer.fire` passed `getBody(String.class)` to 
`EventClient.fireEvent(name, options, payload)`. A null payload fails in 
okhttp's `RequestBody.create`. The producer now calls `fireEvent(name, 
options)` when there is no body. That overload sends the request without a 
body, so Consul fires the event with an empty payload.
   
   ### 2. GET_SESSIONS, session RENEW and preparedQuery GET put an Optional in 
the body
   
   `KeyValueClient.getSession`, `SessionClient.renewSession` and 
`PreparedQueryClient.getPreparedQuery` return an `Optional`. The producers set 
it as the body as is, so `CamelConsulResult` was always `true`. They now unwrap 
it with `orElse(null)`, as session `INFO` does. The body is the session id 
(`String`), the `SessionInfo` or the `StoredQuery`. When there is none, the 
body stays unchanged and `CamelConsulResult` is `false`.
   
   ### 3. The agent and status actions never set CamelConsulResult
   
   `ConsulAgentProducer` and `ConsulStatusProducer` returned the value from 
their `@InvokeOnHeader` methods, so `HeaderSelectorProducer` set the body but 
nothing set `CamelConsulResult`. These methods now call `setBodyAndResult`, 
like the other producers. Agent `REGISTER` and `DEREGISTER` set it to `true`, 
as the other write actions do (session `DESTROY`, kv `DELETE_KEY`).
   
   Found close by: catalog `REGISTER` and `DEREGISTER` called 
`setBodyAndResult(message, null)`, so `CamelConsulResult` was always `false` 
after a successful register. They now set it to `true`.
   
   The agent and status action methods now return `void` instead of `Object`. 
The generated `InvokeOnHeader` factories are regenerated to match.
   
   ### Tests
   
   New `ConsulProducerResultTest` uses a mocked Consul client (no Consul 
needed). It covers FIRE with and without a body, GET_SESSIONS, RENEW and 
preparedQuery GET (found and not found), the agent SERVICES/REGISTER/DEREGISTER 
actions, status LEADER/PEERS and catalog REGISTER. 7 of its 8 tests failed 
before the fix. FIRE with a body was already fine. The full module suite 
passes: 23 unit tests, plus 27 ITs against the test-infra Consul container (1 
skipped, as on main).
   
   ### Docs and generated files
   
   - `@BodyTypes`: FIRE accepts a null body. GET_SESSIONS, RENEW and GET give 
the unwrapped type, or leave the body unchanged. `consul.json` is regenerated 
and copied to the catalog.
   - Upgrade guide 4.24: new `camel-consul` section. The body type changes for 
the three actions, and so do the `CamelConsulResult` values for agent, status 
and catalog register/deregister.
   
   ### Not changed
   
   - `processResult`, the `HeaderSelectorProducer` fallback for methods that 
return a value, is not used any more by consul. It stays as it is in 
camel-support.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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