/** * Calling close will force the method to close, and will * force any open stream to terminate. If the session is local, * Then that too will be closed. */ public synchronized void close() { if(closed) return; // multiple calls ok closed = true; // mark as closed to prevent recursive calls if(methodstream != null) { try { methodstream.close(); } catch (IOException ioe) {/*failure is ok*/} ; methodstream = null; } if(this.request != null) { this.request.releaseConnection(); this.request = null; } if(session != null) { session.removeMethod(this); if(localsession) { session.close(); session = null; } } }
if(methodstream != null) { try { this.methodstream.close(); // May recursr } catch (IOException ioe) {/*failure is ok*/} this.methodstream = null;
HTTPMethodStream stream = (HTTPMethodStream) method.getResponseBodyAsStream(); Assert.assertTrue(method.hasStreamOpen()); stream.close(); Assert.assertTrue(method.isClosed()); Assert.assertFalse(method.hasStreamOpen());