-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Issue #2295: Ensure ignoreExceptions take precedence over recordExceptions #2304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you. |
@RobWin You raise a valid concern about backward compatibility. This change fixes a logical inconsistency where the ignoreExceptions configuration wasn't properly taking precedence over recordExceptions. As for backward compatibility impact:
For maintaining backward compatibility, we could:
I'm open to any other suggestions you might have to address backward compatibility concerns while fixing this logical issue. |
Yes, I think a flag to preserve backwards compability would be helpful, if it is not too much effort. |
Signed-off-by: Kim Sumin <ksoomin25@gmail.com>
cf50997
to
21df745
Compare
@RobWin Thank you for the feedback! I've implemented the backward compatibility flag as requested. I added a new field: private boolean ignoreExceptionsPrecedenceEnabled = false; With corresponding builder methods: public Builder ignoreExceptionsPrecedenceEnabled(boolean enable) { ... }
public Builder enableIgnoreExceptionsPrecedence() { ... } Behavior:
QuestionHow do you feel about the field name The current name follows the existing |
Hi, thank you. |
Problem
In the current behavior of CircuitBreakerConfig, exception handling may not fully align with user expectations when both recordExceptions and ignoreExceptions are configured.
For example, if a subclass is listed in ignoreExceptions, but its superclass is also included in recordExceptions, the subclass may still be recorded.
This can make it difficult to selectively ignore specific exceptions while keeping track of their more general types.
This can lead to behavior that doesn’t match user expectations — for example, when users want to ignore specific exceptions while still tracking more general ones.
Expected Behavior
Exceptions listed in ignoreExceptions should never be recorded, even if they are subclasses of exceptions defined in recordExceptions.
Changes Introduced
Updated the CircuitBreakerConfig.Builder.build() method to ensure that the recordExceptionPredicate always checks ignoreExceptionPredicate first.
The final predicate now ensures that if an exception matches the ignore list, it will be excluded from recording regardless of any match in the record list.
Testing
Added unit tests to verify correct handling of exception hierarchy.
Confirmed that specific exceptions in ignoreExceptions are not recorded even when their superclass is in recordExceptions.
Summary
This change ensures consistent and predictable behavior when both recordExceptions and ignoreExceptions are configured. It guarantees that ignored exceptions always take precedence, providing better control over which failures are recorded.
Related Issue
Fixes #2295
@RobWin When you have a moment, I’d love your feedback on this fix.
It addresses how ignoreExceptions and recordExceptions interact and ensures the intended priority behavior. Thanks in advance!