question: protected void cleanUpStreams ( Exception inflight ) { if ( stream != null ) { try { stream . close ( ) ; stream = null ; } catch ( IOException closeException ) { inflight . addSuppressed ( closeException ) ; } } if ( connection != null ) { byte [ ] buf = new byte [ 8 * 2014 ] ; InputStream es = connection . getErrorStream ( ) ; if ( es != null ) { try { try { while ( es . read ( buf ) > 0 ) { } } finally { es . close ( ) ; } } catch ( IOException errorStreamError ) { inflight . addSuppressed ( errorStreamError ) ; } } } }
target:  According to https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html we should read the error stream so the connection can be reused.