Skip to content

Commit bed229b

Browse files
On exception abort Future, do not rethrow
1 parent 57ea85a commit bed229b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,29 @@ public void updated(final Connection c) {
250250
connectionManager.doAsyncTrackedConnection(request, future, connectHandler);
251251
} catch (Exception e) {
252252
if (e instanceof RuntimeException) {
253-
throw (RuntimeException) e;
253+
abort(future, e);
254254
} else if (e instanceof IOException) {
255-
throw (IOException) e;
256-
}
257-
if (LOGGER.isWarnEnabled()) {
258-
LOGGER.warn(e.toString(), e);
255+
abort(future, e);
256+
} else {
257+
if (LOGGER.isWarnEnabled()) {
258+
LOGGER.warn(e.toString(), e);
259+
abort(future, e);
260+
}
259261
}
260262
}
261263

262264
return future;
263265
}
264266

267+
private void abort(GrizzlyResponseFuture<?> future, Throwable t) {
268+
if (!future.isDone()) {
269+
LOGGER.debug("Aborting Future {}\n", future);
270+
LOGGER.debug(t.getMessage(), t);
271+
future.abort(t);
272+
}
273+
}
274+
275+
265276
@Override
266277
public void close() {
267278

0 commit comments

Comments
 (0)