@Override public void handleException(Throwable throwable) { throw ExceptionUtil.rethrow(throwable); } };
@SuppressWarnings("unchecked") @Override public E join() { if (result instanceof Throwable) { sneakyThrow((Throwable) result); } return (E) result; }
public static RuntimeException rethrow(final Throwable t, RuntimeExceptionFactory runtimeExceptionFactory) { rethrowIfError(t); throw (RuntimeException) peel(t, null, null, runtimeExceptionFactory); }
private void unRegisterPartitionListenerIfExists() { if (this.partitionLostRegistration == null) { return; } try { getNodeEngine().getPartitionService().removePartitionLostListener(this.partitionLostRegistration); } catch (Exception ex) { if (peel(ex, HazelcastInstanceNotActiveException.class, null) instanceof HazelcastInstanceNotActiveException) { throw rethrow(ex); } } this.partitionLostRegistration = null; }
private boolean doAwait(long time, TimeUnit unit, long threadId) throws InterruptedException { try { long timeout = unit.toMillis(time); Data key = lockProxy.getKeyData(); AwaitOperation op = new AwaitOperation(namespace, key, threadId, timeout, conditionId); Future f = invoke(op); return Boolean.TRUE.equals(f.get()); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override protected Throwable adjustThrowable(Throwable t) { return peel(t); }
private void unRegisterPartitionListenerIfExists() { if (this.partitionLostRegistration == null) { return; } try { getNodeEngine().getPartitionService().removePartitionLostListener(this.partitionLostRegistration); } catch (Exception ex) { if (peel(ex, HazelcastInstanceNotActiveException.class, null) instanceof HazelcastInstanceNotActiveException) { throw rethrow(ex); } } this.partitionLostRegistration = null; }
private boolean doAwait(long time, TimeUnit unit, long threadId) throws InterruptedException { try { long timeout = unit.toMillis(time); Data key = lockProxy.getKeyData(); AwaitOperation op = new AwaitOperation(namespace, key, threadId, timeout, conditionId); Future f = invoke(op); return Boolean.TRUE.equals(f.get()); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override protected Throwable adjustThrowable(Throwable t) { return peel(t); }
void rethrowIfFailed() { if (error != null) { throw ExceptionUtil.rethrow(error); } } }
@SuppressWarnings("unchecked") @Override public E join() { if (result instanceof Throwable) { sneakyThrow((Throwable) result); } return (E) result; }
@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { checkNotNull(unit, "unit can't be null"); Operation op = new AwaitOperation(name, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> f = invokeOnPartition(op); try { return f.get(); } catch (ExecutionException e) { throw rethrowAllowInterrupted(e); } }
public static RuntimeException rethrow(final Throwable t) { rethrowIfError(t); throw peel(t); }
private Throwable peelIfNeeded(Throwable t) { if (t == null) { return null; } for (Class<? extends Throwable> clazz : NON_PEELABLE_EXCEPTIONS) { if (clazz.isAssignableFrom(t.getClass())) { return t; } } return peel(t); } }
protected <T> T getSafely(Future<T> future) { try { return future.get(); } catch (Throwable throwable) { throw rethrow(throwable); } }
@Override public Future<V> call() { try { return executor.submit(callable); } catch (Throwable t) { ExceptionUtil.sneakyThrow(t); } return null; }
@Override public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException { checkNotNegative(permits, "permits can't be negative"); try { Operation operation = new AcquireOperation(name, permits, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> future = invokeOnPartition(operation); return future.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
/** * This rethrow the exception providing an allowed Exception in first priority, even it is a Runtime exception */ public static <T extends Throwable> RuntimeException rethrowAllowedTypeFirst(final Throwable t, Class<T> allowedType) throws T { rethrowIfError(t); if (allowedType.isAssignableFrom(t.getClass())) { throw (T) t; } else { throw peel(t); } }
private Throwable peelIfNeeded(Throwable t) { if (t == null) { return null; } for (Class<? extends Throwable> clazz : NON_PEELABLE_EXCEPTIONS) { if (clazz.isAssignableFrom(t.getClass())) { return t; } } return peel(t); } }
private void sleepBeforeNextTry() { try { Thread.sleep(invocationRetryPauseMillis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ExceptionUtil.rethrow(e); } }