Skip to content

Commit

Permalink
[SPARK-43125][CONNECT] Fix Connect Server Can't Handle Exception With…
Browse files Browse the repository at this point in the history
… Null Message

### What changes were proposed in this pull request?
Fix the bug when Connect Server throw Exception without message.

### Why are the changes needed?
Fix bug

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Unnecessary

Closes #40780 from Hisoka-X/SPARK-43125_Exception_NPE.

Authored-by: Hisoka <fanjiaeminem@qq.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
Hisoka-X authored and HyukjinKwon committed Apr 14, 2023
1 parent bc1a6a1 commit ea49637
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class SparkConnectService(debug: Boolean)
}

private def buildStatusFromThrowable(st: Throwable): RPCStatus = {
val message = StringUtils.abbreviate(st.getMessage, 2048)
RPCStatus
.newBuilder()
.setCode(RPCCode.INTERNAL_VALUE)
Expand All @@ -85,7 +86,7 @@ class SparkConnectService(debug: Boolean)
.setDomain("org.apache.spark")
.putMetadata("classes", compact(render(allClasses(st.getClass).map(_.getName))))
.build()))
.setMessage(StringUtils.abbreviate(st.getMessage, 2048))
.setMessage(if (message != null) message else "")
.build()
}

Expand Down

0 comments on commit ea49637

Please sign in to comment.