Andrea Cosentino created CAMEL-26891:
----------------------------------------
Summary: camel-whatsapp - do not log the response body at INFO
Key: CAMEL-26891
URL: https://issues.apache.org/jira/browse/CAMEL-26891
Project: Camel
Issue Type: Bug
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.24.0
The WhatsApp producer logs the full REST response body at INFO on every
completed response, before it inspects the status to decide success or error.
Routine response bodies do not need to be in normal (INFO) application logs and
make that output unnecessarily verbose.
*Today.* In {{WhatsAppServiceRestAPIAdapter}}, once the HTTP response completes
the adapter calls {{LOG.info(...)}} with both the status code and
{{response.body()}}, and only afterwards checks whether the status is a
success. The entire response body is therefore written to the log at INFO for
every request. This is also inconsistent with the outbound side:
{{WhatsAppProducer}} already logs the message being sent at DEBUG, not INFO.
*After the change.* The INFO line logs only the HTTP status code;
{{response.body()}} is no longer included at INFO. If a body-level line is
wanted for diagnostics, it is logged at DEBUG instead, consistent with how the
outbound message is already logged.
*Classes involved.*
*
{{org.apache.camel.component.whatsapp.service.WhatsAppServiceRestAPIAdapter}}:
the response-completion handler that currently logs the body at INFO.
* {{org.apache.camel.component.whatsapp.WhatsAppProducer}}: referenced only for
the existing DEBUG logging of the outbound message.
*Code-level change.* Drop {{response.body()}} from the INFO statement so it
logs the status code only, and move any body-level logging to DEBUG. This
touches a log statement and a test only; there is no {{@UriParam}} or metadata
change, so no catalog or DSL regeneration is required.
*Tests.* Add a focused log-capture test (a logback or log4j ListAppender on
{{WhatsAppServiceRestAPIAdapter}}) that simulates a completed response and
asserts that a sentinel value present in the response body does not appear in
INFO-level output, while the status code still does. Use AssertJ, following the
existing camel-whatsapp tests; the new test class and methods are
package-private.
_AI-generated by Codex on behalf of oscerd._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)