Skip to content

Improve the logic of registerBeanPostProcessors() in PostProcessorRegistrationDelegate #26399

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

Closed
wants to merge 1 commit into from

Conversation

Jirath-Liu
Copy link

#26398
merge the three filtering step to one for statement
the main code is below

                // Separate between BeanPostProcessors that implement PriorityOrdered,
		// Ordered, and the rest.
		List<BeanPostProcessor> priorityOrderedPostProcessors = new ArrayList<>();
		List<BeanPostProcessor> internalPostProcessors = new ArrayList<>();
		List<BeanPostProcessor> orderedPostProcessors = new ArrayList<>();
		List<BeanPostProcessor> nonOrderedPostProcessors = new ArrayList<>();
		for (String ppName : postProcessorNames) {
			BeanPostProcessor pp = beanFactory.getBean(ppName, BeanPostProcessor.class);
			if (pp instanceof MergedBeanDefinitionPostProcessor) {
				internalPostProcessors.add(pp);
			}
			else if (beanFactory.isTypeMatch(ppName, PriorityOrdered.class)) {
				priorityOrderedPostProcessors.add(pp);
			}
			else if (beanFactory.isTypeMatch(ppName, Ordered.class)) {
				orderedPostProcessors.add(pp);
			}
			else {
				nonOrderedPostProcessors.add(pp);
			}
		}

with merging the filtering,

  • the goal of this function is more distinct
  • can save unnecessary code
  • save more space as no need to use List<String> orderedPostProcessorNames
  • achieve the goal with only one for statement

@pivotal-issuemaster
Copy link

@Jirath-Liu Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@Jirath-Liu Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 18, 2021
@sbrannen sbrannen changed the title fix:improve the logic of registerBeanPostProcessors Improve the logic of registerBeanPostProcessors() in PostProcessorRegistrationDelegate Jan 18, 2021
@sbrannen
Copy link
Member

Thanks for PR.

Unfortunately, the proposal changes the order in which PriorityOrdered, Ordered, and non-ordered BeanPostProcessors are instantiated which constitutes a breaking change.

In light of that, I am closing this PR.

For additional information, please see all declined PRs involving proposed changes to PostProcessorRegistrationDelegate.

@sbrannen sbrannen closed this Jan 18, 2021
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants