Skip to content

Stop using Spring Boot for pure Spring applications #2172

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 3 commits into from
Apr 24, 2023

Conversation

IlyaMuravjov
Copy link
Collaborator

@IlyaMuravjov IlyaMuravjov commented Apr 21, 2023

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:

  1. The set of valid pure Spring applications is not strictly a subset of valid Spring Boot applications, because Spring Boot reserves some names (e.g. application.xml), meaning that Spring Boot can't handle every valid pure Spring application
  2. To use Spring Boot when user doesn't have it we need to package all major versions of Spring Boot with the plugin, increasing plugin weight

Besides that the fall back strategy for the case when SpringApplication fails to start is improved from using empty bean list to manually creating AnnotationConfigApplicationContext and only using empty bean list if even creating AnnotationConfigApplicationContext manually fails.

Finally, now SpringApplication is shutdown with UtBotSpringShutdownException which is caught by catching all the exceptions that have UtBotSpringShutdownException which have UtBotSpringShutdownException as one of their causes, earlier this approach was rejected because only UtBotSpringShutdownException 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 configuration

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@IlyaMuravjov IlyaMuravjov added ctg-enhancement New feature, improvement or change request comp-spring Issue is related to Spring projects support labels Apr 21, 2023
@IlyaMuravjov IlyaMuravjov force-pushed the ilya_m/spring_without_boot branch from 5eb0c6a to 7c6c685 Compare April 24, 2023 07:47
@IlyaMuravjov IlyaMuravjov force-pushed the ilya_m/spring_without_boot branch from 11378d1 to 1c0b6c1 Compare April 24, 2023 08:57
@EgorkaKulikov EgorkaKulikov enabled auto-merge (squash) April 24, 2023 09:13
@EgorkaKulikov EgorkaKulikov merged commit 6a59c72 into main Apr 24, 2023
@EgorkaKulikov EgorkaKulikov deleted the ilya_m/spring_without_boot branch April 24, 2023 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle application.xml conflict with user's Spring project
2 participants