cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amog...@apache.org
Subject git commit: updated refs/heads/master to c804660
Date Wed, 23 Jul 2014 18:59:46 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master bb1c70b3d -> c804660c7


CLOUDSTACK-7168: Revert "Fixed Coverity Issues reported" that broke CI

This reverts commit 4523490d44160b054de9e943f72db1d0ce06054a.


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

Branch: refs/heads/master
Commit: c804660c74f08008be4f71607681c83d31f3cc55
Parents: bb1c70b
Author: amoghvk <amogh.vasekar@citrix.com>
Authored: Wed Jul 23 11:37:36 2014 -0700
Committer: amoghvk <amogh.vasekar@citrix.com>
Committed: Wed Jul 23 11:37:36 2014 -0700

----------------------------------------------------------------------
 .../api/command/user/vm/DeployVMCmd.java        |   4 +-
 .../storage/dao/VMTemplatePoolDaoImpl.java      |  67 ++++++++----
 .../com/cloud/upgrade/dao/Upgrade440to450.java  |   5 +-
 .../endpoint/DefaultEndPointSelector.java       |  28 +++--
 .../storage/volume/VolumeServiceImpl.java       |   5 +-
 .../kvm/resource/BridgeVifDriver.java           |  24 ++---
 server/src/com/cloud/api/ApiResponseHelper.java |  76 ++++++--------
 .../src/com/cloud/api/doc/ApiXmlDocWriter.java  |  25 ++---
 .../com/cloud/resource/ResourceManagerImpl.java |  21 ++--
 .../cloud/server/ConfigurationServerImpl.java   |   6 +-
 utils/src/com/cloud/utils/nio/NioClient.java    | 104 +++++++++----------
 11 files changed, 193 insertions(+), 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 14b703c..1beb595 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -225,8 +225,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
             Iterator iter = parameterCollection.iterator();
             while (iter.hasNext()) {
                 HashMap<String, String> value = (HashMap<String, String>)iter.next();
-                for (Map.Entry<String,String> entry: value.entrySet()) {
-                    customparameterMap.put(entry.getKey(),entry.getValue());
+                for (String key : value.keySet()) {
+                    customparameterMap.put(key, value.get(key));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/engine/schema/src/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java
index aacd4ff..12a0921 100644
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java
@@ -18,6 +18,7 @@ package com.cloud.storage.dao;
 
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -169,25 +170,36 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV
     @Override
     public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, long
datacenterId, long podId, VMTemplateStoragePoolVO.Status downloadState) {
         TransactionLegacy txn = TransactionLegacy.currentTxn();
+        PreparedStatement pstmt = null;
         List<VMTemplateStoragePoolVO> result = new ArrayList<VMTemplateStoragePoolVO>();
-        String sql = DOWNLOADS_STATE_DC_POD;
-        try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
+        ResultSet rs = null;
+        try {
+            String sql = DOWNLOADS_STATE_DC_POD;
+            pstmt = txn.prepareStatement(sql);
+
             pstmt.setLong(1, datacenterId);
             pstmt.setLong(2, podId);
             pstmt.setLong(3, templateId);
             pstmt.setString(4, downloadState.toString());
-            try(ResultSet rs = pstmt.executeQuery();) {
-                while (rs.next()) {
-                    // result.add(toEntityBean(rs, false)); TODO: this is buggy in
-                    // GenericDaoBase for hand constructed queries
-                    long id = rs.getLong(1); // ID column
-                    result.add(findById(id));
-                }
-            }catch (Exception e) {
-                s_logger.warn("Exception: ", e);
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                // result.add(toEntityBean(rs, false)); TODO: this is buggy in
+                // GenericDaoBase for hand constructed queries
+                long id = rs.getLong(1); // ID column
+                result.add(findById(id));
             }
         } 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;
 
@@ -195,23 +207,34 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV
 
     public List<VMTemplateStoragePoolVO> listByHostTemplate(long hostId, long templateId)
{
         TransactionLegacy txn = TransactionLegacy.currentTxn();
+        PreparedStatement pstmt = null;
         List<VMTemplateStoragePoolVO> result = new ArrayList<VMTemplateStoragePoolVO>();
-        String sql = HOST_TEMPLATE_SEARCH;
-        try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
+        ResultSet rs = null;
+        try {
+            String sql = HOST_TEMPLATE_SEARCH;
+            pstmt = txn.prepareStatement(sql);
+
             pstmt.setLong(1, hostId);
             pstmt.setLong(2, templateId);
-            try(ResultSet rs = pstmt.executeQuery();) {
-                while (rs.next()) {
-                    // result.add(toEntityBean(rs, false)); TODO: this is buggy in
-                    // GenericDaoBase for hand constructed queries
-                    long id = rs.getLong(1); // ID column
-                    result.add(findById(id));
-                }
-            }catch (Exception e) {
-                s_logger.warn("Exception: ", e);
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                // result.add(toEntityBean(rs, false)); TODO: this is buggy in
+                // GenericDaoBase for hand constructed queries
+                long id = rs.getLong(1); // ID column
+                result.add(findById(id));
             }
         } 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;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java
index aad5162..caf3b42 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java
@@ -22,7 +22,6 @@ import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.log4j.Logger;
 
@@ -81,8 +80,8 @@ public class Upgrade440to450 implements DbUpgrade {
         uniqueKeys.put("storage_pool", keys);
 
         s_logger.debug("Droping id_2 key from storage_pool table");
-        for (Map.Entry<String, List<String>> entry: uniqueKeys.entrySet()) {
-            DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(), entry.getValue(), false);
+        for (String tableName : uniqueKeys.keySet()) {
+            DbUpgradeUtils.dropKeysIfExist(conn, tableName, uniqueKeys.get(tableName), false);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index 0a867f6..f06b43e 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -115,21 +115,33 @@ public class DefaultEndPointSelector implements EndPointSelector {
         // TODO: order by rand() is slow if there are lot of hosts
         sbuilder.append(" ORDER by rand() limit 1");
         String sql = sbuilder.toString();
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
         HostVO host = null;
         TransactionLegacy txn = TransactionLegacy.currentTxn();
-        try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
+
+        try {
+            pstmt = txn.prepareStatement(sql);
             pstmt.setLong(1, poolId);
-            try(ResultSet rs = pstmt.executeQuery();) {
-                while (rs.next()) {
-                    long id = rs.getLong(1);
-                    host = hostDao.findById(id);
-                }
-            }catch (SQLException e) {
-                s_logger.warn("can't find endpoint", e);
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                long id = rs.getLong(1);
+                host = hostDao.findById(id);
             }
         } catch (SQLException e) {
             s_logger.warn("can't find endpoint", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
         }
+
         if (host == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 821c939..3fc43ea 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -1464,9 +1464,8 @@ public class VolumeServiceImpl implements VolumeService {
                     }
 
                     // Delete volumes which are not present on DB.
-                    for (Map.Entry<Long,TemplateProp> entry : volumeInfos.entrySet())
{
-                        Long uniqueName = entry.getKey();
-                        TemplateProp tInfo = entry.getValue();
+                    for (Long uniqueName : volumeInfos.keySet()) {
+                        TemplateProp tInfo = volumeInfos.get(uniqueName);
 
                         //we cannot directly call expungeVolumeAsync here to
                         // reuse delete logic since in this case, our db does not have

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
index 3b034bb..e684b8d 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
@@ -104,16 +104,16 @@ public class BridgeVifDriver extends VifDriverBase {
         String trafficLabel = nic.getName();
         if (nic.getType() == Networks.TrafficType.Guest) {
             Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue()
!= -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
-            if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) &&
(vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged"))
||
-                    (nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
-                    if (trafficLabel != null && !trafficLabel.isEmpty()) {
-                        s_logger.debug("creating a vNet dev and bridge for guest traffic
per traffic label " + trafficLabel);
-                        String brName = createVnetBr(vNetId, trafficLabel, protocol);
-                        intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter), networkRateKBps);
-                    } else {
-                        String brName = createVnetBr(vNetId, "private", protocol);
-                        intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter), networkRateKBps);
-                    }
+            if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("untagged")
||
+                nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
+                if (trafficLabel != null && !trafficLabel.isEmpty()) {
+                    s_logger.debug("creating a vNet dev and bridge for guest traffic per
traffic label " + trafficLabel);
+                    String brName = createVnetBr(vNetId, trafficLabel, protocol);
+                    intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter), networkRateKBps);
+                } else {
+                    String brName = createVnetBr(vNetId, "private", protocol);
+                    intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter), networkRateKBps);
+                }
             } else {
                 intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter), networkRateKBps);
             }
@@ -123,8 +123,8 @@ public class BridgeVifDriver extends VifDriverBase {
             intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType,
nicAdapter));
         } else if (nic.getType() == Networks.TrafficType.Public) {
             Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue()
!= -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
-            if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) &&
(vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged"))
||
-                    (nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
+            if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("untagged")
||
+                nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
                 if (trafficLabel != null && !trafficLabel.isEmpty()) {
                     s_logger.debug("creating a vNet dev and bridge for public traffic per
traffic label " + trafficLabel);
                     String brName = createVnetBr(vNetId, trafficLabel, protocol);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 70ed47d..013da0b 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1026,24 +1026,20 @@ public class ApiResponseHelper implements ResponseGenerator {
 
 
         IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
+        response.setPublicIpAddressId(ip.getUuid());
+        response.setPublicIpAddress(ip.getAddress().addr());
 
-        if (ip != null)
-        {
-            response.setPublicIpAddressId(ip.getUuid());
-            response.setPublicIpAddress(ip.getAddress().addr());
-            if (fwRule.getDestinationIpAddress() != null)
-            {
-                response.setDestNatVmIp(fwRule.getDestinationIpAddress().toString());
-                UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId());
-                if (vm != null) {
-                    response.setVirtualMachineId(vm.getUuid());
-                    response.setVirtualMachineName(vm.getHostName());
+        if (ip != null && fwRule.getDestinationIpAddress() != null) {
+            response.setDestNatVmIp(fwRule.getDestinationIpAddress().toString());
+            UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId());
+            if (vm != null) {
+                response.setVirtualMachineId(vm.getUuid());
+                response.setVirtualMachineName(vm.getHostName());
 
-                    if (vm.getDisplayName() != null) {
-                        response.setVirtualMachineDisplayName(vm.getDisplayName());
-                    } else {
-                        response.setVirtualMachineDisplayName(vm.getHostName());
-                    }
+                if (vm.getDisplayName() != null) {
+                    response.setVirtualMachineDisplayName(vm.getDisplayName());
+                } else {
+                    response.setVirtualMachineDisplayName(vm.getHostName());
                 }
             }
         }
@@ -1075,20 +1071,18 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setProtocol(fwRule.getProtocol());
 
         IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
-
-        if (ip != null) {
-            response.setPublicIpAddressId(ip.getId());
-            response.setPublicIpAddress(ip.getAddress().addr());
-            if (fwRule.getDestIpAddress() != null) {
-                UserVm vm = ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
-                if (vm != null) {// vm might be destroyed
-                    response.setVirtualMachineId(vm.getUuid());
-                    response.setVirtualMachineName(vm.getHostName());
-                    if (vm.getDisplayName() != null) {
-                        response.setVirtualMachineDisplayName(vm.getDisplayName());
-                    } else {
-                        response.setVirtualMachineDisplayName(vm.getHostName());
-                    }
+        response.setPublicIpAddressId(ip.getId());
+        response.setPublicIpAddress(ip.getAddress().addr());
+
+        if (ip != null && fwRule.getDestIpAddress() != null) {
+            UserVm vm = ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
+            if (vm != null) {// vm might be destroyed
+                response.setVirtualMachineId(vm.getUuid());
+                response.setVirtualMachineName(vm.getHostName());
+                if (vm.getDisplayName() != null) {
+                    response.setVirtualMachineDisplayName(vm.getDisplayName());
+                } else {
+                    response.setVirtualMachineDisplayName(vm.getHostName());
                 }
             }
         }
@@ -1707,9 +1701,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
-        for (Map.Entry<Service,Set<Provider>> entry : serviceProviderMap.entrySet())
{
-            Service service = entry.getKey();
-            Set<Provider> srvc_providers = entry.getValue();
+        for (Service service : serviceProviderMap.keySet()) {
             ServiceResponse svcRsp = new ServiceResponse();
             // skip gateway service
             if (service == Service.Gateway) {
@@ -1717,7 +1709,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
             svcRsp.setName(service.getName());
             List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
-            for (Provider provider : srvc_providers) {
+            for (Provider provider : serviceProviderMap.get(service)) {
                 if (provider != null) {
                     ProviderResponse providerRsp = new ProviderResponse();
                     providerRsp.setName(provider.getName());
@@ -1964,9 +1956,8 @@ public class ApiResponseHelper implements ResponseGenerator {
             Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId);
             if (domain != null) {
                 response.setDomainId(domain.getUuid());
-                response.setDomainName(domain.getName());
             }
-
+            response.setDomainName(domain.getName());
         }
 
         response.setSpecifyIpRanges(network.getSpecifyIpRanges());
@@ -2572,10 +2563,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
-        for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet())
{
-            Service service = entry.getKey();
-            Set<Provider> srvc_providers = entry.getValue();
-
+        for (Service service : serviceProviderMap.keySet()) {
             ServiceResponse svcRsp = new ServiceResponse();
             // skip gateway service
             if (service == Service.Gateway) {
@@ -2583,7 +2571,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
             svcRsp.setName(service.getName());
             List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
-            for (Provider provider : srvc_providers) {
+            for (Provider provider : serviceProviderMap.get(service)) {
                 if (provider != null) {
                     ProviderResponse providerRsp = new ProviderResponse();
                     providerRsp.setName(provider.getName());
@@ -3126,6 +3114,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         } else if (usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType()
== UsageTypes.ISO) {
             //Template/ISO ID
             VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
+            usageRecResponse.setUsageId(tmpl.getUuid());
             if (tmpl != null) {
                 usageRecResponse.setUsageId(tmpl.getUuid());
             }
@@ -3400,11 +3389,10 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         //set Lb instances information
         List<ApplicationLoadBalancerInstanceResponse> instanceResponses = new ArrayList<ApplicationLoadBalancerInstanceResponse>();
-        for (Map.Entry<Ip,UserVm> entry : lbInstances.entrySet()) {
-            Ip ip = entry.getKey();
-            UserVm vm = entry.getValue();
+        for (Ip ip : lbInstances.keySet()) {
             ApplicationLoadBalancerInstanceResponse instanceResponse = new ApplicationLoadBalancerInstanceResponse();
             instanceResponse.setIpAddress(ip.addr());
+            UserVm vm = lbInstances.get(ip);
             instanceResponse.setId(vm.getUuid());
             instanceResponse.setName(vm.getInstanceName());
             instanceResponse.setObjectName("loadbalancerinstance");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
index 6824185..fe07056 100644
--- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
+++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
@@ -144,8 +144,10 @@ public class ApiXmlDocWriter {
         }
 
         for (String fileName : fileNames) {
-            try(FileInputStream in = new FileInputStream(fileName);) {
+            try {
+                FileInputStream in = new FileInputStream(fileName);
                 preProcessedCommands.load(in);
+                in.close();
             } catch (FileNotFoundException ex) {
                 System.out.println("Can't find file " + fileName);
                 System.exit(2);
@@ -593,17 +595,14 @@ public class ApiXmlDocWriter {
                 addDir(files[i], out);
                 continue;
             }
-            try(FileInputStream in = new FileInputStream(files[i].getPath());) {
-                out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length())));
-                int len;
-                while ((len = in.read(tmpBuf)) > 0) {
-                    out.write(tmpBuf, 0, len);
-                }
-                out.closeEntry();
-            }catch(IOException ex)
-            {
-                s_logger.error("addDir:Exception:"+ ex.getMessage(),ex);
+            FileInputStream in = new FileInputStream(files[i].getPath());
+            out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length())));
+            int len;
+            while ((len = in.read(tmpBuf)) > 0) {
+                out.write(tmpBuf, 0, len);
             }
+            out.closeEntry();
+            in.close();
         }
     }
 
@@ -620,7 +619,8 @@ public class ApiXmlDocWriter {
     private static void writeAlertTypes(String dirName) {
         XStream xs = new XStream();
         xs.alias("alert", Alert.class);
-        try(ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName +
"/alert_types.xml"), "alerts");) {
+        try {
+            ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName +
"/alert_types.xml"), "alerts");
             for (Field f : AlertManager.class.getFields()) {
                 if (f.getClass().isAssignableFrom(Number.class)) {
                     String name = f.getName().substring(11);
@@ -628,6 +628,7 @@ public class ApiXmlDocWriter {
                     out.writeObject(alert);
                 }
             }
+            out.close();
         } catch (IOException e) {
             s_logger.error("Failed to create output stream to write an alert types ", e);
         } catch (IllegalAccessException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/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 6f089af..68c9286 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -136,6 +136,7 @@ import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
+import com.cloud.user.User;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.UriUtils;
 import com.cloud.utils.component.Manager;
@@ -322,29 +323,29 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         String eventName;
         for (ResourceListener l : lst) {
-            if (event.equals(ResourceListener.EVENT_DISCOVER_BEFORE)) {
+            if (event == ResourceListener.EVENT_DISCOVER_BEFORE) {
                 l.processDiscoverEventBefore((Long)params[0], (Long)params[1], (Long)params[2],
(URI)params[3], (String)params[4], (String)params[5],
                     (List<String>)params[6]);
                 eventName = "EVENT_DISCOVER_BEFORE";
-            } else if (event.equals(ResourceListener.EVENT_DISCOVER_AFTER)) {
+            } else if (event == ResourceListener.EVENT_DISCOVER_AFTER) {
                 l.processDiscoverEventAfter((Map<? extends ServerResource, Map<String,
String>>)params[0]);
                 eventName = "EVENT_DISCOVER_AFTER";
-            } else if (event.equals(ResourceListener.EVENT_DELETE_HOST_BEFORE)) {
+            } else if (event == ResourceListener.EVENT_DELETE_HOST_BEFORE) {
                 l.processDeleteHostEventBefore((HostVO)params[0]);
                 eventName = "EVENT_DELETE_HOST_BEFORE";
-            } else if (event.equals(ResourceListener.EVENT_DELETE_HOST_AFTER)) {
+            } else if (event == ResourceListener.EVENT_DELETE_HOST_AFTER) {
                 l.processDeletHostEventAfter((HostVO)params[0]);
                 eventName = "EVENT_DELETE_HOST_AFTER";
-            } else if (event.equals(ResourceListener.EVENT_CANCEL_MAINTENANCE_BEFORE)) {
+            } else if (event == ResourceListener.EVENT_CANCEL_MAINTENANCE_BEFORE) {
                 l.processCancelMaintenaceEventBefore((Long)params[0]);
                 eventName = "EVENT_CANCEL_MAINTENANCE_BEFORE";
-            } else if (event.equals(ResourceListener.EVENT_CANCEL_MAINTENANCE_AFTER)) {
+            } else if (event == ResourceListener.EVENT_CANCEL_MAINTENANCE_AFTER) {
                 l.processCancelMaintenaceEventAfter((Long)params[0]);
                 eventName = "EVENT_CANCEL_MAINTENANCE_AFTER";
-            } else if (event.equals(ResourceListener.EVENT_PREPARE_MAINTENANCE_BEFORE)) {
+            } else if (event == ResourceListener.EVENT_PREPARE_MAINTENANCE_BEFORE) {
                 l.processPrepareMaintenaceEventBefore((Long)params[0]);
                 eventName = "EVENT_PREPARE_MAINTENANCE_BEFORE";
-            } else if (event.equals(ResourceListener.EVENT_PREPARE_MAINTENANCE_AFTER)) {
+            } else if (event == ResourceListener.EVENT_PREPARE_MAINTENANCE_AFTER) {
                 l.processPrepareMaintenaceEventAfter((Long)params[0]);
                 eventName = "EVENT_PREPARE_MAINTENANCE_AFTER";
             } else {
@@ -797,7 +798,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @DB
     protected boolean doDeleteHost(final long hostId, boolean isForced, final boolean isForceDeleteStorage)
{
-        _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
+        User caller = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
         // Verify that host exists
         final HostVO host = _hostDao.findById(hostId);
         if (host == null) {
@@ -1462,7 +1463,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 Map.Entry<String, ResourceStateAdapter> item = it.next();
                 ResourceStateAdapter adapter = item.getValue();
 
-                String msg = "Dispatching resource state event " + event + " to " + item.getKey();
+                String msg = new String("Dispatching resource state event " + event + " to
" + item.getKey());
                 s_logger.debug(msg);
 
                 if (event == ResourceStateAdapter.Event.CREATE_HOST_VO_FOR_CONNECTED) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 6e72d08..7c3b5a5 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -1221,9 +1221,9 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
                 defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter);
                 defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter);
 
-                for (Map.Entry<Service,Provider> entry : defaultVpcNetworkOfferingProviders.entrySet())
{
-                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(),
entry.getKey(), entry.getValue());
+                for (Service service : defaultVpcNetworkOfferingProviders.keySet()) {
+                    NetworkOfferingServiceMapVO offService =
+                            new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(),
service, defaultVpcNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c804660c/utils/src/com/cloud/utils/nio/NioClient.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/NioClient.java b/utils/src/com/cloud/utils/nio/NioClient.java
index db17b7a..34d03c2 100755
--- a/utils/src/com/cloud/utils/nio/NioClient.java
+++ b/utils/src/com/cloud/utils/nio/NioClient.java
@@ -48,63 +48,61 @@ public class NioClient extends NioConnection {
     @Override
     protected void init() throws IOException {
         _selector = Selector.open();
+        SocketChannel sch = null;
         InetSocketAddress addr = null;
-        try(SocketChannel sch = SocketChannel.open();) {
-            try {
-                sch.configureBlocking(true);
-                s_logger.info("Connecting to " + _host + ":" + _port);
-
-                if (_bindAddress != null) {
-                    s_logger.info("Binding outbound interface at " + _bindAddress);
-
-                    addr = new InetSocketAddress(_bindAddress, 0);
-                    sch.socket().bind(addr);
-                }
-
-                addr = new InetSocketAddress(_host, _port);
-                sch.connect(addr);
-            } catch (IOException e) {
-                _selector.close();
-                throw e;
-            }
-            SSLEngine sslEngine = null;
-            try {
-                // Begin SSL handshake in BLOCKING mode
-                sch.configureBlocking(true);
-
-                SSLContext sslContext = Link.initSSLContext(true);
-                sslEngine = sslContext.createSSLEngine(_host, _port);
-                sslEngine.setUseClientMode(true);
-
-                Link.doHandshake(sch, sslEngine, true);
-                s_logger.info("SSL: Handshake done");
-                s_logger.info("Connected to " + _host + ":" + _port);
-            } catch (Exception e) {
-                _selector.close();
-                throw new IOException("SSL: Fail to init SSL! " + e);
-            }
 
-            Task task = null;
-            try {
-                sch.configureBlocking(false);
-                Link link = new Link(addr, this);
-                link.setSSLEngine(sslEngine);
-                SelectionKey key = sch.register(_selector, SelectionKey.OP_READ);
-                link.setKey(key);
-                key.attach(link);
-                // Notice we've already connected due to the handshake, so let's get the
-                // remaining task done
-                task = _factory.create(Task.Type.CONNECT, link, null);
-            } catch (Exception e) {
-                _selector.close();
-                throw new IOException("Fail to init NioClient! " + e);
+        try {
+            sch = SocketChannel.open();
+            sch.configureBlocking(true);
+            s_logger.info("Connecting to " + _host + ":" + _port);
+
+            if (_bindAddress != null) {
+                s_logger.info("Binding outbound interface at " + _bindAddress);
+
+                addr = new InetSocketAddress(_bindAddress, 0);
+                sch.socket().bind(addr);
             }
-            _executor.execute(task);
-        }catch(IOException ex)
-        {
-            s_logger.error("NioClient:init:Exception:"+ex.getMessage());
-            throw new IOException("NioClient:init:Exception:"+ex.getMessage(),ex);
+
+            addr = new InetSocketAddress(_host, _port);
+            sch.connect(addr);
+        } catch (IOException e) {
+            _selector.close();
+            throw e;
+        }
+
+        SSLEngine sslEngine = null;
+        try {
+            // Begin SSL handshake in BLOCKING mode
+            sch.configureBlocking(true);
+
+            SSLContext sslContext = Link.initSSLContext(true);
+            sslEngine = sslContext.createSSLEngine(_host, _port);
+            sslEngine.setUseClientMode(true);
+
+            Link.doHandshake(sch, sslEngine, true);
+            s_logger.info("SSL: Handshake done");
+            s_logger.info("Connected to " + _host + ":" + _port);
+        } catch (Exception e) {
+            _selector.close();
+            throw new IOException("SSL: Fail to init SSL! " + e);
+        }
+
+        Task task = null;
+        try {
+            sch.configureBlocking(false);
+            Link link = new Link(addr, this);
+            link.setSSLEngine(sslEngine);
+            SelectionKey key = sch.register(_selector, SelectionKey.OP_READ);
+            link.setKey(key);
+            key.attach(link);
+            // Notice we've already connected due to the handshake, so let's get the
+            // remaining task done
+            task = _factory.create(Task.Type.CONNECT, link, null);
+        } catch (Exception e) {
+            _selector.close();
+            throw new IOException("Fail to init NioClient! " + e);
         }
+        _executor.execute(task);
     }
 
     @Override


Mime
View raw message