You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2015/12/03 09:42:28 UTC

spark git commit: [SPARK-12088][SQL] check connection.isClosed before calling connection…

Repository: spark
Updated Branches:
  refs/heads/master ec2b6c26c -> 5349851f3


[SPARK-12088][SQL] check connection.isClosed before calling connection…

In Java Spec java.sql.Connection, it has
boolean getAutoCommit() throws SQLException
Throws:
SQLException - if a database access error occurs or this method is called on a closed connection

So if conn.getAutoCommit is called on a closed connection, a SQLException will be thrown. Even though the code catch the SQLException and program can continue, I think we should check conn.isClosed before calling conn.getAutoCommit to avoid the unnecessary SQLException.

Author: Huaxin Gao <hu...@oc0558782468.ibm.com>

Closes #10095 from huaxingao/spark-12088.


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

Branch: refs/heads/master
Commit: 5349851f368a1b5dab8a99c0d51c9638ce7aec56
Parents: ec2b6c2
Author: Huaxin Gao <hu...@oc0558782468.ibm.com>
Authored: Thu Dec 3 08:42:21 2015 +0000
Committer: Sean Owen <so...@cloudera.com>
Committed: Thu Dec 3 08:42:21 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/spark/blob/5349851f/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
index 392d3ed..b9dd7f6 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
@@ -498,7 +498,7 @@ private[sql] class JDBCRDD(
       }
       try {
         if (null != conn) {
-          if (!conn.getAutoCommit && !conn.isClosed) {
+          if (!conn.isClosed && !conn.getAutoCommit) {
             try {
               conn.commit()
             } catch {


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