[
https://issues.apache.org/jira/browse/HADOOP-9844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14329631#comment-14329631
]
Steve Loughran commented on HADOOP-9844:
----------------------------------------
Actually there's one case where it may be null: someone overrides
Throwable.toString(), doesn't call super.toString() & generates a null string.
Or even worse: NPEs.
Maybe we need some util method, {{toString(Throwable)}} that handles both
situations, so no matter what happens, some string, even just the classname of
the exception, makes it back.
{code}
String toString(Throwable t) {
try {
String ts = t.toString();
return (ts != null && !ts.isEmpty()) ? ts : t.getClass().getName() ;
} catch (Throwable t2) {
log.warn("when stringifying {}", t, t2);
return t.getClass().getName();
}
{code}
> NPE when trying to create an error message response of RPC
> ----------------------------------------------------------
>
> Key: HADOOP-9844
> URL: https://issues.apache.org/jira/browse/HADOOP-9844
> Project: Hadoop Common
> Issue Type: Bug
> Affects Versions: 3.0.0, 2.1.1-beta, 2.6.0
> Reporter: Steve Loughran
> Assignee: Steve Loughran
> Attachments: HADOOP-9844-001.patch
>
>
> I'm seeing an NPE which is raised when the server is trying to create an
> error response to send back to the caller and there is no error text.
> The root cause is probably somewhere in SASL, but sending something back to
> the caller would seem preferable to NPE-ing server-side.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)