Stop using Spring Boot for pure Spring applications #2172
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2156
Fixes partially #2159
Earlier we used to analyze every Spring application (Spring Boot or not) by starting
org.springframework.boot.SpringApplication
, letting it find beans and killing it by destroying beans.Now for pure Spring applications (without Spring Boot)
AnnotationConfigApplicationContext
is created manually to find beans, this solves two problems:application.xml
), meaning that Spring Boot can't handle every valid pure Spring applicationBesides that the fall back strategy for the case when
SpringApplication
fails to start is improved from using empty bean list to manually creatingAnnotationConfigApplicationContext
and only using empty bean list if even creatingAnnotationConfigApplicationContext
manually fails.Finally, now
SpringApplication
is shutdown withUtBotSpringShutdownException
which is caught by catching all the exceptions that haveUtBotSpringShutdownException
which haveUtBotSpringShutdownException
as one of their causes, earlier this approach was rejected because onlyUtBotSpringShutdownException
itself was attempted to be caught which is not enough because Spring may wrap it into other exceptions.How to test
Manual tests
Generate tests for Spring project with
application.xml
(e.g. spring-starter-28 or the one provided in #2156) using any configurationSelf-check list