[ 
https://issues.apache.org/jira/browse/CAMEL-26264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138140#comment-18138140
 ] 

Claus Ibsen commented on CAMEL-26264:
-------------------------------------

Fixed on main via https://github.com/apache/camel/pull/29104 (fix version 
4.24.0).

_Claude Code on behalf of davsclaus_

> camel-consul - event FIRE with no body fails with a NullPointerException, and 
> some actions put a java.util.Optional in the body
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26264
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26264
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-consul
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of consul (CAMEL-24961, PR #28409).
> h4. 1. event FIRE with no body fails with a NullPointerException
> {{ConsulEventProducer.fire}} (main 2a465aa4814c, line 41) passes 
> {{getBody(String.class)}} to {{fireEvent}}, and a null payload fails with a 
> NullPointerException in okhttp's {{RequestBody.create}}. Checked on 
> 4.24.0-SNAPSHOT with Consul 2.0.4 (test-infra docker).
> Proposed: send an empty payload when there is no body.
> h4. 2. GET_SESSIONS, session RENEW and preparedQuery GET put an Optional in 
> the body
> {{ConsulKeyValueProducer.getSessions}} (line 93), 
> {{ConsulSessionProducer.renew}} (lines 80-85) and 
> {{ConsulPreparedQueryProducer}} GET (lines 45-47) set the client's 
> {{Optional}} as the body, and {{CamelConsulResult}} is then always true; 
> session INFO unwraps it ({{orElse(null)}}, lines 62 and 66). Checked on 
> 4.24.0-SNAPSHOT with Consul for GET_SESSIONS; RENEW and preparedQuery GET 
> read in the code.
> Proposed: unwrap the Optional with {{orElse(null)}}, as INFO does.
> h4. 3. The agent and status actions never set CamelConsulResult
> {{ConsulAgentProducer}} (lines 34-62) and {{ConsulStatusProducer}} (lines 
> 32-40) return the value from {{@InvokeOnHeader}} methods and do not call 
> {{setBodyAndResult}}, so {{CamelConsulResult}} is not set, unlike the other 
> producers. Checked on 4.24.0-SNAPSHOT with Consul.
> Proposed: use {{setBodyAndResult}} in these actions.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to