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

Document Lifecycle.stop() method synchronous or asynchronous behaviour [SPR-8570] #13214

Closed
spring-issuemaster opened this issue Jul 29, 2011 · 3 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jul 29, 2011

Juan Antonio Farré Basurte opened SPR-8570 and commented

I've been searching for documentation regarding Lifecycle interface and Lifecycle.stop() method.
I haven't been able to clarify whether this method should perform a synchronous stop of the component or just start an asynchronous shutdown sequence and probably return before shutdown is complete (and without a mean to signal shutdown completion).
Having SmartLifecycle.stop(Runnable) method specifically designed for asynchronous shutdown, looks logical to have stop() behave synchronously, but I've found references to components whose stop() method behaves asynchronously and a really haven't been able to get a clear idea of what's considered correct or standard behaviour.
I believe it's important to document it somewhere, preferably both in the javadoc of the interface and the method and in Spring Framework reference documentation 3.6.1 Lyfecycle callbacks.


Affects: 3.0.5

Referenced from: commits 6404440, 272f145, 35d2ab3

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 29, 2011

Chris Beams commented

Hi Juan,

Good question - I've updated the documentation for Lifecycle#stop to reflect that it is typically the case that the implementation is synchronous, and that if asynchronous behaviour is preferred, users should consider implementing SmartLifecycle#stop(Runnable).

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 29, 2011

Juan Antonio Farré Basurte commented

Hi, Chris,
Thanks for the quick response and for clarifying this question.
Now an additional doubt arises for me:
As SmartLifecycle extends Lifecycle, implementing SmartLifecycle requires implementing Lifecycle.stop(), too.
Hence, I will have two stop implementations: a synchronous and an asynchronous one.
Can I expect that instances of SmartLifecycle will have their asynchronous stop method invoked with priority over the synchronous one? Always? Or in what cases?
May be this detail is also worth being explicitly documented.
Thanks a lot again,

Juan

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 2, 2011

Chris Beams commented

the #stop() method will not be called at all by DefaultLifecycleProcessor for implementations of SmartLifecycle. Only the #stop(Runnable) variant will be called.

I have clarified this in the Javadoc for SmartLifecycle#stop(Runnable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.