Example usage for java.rmi UnmarshalException getCause

List of usage examples for java.rmi UnmarshalException getCause

Introduction

In this page you can find the example usage for java.rmi UnmarshalException getCause.

Prototype

public Throwable getCause() 

Source Link

Document

Returns the cause of this exception.

Usage

From source file:net.sf.ehcache.distribution.RMICacheManagerPeerTest.java

/**
 * See if socket.setSoTimeout(socketTimeoutMillis) works. Should throw a SocketTimeoutException
 *
 * @throws RemoteException//from  w w  w.  j  a v  a  2  s  .  c  om
 */
public void testFailsIfTimeoutExceeded() throws Exception {

    RMICachePeer rmiCachePeer = new SlowRMICachePeer(cache, hostName, port, new Integer(1000));
    peerListener.addCachePeer(cache.getName(), rmiCachePeer);
    peerListener.init();

    try {
        CachePeer cachePeer = new ManualRMICacheManagerPeerProvider()
                .lookupRemoteCachePeer(rmiCachePeer.getUrl());
        cachePeer.put(new Element("1", new Date()));
        fail();
    } catch (UnmarshalException e) {
        assertEquals(SocketTimeoutException.class, e.getCause().getClass());
    }
}

From source file:com.googlecode.jmxtrans.model.Query.java

public Iterable<Result> fetchResults(MBeanServerConnection mbeanServer, ObjectName queryName)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
    MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
    ObjectInstance oi = mbeanServer.getObjectInstance(queryName);

    List<String> attributes;
    if (attr.isEmpty()) {
        attributes = new ArrayList<>();
        for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
            attributes.add(attrInfo.getName());
        }// w w  w. j av  a 2  s  .  c o  m
    } else {
        attributes = attr;
    }

    try {
        if (!attributes.isEmpty()) {
            logger.debug("Executing queryName [{}] from query [{}]", queryName.getCanonicalName(), this);

            AttributeList al = mbeanServer.getAttributes(queryName,
                    attributes.toArray(new String[attributes.size()]));

            return new JmxResultProcessor(this, oi, al.asList(), info.getClassName(), queryName.getDomain())
                    .getResults();
        }
    } catch (UnmarshalException ue) {
        if ((ue.getCause() != null) && (ue.getCause() instanceof ClassNotFoundException)) {
            logger.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: "
                    + "http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52",
                    ue.getMessage());
        } else {
            throw ue;
        }
    }
    return ImmutableList.of();
}