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

LoggingSystem not available on shutdown to log DisposableBean#destroy invocations #26660

Closed
HaojunRen opened this issue May 25, 2021 · 14 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@HaojunRen
Copy link

HaojunRen commented May 25, 2021

I run Spring Boot 2.5.0 application in Spring Tool Suite (Version: 3.9.7.RELEASE). Stopping that application by STS 'stop' button, I find destroy of DisposableBean not excuted. If I return to Spring Boot 2.4.x or 2.3.x, the function will be fine.

Is it an issue or be lated with Spring Tool Suite? Refer to my code, in 2.5.0, ‘Shutting down...’ loggger won't print...

public class MyOperation implements DisposableBean {

    private static final Logger LOG = LoggerFactory.getLogger(MyOperation.class);

    @Override
    public void destroy() throws Exception {
        LOG.info("Shutting down...");
    }

}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 25, 2021
@snicoll

This comment has been minimized.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 25, 2021
@HaojunRen

This comment has been minimized.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 25, 2021
@snicoll

This comment has been minimized.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels May 25, 2021
@HaojunRen

This comment has been minimized.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 25, 2021
@snicoll

This comment has been minimized.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels May 25, 2021
@HaojunRen

This comment has been minimized.

@snicoll snicoll added for: external-project For an external project and not something we can fix and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels May 25, 2021
@HaojunRen HaojunRen reopened this May 26, 2021
@HaojunRen

This comment has been minimized.

@HaojunRen

This comment has been minimized.

@snicoll

This comment has been minimized.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged and removed for: external-project For an external project and not something we can fix labels May 26, 2021
@HaojunRen
Copy link
Author

HaojunRen commented May 26, 2021

example.zip

Please try this example, 'DisposableBean' is called, but log does not output in STS with Spring Boot 2.5.0, BUT can output in 2.4.x, 2.3.x

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 26, 2021
@snicoll snicoll changed the title Spring Boot 2.5.0 not support destroy of DisposableBean LoggingSystem not available on shutdown to log DisposableBean#destroy invocations May 26, 2021
@snicoll
Copy link
Member

snicoll commented May 26, 2021

Thanks. Something changed in Spring Boot 2.5.0 that stops the LoggingSystem early potentially. That has no impact on calling DisposableBean so I've renamed the issue accordingly.

@snicoll snicoll added for: team-attention An issue we'd like other members of the team to review type: regression A regression from a previous release and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels May 26, 2021
@snicoll snicoll added this to the 2.5.1 milestone May 26, 2021
@HaojunRen
Copy link
Author

OK, thanks very much

@philwebb philwebb modified the milestones: 2.5.1, 2.5.x May 26, 2021
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label May 26, 2021
@philwebb
Copy link
Member

With Spring Boot 2.5 we change the logging system to always register a shutdown hook (See #25046). What's happening now is that when the app terminates both the logging system and the ApplicationContext are shutdown. That happens in parallel so it's possible for the logging system to be closed before the disposable beans have had a chance to add logging.

@philwebb
Copy link
Member

Fixing this one is a bit tricky. I have something on this branch, but I'd like someone else from the team to review it.

It works by tracking ApplicationContexts that are started in a weak map then checking them all for isActive() false before calling the real shutdown hook.

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label May 27, 2021
wilkinsona added a commit to wilkinsona/spring-boot that referenced this issue Jun 9, 2021
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jun 10, 2021
@philwebb philwebb modified the milestones: 2.5.x, 2.5.1 Jun 10, 2021
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

5 participants