camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/8] camel git commit: CAMEL-9845: camel-jdbc - Silent ignore close errors
Date Sat, 09 Apr 2016 07:23:28 GMT
CAMEL-9845: camel-jdbc - Silent ignore close errors


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

Branch: refs/heads/camel-2.16.x
Commit: eed00f12de3fe87d3ab9c76ee2266e0ca5ee44a4
Parents: 9160475
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Apr 9 09:19:18 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Apr 9 09:23:11 2016 +0200

----------------------------------------------------------------------
 .../camel/component/jdbc/JdbcProducer.java      | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eed00f12/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index 5d45864..9e05937 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -91,7 +91,7 @@ public class JdbcProducer extends DefaultProducer {
                 if (conn != null) {
                     conn.rollback();
                 }
-            } catch (SQLException sqle) {
+            } catch (Throwable sqle) {
                 LOG.warn("Error occurred during jdbc rollback. This exception will be ignored.",
sqle);
             }
             throw e;
@@ -246,9 +246,11 @@ public class JdbcProducer extends DefaultProducer {
     private void closeQuietly(ResultSet rs) {
         if (rs != null) {
             try {
-                rs.close();
-            } catch (SQLException sqle) {
-                LOG.warn("Error by closing result set: " + sqle, sqle);
+                if (!rs.isClosed()) {
+                    rs.close();
+                }
+            } catch (Throwable sqle) {
+                LOG.debug("Error by closing result set", sqle);
             }
         }
     }
@@ -256,9 +258,11 @@ public class JdbcProducer extends DefaultProducer {
     private void closeQuietly(Statement stmt) {
         if (stmt != null) {
             try {
-                stmt.close();
-            } catch (SQLException sqle) {
-                LOG.warn("Error by closing statement: " + sqle, sqle);
+                if (!stmt.isClosed()) {
+                    stmt.close();
+                }
+            } catch (Throwable sqle) {
+                LOG.debug("Error by closing statement", sqle);
             }
         }
     }
@@ -267,8 +271,8 @@ public class JdbcProducer extends DefaultProducer {
         if (con != null && autoCommit != null) {
             try {
                 con.setAutoCommit(autoCommit);
-            } catch (SQLException sqle) {
-                LOG.warn("Error by resetting auto commit to its original value: " + sqle,
sqle);
+            } catch (Throwable sqle) {
+                LOG.debug("Error by resetting auto commit to its original value", sqle);
             }
         }
     }
@@ -276,9 +280,11 @@ public class JdbcProducer extends DefaultProducer {
     private void closeQuietly(Connection con) {
         if (con != null) {
             try {
-                con.close();
-            } catch (SQLException sqle) {
-                LOG.warn("Error by closing connection: " + sqle, sqle);
+                if (!con.isClosed()) {
+                    con.close();
+                }
+            } catch (Throwable sqle) {
+                LOG.debug("Error by closing connection", sqle);
             }
         }
     }


Mime
View raw message