Repository: spark
Updated Branches:
  refs/heads/branch-2.0 912487eaf -> c2cce2e60


[SPARK-18022][SQL] java.lang.NullPointerException instead of real exception 
when saving DF to MySQL

## What changes were proposed in this pull request?

On null next exception in JDBC, don't init it as cause or suppressed

## How was this patch tested?

Existing tests

Author: Sean Owen <so...@cloudera.com>

Closes #15599 from srowen/SPARK-18022.

(cherry picked from commit 6c7d094ec4d45a05c1ec8a418e507e45f5a88b7d)
Signed-off-by: Sean Owen <so...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c2cce2e6
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c2cce2e6
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c2cce2e6

Branch: refs/heads/branch-2.0
Commit: c2cce2e60c491d5ff2b1eb1f30eb507f0d40dae1
Parents: 912487e
Author: Sean Owen <so...@cloudera.com>
Authored: Wed Oct 26 14:19:40 2016 +0200
Committer: Sean Owen <so...@cloudera.com>
Committed: Wed Oct 26 14:19:59 2016 +0200

----------------------------------------------------------------------
 .../apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/c2cce2e6/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
index 7a8b825..2869e80 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
@@ -236,7 +236,7 @@ object JdbcUtils extends Logging {
     } catch {
       case e: SQLException =>
         val cause = e.getNextException
-        if (e.getCause != cause) {
+        if (cause != null && e.getCause != cause) {
           if (e.getCause == null) {
             e.initCause(cause)
           } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to