File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments