-
Bug
-
Resolution: Not a Bug
-
Major
-
None
-
fuse-7.11.1-GA
-
None
I need to mask some sensitive information on the logs, and it works well if I use the Camel context's "logMask" option, or a custom exchange formatted, as seen below:
// code placeholder 13:12:27.907 INFO [Camel (cbr-example-context) thread #3 - timer://foo] Exchange[, Id: ID-laptop-t14s-1686333907675-2-1, ExchangePattern: InOnly, Properties: CamelCreatedTimestamp: Fri Jun 09 13:12:27 COT 2023CamelExternalRedelivered: falseCamelMessageHistory: [DefaultMessageHistory[routeId=test, node=setBody1], DefaultMessageHistory[routeId=test, node=process3], DefaultMessageHistory[routeId=test, node=to2]]CamelTimerCounter: 1CamelTimerFiredTime: Fri Jun 09 13:12:27 COT 2023CamelTimerName: fooCamelTimerPeriod: 1000CamelToEndpoint: log://exchange?multiline=true&showAll=true , Headers: breadcrumbId: ID-laptop-t14s-1686333907675-2-1firedTime: Fri Jun 09 13:12:27 COT 2023Password: ***Username: *** , BodyType: String, Body: HHH<node> <password>xxxxx</password> </node>, Out: null:
However, when an Exception is dumped, neither the custom exchange formatter nor the "logMask" parameter, are considered when dumping an Exception on the logs, as seen below, as none of the sensitive parameters are masked:
13:12:27.908 INFO [Camel (cbr-example-context) thread #3 - timer://foo] === Boom? ===13:12:27.908 INFO [Camel (cbr-example-context) thread #3 - timer://foo] 1 exchangeFormatter --> org.apache.camel.processor.DefaultExchangeFormatter13:12:27.909 ERROR [Camel (cbr-example-context) thread #3 - timer://foo] Failed delivery for (MessageId: ID-laptop-t14s-1686333907675-2-2 on ExchangeId: ID-laptop-t14s-1686333907675-2-1). Exhausted after delivery attempt: 1 caught: java.lang.Exception: Boom! HERE PAL! Message History -----------------------------------------------------------------------------------------------------------------------------------RouteId ProcessorId Processor Elapsed (ms)[test ] [test ] [timer://foo?delay=2000&repeatCount=1 ] [ 19][test ] [setBody1 ] [setBody[constant{HELLO!}] ] [ 2][test ] [process3 ] [ref:passwordInjector ] [ 0][test ] [to2 ] [log:exchange?showAll=true&multiline=true ] [ 14][test ] [process4 ] [ref:throwException ] [ 0] Exchange --------------------------------------------------------------------------------------------------------------------------------------- Exchange[ Id ID-laptop-t14s-1686333907675-2-1 ExchangePattern InOnly Headers {breadcrumbId=ID-laptop-t14s-1686333907675-2-1, CamelRedelivered=false, CamelRedeliveryCounter=0, firedTime=Fri Jun 09 13:12:27 COT 2023, Password=thepassword, Username=TheUsername} BodyType String Body <node> <password>abc</password> </node> ] Stacktrace---------------------------------------------------------------------------------------------------------------------------------------java.lang.Exception: Boom!
The following code on class "org/apache/camel/processor/RedeliveryErrorHandler.java", seems to be ignoring the custom formater:
if (!shouldRedeliver && data.currentRedeliveryPolicy.isLogExhaustedMessageHistory()) { // only use the exchange formatter if we should log exhausted message body (and if using a custom formatter then always use it) ExchangeFormatter formatter = customExchangeFormatter ? exchangeFormatter : (data.currentRedeliveryPolicy.isLogExhaustedMessageBody() || camelContext.isLogExhaustedMessageBody() ? exchangeFormatter : null); log.info("1 exchangeFormatter --> " + exchangeFormatter.getClass().getName()); String routeStackTrace = MessageHelper.dumpMessageHistoryStacktrace(exchange, formatter, e != null && logStackTrace); if (routeStackTrace != null) { msg = msg + "\n" + routeStackTrace; } }
The log.info statement shows the following:
1 exchangeFormatter --> org.apache.camel.processor.DefaultExchangeFormatter
The full log is on attached file: "jira-fuse.log"