/** * Stop routine will close the closeable -if not null - and set the * reference to null afterwards * This operation does raise any exception on the close, though it does * record it */ @Override protected void serviceStop() { C target = getCloseable(); if (target != null) { try { target.close(); } catch (IOException ioe) { noteFailure(ioe); } setCloseable(null); } } }
/** * Stop routine will close the closeable -if not null - and set the * reference to null afterwards * This operation does raise any exception on the close, though it does * record it */ @Override protected void serviceStop() { C target = getCloseable(); if (target != null) { try { target.close(); } catch (IOException ioe) { noteFailure(ioe); } setCloseable(null); } } }
/** * This does not recurse forever, as the service has already entered the * STOPPED state before the inner close tries to stop it -that operation * is a no-op * @throws Throwable */ @Test public void testCloseSelf() throws Throwable { ClosingService<ClosingService> svc = new ClosingService<ClosingService>(""); svc.setCloseable(svc); svc.stop(); }
/** * This does not recurse forever, as the service has already entered the * STOPPED state before the inner close tries to stop it -that operation * is a no-op * @throws Throwable */ @Test public void testCloseSelf() throws Throwable { ClosingService<ClosingService> svc = new ClosingService<ClosingService>(""); svc.setCloseable(svc); svc.stop(); }