You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2020/05/30 11:33:57 UTC

[cloudstack] branch master updated: cleanup of redundant check for sameOwner (#4110)

This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 630d826  cleanup of redundant check for sameOwner (#4110)
630d826 is described below

commit 630d826ce01ee574c4dbfafb819c63ff56ab09cd
Author: Lucas Asth <as...@hotmail.com>
AuthorDate: Sat May 30 08:33:39 2020 -0300

    cleanup of redundant check for sameOwner (#4110)
    
    Entity ownership is already being verified at line 508.
---
 server/src/main/java/com/cloud/user/AccountManagerImpl.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
index 98b4aa8..9fb1858 100644
--- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
@@ -507,14 +507,12 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
         ControlledEntity prevEntity = null;
         if (sameOwner) {
             for (ControlledEntity entity : entities) {
-                if (sameOwner) {
-                    if (ownerId == null) {
-                        ownerId = entity.getAccountId();
-                    } else if (ownerId.longValue() != entity.getAccountId()) {
-                        throw new PermissionDeniedException("Entity " + entity + " and entity " + prevEntity + " belong to different accounts");
-                    }
-                    prevEntity = entity;
+                if (ownerId == null) {
+                    ownerId = entity.getAccountId();
+                } else if (ownerId.longValue() != entity.getAccountId()) {
+                    throw new PermissionDeniedException("Entity " + entity + " and entity " + prevEntity + " belong to different accounts");
                 }
+                prevEntity = entity;
             }
         }