Skip to content

Fix BeanFactory propagation for MMInvokerHelper #2694

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

Merged
merged 2 commits into from
Jan 15, 2019

Conversation

artembilan
Copy link
Member

  • Remove check for null in the
    MessagingMethodInvokerHelper.isProvidedMessageHandlerFactoryBean()
  • Fix RecipientListRouter for BeanFactory propagation to the
    Recipient.selector
  • Fix tests for BeanFactory population and propagation
  • Add errorChannel into the TestUtils.createTestApplicationContext()
  • Fix some Sonar smell, including new reported

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

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

Just 2 comments.

@@ -56,7 +56,10 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public T processMessage(Message<?> message) {
if (this.delegate == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

2019

BeanFactory beanFactory = getBeanFactory();
return beanFactory != null
&& beanFactory.containsBean(IntegrationContextUtils.MESSAGE_HANDLER_FACTORY_BEAN_NAME);
return getBeanFactory().containsBean(IntegrationContextUtils.MESSAGE_HANDLER_FACTORY_BEAN_NAME);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the extensive changes to the tests, this looks like it's a big breaking change. Should we retain the null check until 5.2?

Copy link
Member Author

Choose a reason for hiding this comment

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

Even if we have such a check here, that doesn't mean that we are good to live with the propagation bug in the BeanNameMessageProcessor and RecipientListRouter. I mean this with the beanFactory != null we jsut mask the real problem in several places and we may have some questions in the future from community.

Not sure why massive changes in the tests scares you to merge it as a bug into the current version...
More over some tests have critical issues with not closed application context which may cause sporadic failures on CI.

Copy link
Contributor

@garyrussell garyrussell Jan 14, 2019

Choose a reason for hiding this comment

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

My point is that we'll get an NPE, which is never good.

Perhaps add an Assert.state() in initialize() and also remove the null checks there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. That is my next step after some review here. We really don't have consistency over there.
The point is that without BF propagation our method invocations might be different and that could be some kind of surprise for end-users.

But I really can relax the requirement here and bring check back. As long as I have a fix for propagation and we are protected in tests already 😄

So, do we have a deal to merge this into the current version if I revert NPe check in the MessagingMethodInvokerHelper?
We really can make it strict then in the next version catching more non-propagated bean factory if any...

Copy link
Contributor

Choose a reason for hiding this comment

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

So, do we have a deal to merge this into the current version if I revert NPe check in the MessagingMethodInvokerHelper?
We really can make it strict then in the next version catching more non-propagated bean factory if any...

Agreed.

@artembilan artembilan added this to the 5.1.3 milestone Jan 14, 2019
* Remove check for `null` in the
`MessagingMethodInvokerHelper.isProvidedMessageHandlerFactoryBean()`
* Fix `RecipientListRouter` for `BeanFactory` propagation to the
`Recipient.selector`
* Fix tests for `BeanFactory` population and propagation
* Add `errorChannel` into the `TestUtils.createTestApplicationContext()`
* Fix some Sonar smell, including new reported
`MessagingMethodInvokerHelper` to avoid breaking changes in the current
point release
* Some other polishing and optimizations in the
`MessagingMethodInvokerHelper`
@artembilan artembilan force-pushed the BeanFactoryPropagation branch from 2011ee9 to ab94a68 Compare January 15, 2019 19:40
@artembilan
Copy link
Member Author

Pushed the fix as we discussed after rebasing.

@garyrussell garyrussell merged commit eed16f0 into spring-projects:master Jan 15, 2019
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