cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [24/30] git commit: updated refs/heads/master to 64ff67d
Date Fri, 14 Aug 2015 19:47:47 GMT
CLOUDSTACK-8656: reorganise sychronized block

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

Branch: refs/heads/master
Commit: 882de20e1cd077859d88a0eebc8dbf3717afb100
Parents: 07bee31
Author: Daan Hoogland <daan@onecht.net>
Authored: Fri Aug 14 16:03:17 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Fri Aug 14 16:03:17 2015 +0200

----------------------------------------------------------------------
 .../com/cloud/utils/db/ConnectionConcierge.java | 23 ++++++--------------
 1 file changed, 7 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/882de20e/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java b/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
index f5a3b2f..a1c473d 100644
--- a/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
+++ b/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
@@ -142,26 +142,17 @@ public class ConnectionConcierge {
         }
 
         protected String testValidity(String name, Connection conn) {
-            PreparedStatement pstmt = null;
-            try {
-                if (conn != null) {
-                    synchronized (conn) {
-                        pstmt = conn.prepareStatement("SELECT 1");
+            if (conn != null) {
+                synchronized (conn) {
+                    try (PreparedStatement pstmt = conn.prepareStatement("SELECT 1");) {
                         pstmt.executeQuery();
-                    }
-                }
-                return null;
-            } catch (Throwable th) {
-                s_logger.error("Unable to keep the db connection for " + name, th);
-                return th.toString();
-            } finally {
-                if (pstmt != null) {
-                    try {
-                        pstmt.close();
-                    } catch (SQLException e) {
+                    } catch (Throwable th) {
+                        s_logger.error("Unable to keep the db connection for " + name, th);
+                        return th.toString();
                     }
                 }
             }
+            return null;
         }
 
         @Override


Mime
View raw message