cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [01/20] git commit: updated refs/heads/4.5 to 64e938b
Date Mon, 02 Feb 2015 10:16:59 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.5 1bab1d085 -> 64e938b70


Fixed few coverity patches

NPE in delete firewall rules observed, cherry-picking fix from master.

(cherry picked from commit 31a42d2b7a5a9d3dbf10dc680d7e8877ed4e40c6)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 737edd90dc253789e442634b389ca5db835ee6e0
Parents: 1bab1d0
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Oct 9 11:42:49 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Feb 2 12:48:38 2015 +0530

----------------------------------------------------------------------
 .../admin/network/UpdatePhysicalNetworkCmd.java |   8 +-
 .../user/firewall/DeleteFirewallRuleCmd.java    |   5 +-
 .../command/user/vpn/UpdateVpnGatewayCmd.java   |   6 +-
 .../manager/ClusteredAgentManagerImpl.java      |  43 +++----
 .../src/com/cloud/utils/db/GenericDaoBase.java  | 122 +++++++++----------
 .../cloudstack/discovery/ApiDiscoveryTest.java  |  24 ++--
 .../cloud/network/element/NuageVspElement.java  |   6 +-
 utils/src/com/cloud/utils/script/Script.java    |  24 ++--
 8 files changed, 121 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
index 8e29c39..ed3fa97 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
@@ -97,9 +97,11 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
     @Override
     public void execute() {
         PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(),
getTags(), getVlan(), getState());
-        PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
+        if (result != null) {
+            PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java
index f8d1c18..0f10012 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java
@@ -113,7 +113,10 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd {
 
     @Override
     public Long getSyncObjId() {
-        return _firewallService.getFirewallRule(id).getNetworkId();
+        FirewallRule fwlrule = _firewallService.getFirewallRule(id);
+        if (fwlrule != null)
+            return fwlrule.getNetworkId();
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java
index 66c59ad..bbe820a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java
@@ -85,8 +85,10 @@ public class UpdateVpnGatewayCmd extends BaseAsyncCustomIdCmd {
     @Override
     public void execute() {
         Site2SiteVpnGateway result = _s2sVpnService.updateVpnGateway(id, this.getCustomId(),
getDisplay());
-        Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
-        response.setResponseName(getCommandName());
+        if (result != null) {
+            Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
+            response.setResponseName(getCommandName());
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 72d7c3b..600dca2 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -195,35 +195,36 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements
Clust
         long cutSeconds = (System.currentTimeMillis() >> 10) - getTimeout();
         List<HostVO> hosts = _hostDao.findAndUpdateDirectAgentToLoad(cutSeconds, LoadSize.value().longValue(),
_nodeId);
         List<HostVO> appliances = _hostDao.findAndUpdateApplianceToLoad(cutSeconds,
_nodeId);
-        hosts.addAll(appliances);
 
-        if (hosts != null && hosts.size() > 0) {
-            s_logger.debug("Found " + hosts.size() + " unmanaged direct hosts, processing
connect for them...");
-            for (HostVO host : hosts) {
-                try {
-                    AgentAttache agentattache = findAttache(host.getId());
-                    if (agentattache != null) {
-                        // already loaded, skip
-                        if (agentattache.forForward()) {
-                            if (s_logger.isInfoEnabled()) {
-                                s_logger.info(host + " is detected down, but we have a forward
attache running, disconnect this one before launching the host");
+       if (hosts != null) {
+            hosts.addAll(appliances);
+            if (hosts.size() > 0) {
+                s_logger.debug("Found " + hosts.size() + " unmanaged direct hosts, processing
connect for them...");
+                for (HostVO host : hosts) {
+                    try {
+                        AgentAttache agentattache = findAttache(host.getId());
+                        if (agentattache != null) {
+                            // already loaded, skip
+                            if (agentattache.forForward()) {
+                                if (s_logger.isInfoEnabled()) {
+                                    s_logger.info(host + " is detected down, but we have
a forward attache running, disconnect this one before launching the host");
+                                }
+                                removeAgent(agentattache, Status.Disconnected);
+                            } else {
+                                continue;
                             }
-                            removeAgent(agentattache, Status.Disconnected);
-                        } else {
-                            continue;
                         }
-                    }
 
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Loading directly connected host " + host.getId()
+ "(" + host.getName() + ")");
+                        if (s_logger.isDebugEnabled()) {
+                            s_logger.debug("Loading directly connected host " + host.getId()
+ "(" + host.getName() + ")");
+                        }
+                        loadDirectlyConnectedHost(host, false);
+                    } catch (Throwable e) {
+                        s_logger.warn(" can not load directly connected host " + host.getId()
+ "(" + host.getName() + ") due to ", e);
                     }
-                    loadDirectlyConnectedHost(host, false);
-                } catch (Throwable e) {
-                    s_logger.warn(" can not load directly connected host " + host.getId()
+ "(" + host.getName() + ") due to ", e);
                 }
             }
         }
-
         if (s_logger.isTraceEnabled()) {
             s_logger.trace("End scanning directly connected hosts");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
index 4c47404..e75646a 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@@ -1641,81 +1641,71 @@ public abstract class GenericDaoBase<T, ID extends Serializable>
extends Compone
     @SuppressWarnings("unchecked")
     protected void loadCollection(T entity, Attribute attr) {
         EcInfo ec = (EcInfo)attr.attache;
-
         TransactionLegacy txn = TransactionLegacy.currentTxn();
-        ResultSet rs = null;
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = txn.prepareStatement(ec.selectSql);
+        try(PreparedStatement pstmt = txn.prepareStatement(ec.selectSql);)
+        {
             pstmt.setObject(1, _idField.get(entity));
-            rs = pstmt.executeQuery();
-            ArrayList lst = new ArrayList();
-            if (ec.targetClass == Integer.class) {
-                while (rs.next()) {
-                    lst.add(rs.getInt(1));
-                }
-            } else if (ec.targetClass == Long.class) {
-                while (rs.next()) {
-                    lst.add(rs.getLong(1));
-                }
-            } else if (ec.targetClass == String.class) {
-                while (rs.next()) {
-                    lst.add(rs.getString(1));
-                }
-            } else if (ec.targetClass == Short.class) {
-                while (rs.next()) {
-                    lst.add(rs.getShort(1));
-                }
-            } else if (ec.targetClass == Date.class) {
-                while (rs.next()) {
-                    lst.add(DateUtil.parseDateString(s_gmtTimeZone, rs.getString(1)));
+            try(ResultSet rs = pstmt.executeQuery();)
+            {
+                ArrayList lst = new ArrayList();
+                if (ec.targetClass == Integer.class) {
+                    while (rs.next()) {
+                        lst.add(rs.getInt(1));
+                    }
+                } else if (ec.targetClass == Long.class) {
+                    while (rs.next()) {
+                        lst.add(rs.getLong(1));
+                    }
+                } else if (ec.targetClass == String.class) {
+                    while (rs.next()) {
+                        lst.add(rs.getString(1));
+                    }
+                } else if (ec.targetClass == Short.class) {
+                    while (rs.next()) {
+                        lst.add(rs.getShort(1));
+                    }
+                } else if (ec.targetClass == Date.class) {
+                    while (rs.next()) {
+                        lst.add(DateUtil.parseDateString(s_gmtTimeZone, rs.getString(1)));
+                    }
+                } else if (ec.targetClass == Boolean.class) {
+                    while (rs.next()) {
+                        lst.add(rs.getBoolean(1));
+                    }
+                } else {
+                    assert (false) : "You'll need to add more classeses";
                 }
-            } else if (ec.targetClass == Boolean.class) {
-                while (rs.next()) {
-                    lst.add(rs.getBoolean(1));
+                if (ec.rawClass == null) {
+                    Object[] array = (Object[]) Array.newInstance(ec.targetClass);
+                    lst.toArray(array);
+                    try {
+                        attr.field.set(entity, array);
+                    } catch (IllegalArgumentException e) {
+                        throw new CloudRuntimeException("Come on we screen for this stuff,
don't we?", e);
+                    } catch (IllegalAccessException e) {
+                        throw new CloudRuntimeException("Come on we screen for this stuff,
don't we?", e);
+                    }
+                } else {
+                    try {
+                        Collection coll = (Collection) ec.rawClass.newInstance();
+                        coll.addAll(lst);
+                        attr.field.set(entity, coll);
+                    } catch (IllegalAccessException e) {
+                        throw new CloudRuntimeException("Come on we screen for this stuff,
don't we?", e);
+                    } catch (InstantiationException e) {
+                        throw new CloudRuntimeException("Never should happen", e);
+                    }
                 }
-            } else {
-                assert (false) : "You'll need to add more classeses";
             }
-
-            if (ec.rawClass == null) {
-                Object[] array = (Object[])Array.newInstance(ec.targetClass);
-                lst.toArray(array);
-                try {
-                    attr.field.set(entity, array);
-                } catch (IllegalArgumentException e) {
-                    throw new CloudRuntimeException("Come on we screen for this stuff, don't
we?", e);
-                } catch (IllegalAccessException e) {
-                    throw new CloudRuntimeException("Come on we screen for this stuff, don't
we?", e);
-                }
-            } else {
-                try {
-                    Collection coll = (Collection)ec.rawClass.newInstance();
-                    coll.addAll(lst);
-                    attr.field.set(entity, coll);
-                } catch (IllegalAccessException e) {
-                    throw new CloudRuntimeException("Come on we screen for this stuff, don't
we?", e);
-                } catch (InstantiationException e) {
-                    throw new CloudRuntimeException("Never should happen", e);
-                }
+            catch (SQLException e) {
+                throw new CloudRuntimeException("loadCollection: Exception : " +e.getMessage(),
e);
             }
         } catch (SQLException e) {
-            throw new CloudRuntimeException("Error executing " + pstmt, e);
+            throw new CloudRuntimeException("loadCollection: Exception : " +e.getMessage(),
e);
         } catch (IllegalArgumentException e) {
-            throw new CloudRuntimeException("Error executing " + pstmt, e);
+            throw new CloudRuntimeException("loadCollection: Exception : " +e.getMessage(),
e);
         } catch (IllegalAccessException e) {
-            throw new CloudRuntimeException("Error executing " + pstmt, e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-                s_logger.error("Why are we getting an exception at close? ", e);
-            }
+            throw new CloudRuntimeException("loadCollection: Exception : " +e.getMessage(),
e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
b/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
index 30cb0bc..49bf5a5 100644
--- a/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
+++ b/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
@@ -82,21 +82,25 @@ public class ApiDiscoveryTest {
     @Test
     public void verifyListSingleApi() throws Exception {
         ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser,
testApiName);
-        ApiDiscoveryResponse response = responses.getResponses().get(0);
-        assertTrue("No. of response items should be one", responses.getCount() == 1);
-        assertEquals("Error in api name", testApiName, response.getName());
-        assertEquals("Error in api description", testApiDescription, response.getDescription());
-        assertEquals("Error in api since", testApiSince, response.getSince());
-        assertEquals("Error in api isAsync", testApiAsync, response.getAsync());
+        if (responses != null) {
+            ApiDiscoveryResponse response = responses.getResponses().get(0);
+            assertTrue("No. of response items should be one", responses.getCount() == 1);
+            assertEquals("Error in api name", testApiName, response.getName());
+            assertEquals("Error in api description", testApiDescription, response.getDescription());
+            assertEquals("Error in api since", testApiSince, response.getSince());
+            assertEquals("Error in api isAsync", testApiAsync, response.getAsync());
+        }
     }
 
     @Test
     public void verifyListApis() throws Exception {
         ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser,
null);
-        assertTrue("No. of response items > 1", responses.getCount() == 1);
-        for (ApiDiscoveryResponse response : responses.getResponses()) {
-            assertFalse("API name is empty", response.getName().isEmpty());
-            assertFalse("API description is empty", response.getDescription().isEmpty());
+        if (responses != null) {
+            assertTrue("No. of response items > 1", responses.getCount().intValue() ==
1);
+            for (ApiDiscoveryResponse response : responses.getResponses()) {
+                assertFalse("API name is empty", response.getName().isEmpty());
+                assertFalse("API description is empty", response.getDescription().isEmpty());
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
index 06f9733..e777268 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
@@ -405,13 +405,15 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
 
     @Override
     public boolean applyNetworkACLs(Network network, List<? extends NetworkACLItem>
rules) throws ResourceUnavailableException {
-        s_logger.debug("Handling applyNetworkACLs for network " + network.getName() + " with
" + rules.size() + " Network ACLs");
         if (rules == null || rules.isEmpty()) {
             s_logger.debug("No rules to apply. So, delete all the existing ACL in VSP from
Subnet with uuid " + network.getUuid());
         } else {
             s_logger.debug("New rules has to applied. So, delete all the existing ACL in
VSP from Subnet with uuid " + network.getUuid());
         }
-        applyACLRules(network, rules, true);
+        if (rules != null) {
+            s_logger.debug("Handling applyNetworkACLs for network " + network.getName() +
" with " + rules.size() + " Network ACLs");
+            applyACLRules(network, rules, true);
+        }
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/737edd90/utils/src/com/cloud/utils/script/Script.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/script/Script.java b/utils/src/com/cloud/utils/script/Script.java
index 9713b14..49734ae 100755
--- a/utils/src/com/cloud/utils/script/Script.java
+++ b/utils/src/com/cloud/utils/script/Script.java
@@ -313,19 +313,19 @@ public class Script implements Callable<String> {
 
         @Override
         public void run() {
-            done = false;
-            try {
-                result = interpreter.interpret(reader);
-            } catch (IOException ex) {
-                result = stackTraceAsString(ex);
-            } catch (Exception ex) {
-                result = stackTraceAsString(ex);
-            } finally {
-                synchronized (this) {
-                    done = true;
-                    notifyAll();
+            synchronized(this) {
+                done = false;
+                try {
+                    result = interpreter.interpret(reader);
+                } catch (IOException ex) {
+                    result = stackTraceAsString(ex);
+                } catch (Exception ex) {
+                    result = stackTraceAsString(ex);
+                } finally {
+                        done = true;
+                        notifyAll();
+                        IOUtils.closeQuietly(reader);
                 }
-                IOUtils.closeQuietly(reader);
             }
         }
 


Mime
View raw message