cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject [11/18] git commit: updated refs/heads/resize-root to 6d6e790
Date Mon, 10 Mar 2014 21:37:39 GMT
findbugs: null check before use of pointer

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

Branch: refs/heads/resize-root
Commit: e0d20fb6eb7b9550ad8b543e2df0ad00d8c9965e
Parents: 579cb9c
Author: Daan Hoogland <daan@onecht.net>
Authored: Mon Mar 10 13:08:15 2014 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon Mar 10 13:08:15 2014 +0100

----------------------------------------------------------------------
 server/src/com/cloud/network/NetworkModelImpl.java | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0d20fb6/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 9212a89..7b4b2be 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1533,28 +1533,34 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
 
     @Override
     public void checkNetworkPermissions(Account owner, Network network) {
+        // dahn 20140310: I was thinking of making this an assert but
+        //                as we hardly ever test with asserts I think
+        //                we better make sure at runtime.
+        if (network == null) {
+            throw new CloudRuntimeException("cannot check permissions on (Network) <null>");
+        }
         // Perform account permission check
         if (network.getGuestType() != Network.GuestType.Shared || (network.getGuestType()
== Network.GuestType.Shared && network.getAclType() == ACLType.Account)) {
             AccountVO networkOwner = _accountDao.findById(network.getAccountId());
             if (networkOwner == null)
-                throw new PermissionDeniedException("Unable to use network with id= " + ((network
!= null) ? ((NetworkVO)network).getUuid() : "") +
+                throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid()
+
                     ", network does not have an owner");
             if (owner.getType() != Account.ACCOUNT_TYPE_PROJECT && networkOwner.getType()
== Account.ACCOUNT_TYPE_PROJECT) {
                 if (!_projectAccountDao.canAccessProjectAccount(owner.getAccountId(), network.getAccountId()))
{
-                    throw new PermissionDeniedException("Unable to use network with id= "
+ ((network != null) ? ((NetworkVO)network).getUuid() : "") +
+                    throw new PermissionDeniedException("Unable to use network with id= "
+ ((NetworkVO)network).getUuid() +
                         ", permission denied");
                 }
             } else {
                 List<NetworkVO> networkMap = _networksDao.listBy(owner.getId(), network.getId());
                 if (networkMap == null || networkMap.isEmpty()) {
-                    throw new PermissionDeniedException("Unable to use network with id= "
+ ((network != null) ? ((NetworkVO)network).getUuid() : "") +
+                    throw new PermissionDeniedException("Unable to use network with id= "
+ ((NetworkVO)network).getUuid() +
                         ", permission denied");
                 }
             }
 
         } else {
             if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) {
-                throw new PermissionDeniedException("Shared network id=" + ((network != null)
? ((NetworkVO)network).getUuid() : "") + " is not available in domain id=" +
+                throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid()
+ " is not available in domain id=" +
                     owner.getDomainId());
             }
         }


Mime
View raw message