-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Use DeferredLog in CloudFoundryVcapEnvironmentPostProcessor #19027
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
Conversation
Use DeferredLog in CloudFoundryVcapEnvironmentPostProcessor since the logging system is not yet initialized when the EnvironmentPostProcessor's are invoked.
Receiving the ApplicationPreparedEvent is a prerequisite for being able to use DeferredLog in CloudFoundryVcapEnvironmentPostProcessor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and thank you for the PR!
I am not sure yet if we should backport this to 2.1.x
or not, flagging for team attention. I've also added a minor comment. We can take care of it as part of the merge or you can update this PR if you have time.
@@ -89,9 +90,9 @@ | |||
* @author Andy Wilkinson | |||
* @since 1.3.0 | |||
*/ | |||
public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered { | |||
public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered, ApplicationListener<ApplicationEvent> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could implement ApplicationListener<ApplicationPreparedEvent>
instead and avoid the if check in the listener implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out. Fixed with a9c1e03
Directly listen for ApplicationPreparedEvent instead of ApplicationEvent and avoid the event type check.
This seems to me like something that we should fix in 2.1.x. The fix doesn't look risky so I suspect I've missed something. What's making you unsure, @snicoll? |
I can’t remember now. Thanks for confirming! |
@markbigler thank you for making your first contribution to Spring Boot. This is merged in |
If I'm not wrong, currently nothing will be logged because the logging system has not yet been initialized when the EnvironmentPostProcessor's are invoked.
This PR makes use of the DeferredLog, so the log entries are no longer lost and become visible as soon as the logging system is ready.