cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosheduku...@apache.org
Subject git commit: updated refs/heads/master to bd3d828
Date Thu, 31 Jul 2014 10:30:59 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 45557cc02 -> bd3d8286d


Fixed a simple coverity issue


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

Branch: refs/heads/master
Commit: bd3d8286d3ff191f48a29b417b44b966974890d0
Parents: 45557cc
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Jul 31 16:00:42 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Thu Jul 31 16:00:42 2014 +0530

----------------------------------------------------------------------
 .../entity/api/db/dao/EngineHostDaoImpl.java    | 28 +++++++-------------
 1 file changed, 9 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd3d8286/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
index 35d7bbc..fd68c54 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
@@ -498,31 +498,21 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO,
Long> implem
     @Override
     public List<EngineHostVO> findLostHosts(long timeout) {
         TransactionLegacy txn = TransactionLegacy.currentTxn();
-        PreparedStatement pstmt = null;
         List<EngineHostVO> result = new ArrayList<EngineHostVO>();
-        ResultSet rs = null;
-        try {
-            String sql =
+        String sql =
                 "select h.id from host h left join  cluster c on h.cluster_id=c.id where
h.mgmt_server_id is not null and h.last_ping < ? and h.status in ('Up', 'Updating', 'Disconnected',
'Connecting') and h.type not in ('ExternalFirewall', 'ExternalLoadBalancer', 'TrafficMonitor',
'SecondaryStorage', 'LocalSecondaryStorage', 'L2Networking') and (h.cluster_id is null or
c.managed_state = 'Managed') ;";
-            pstmt = txn.prepareStatement(sql);
+        try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
             pstmt.setLong(1, timeout);
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long id = rs.getLong(1); //ID column
-                result.add(findById(id));
+            try(ResultSet rs = pstmt.executeQuery();) {
+                while (rs.next()) {
+                    long id = rs.getLong(1); //ID column
+                    result.add(findById(id));
+                }
+            }catch (Exception e) {
+                s_logger.warn("Exception: ", e);
             }
         } catch (Exception e) {
             s_logger.warn("Exception: ", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
         return result;
     }


Mime
View raw message