Example usage for org.springframework.util ReflectionUtils rethrowRuntimeException

List of usage examples for org.springframework.util ReflectionUtils rethrowRuntimeException

Introduction

In this page you can find the example usage for org.springframework.util ReflectionUtils rethrowRuntimeException.

Prototype

public static void rethrowRuntimeException(Throwable ex) 

Source Link

Document

Rethrow the given Throwable exception , which is presumably the target exception of an InvocationTargetException .

Usage

From source file:org.springframework.cloud.zookeeper.discovery.ZookeeperLifecycle.java

@Override
protected void deregister() {
    if (!this.properties.isRegister()) {
        return;//  w  w w.  j  a  v a2  s .  co  m
    }
    try {
        this.serviceDiscovery.getServiceDiscovery()
                .unregisterService(this.serviceDiscovery.getServiceInstance());
    } catch (Exception e) {
        ReflectionUtils.rethrowRuntimeException(e);
    }
}

From source file:org.springframework.cloud.zookeeper.discovery.ZookeeperServiceDiscovery.java

/**
 * One can override this method to provide custom way of registering a service
 * instance (e.g. when no payload is required).
 *//*  ww  w  .  j ava 2 s  .com*/
public void configureServiceInstance(AtomicReference<ServiceInstance<ZookeeperInstance>> serviceInstance,
        String appName, ApplicationContext context, AtomicInteger port, String host, UriSpec uriSpec) {
    // @formatter:off
    try {
        ZookeeperInstance zookeeperInstance = new ZookeeperInstance(context.getId(), appName,
                this.properties.getMetadata());
        if (StringUtils.hasText(this.properties.getInitialStatus())) {
            zookeeperInstance.getMetadata().put(INSTANCE_STATUS_KEY, this.properties.getInitialStatus());
        }
        serviceInstance.set(ServiceInstance.<ZookeeperInstance>builder().name(appName)
                .payload(zookeeperInstance).port(port.get()).address(host).uriSpec(uriSpec).build());
    } catch (Exception e) {
        ReflectionUtils.rethrowRuntimeException(e);
    }
    // @formatter:on
}

From source file:org.springframework.integration.amqp.support.BoundRabbitChannelAdvice.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    try {// ww w  .ja va  2s . co  m
        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();
    }
}