@Test public void startException() throws Exception { LifecycleSupport underTest = new LifecycleSupport() { @Override protected void doStart() throws Exception { throw new TestException(); } }; try { underTest.start(); fail(); } catch (TestException e) { } assertState(underTest, State.FAILED); }
@Override public final void start() throws Exception { ensure(State.NEW, State.STOPPED); Locks.lock(lock); try { ensure(State.NEW, State.STOPPED); try { logTransition("Starting"); doStart(); current = State.STARTED; logTransition("Started"); } catch (Throwable failure) { doFailed("start", failure); } } finally { lock.unlock(); } }
LifecycleSupport extends ComponentSupport implements Lifecycle { @Override public final void start() throws Exception { ensure(State.NEW, State.STOPPED); Locks.lock(lock); try { ensure(State.NEW, State.STOPPED); try { logTransition("Starting"); doStart(); current = State.STARTED; logTransition("Started"); } catch (Throwable failure) { doFailed("start", failure); } } finally { lock.unlock(); } } }
LifecycleSupport extends ComponentSupport implements Lifecycle { @Override public final void start() throws Exception { ensure(State.NEW, State.STOPPED); Locks.lock(lock); try { ensure(State.NEW, State.STOPPED); try { logTransition("Starting"); doStart(); current = State.STARTED; logTransition("Started"); } catch (Throwable failure) { doFailed("start", failure); } } finally { lock.unlock(); } }  }
LifecycleSupport extends ComponentSupport implements Lifecycle { @Override public final void start() throws Exception { ensure(State.NEW, State.STOPPED); Locks.lock(lock); try { ensure(State.NEW, State.STOPPED); try { logTransition("Starting"); doStart(); current = State.STARTED; logTransition("Started"); } catch (Throwable failure) { doFailed("start", failure); } } finally { lock.unlock(); } }  @Override final void start(); @Override final void stop(); }
LifecycleSupport extends ComponentSupport implements Lifecycle { @Override public final void start() throws Exception { ensure(State.NEW, State.STOPPED); Locks.lock(lock); try { ensure(State.NEW, State.STOPPED); try { logTransition("Starting"); doStart(); current = State.STARTED; logTransition("Started"); } catch (Throwable failure) { doFailed("start", failure); } } finally { lock.unlock(); } }  @Override final void start(); @Override final void stop();  }