gnodet-bot commented on code in PR #27520:
URL: https://github.com/apache/camel/pull/27520#discussion_r4213040000


##########
core/camel-base/src/main/java/org/apache/camel/impl/event/ExchangeFailureHandledEvent.java:
##########
@@ -70,6 +70,11 @@ public final String toString() {
             String uri = URISupport.sanitizeUri(deadLetterUri);
             return getExchange().getExchangeId() + " exchange failed"
                    + " and sent to dead letter channel: " + uri;
+        } else if (failureHandler == null || failureHandler.toString() == null
+                || "null".equals(failureHandler.toString())) {

Review Comment:
   💡 `failureHandler.toString()` is called twice here — once for the `== null` 
check and again for `"null".equals(...)`. Since `toString()` is a non-trivial 
call on an unknown type, extracting it to a local variable avoids the 
redundancy and makes the intent clearer:
   
   ```suggestion
           } else if (failureHandler == null
                   || "null".equals(failureHandler.toString())) {
   ```
   
   (The `toString() == null` guard is redundant in practice — 
`Object.toString()` cannot return `null` per the JDK contract, and any override 
that does would be severely broken. If you want to be extra-defensive, 
`String.valueOf(failureHandler)` handles both null-reference and 
null-return-from-toString in one call.)
   
   Same nit applies to `ExchangeFailureHandlingEvent.java` lines 62–63.



-- 
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