cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/4] git commit: updated refs/heads/4.9 to 80724b0
Date Thu, 08 Dec 2016 18:56:55 GMT
CLOUDSTACK-9656: Preventing autoboxing NPE in Usage by setting a default role when not found


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

Branch: refs/heads/4.9
Commit: 1a034d168deed4187ebb40215c1dc217778a66d1
Parents: 26a2c9e
Author: Patrick Dube <pdube@cloudops.com>
Authored: Thu Dec 8 13:26:46 2016 -0500
Committer: Patrick Dube <pdube@cloudops.com>
Committed: Thu Dec 8 13:26:46 2016 -0500

----------------------------------------------------------------------
 engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a034d16/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
index 39f57df..626b8cc 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
@@ -32,6 +32,7 @@ import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
 
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -113,7 +114,14 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long>
implements Usage
                 pstmt.setLong(1, acct.getId());
                 pstmt.setString(2, acct.getAccountName());
                 pstmt.setShort(3, acct.getType());
-                pstmt.setLong(4, acct.getRoleId());
+
+                //prevent autoboxing NPE by defaulting to User role
+                if(acct.getRoleId() == null){
+                    pstmt.setLong(4, RoleType.User.getId());
+                }else{
+                    pstmt.setLong(4, acct.getRoleId());
+                }
+
                 pstmt.setLong(5, acct.getDomainId());
 
                 Date removed = acct.getRemoved();


Mime
View raw message