You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/17 10:11:03 UTC

[19/39] git commit: updated refs/heads/vpc-toolkit-hugo to 34bed5f

Findbugs fixes in cloud-utils project and a few other places


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

Branch: refs/heads/vpc-toolkit-hugo
Commit: aacf8ef77b9859329be5199dad195f7ebcd8dbf6
Parents: 33d6bc2
Author: Koushik Das <ko...@apache.org>
Authored: Tue Jul 15 14:23:17 2014 +0530
Committer: Koushik Das <ko...@apache.org>
Committed: Tue Jul 15 14:23:17 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/agent/api/to/NicTO.java       |  6 ++--
 .../orchestration/VolumeOrchestrator.java       |  2 +-
 .../com/cloud/usage/dao/UsageVolumeDaoImpl.java |  2 +-
 .../dao/ManagementServerHostDaoImpl.java        |  6 ++--
 utils/src/com/cloud/utils/NumbersUtil.java      | 34 +++++++++++---------
 utils/src/com/cloud/utils/SwiftUtil.java        |  2 +-
 utils/src/com/cloud/utils/UriUtils.java         |  4 +--
 utils/src/com/cloud/utils/net/NetUtils.java     |  4 +--
 .../src/com/cloud/utils/ssh/SSHKeysHelper.java  |  5 ++-
 .../storage/encoding/DecodedDataObject.java     |  1 +
 10 files changed, 37 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/api/src/com/cloud/agent/api/to/NicTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/NicTO.java b/api/src/com/cloud/agent/api/to/NicTO.java
index 0cbc2d8..bd681f2 100644
--- a/api/src/com/cloud/agent/api/to/NicTO.java
+++ b/api/src/com/cloud/agent/api/to/NicTO.java
@@ -24,7 +24,7 @@ public class NicTO extends NetworkTO {
     Integer networkRateMulticastMbps;
     boolean defaultNic;
     boolean pxeDisable;
-    String uuid;
+    String nicUuid;
     List<String> nicSecIps;
 
     public NicTO() {
@@ -69,12 +69,12 @@ public class NicTO extends NetworkTO {
 
     @Override
     public String getUuid() {
-        return uuid;
+        return nicUuid;
     }
 
     @Override
     public void setUuid(String uuid) {
-        this.uuid = uuid;
+        this.nicUuid = uuid;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 9ba3451..098f976 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -756,7 +756,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
 
         ServiceOffering svo = _entityMgr.findById(ServiceOffering.class, vm.getServiceOfferingId());
         DiskOffering diskVO = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
-        Long clusterId = (storagePool == null ? null : storagePool.getClusterId());
+        Long clusterId = storagePool.getClusterId();
 
         VolumeInfo vol = null;
         if (volume.getState() == Volume.State.Allocated) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/engine/schema/src/com/cloud/usage/dao/UsageVolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageVolumeDaoImpl.java b/engine/schema/src/com/cloud/usage/dao/UsageVolumeDaoImpl.java
index 5beafa6..7ef4222 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageVolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageVolumeDaoImpl.java
@@ -88,8 +88,8 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl
                 pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
                 pstmt.setLong(2, usage.getAccountId());
                 pstmt.setLong(3, usage.getId());
+                pstmt.executeUpdate();
             }
-            pstmt.executeUpdate();
             txn.commit();
         } catch (Exception e) {
             txn.rollback();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/framework/cluster/src/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/cluster/src/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java b/framework/cluster/src/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java
index 97b9a54..ce4667e 100644
--- a/framework/cluster/src/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java
+++ b/framework/cluster/src/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java
@@ -61,7 +61,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
 
             pstmt.executeUpdate();
         } catch (SQLException e) {
-            throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
+            throw new CloudRuntimeException("DB exception: ", e);
         }
     }
 
@@ -227,7 +227,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
                 throw new CloudRuntimeException("Invalid cluster session detected, runId " + runId + " is no longer valid", new ClusterInvalidSessionException("runId " + runId + " is no longer valid"));
             }
         } catch (SQLException e) {
-            throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
+            throw new CloudRuntimeException("DB exception: ", e);
         }
     }
 
@@ -255,7 +255,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
                 orphanList.add(rs.getLong(1));
             }
         } catch (SQLException e) {
-            throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
+            throw new CloudRuntimeException("DB exception: ", e);
         }
 
         return orphanList;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/utils/src/com/cloud/utils/NumbersUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/NumbersUtil.java b/utils/src/com/cloud/utils/NumbersUtil.java
index fd5c77f..8b93a40 100755
--- a/utils/src/com/cloud/utils/NumbersUtil.java
+++ b/utils/src/com/cloud/utils/NumbersUtil.java
@@ -101,24 +101,28 @@ public class NumbersUtil {
      * @return interval in ms
      */
     public static long parseInterval(String str, long defaultValue) {
-        SimpleDateFormat sdf = null;
-        if (str.contains("D")) {
-            sdf = new SimpleDateFormat("dd'D'HH'h'mm'M'ss'S'SSS'ms'");
-        } else if (str.contains("h")) {
-            sdf = new SimpleDateFormat("HH'h'mm'M'ss'S'SSS'ms'");
-        } else if (str.contains("M")) {
-            sdf = new SimpleDateFormat("mm'M'ss'S'SSS'ms'");
-        } else if (str.contains("S")) {
-            sdf = new SimpleDateFormat("ss'S'SSS'ms'");
-        } else if (str.contains("ms")) {
-            sdf = new SimpleDateFormat("SSS'ms'");
-        }
-        Date date;
         try {
-            if (str == null || sdf == null) {
+            if (str == null) {
+                throw new ParseException("String is wrong", 0);
+            }
+
+            SimpleDateFormat sdf = null;
+            if (str.contains("D")) {
+                sdf = new SimpleDateFormat("dd'D'HH'h'mm'M'ss'S'SSS'ms'");
+            } else if (str.contains("h")) {
+                sdf = new SimpleDateFormat("HH'h'mm'M'ss'S'SSS'ms'");
+            } else if (str.contains("M")) {
+                sdf = new SimpleDateFormat("mm'M'ss'S'SSS'ms'");
+            } else if (str.contains("S")) {
+                sdf = new SimpleDateFormat("ss'S'SSS'ms'");
+            } else if (str.contains("ms")) {
+                sdf = new SimpleDateFormat("SSS'ms'");
+            }
+            if (sdf == null) {
                 throw new ParseException("String is wrong", 0);
             }
-            date = sdf.parse(str);
+
+            Date date = sdf.parse(str);
             return date.getTime();
         } catch (ParseException e) {
             if (defaultValue != -1) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/utils/src/com/cloud/utils/SwiftUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/SwiftUtil.java b/utils/src/com/cloud/utils/SwiftUtil.java
index 07a7292..1136818 100644
--- a/utils/src/com/cloud/utils/SwiftUtil.java
+++ b/utils/src/com/cloud/utils/SwiftUtil.java
@@ -100,7 +100,7 @@ public class SwiftUtil {
             String[] lines = parser.getLines().split("\\n");
             for (String line : lines) {
                 if (line.contains("Errno") || line.contains("failed") || line.contains("not found")) {
-                    throw new CloudRuntimeException("Failed to upload file: " + lines.toString());
+                    throw new CloudRuntimeException("Failed to upload file: " + Arrays.toString(lines));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/utils/src/com/cloud/utils/UriUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UriUtils.java b/utils/src/com/cloud/utils/UriUtils.java
index a329503..6b28afb 100644
--- a/utils/src/com/cloud/utils/UriUtils.java
+++ b/utils/src/com/cloud/utils/UriUtils.java
@@ -205,9 +205,9 @@ public class UriUtils {
             URI uri = new URI(url);
             if (uri.getScheme().equalsIgnoreCase("http")) {
                 httpConn = (HttpURLConnection)uri.toURL().openConnection();
-                httpConn.setConnectTimeout(2000);
-                httpConn.setReadTimeout(5000);
                 if (httpConn != null) {
+                    httpConn.setConnectTimeout(2000);
+                    httpConn.setReadTimeout(5000);
                     String contentLength = httpConn.getHeaderField("content-length");
                     if (contentLength != null) {
                         remoteSize = Long.parseLong(contentLength);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/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 cde97d4..1b2c0e8 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -1420,10 +1420,10 @@ public class NetUtils {
     public static boolean isSameIsolationId(String one, String other) {
         // check nulls
         // check empty strings
-        if ((one == null || one.equals("")) && (other == null || other.equals(""))) {
+        if ((one == null || one.isEmpty()) && (other == null || other.isEmpty())) {
             return true;
         }
-        if ((one == null || other == null) && !(one == null && other == null)) {
+        if (one == null || other == null) {
             return false;
         }
         // check 'untagged'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java b/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
index ab54c2c..39db5c4 100644
--- a/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
+++ b/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
@@ -69,8 +69,11 @@ public class SSHKeysHelper {
             e.printStackTrace();
         }
 
-        String sumString = toHexString(md5.digest(keyBytes));
         String rString = "";
+        String sumString = "";
+        if (md5 != null) {
+            sumString = toHexString(md5.digest(keyBytes));
+        }
 
         for (int i = 2; i <= sumString.length(); i += 2) {
             rString += sumString.substring(i - 2, i);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aacf8ef7/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
index d8d354d..56be699 100644
--- a/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
+++ b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
@@ -29,6 +29,7 @@ public class DecodedDataObject {
     public DecodedDataObject(String objType, Long size, String name, String path, DecodedDataStore store) {
         this.objType = objType;
         this.size = size;
+        this.name = name;
         this.path = path;
         this.store = store;
     }