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


##########
components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceReifier.java:
##########
@@ -80,12 +80,14 @@ public Processor createProcessor() throws Exception {
         if (b != null) {
             throwExceptionWhenHalfOpenOrOpenState = b;
         }
+        // a referenced CircuitBreakerConfig can have its own record and 
ignore exceptions
+        boolean baseConfig = config.getConfig() != null;
         Predicate<Throwable> recordPredicate = null;
-        if (!config.getRecordExceptions().isEmpty()) {
+        if (baseConfig || !config.getRecordExceptions().isEmpty()) {
             recordPredicate = cbConfig.getRecordExceptionPredicate();
         }
         Predicate<Throwable> ignorePredicate = null;
-        if (!config.getIgnoreExceptions().isEmpty()) {
+        if (baseConfig || !config.getIgnoreExceptions().isEmpty()) {

Review Comment:
   ℹ️ **Predicate replacement edge case — class-based exception lists are safe, 
predicate-based ones are not**
   
   When `baseConfig=true` and EIP-level exception lists are also configured, 
the composition semantics differ depending on how the base config was built:
   
   - **Class-based** (`base.ignoreExceptions(SomeException.class)`): 
`CircuitBreakerConfig.from(base)` copies the class array into the builder; 
`builder.ignoreException(newPredicate)` sets a *separate* predicate field. At 
`build()` time, resilience4j's `PredicateCreator` ORs both → the base's 
exception classes are **preserved** in the final ignore predicate. ✅
   
   - **Predicate-based** (`base.ignoreException(customPredicate)`): 
`from(base)` copies `customPredicate` into `ignoreExceptionPredicate`; 
`builder.ignoreException(anotherPredicate)` then **replaces** it. The base's 
custom predicate is silently lost. ⚠️
   
   The test covers the class-based case 
(`.ignoreExceptions(IllegalStateException.class)`) which is the common case, so 
typical usage is safe. If the base config was built with a custom 
`Predicate<Throwable>` via `.ignoreException(pred)`, and the EIP also sets 
`ignoreExceptions`, the base's predicate will be replaced rather than composed.
   
   Worth a note in the `config` option's description — something like _"Note: 
if the referenced config uses a custom `ignoreException` predicate, it is 
replaced rather than composed when EIP-level `ignoreExceptions` are also set."_



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