public void copyHttpFutureResult() { if (!isDone() && httpFuture.isDone()) { try { completed(httpFuture.get()); } catch(ExecutionException e) { failed(clientException(e.getCause(), null)); } catch (InterruptedException e) { // cant happen because already isDone failed(e); } } } }
@Override public synchronized void close() { completed = true; ResultFuture<T> future = this.future; if (future != null) { // if connect fails, then the httpclient just calls close() after setting its future, but never our failed(). // so copy the httpFuture-result into our ResultFuture. future.copyHttpFutureResult(); if (!future.isDone()) { // doesnt happen? future.failed(clientException(new IOException("connect failed"), null)); } } releaseResources(); }
public void copyHttpFutureResult() { if (!isDone() && httpFuture.isDone()) { try { completed(httpFuture.get()); } catch(ExecutionException e) { failed(clientException(e.getCause(), null)); } catch (InterruptedException e) { // cant happen because already isDone failed(e); } } } }
public void copyHttpFutureResult() { if (!isDone() && httpFuture.isDone()) { try { completed(httpFuture.get()); } catch(ExecutionException e) { failed(clientException(e.getCause(), null)); } catch (InterruptedException e) { // cant happen because already isDone failed(e); } } } }
@Override public synchronized void close() { completed = true; ResultFuture<T> future = this.future; if (future != null) { // if connect fails, then the httpclient just calls close() after setting its future, but never our failed(). // so copy the httpFuture-result into our ResultFuture. future.copyHttpFutureResult(); if (!future.isDone()) { // doesnt happen? future.failed(clientException(new IOException("connect failed"), null)); } } releaseResources(); }
@Override public synchronized void close() { completed = true; ResultFuture<T> future = this.future; if (future != null) { // if connect fails, then the httpclient just calls close() after setting its future, but never our failed(). // so copy the httpFuture-result into our ResultFuture. future.copyHttpFutureResult(); if (!future.isDone()) { // doesnt happen? future.failed(clientException(new IOException("connect failed"), null)); } } releaseResources(); }
public synchronized Future<T> future(Future<T> httpFuture) { if (completed) { // already failed or fully buffered return httpFuture; } future = new ResultFuture<T>(httpFuture); future.copyHttpFutureResult(); if (!future.isDone() && hasResult) { // response(-headers) is available, but not yet the full response-stream. Return immediately the result future.completed(getResult()); } return future; }
public synchronized Future<T> future(Future<T> httpFuture) { if (completed) { // already failed or fully buffered return httpFuture; } future = new ResultFuture<T>(httpFuture); future.copyHttpFutureResult(); if (!future.isDone() && hasResult) { // response(-headers) is available, but not yet the full response-stream. Return immediately the result future.completed(getResult()); } return future; }
public synchronized Future<T> future(Future<T> httpFuture) { if (completed) { // already failed or fully buffered return httpFuture; } future = new ResultFuture<T>(httpFuture); future.copyHttpFutureResult(); if (!future.isDone() && hasResult) { // response(-headers) is available, but not yet the full response-stream. Return immediately the result future.completed(getResult()); } return future; }