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 ef6ec7b
Date Thu, 13 Nov 2014 11:57:05 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master fc4dceaa9 -> ef6ec7b27


Fixed few coverity issues like invalid boxing unboxing issues, resource leaks, null dereferences


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

Branch: refs/heads/master
Commit: ef6ec7b27675ea44d45c68b30eb2f508655703be
Parents: fc4dcea
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Nov 13 17:25:26 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Thu Nov 13 17:26:24 2014 +0530

----------------------------------------------------------------------
 .../firewall/CreateEgressFirewallRuleCmd.java   |  7 +++---
 .../firewall/DeleteEgressFirewallRuleCmd.java   |  7 ++++--
 .../api/command/test/AddIpToVmNicTest.java      |  9 +-------
 .../manager/ClusteredAgentManagerImpl.java      | 11 ++++-----
 .../resource/VmwareStorageProcessor.java        |  7 +++---
 .../network/resource/JuniperSrxResource.java    | 20 ++++++++--------
 server/src/com/cloud/api/ApiServer.java         | 12 ++++++----
 .../cloud/ha/HighAvailabilityManagerImpl.java   | 24 +++++++++++---------
 .../com/cloud/resource/ResourceManagerImpl.java | 12 ++++++----
 utils/src/com/cloud/utils/net/NetUtils.java     | 10 +++++---
 10 files changed, 63 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
index 59af693..b130370 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
@@ -179,7 +179,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements
F
     @Override
     public Integer getSourcePortStart() {
         if (publicStartPort != null) {
-            return publicStartPort.intValue();
+            return publicStartPort;
         }
         return null;
     }
@@ -188,12 +188,11 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd
implements F
     public Integer getSourcePortEnd() {
         if (publicEndPort == null) {
             if (publicStartPort != null) {
-                return publicStartPort.intValue();
+                return publicStartPort;
             }
         } else {
-            return publicEndPort.intValue();
+            return publicEndPort;
         }
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java
index 17968fc..d08169d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java
@@ -115,8 +115,11 @@ public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd {
 
     @Override
     public Long getSyncObjId() {
-        return _firewallService.getFirewallRule(id).getNetworkId();
-    }
+        FirewallRule fw = _firewallService.getFirewallRule(id);
+        if (fw != null)
+            return fw.getNetworkId();
+        return null;
+     }
 
     @Override
     public ApiCommandJobType getInstanceType() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/api/test/org/apache/cloudstack/api/command/test/AddIpToVmNicTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/command/test/AddIpToVmNicTest.java b/api/test/org/apache/cloudstack/api/command/test/AddIpToVmNicTest.java
index 6f5ab3e..4139543 100644
--- a/api/test/org/apache/cloudstack/api/command/test/AddIpToVmNicTest.java
+++ b/api/test/org/apache/cloudstack/api/command/test/AddIpToVmNicTest.java
@@ -47,15 +47,10 @@ public class AddIpToVmNicTest extends TestCase {
     private ResponseGenerator responseGenerator;
     private SuccessResponse successResponseGenerator;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     @Override
     @Before
     public void setUp() {
-        addIpToVmNicCmd = new AddIpToVmNicCmd() {
-        };
-        removeIpFromVmNicCmd = new RemoveIpFromVmNicCmd();
+
     }
 
     @Test
@@ -108,8 +103,6 @@ public class AddIpToVmNicTest extends TestCase {
         Mockito.when(networkService.releaseSecondaryIpFromNic(Matchers.anyInt())).thenReturn(true);
 
         removeIpFromNic._networkService = networkService;
-        successResponseGenerator = Mockito.mock(SuccessResponse.class);
-
         removeIpFromNic.execute();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/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 4045fed..ca978ff 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -497,17 +497,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements
Clust
                 } catch (UnknownHostException e) {
                     throw new CloudRuntimeException("Unable to resolve " + ip);
                 }
-                try {
-                    ch = SocketChannel.open(new InetSocketAddress(addr, Port.value()));
-                    ch.configureBlocking(true); // make sure we are working at blocking mode
-                    ch.socket().setKeepAlive(true);
-                    ch.socket().setSoTimeout(60 * 1000);
+                try (SocketChannel ch1 = SocketChannel.open(new InetSocketAddress(addr, Port.value()));){
+                    ch1.configureBlocking(true); // make sure we are working at blocking
mode
+                    ch1.socket().setKeepAlive(true);
+                    ch1.socket().setSoTimeout(60 * 1000);
                     try {
                         SSLContext sslContext = Link.initSSLContext(true);
                         sslEngine = sslContext.createSSLEngine(ip, Port.value());
                         sslEngine.setUseClientMode(true);
 
-                        Link.doHandshake(ch, sslEngine, true);
+                        Link.doHandshake(ch1, sslEngine, true);
                         s_logger.info("SSL: Handshake done");
                     } catch (Exception e) {
                         throw new IOException("SSL: Fail to init SSL! " + e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index b256ae3..74f49b4 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -336,9 +336,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
             TemplateObjectTO newTemplate = new TemplateObjectTO();
 
             if (managed) {
-                String path = dsMo.getDatastorePath(managedStoragePoolRootVolumeName + ".vmdk");
-
-                newTemplate.setPath(path);
+                if(dsMo != null) {
+                    String path = dsMo.getDatastorePath(managedStoragePoolRootVolumeName
+ ".vmdk");
+                    newTemplate.setPath(path);
+                }
             }
             else {
                 newTemplate.setPath(templateUuidName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
index 2089b1d..b2f8596 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
@@ -191,16 +191,18 @@ public class JuniperSrxResource implements ServerResource {
                     throw new Exception("Failed to find Juniper SRX XML file: " + filename);
                 }
 
-                FileReader fr = new FileReader(xmlFilePath);
-                BufferedReader br = new BufferedReader(fr);
-
-                String xml = "";
-                String line;
-                while ((line = br.readLine()) != null) {
-                    xml += line.trim();
+                try(FileReader fr = new FileReader(xmlFilePath);
+                BufferedReader br = new BufferedReader(fr);) {
+                    String xml = "";
+                    String line;
+                    while ((line = br.readLine()) != null) {
+                        xml += line.trim();
+                    }
+                    return xml;
+                }catch (Exception e) {
+                    s_logger.debug(e);
+                    return null;
                 }
-
-                return xml;
             } catch (Exception e) {
                 s_logger.debug(e);
                 return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 2156d60..b335a66 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -401,12 +401,14 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
             // Map<String, Collection<String>> parameterMap = paramMultiMap.asMap();
             final Map parameterMap = new HashMap<String, String[]>();
             String responseType = HttpUtils.RESPONSE_TYPE_XML;
-            for (final NameValuePair param : paramList) {
-                if (param.getName().equalsIgnoreCase("response")) {
-                    responseType = param.getValue();
-                    continue;
+            if(paramList != null) {
+                for (final NameValuePair param : paramList) {
+                    if (param.getName().equalsIgnoreCase("response")) {
+                        responseType = param.getValue();
+                        continue;
+                    }
+                    parameterMap.put(param.getName(), new String[]{param.getValue()});
                 }
-                parameterMap.put(param.getName(), new String[] {param.getValue()});
             }
 
             // Get the type of http method being used.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index fabdde6..7cc63df 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -265,18 +265,20 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements
HighAvai
             "] is down." +
             ((sb != null) ? sb.toString() : ""));
 
-        for (VMInstanceVO vm : vms) {
-            if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Notifying HA Mgr of to restart vm " + vm.getId() + "-" +
vm.getInstanceName());
-            }
-            vm = _instanceDao.findByUuid(vm.getUuid());
-            Long hostId = vm.getHostId();
-            if ( hostId != null && !hostId.equals(host.getId()) ) {
-                s_logger.debug("VM " + vm.getInstanceName() + " is not on down host " + host.getId()
+ " it is on other host "
-                        + hostId + " VM HA is done");
-                continue;
+        if (vms != null) {
+            for (VMInstanceVO vm : vms) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Notifying HA Mgr of to restart vm " + vm.getId() + "-"
+ vm.getInstanceName());
+                }
+                vm = _instanceDao.findByUuid(vm.getUuid());
+                Long hostId = vm.getHostId();
+                if (hostId != null && !hostId.equals(host.getId())) {
+                    s_logger.debug("VM " + vm.getInstanceName() + " is not on down host "
+ host.getId() + " it is on other host "
+                            + hostId + " VM HA is done");
+                    continue;
+                }
+                scheduleRestart(vm, investigate);
             }
-            scheduleRestart(vm, investigate);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 5cc2d36..30d8568 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -1632,12 +1632,14 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
             try {
                 clusterId = Long.valueOf(cluster);
             } catch (NumberFormatException e) {
-                ClusterVO c = _clusterDao.findBy(cluster, podId);
-                if (c == null) {
-                    c = new ClusterVO(dcId, podId, cluster);
-                    c = _clusterDao.persist(c);
+                if (podId != null) {
+                    ClusterVO c = _clusterDao.findBy(cluster, podId.longValue());
+                    if (c == null) {
+                        c = new ClusterVO(dcId, podId.longValue(), cluster);
+                        c = _clusterDao.persist(c);
+                    }
+                    clusterId = c.getId();
                 }
-                clusterId = c.getId();
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef6ec7b2/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index 016ad47..0eda3f8 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -1317,11 +1317,15 @@ public class NetUtils {
         BigInteger startInt = convertIPv6AddressToBigInteger(start);
         BigInteger endInt = convertIPv6AddressToBigInteger(end);
         if (endInt != null) {
-            if (startInt.compareTo(endInt) > 0) {
-                return null;
+            if (startInt != null)
+            {
+                if(startInt.compareTo(endInt) > 0) {
+                    return null;
+                }
             }
+            return endInt.subtract(startInt).add(BigInteger.ONE);
         }
-        return endInt.subtract(startInt).add(BigInteger.ONE);
+        return null;
     }
 
     public static boolean isIp6InRange(String ip6, String ip6Range) {


Mime
View raw message