assert client != null;
try {
//Ensure client is empty
ApacheHttpClient4Handler clientHandler = ( ( ApacheHttpClient4 ) client ).getClientHandler();
SingleClientConnManager connectionManager = ( SingleClientConnManager ) clientHandler.getHttpClient().getConnectionManager();
@Nullable AbstractPooledConnAdapter managedConn = ( AbstractPooledConnAdapter ) Reflection.field( "managedConn" ).ofType( Class.forName( "org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter" ) ).in( connectionManager ).get();
if ( managedConn != null ) {
throw new IllegalStateException( "Connection not closed properly: " + managedConn.getRoute() );
}
} catch ( ClassNotFoundException e ) {
throw new RuntimeException( e );
}
}