Add @ConditionalOnMissingBean guard to StepEventPublisherBridge bean#7
Add @ConditionalOnMissingBean guard to StepEventPublisherBridge bean#7casc84ab wants to merge 1 commit into
Conversation
Prevent duplicate StepEventPublisher bean registration when multiple bridge modules (core, domain, data) are on the classpath. The condition checks for the StepEventPublisher interface type to detect beans from any bridge implementation.
ancongui
left a comment
There was a problem hiding this comment.
Code Review: Add @ConditionalOnMissingBean guard to StepEventPublisherBridge bean
Summary
This PR adds @ConditionalOnMissingBean(type = "org.fireflyframework.transactional.saga.events.StepEventPublisher") to the stepEventPublisherBridge() bean method in StepBridgeConfiguration. This prevents duplicate StepEventPublisher bean registration when multiple bridge modules are on the classpath.
CI Status
✅ All checks pass (CodeQL, build)
Findings
1. Correct use of string-based type reference (Severity: None — good practice)
Using type = "org.fireflyframework.transactional.saga.events.StepEventPublisher" is the correct approach here since it avoids potential ClassNotFoundException if the transactional module isn't on the classpath. This is consistent with Spring Boot auto-configuration conventions.
2. Condition checks for interface type, not concrete class (Severity: None — well designed)
The condition checks for the StepEventPublisher interface rather than a specific implementation. This means ANY implementation of the interface (from core, domain, or data modules) will prevent this bean from being registered — which is the correct behavior.
3. @Primary + @ConditionalOnMissingBean combination (Severity: Low — same as core PR)
Same note as the core PR: consider whether @Primary is still needed since @ConditionalOnMissingBean prevents multiple beans. Not a blocker.
4. Auto-configuration ordering determinism (Severity: Medium — worth noting)
Same concern as the core PR: with all three bridge modules using @ConditionalOnMissingBean, the "winner" depends on Spring's auto-configuration order. Consider using @AutoConfigureBefore/@AutoConfigureAfter to make this deterministic.
Recommendation
APPROVE — Clean, minimal change that follows Spring Boot conventions. The change is safe and correctly prevents bean conflicts.
Summary
@ConditionalOnMissingBean(type = "org.fireflyframework.transactional.saga.events.StepEventPublisher")toStepBridgeConfiguration.stepEventPublisherBridge()to prevent duplicate bean registration.StepEventPublisherinterface type to detect beans from any bridge implementation (core, domain, or data).Test plan
fireflyframework-domainon classpathfireflyframework-domainandfireflyframework-coreon classpath