• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aspectran / aspectran / #4668

18 Oct 2025 02:19PM UTC coverage: 36.323% (+0.02%) from 36.307%
#4668

push

github

topframe
Fix(bean): Unify and correct @Profile handling for all bean definitions

Previously, @Profile annotations on bean classes were not processed correctly, leading to beans being instantiated even when their profile was not active.

This was caused by two issues:
1. For @Component-scanned beans, the parser identified the profile mismatch but failed to remove the invalid bean rule from the registry.
2. For XML-defined beans, class-level @Profile annotations were ignored entirely.

This commit introduces a unified filtering mechanism in 'BeanRuleRegistry.postProcess()'. Before the annotation parsing stage, it now inspects all registered bean rules from all sources (XML, component scan) and removes any that do not match the active environment profiles.

This ensures that @Profile works consistently and reliably, regardless of how a bean is defined. The implementation has been optimized to avoid redundant checks and refactored for clarity.

25 of 43 new or added lines in 1 file covered. (58.14%)

4 existing lines in 2 files now uncovered.

15059 of 41459 relevant lines covered (36.32%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.94
/core/src/main/java/com/aspectran/core/component/bean/BeanRuleRegistry.java


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc