[ 
https://issues.apache.org/jira/browse/HADOOP-9844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15384124#comment-15384124
 ] 

Vinayakumar B commented on HADOOP-9844:
---------------------------------------

{code}-      headerBuilder.setExceptionClassName(errorClass);
-      headerBuilder.setErrorMsg(error);
+      headerBuilder.setExceptionClassName(errorClass != null
+          ? errorClass : "RPC failure with no error provided");
+      headerBuilder.setErrorMsg(error != null ? error : "");{code}
In current uses, {{errorClass}} can be null only if response is SUCCESS. Even 
though its null, {{Client.java#receiveRpcResponse()}} handled this case.
So instead of setting with custom string, need not set anything(not even null 
for both errorClass and errorMsg)
Like below,
{code}
     } else { // Rpc Failure
-      headerBuilder.setExceptionClassName(errorClass);
-      headerBuilder.setErrorMsg(error);
-      headerBuilder.setErrorDetail(erCode);
+      if (errorClass != null) {
+        headerBuilder.setExceptionClassName(errorClass);
+      }
+      if (error != null) {
+        headerBuilder.setErrorMsg(error);
+      }
+      if (erCode != null) {
+        headerBuilder.setErrorDetail(erCode);
+      }
       RpcResponseHeaderProto header = headerBuilder.build();
{code}

+1 once fixed

> 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
>          Components: ipc
>    Affects Versions: 2.7.1, 3.0.0-alpha1
>            Reporter: Steve Loughran
>            Assignee: Steve Loughran
>         Attachments: HADOOP-9844-001.patch, HADOOP-9844-002.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)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to