jetty.project
jetty.project copied to clipboard
Make LifeCycle implement AutoCloseable
It is so handy in tests to be able to create a LifeCycle in a test method and use it with try-with-resources.
public interface LifeCycle extends AutoCloseable
{
...
@Override
public default void close() throws Exception
{
stop();
}
}
Thoughts?
We certainly can do:
public interface LifeCycle
{
...
interface Closeable extends LifeCycle, AutoCloseable
{
@Override
default void close() throws Exception
{
stop();
}
}
}
Not sure about making all LifeCycles autocloseable
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
@gregw
I agree that making all LifeCycle also AutoCloseable may be a bit too much, although all LifeCycle have already a stop() method so they kind of are already stoppable/closeable.
I think introducing LifeCycle.AutoCloseable is a bit of duplication, since components can just implement directly AutoCloseable directly and just implement close() as a one-liner calling stop().