Added check for a null exception "cause" to avoid NPE

Added check for a null exception "cause" to avoid NPE when the exception doesn't have a root cause attached.
+1 for the change.  Just a convention, that I would probably write it as:
final Throwable rootCause = e.getCause();
final Throwable t = rootCause == null ? e : rootCause;