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

Resttemplate throws NPE with spring-boot-starter-log4j2 within tests #26120

Closed
mnhock opened this issue Nov 19, 2020 · 2 comments
Closed

Resttemplate throws NPE with spring-boot-starter-log4j2 within tests #26120

mnhock opened this issue Nov 19, 2020 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@mnhock
Copy link
Contributor

mnhock commented Nov 19, 2020

Resttemplate throws a NPE with dependency spring-boot-starter-log4j2 within tests calling RestTemplate construtor.

Repository for reproduce:

https://github.com/mnhock/resttemplate-bug

Simple call the RestConfigurationTest.

If you remove spring-boot-starter-log4j2 dependency from the pom it works.

The problem is that the init of the Logger depends on the SpringProperties as well but is initialized before the localProperties is initialized.

	private static final Log logger = LogFactory.getLog(SpringProperties.class);
	private static final Properties localProperties = new Properties();

I think the problem exists with other files changed in #25151 as well.

Thanks,
Martin

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 19, 2020
@jhoeller jhoeller self-assigned this Nov 19, 2020
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 19, 2020
@jhoeller jhoeller added this to the 5.3.2 milestone Nov 19, 2020
@jhoeller
Copy link
Contributor

Where exactly does logger initialization refer back to SpringProperties? Is that somewhere in Boot?

Anyway, the most defensive option is to get rid of logger usage in SpringProperties altogether.

@snicoll
Copy link
Member

snicoll commented Nov 20, 2020

For the record, this issue has been fixed in Spring Boot as well, see spring-projects/spring-boot#24163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants