Example usage for java.io NotSerializableException initCause

List of usage examples for java.io NotSerializableException initCause

Introduction

In this page you can find the example usage for java.io NotSerializableException initCause.

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

From source file:org.mule.keygenerator.MD5MuleEventKeyGenerator.java

public Serializable generateKey(MuleEvent event) throws NotSerializableException {
    try {//from w  w  w . ja  v a 2  s.c  o  m
        byte[] bytesOfMessage = event.getMessageAsBytes();
        MessageDigest md = MessageDigest.getInstance("MD5");
        String key = new String(md.digest(bytesOfMessage));

        if (logger.isDebugEnabled()) {
            logger.debug("Generated key for event: " + event + " key: " + key);
        }

        return key;
    } catch (Exception e) {
        NotSerializableException notSerializableException = new NotSerializableException(e.getMessage());
        notSerializableException.initCause(e);

        throw notSerializableException;
    }
}