allthingssecurity opened a new pull request, #27250: URL: https://github.com/apache/camel/pull/27250
# Description [CAMEL-25253](https://issues.apache.org/jira/browse/CAMEL-25253) `DynamicRouterFilterService.addFilterForChannel(..., update=true)` only added the new filter to the channel's `ConcurrentSkipListSet`, which orders and compares filters by priority and id: - same priority: the set kept the old filter, so the update was silently ignored (old predicate and destination) while the id was returned as if it had succeeded; - other priority: both filters stayed, so the subscription routed with its old and new definition (duplicates in `allMatch` mode). Also, `filterMap.get(channel).stream()` failed with a `NullPointerException` for a channel without filters as soon as another channel had some. This change gets or creates the channel's set and statistics first, and on an update removes the existing filter before adding the new one. The statistics of the replaced filter stay, as `removeFilterById` keeps those of a removed filter on purpose. (The existing `testUpdateFilter` passes either way: its factory returns the same mock for both filters.) Tests: - `DynamicRouterFilterServiceUpdateTest` (new, 3 tests) with the default filter factory. - Without the change all three fail (`expected: <mock:new> but was: <mock:old>`, `expected: <1> but was: <2>`, `NullPointerException`). - With the change the camel-dynamic-router suite passes: 137 unit tests and 21 integration tests. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested the affected module, including the formatter and import-sort plugins. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
