Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INT-3829: Care about @Profile on the @Bean #1571

Closed
wants to merge 2 commits into from

Conversation

artembilan
Copy link
Member

JIRA: https://jira.spring.io/browse/INT-3829

Alongside with the @Bean definition we can use for example @Profile @Conditional annotation.
And the final bean won't be populated to the context.

Previously the MessagingAnnotationPostProcessor did take care about that infrastructure outcome,
hence we ended up with the NoSuchBeanDefinitionException

  • Add appropriate try...catch(NoSuchBeanDefinitionException) to the AbstractMethodAnnotationPostProcessor and
    InboundChannelAdapterAnnotationPostProcessor to skip further endpoint processing if there is the target bean
    by the condition reason.

JIRA: https://jira.spring.io/browse/INT-3829

Alongside with the `@Bean` definition we can use for example `@Profile` `@Conditional` annotation.
And the final bean won't be populated to the context.

Previously the `MessagingAnnotationPostProcessor` did take care about that infrastructure outcome,
hence we ended up with the `NoSuchBeanDefinitionException`

* Add appropriate `try...catch(NoSuchBeanDefinitionException)` to the `AbstractMethodAnnotationPostProcessor` and
`InboundChannelAdapterAnnotationPostProcessor` to skip further endpoint processing if there is the target bean
by the condition reason.
catch (NoSuchBeanDefinitionException e) {
// Skip the @Bean for farther endpoint processing.
// Mainly by the @Conditional reason.
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add a DEBUG log here - just in case, in future, it's some other bean that's missing (not the @Bean).

It's ok in the abstract class because we're only looking for the @Bean there (instead of the more general create... method). However, it won't hurt to add a DEBUG (or TRACE) log there too.

@artembilan
Copy link
Member Author

Pushed

@garyrussell
Copy link
Contributor

Polishing here: garyrussell@82f6f51

@garyrussell
Copy link
Contributor

Merged as c23aa70

@artembilan artembilan deleted the INT-3829 branch January 6, 2016 18:39
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.

None yet

2 participants