service.shutdown();
try {
return taskFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (final CancellationException e) {
// callable was interrupted
throw new ExecutionException(e);
} catch (final InterruptedException e) {
// service was shutdown
throw new ExecutionException(e);
} catch (final ExecutionException e) {
// callable failed unexpectedly
throw e;
} catch (final TimeoutException e) {
// time-out
throw new ExecutionException(e);
}
} catch (final OutOfMemoryError e) {
org.apache.log4j.Logger.getLogger(TimeoutRequest.class).warn("OutOfMemoryError / retry follows", e);
// in case that no memory is there to create a new native thread
try {
return this.call.call();
} catch (final Exception e1) {
throw new ExecutionException(e1);
}
}
}