Andrea Cosentino created CAMEL-25087:
----------------------------------------

             Summary: camel-coap - add a muteException consumer option
                 Key: CAMEL-25087
                 URL: https://issues.apache.org/jira/browse/CAMEL-25087
             Project: Camel
          Issue Type: Improvement
          Components: camel-coap
            Reporter: Andrea Cosentino
             Fix For: 4.18.5, 4.23.0, 4.22.2


CAMEL-23651, and then CAMEL-24428, CAMEL-24476, CAMEL-24477 and CAMEL-24478, 
gave the consumers that reply to the caller a {{muteException}} option 
defaulting to {{true}}, so that a failed exchange does not return the 
exception's message to the remote caller. camel-coap has no such option.

{{CamelCoapResource.handleRequest}} differs from those consumers in two places:
# After {{consumer.getProcessor().process(camelExchange)}} it does not check 
{{camelExchange.isFailed()}}, so a failed exchange is answered with {{2.05 
Content}} and whatever body the message held when the route failed.
# An exception raised while the consumer builds the response, for example 
converting the final body to {{byte[]}}, is caught and its message is sent back 
as the {{5.00}} payload:
{code:java}
} catch (Exception e) {
    cexchange.respond(ResponseCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
{code}

Proposal: add a {{muteException}} consumer option, defaulting to {{true}} to 
match the other consumers. Answer a failed exchange with {{5.00 Internal Server 
Error}}, with an empty payload when muted and the exception message when 
{{muteException=false}}, and apply the same rule in the catch block. Add an 
upgrade-guide entry for both changes.

_Claude Code on behalf of oscerd_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to