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

Backport "ApplicationContext environment inheritance may causes child context environment property sources to be lost" [SPR-9446] #14081

spring-projects-issues opened this issue May 26, 2012 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented May 26, 2012

Chris Beams opened SPR-9446 and commented

This issue is a backport sub-task of #14080

Issue Links:

  • #14076 Backport "Eliminate package cycle between ContextLoader and WebApplicationContextUtils" ("is depended on by")

Referenced from: commits dc822cd, a387d13, 20f87ab

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 27, 2012

Chris Beams commented

commit 5308b814c429760da47f68f94f3a7b5288999005
Author: Chris Beams <>
Commit: Chris Beams <>

    Introduce ConfigurableEnvironment#merge
    Prior to this change, AbstractApplicationContext#setParent replaced the
    child context's Environment with the parent's Environment if available.
    This has the negative effect of potentially changing the type of the
    child context's Environment, and in any case causes property sources
    added directly against the child environment to be ignored. This
    situation could easily occur if a WebApplicationContext child had a
    non-web ApplicationContext set as its parent. In this case the parent
    Environment type would (likely) be StandardEnvironment, while the child
    Environment type would (likely) be StandardServletEnvironment. By
    directly inheriting the parent environment, critical property sources
    such as ServletContextPropertySource are lost entirely.
    This commit introduces the concept of merging an environment through
    the new ConfigurableEnvironment#merge method. Instead of replacing the
    child's environment with the parent's,
    AbstractApplicationContext#setParent now merges property sources as
    well as active and default profile names from the parent into the
    child. In this way, distinct environment objects are maintained with
    specific types and property sources preserved. See #merge Javadoc for
    additional details.
    Issue: SPR-9446
    Backport-Issue: SPR-9444, SPR-9439
    Backport-Commit: 9fcfd7e827323a0a47161779ff7fcad224b473d4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant