From 630d826ce01ee574c4dbfafb819c63ff56ab09cd Mon Sep 17 00:00:00 2001 From: Lucas Asth Date: Sat, 30 May 2020 08:33:39 -0300 Subject: [PATCH] cleanup of redundant check for sameOwner (#4110) Entity ownership is already being verified at line 508. --- .../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 98b4aa8a83e..9fb185833ca 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; } }