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

Configuring server.* properties in a child context has no effect in Spring Boot 2.3 #21789

Closed
stijnvanbever opened this issue Jun 9, 2020 · 3 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@stijnvanbever
Copy link

When using an ApplicationContext hierarchy in our Spring Boot application, we notice that @PropertySource isn't working as before in our child applicationcontext.

My setup consists of 2 child contexts with each a simple RestController that will return "Hello World".
Each of these child contexts has their own Configuration that will fetch their properties using a @PropertySource annotation.
In these configurations files I configure a different server.port.
Context A will have port 8081 and Context B will have port 8082.

When using 2.3.0 it seems that these properties aren't correctly picked up as I see that both modules try to use port 8080 and I get the error: "Web server failed to start. Port 8080 was already in use.".

When downgrading to 2.2.7 this works as it should be and Context A will use port 8081 and Context B will use port 8082.

This repository contains a project that replicates this problem: https://github.com/stijnvanbever/spring-context-hierarchy

My setup:
Spring Boot version: 2.3.0
JVM: OpenJDK 11.0.6

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 9, 2020
@wilkinsona wilkinsona self-assigned this Jun 9, 2020
@wilkinsona wilkinsona changed the title PropertySource not working in ApplicationContext Hierarchy when upgrading to 2.3.0 Configuring server.* properties in a child context has no effect in Spring Boot 2.3 Jun 9, 2020
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 9, 2020
@wilkinsona
Copy link
Member

Thanks very much for the sample. I've reproduced the problem.

The change in behaviour from 2.2 to 2.3 is due to ServerProperties being registered in the parent context in 2.3 due to this change. When a configuration properties bean is present in the parent context it isn't registered in the child. As a result, your child contexts see the server configuration from the parent as they no longer register their own ServerProperties beans.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Jun 9, 2020
@stijnvanbever
Copy link
Author

I see. Thanks for the explanation.

Is there anything I can do to contribute to a fix?

@wilkinsona
Copy link
Member

Thanks very much for the offer, @stijnvanbever. We're not yet sure on how to fix it. We'll hopefully figure that out later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants