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 "Eliminate package cycle between ContextLoader and WebApplicationContextUtils" [SPR-9440] #14076

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


Copy link

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

Chris Beams opened SPR-9440 and commented

This issue is a backport sub-task of #14075

Issue Links:

  • #14081 Backport "ApplicationContext environment inheritance may causes child context environment property sources to be lost" ("depends on")

Referenced from: commits 1eb5029

Copy link
Collaborator Author

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

Chris Beams commented

commit 02461b96c83437c34f65b61b7c69b68997c9b4dc
Author: Chris Beams <>
Commit: Chris Beams <>

    Introduce ConfigurableWebEnvironment
    Changes introduced in Spring 3.1 for Environment support inadvertently
    established a cyclic dependency between the
    org.springframework.web.context and packages, specifically through
    web.context.ContextLoader's invocation of
    This commit introduces ConfigurableWebEnvironment to break this cyclic
    dependency. All web.context.ConfigurableWebApplicationContext types now
    return web.context.ConfigurableWebEnvironment from their #getEnvironment
    methods; now implements
    ConfigurableWebEnvironment and makes the call to
    within its implementation of #initPropertySources. This means that
    web.context.ContextLoader now invokes
    web.context.ConfigurableWebEnvironment#initPropertySources instead of
    and thus the cycle is broken.
    Issue: SPR-9440
    Backport-Issue: SPR-9439
    Backport-Commit: 2a2b6eef9107a877492e965b5e063d6f1712e7f9
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