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

Stop using SpringFactoriesLoader.loadFactoryNames in the TestContext framework #28666

Closed
sbrannen opened this issue Jun 20, 2022 · 1 comment
Closed
Assignees
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: task A general task
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jun 20, 2022

AbstractTestContextBootstrapper.getDefaultTestExecutionListenerClassNames() is currently the only remaining use of SpringFactoriesLoader.loadFactoryNames() in the core Spring Framework.

Since SpringFactoriesLoader.loadFactoryNames() will be deprecated in #27954, we should stop using it and remove the getDefaultTestExecutionListenerClassNames() method from AbstractTestContextBootstrapper.

We should likely remove getDefaultTestExecutionListenerClasses() as well and refactor getTestExecutionListeners() to make use of the new FailureHandler support in SpringFactoriesLoader.

@sbrannen sbrannen added in: test Issues in the test module type: task A general task labels Jun 20, 2022
@sbrannen sbrannen added this to the 6.0.0-M5 milestone Jun 20, 2022
@sbrannen sbrannen self-assigned this Jun 20, 2022
@sbrannen
Copy link
Member Author

Since getDefaultTestExecutionListenerClassNames() and getDefaultTestExecutionListenerClasses() are both protected methods and therefore part of the "public" API for anyone extending AbstractTestContextBootstrapper (see #27954 (comment)), we could potentially deprecate those two methods in 5.3.x.

@jhoeller & @snicoll, thoughts?

@sbrannen sbrannen added the theme: aot An issue related to Ahead-of-time processing label Jun 20, 2022
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 15, 2022
Commit d1b65f6 introduced a regression regarding the handling of
missing dependencies for optional (typically default)
TestExecutionListeners.

Prior to d1b65f6 a TestExecutionListener was instantiated using
java.lang.Class.newInstance() which never throws an
InvocationTargetException. With the switch to the new
SpringFactoriesLoader APIs, a TestExecutionListener is now instantiated
using java.lang.reflect.Constructor.newInstance(Object...) which can
throw an InvocationTargetException.

This commit addresses the regression by unwrapping the target exception
in an InvocationTargetException.

See spring-projectsgh-28666
Closes spring-projectsgh-28828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: task A general task
Projects
None yet
Development

No branches or pull requests

1 participant