public synchronized void close ( ) { if ( closed ) return ; // recursive calls ok closed = true ; // mark as closed to prevent recursive calls if ( methodstream != null ) { try { this . methodstream . close ( ) ; // May recursr } catch ( IOException ioe ) { /*failure is ok*/ } this . methodstream = null ; } // Force release underlying connection back to the connection manager if ( this . lastresponse != null ) { if ( false ) { try { try { // Attempt to keep connection alive by consuming its remaining content EntityUtils . consume ( this . lastresponse . getEntity ( ) ) ; } finally { HttpClientUtils . closeQuietly ( this . lastresponse ) ; // Paranoia } } catch ( IOException ignore ) { /*ignore*/ } } else HttpClientUtils . closeQuietly ( this . lastresponse ) ; this . lastresponse = null ; } if ( session != null ) { session . removeMethod ( this ) ; if ( localsession ) { session . close ( ) ; session = null ; } } this . lastrequest = null ; }
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 .