Skip to content

Commit f6f2b7a

Browse files
committed
Clarify comments
1 parent ad38533 commit f6f2b7a

File tree

1 file changed

+5
-2
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc

1 file changed

+5
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,15 @@ object JdbcUtils extends Logging {
652652
case e: SQLException =>
653653
val cause = e.getNextException
654654
if (cause != null && e.getCause != cause) {
655+
// If there is no cause already, set 'next exception' as cause. If cause is null,
656+
// it *may* be because no cause was set yet
655657
if (e.getCause == null) {
656658
try {
657659
e.initCause(cause)
658660
} catch {
659-
// cause may have been explicitly initialized to null, in which case this
660-
// fails. No way to detect it, can only catch the exception.
661+
// Or it may be null because the cause *was* explicitly initialized, to *null*,
662+
// in which case this fails. There is no other way to detect it.
663+
// addSuppressed in this case as well.
661664
case _: IllegalStateException => e.addSuppressed(cause)
662665
}
663666
} else {

0 commit comments

Comments
 (0)