You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "eason-yuchen-liu (via GitHub)" <gi...@apache.org> on 2026/04/01 05:04:52 UTC

Re: [PR] [SPARK-56092][SS] Fix NPE in StreamingQueryException.toString() when cause is null [spark]

eason-yuchen-liu commented on code in PR #55044:
URL: https://github.com/apache/spark/pull/55044#discussion_r3019784151


##########
common/utils/src/main/scala/org/apache/spark/sql/streaming/StreamingQueryException.scala:
##########
@@ -98,9 +98,15 @@ class StreamingQueryException private[sql](
   override def getMessage: String =
     if (queryDebugString.isEmpty) message else s"${message}\n${queryDebugString}"
 
-  override def toString(): String =
-    s"""${classOf[StreamingQueryException].getName}: ${cause.getMessage}
+  override def toString(): String = {
+    val causeMsg = if (cause != null) {
+      Option(cause.getMessage).getOrElse(message)
+    } else {
+      message

Review Comment:
   It will be nice to have a distinction between cause being empty and non-empty.
   ```suggestion
         s"$message (no cause)"
   ```



##########
common/utils/src/main/scala/org/apache/spark/sql/streaming/StreamingQueryException.scala:
##########
@@ -98,9 +98,15 @@ class StreamingQueryException private[sql](
   override def getMessage: String =
     if (queryDebugString.isEmpty) message else s"${message}\n${queryDebugString}"
 
-  override def toString(): String =
-    s"""${classOf[StreamingQueryException].getName}: ${cause.getMessage}
+  override def toString(): String = {
+    val causeMsg = if (cause != null) {
+      Option(cause.getMessage).getOrElse(message)

Review Comment:
   I think if the message of cause is empty, we should live with it.
   ```suggestion
         cause.getMessage
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org