Dpk376 opened a new pull request, #6051: URL: https://github.com/apache/fineract/pull/6051
## Description Closes [FINERACT-2661](https://issues.apache.org/jira/browse/FINERACT-2661) `DefaultCommandHandlerManager.lookup()` previously used `.findFirst()` to resolve a matching handler. If two handlers both matched the same command, the first one would silently win — producing unpredictable behavior. The original code even had a `// TODO: make sure there are no duplicate handlers` comment acknowledging this gap. ## Changes **Startup validation (`@PostConstruct`):** Added `validateNoDuplicateHandlers()` that groups all registered `CommandHandler` beans by their generic `CommandHandler<REQ, RES>` type signature. If duplicates exist, the application fails fast at startup with an `IllegalStateException` listing the offending handlers. **Runtime guard:** Hardened `lookup()` to collect all matching handlers and throw `DuplicateCommandHandlerException` if more than one matches — defense in depth for handlers with custom `matches()` logic. **New exception:** `DuplicateCommandHandlerException` added alongside existing exception classes. ## Tests 4 unit tests in `DefaultCommandHandlerManagerTest` (no Spring context needed) — all pass. ## Checklist - [x] Code compiles cleanly - [x] Unit tests added and passing - [x] Follows existing exception class pattern -- 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]
