Skip to content

AbstractRefreshableApplicationContext should not appear in the type hierarchy of our application context implementations #16096

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
snicoll opened this issue Mar 5, 2019 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Mar 5, 2019

Several ApplicationContext implementations we use inherits from AbstractRefreshableApplicationContext which is a hierarchy we shouldn't be using in modern-day arrangements:

  • AnnotationConfigWebApplicationContext
  • AnnotationConfigReactiveWebApplicationContext

While the latter is in our code base, the former is in the framework code base with no clear sign we shouldn't be using it anymore. Those contexts don't hold a BeanFactory instance before they refresh and therefore prevent any use of functional bean registration.

A potential replacement would be a GenericWebApplicationContext sub-class with a AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx) invocation.

@snicoll snicoll added the type: bug A general bug label Mar 5, 2019
@snicoll snicoll added this to the 2.2.x milestone Mar 5, 2019
@wilkinsona wilkinsona changed the title Remove use of AbstractRefreshableApplicationContext hierarchy AbstractRefreshableApplicationContext should not appear in the type hierarchy of our application context implementations Mar 5, 2019
@wilkinsona
Copy link
Member

Our move to Framework 5.2 is related to this. In 5.2, AnnotationConfigRegistry has two new methods. AnnotationConfigReactiveWebApplicationContext implements AnnotationConfigRegistry and, as a result, does not compile against 5.2 snapshots. AnnotationConfigReactiveWebServerApplicationContext has the same problem.

@snicoll Did you have anything in mind here? Will it help with implementing the new methods on AnnotationConfigRegistry?

@snicoll
Copy link
Member Author

snicoll commented Mar 11, 2019

This is related indirectly. We have contexts in the hierarchy that ultimately do not depend on GenericApplicationContext and some methods where not available. @jhoeller provided a pragmatic fix for that that explains why there are two new methods to implement in 5.2.

It looks like this will be interesting for AnnotationConfigReactiveWebApplicationContext. AnnotationConfigReactiveWebApplicationContext should stop extending from AbstractRefreshableConfigApplicationContext. There is a class affected in framework and I am waiting for Juergen to apply a consistent fix here.

@snicoll snicoll modified the milestones: 2.2.x, 2.2.0.M2 Mar 11, 2019
@philwebb
Copy link
Member

AnnotationConfigReactiveWebApplicationContext intentionally mirrors the hierarchy of frameworks AnnotationConfigWebApplicationContext and I think it's mainly used in tests. We should follow the lead of Spring Framework, but I doubt we can change it to not extend AbstractRefreshableConfigApplicationContext at this point.

@snicoll snicoll self-assigned this Apr 2, 2019
snicoll added a commit to snicoll/spring-boot that referenced this issue Apr 2, 2019
@snicoll
Copy link
Member Author

snicoll commented Apr 2, 2019

@philwebb it's mainly used in tests you are right. As for the regular AnnotationConfigWebApplicationContext it turns out to be in that hierarchy for no proper reason anymore and @jhoeller can't change that at this point.

I've introduced a AnnotationConfigServletWebApplicationContext in
8bf3bfd that, I believe, what Juergen would have liked in framework and use that type in our test infrastructure. I've also changed AnnotationConfigReactiveWebApplicationContext.

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Apr 2, 2019
snicoll added a commit to snicoll/spring-boot that referenced this issue Apr 4, 2019
philwebb pushed a commit to philwebb/spring-boot that referenced this issue Apr 4, 2019
@philwebb
Copy link
Member

philwebb commented Apr 4, 2019

@snicoll I've added a couple of extra commits on a local branch.

The changes you've made look good to me. My only hesitation is with AnnotationConfigReactiveWebApplicationContext since it's a breaking change. We have the same problem as Juergen there. Ideally we'd leave it alone and create a new version, but we really really want to use the existing name. I toyed with AnnotationConfigGenericReactiveWebApplicationContext, but it just sucks!

Since that context is just for reactive code, and since we've probably not got many users working with it directly, I think we should just risk changing the base class. I do think we should perhaps re-introduce deprecated versions of methods from the old class (I've done that on my branch). We can't make them work, but at least we can give people hints that they're deprecated. We should also add additional constructors I think.

Overall, I'm +1 for the changes.

@snicoll snicoll removed the for: team-attention An issue we'd like other members of the team to review label Apr 5, 2019
@snicoll
Copy link
Member Author

snicoll commented Apr 5, 2019

Thanks for the review @philwebb - FYI, I've dropped philwebb@2ce95ef from your polish. I didn't migrate those on purpose as this module can't have a compile dependency on spring-boot.

snicoll added a commit that referenced this issue Apr 5, 2019
This commit migrates `AnnotationConfigReactiveWebApplicationContext`
parent to the `GenericApplicationContext` abstraction. Any use of
`AnnotationConfigWebApplicationContext` is also removed as it also
inherits from the `AbstractRefreshableApplicationContext` outdated
hierarchy.

A new `AnnotationConfigServletWebApplicationContext` context is
introduced instead, extending from `GenericApplicationContext` and
providing the counter part of the reactive context for the Servlet-based
web app tests.

See gh-16096
@snicoll snicoll closed this as completed in 8626a33 Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants