@Test public void closeShouldCloseHttpResourceAndCallSuperJustAtFirstCall() throws IOException { toTest.close(); toTest.close(); verify(mockHttpResource).close(); verify(mockInputStream).close(); }
@Override public void close() throws IOException { if(!closed.compareAndSet(false, true)) { LOGGER.trace("This http stream has already been closed, ignoring close request."); return; } try { LOGGER.debug("Releasing underlying network resources."); resource.close(); } finally { super.close(); } }
HttpResourceInputStream extends InputStreamWrapper { @Override public void close() throws IOException { if(!closed.compareAndSet(false, true)) { LOGGER.trace("This http stream has already been closed, ignoring close request."); return; } try { LOGGER.debug("Releasing underlying network resources."); resource.close(); } finally { super.close(); } } }
HttpResourceInputStream extends InputStreamWrapper { @Override public void close() throws IOException { if(!closed.compareAndSet(false, true)) { LOGGER.trace("This http stream has already been closed, ignoring close request."); return; } try { LOGGER.debug("Releasing underlying network resources."); resource.close(); } finally { super.close(); } } HttpResourceInputStream(HttpResource resource); }
HttpResourceInputStream extends InputStreamWrapper { @Override public void close() throws IOException { if(!closed.compareAndSet(false, true)) { LOGGER.trace("This http stream has already been closed, ignoring close request."); return; } try { LOGGER.debug("Releasing underlying network resources."); resource.close(); } finally { super.close(); } } HttpResourceInputStream(HttpResource resource); @Override void close(); }
HttpResourceInputStream extends InputStreamWrapper { @Override public void close() throws IOException { if(!closed.compareAndSet(false, true)) { LOGGER.trace("This http stream has already been closed, ignoring close request."); return; } try { LOGGER.debug("Releasing underlying network resources."); resource.close(); } finally { super.close(); } } HttpResourceInputStream(HttpResource resource); @Override void close();  }