List of usage examples for org.apache.http.nio.protocol HttpAsyncResponseConsumer close
public void close() throws IOException;
From source file:org.apache.http.impl.nio.client.PipeliningClientExchangeHandlerImpl.java
private void closeConsumer(final HttpAsyncResponseConsumer<?> responseConsumer) { if (responseConsumer != null) { try {/*from w ww .j a v a2s . com*/ responseConsumer.close(); } catch (final IOException ex) { this.log.debug("I/O error closing response consumer", ex); } } }
From source file:org.apache.http.impl.nio.client.PipeliningClientExchangeHandlerImpl.java
@Override public void responseCompleted() throws IOException, HttpException { if (this.log.isDebugEnabled()) { this.log.debug("[exchange: " + getId() + "] Response processed"); }//from w ww. ja v a2 s . com final boolean keepAlive = manageConnectionPersistence(); final HttpAsyncResponseConsumer<T> responseConsumer = this.responseConsumerRef.getAndSet(null); Asserts.check(responseConsumer != null, "Inconsistent state: response consumer is null"); try { responseConsumer.responseCompleted(this.localContext); final T result = responseConsumer.getResult(); final Exception ex = responseConsumer.getException(); try { responseConsumer.close(); } catch (final IOException ioex) { this.log.debug(ioex.getMessage(), ioex); } if (result != null) { this.resultQueue.add(result); } else { failed(ex); } if (!this.resultFuture.isDone() && this.responseConsumerQueue.isEmpty()) { this.resultFuture.completed(new ArrayList<T>(this.resultQueue)); this.resultQueue.clear(); } if (this.resultFuture.isDone()) { close(); } else { if (!keepAlive) { failed(new ConnectionClosedException("Connection closed")); } else { final NHttpClientConnection localConn = getConnection(); if (localConn != null) { localConn.requestOutput(); } else { requestConnection(); } } } } catch (final RuntimeException ex) { failed(ex); throw ex; } }