static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely // been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); } }
static RuntimeException extractCauseFromExecutionException(ExecutionException e) { // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (e.getCause() instanceof DriverException) throw ((DriverException)e.getCause()).copy(); else throw new DriverInternalError("Unexpected exception thrown", e.getCause()); } }
static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); } }
static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); }
static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); } }
static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); } }
static RuntimeException propagateCause(ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); // We could just rethrow e.getCause(). However, the cause of the ExecutionException has likely been // created on the I/O thread receiving the response. Which means that the stacktrace associated // with said cause will make no mention of the current thread. This is painful for say, finding // out which execute() statement actually raised the exception. So instead, we re-create the // exception. if (cause instanceof DriverException) throw ((DriverException) cause).copy(); else throw new DriverInternalError("Unexpected exception thrown", cause); } }
static ResultSet getUninterruptibly(ListenableFuture<ResultSet> future) { if (future instanceof ResultSetFuture) { return ((ResultSetFuture) future).getUninterruptibly(); } try { // emulate ResultSetFuture.getUninterruptibly return Uninterruptibles.getUninterruptibly(future); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Error) throw ((Error) cause); if (cause instanceof DriverException) throw ((DriverException) cause).copy(); throw new DriverInternalError("Unexpected exception thrown", cause); } } }