Skip to content

Commit 9d8910d

Browse files
committed
Improve inline documentation for PostProcessorRegistrationDelegate
This commit introduces warnings in invokeBeanFactoryPostProcessors() and registerBeanPostProcessors() to deter people from submitting PRs that result in breaking changes. Closes gh-26401
1 parent aa7584d commit 9d8910d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,6 +59,19 @@ private PostProcessorRegistrationDelegate() {
5959
public static void invokeBeanFactoryPostProcessors(
6060
ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) {
6161

62+
// WARNING: Although it may appear that the body of this method can be easily
63+
// refactored to avoid the use of multiple loops and multiple lists, the use
64+
// of multiple lists and multiple passes over the names of processors is
65+
// intentional. We must ensure that we honor the contracts for PriorityOrdered
66+
// and Ordered processors. Specifically, we must NOT cause processors to be
67+
// instantiated (via getBean() invocations) or registered in the ApplicationContext
68+
// in the wrong order.
69+
//
70+
// Before submitting a pull request (PR) to change this method, please review the
71+
// list of all declined PRs involving changes to PostProcessorRegistrationDelegate
72+
// to ensure that your proposal does not result in a breaking change:
73+
// https://github.com/spring-projects/spring-framework/issues?q=PostProcessorRegistrationDelegate+is%3Aclosed+label%3A%22status%3A+declined%22
74+
6275
// Invoke BeanDefinitionRegistryPostProcessors first, if any.
6376
Set<String> processedBeans = new HashSet<>();
6477

@@ -192,6 +205,19 @@ else if (beanFactory.isTypeMatch(ppName, Ordered.class)) {
192205
public static void registerBeanPostProcessors(
193206
ConfigurableListableBeanFactory beanFactory, AbstractApplicationContext applicationContext) {
194207

208+
// WARNING: Although it may appear that the body of this method can be easily
209+
// refactored to avoid the use of multiple loops and multiple lists, the use
210+
// of multiple lists and multiple passes over the names of processors is
211+
// intentional. We must ensure that we honor the contracts for PriorityOrdered
212+
// and Ordered processors. Specifically, we must NOT cause processors to be
213+
// instantiated (via getBean() invocations) or registered in the ApplicationContext
214+
// in the wrong order.
215+
//
216+
// Before submitting a pull request (PR) to change this method, please review the
217+
// list of all declined PRs involving changes to PostProcessorRegistrationDelegate
218+
// to ensure that your proposal does not result in a breaking change:
219+
// https://github.com/spring-projects/spring-framework/issues?q=PostProcessorRegistrationDelegate+is%3Aclosed+label%3A%22status%3A+declined%22
220+
195221
String[] postProcessorNames = beanFactory.getBeanNamesForType(BeanPostProcessor.class, true, false);
196222

197223
// Register BeanPostProcessorChecker that logs an info message when

0 commit comments

Comments
 (0)