} finally { if (handle != null) { handle.kill();
} finally { if (handle != null) { handle.kill();
private void kill(SparkAppHandle handle) { if (handle != null) { handle.kill(); } }
protected void waitFor(final SparkAppHandle handle) throws Exception { try { eventually(Duration.ofSeconds(10), Duration.ofMillis(10), () -> { assertTrue("Handle is not in final state.", handle.getState().isFinal()); }); } finally { if (!handle.getState().isFinal()) { handle.kill(); } } // Wait until the handle has been marked as disposed, to make sure all cleanup tasks // have been performed. AbstractAppHandle ahandle = (AbstractAppHandle) handle; eventually(Duration.ofSeconds(10), Duration.ofMillis(10), () -> { assertTrue("Handle is still not marked as disposed.", ahandle.isDisposed()); }); }
@Test public void testKill() throws Exception { SparkAppHandle app = startTest(TEST_KILL); app.kill(); waitFor(app); assertNull(lastError); assertEquals(SparkAppHandle.State.KILLED, app.getState()); }