Skip to content

Add @ConditionalOnMissingBean guard to StepEventPublisherBridge bean#7

Open
casc84ab wants to merge 1 commit into
developfrom
fix/step-event-publisher-bean-guard
Open

Add @ConditionalOnMissingBean guard to StepEventPublisherBridge bean#7
casc84ab wants to merge 1 commit into
developfrom
fix/step-event-publisher-bean-guard

Conversation

@casc84ab
Copy link
Copy Markdown
Contributor

Summary

  • Added @ConditionalOnMissingBean(type = "org.fireflyframework.transactional.saga.events.StepEventPublisher") to StepBridgeConfiguration.stepEventPublisherBridge() to prevent duplicate bean registration.
  • The condition checks for the StepEventPublisher interface type to detect beans from any bridge implementation (core, domain, or data).

Test plan

  • Verify application starts correctly with only fireflyframework-domain on classpath
  • Verify application starts correctly with both fireflyframework-domain and fireflyframework-core on classpath
  • Confirm only one StepEventPublisher bean is registered when multiple modules are present

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.
@casc84ab casc84ab requested a review from ancongui February 13, 2026 09:55
Copy link
Copy Markdown
Contributor

@ancongui ancongui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants