@Nullable public T getResult() { if (this.exception != null) { ReflectionUtils.rethrowRuntimeException(this.exception); } return this.result; }
/** * Handle the given invocation target exception. Should only be called if no * checked exception is expected to be thrown by the target method. * <p>Throws the underlying RuntimeException or Error in case of such a root * cause. Throws an UndeclaredThrowableException otherwise. * @param ex the invocation target exception to handle */ public static void handleInvocationTargetException(InvocationTargetException ex) { rethrowRuntimeException(ex.getTargetException()); }
@Override public void run() { try { ReflectionUtils.makeAccessible(this.method); this.method.invoke(this.target); } catch (InvocationTargetException ex) { ReflectionUtils.rethrowRuntimeException(ex.getTargetException()); } catch (IllegalAccessException ex) { throw new UndeclaredThrowableException(ex); } }
private void invokePortableRemoteObject(@Nullable Method method) throws RemoteException { if (method != null) { try { method.invoke(null, this.exportedObject); } catch (InvocationTargetException ex) { Throwable targetEx = ex.getTargetException(); if (targetEx instanceof RemoteException) { throw (RemoteException) targetEx; } ReflectionUtils.rethrowRuntimeException(targetEx); } catch (Throwable ex) { throw new IllegalStateException("PortableRemoteObject invocation failed", ex); } } }
/** * Handle the given invocation target exception. Should only be called if no * checked exception is expected to be thrown by the target method. * <p>Throws the underlying RuntimeException or Error in case of such a root * cause. Throws an UndeclaredThrowableException otherwise. * @param ex the invocation target exception to handle */ public static void handleInvocationTargetException(InvocationTargetException ex) { rethrowRuntimeException(ex.getTargetException()); }
@Override public void handleError(Throwable t) { super.handleError(t); ReflectionUtils.rethrowRuntimeException(t); } }
@Nullable public T getResult() { if (this.exception != null) { ReflectionUtils.rethrowRuntimeException(this.exception); } return this.result; }
@Override public void run() { try { ReflectionUtils.makeAccessible(this.method); this.method.invoke(this.target); } catch (InvocationTargetException ex) { ReflectionUtils.rethrowRuntimeException(ex.getTargetException()); } catch (IllegalAccessException ex) { throw new UndeclaredThrowableException(ex); } }
@Override public void handleError(Throwable t) { super.handleError(t); ReflectionUtils.rethrowRuntimeException(t); } }
private void invokePortableRemoteObject(@Nullable Method method) throws RemoteException { if (method != null) { try { method.invoke(null, this.exportedObject); } catch (InvocationTargetException ex) { Throwable targetEx = ex.getTargetException(); if (targetEx instanceof RemoteException) { throw (RemoteException) targetEx; } ReflectionUtils.rethrowRuntimeException(targetEx); } catch (Throwable ex) { throw new IllegalStateException("PortableRemoteObject invocation failed", ex); } } }
protected final <T> T tryParse(Callable<T> parser, Class<? extends Exception> check) { try { return parser.call(); } catch (Exception ex) { if (check.isAssignableFrom(ex.getClass())) { throw new JsonParseException(ex); } ReflectionUtils.rethrowRuntimeException(ex); throw new IllegalStateException(ex); } }
private void callFailedListener(SpringApplicationRunListener listener, ConfigurableApplicationContext context, Throwable exception) { try { listener.failed(context, exception); } catch (Throwable ex) { if (exception == null) { ReflectionUtils.rethrowRuntimeException(ex); } if (this.log.isDebugEnabled()) { this.log.error("Error handling failed", ex); } else { String message = ex.getMessage(); message = (message != null) ? message : "no error message"; this.log.warn("Error handling failed (" + message + ")"); } } }
private Object convert(Duration source, ChronoUnit unit, Class<?> type) { try { return type.getConstructor(String.class).newInstance(String .valueOf(DurationStyle.Unit.fromChronoUnit(unit).longValue(source))); } catch (Exception ex) { ReflectionUtils.rethrowRuntimeException(ex); throw new IllegalStateException(ex); } }
private Object findTarget(Object item) { Object current = item; while (current instanceof Advised) { try { current = ((Advised) current).getTargetSource().getTarget(); } catch (Exception e) { ReflectionUtils.rethrowRuntimeException(e); } } return current; }
private void handleRunFailure(ConfigurableApplicationContext context, Throwable exception, Collection<SpringBootExceptionReporter> exceptionReporters, SpringApplicationRunListeners listeners) { try { try { handleExitCode(context, exception); if (listeners != null) { listeners.failed(context, exception); } } finally { reportFailure(exceptionReporters, exception); if (context != null) { context.close(); } } } catch (Exception ex) { logger.warn("Unable to close ApplicationContext", ex); } ReflectionUtils.rethrowRuntimeException(exception); }
/** * Handle the given invocation target exception. Should only be called if no * checked exception is expected to be thrown by the target method. * <p>Throws the underlying RuntimeException or Error in case of such a root * cause. Throws an IllegalStateException else. * @param ex the invocation target exception to handle */ public static void handleInvocationTargetException(InvocationTargetException ex) { rethrowRuntimeException(ex.getTargetException()); }
ReflectionUtils.rethrowRuntimeException(e);
@Override public Object invoke(MethodInvocation invocation) throws Throwable { try { return this.operations.invoke(operations -> { try { Object result = invocation.proceed(); if (this.waitForConfirmsTimeout != null) { this.operations.waitForConfirmsOrDie(this.waitForConfirmsTimeout.toMillis()); } return result; } catch (Throwable t) { // NOSONAR - rethrown below ReflectionUtils.rethrowRuntimeException(t); return null; // not reachable - satisfy compiler } }, this.ackCallback, this.nackCallback); } catch (UndeclaredThrowableException ute) { throw ute.getCause(); } }
/** * Handle the given invocation target exception. Should only be called if no * checked exception is expected to be thrown by the target method. * <p>Throws the underlying RuntimeException or Error in case of such a root * cause. Throws an UndeclaredThrowableException otherwise. * @param ex the invocation target exception to handle */ public static void handleInvocationTargetException(InvocationTargetException ex) { rethrowRuntimeException(ex.getTargetException()); }
@Override public void setStatus(ZookeeperRegistration registration, String status) { ServiceInstance<ZookeeperInstance> serviceInstance = registration.getServiceInstance(); ZookeeperInstance instance = serviceInstance.getPayload(); instance.getMetadata().put(INSTANCE_STATUS_KEY, status); try { getServiceDiscovery().updateService(serviceInstance); } catch (Exception e) { ReflectionUtils.rethrowRuntimeException(e); } }