GutoVeronezi commented on code in PR #6748:
URL: https://github.com/apache/cloudstack/pull/6748#discussion_r1047592431


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -6614,25 +6614,26 @@ public Pair<List<? extends NetworkOffering>, Integer> 
searchForNetworkOfferings(
             ListIterator<NetworkOfferingJoinVO> it = offerings.listIterator();
             while (it.hasNext()) {
                 NetworkOfferingJoinVO offering = it.next();
-                if (StringUtils.isNotEmpty(offering.getDomainId())) {
-                    boolean toRemove = false;
-                    String[] domainIdsArray = 
offering.getDomainId().split(",");
-                    for (String domainIdString : domainIdsArray) {
-                        Long dId = Long.valueOf(domainIdString.trim());
-                        if (caller.getType() != Account.Type.ADMIN &&
-                                !_domainDao.isChildDomain(dId, 
caller.getDomainId())) {
-                            toRemove = true;
-                            break;
-                        }
-                        if (domainId != null && !_domainDao.isChildDomain(dId, 
domainId)) {
-                            toRemove = true;
-                            break;
-                        }
+                if (StringUtils.isEmpty(offering.getDomainId())) {
+                    continue;
+                }
+                boolean toRemove = true;
+                String[] domainIdsArray = offering.getDomainId().split(",");
+                for (String domainIdString : domainIdsArray) {
+                    Long dId = Long.valueOf(domainIdString.trim());
+                    if (caller.getType() != Account.Type.ADMIN &&
+                            _domainDao.isChildDomain(dId, 
caller.getDomainId())) {
+                        toRemove = false;
+                        break;
                     }
-                    if (toRemove) {
-                        it.remove();
+                    if (domainId != null && _domainDao.isChildDomain(dId, 
domainId)) {
+                        toRemove = false;

Review Comment:
   We could call `it.remove()` here instead of creating a variable and having 
to verify it later.



##########
server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java:
##########
@@ -730,20 +730,21 @@ public Pair<List<? extends VpcOffering>, Integer> 
listVpcOfferings(ListVPCOfferi
             ListIterator<VpcOfferingJoinVO> it = offerings.listIterator();
             while (it.hasNext()) {
                 VpcOfferingJoinVO offering = it.next();
-                
if(org.apache.commons.lang3.StringUtils.isNotEmpty(offering.getDomainId())) {
-                    boolean toRemove = true;
-                    String[] domainIdsArray = 
offering.getDomainId().split(",");
-                    for (String domainIdString : domainIdsArray) {
-                        Long dId = Long.valueOf(domainIdString.trim());
-                        if (domainDao.isChildDomain(dId, 
caller.getDomainId())) {
-                            toRemove = false;
-                            break;
-                        }
-                    }
-                    if (toRemove) {
-                        it.remove();
+                
if(org.apache.commons.lang3.StringUtils.isEmpty(offering.getDomainId())) {
+                    continue;
+                }
+                boolean toRemove = true;
+                String[] domainIdsArray = offering.getDomainId().split(",");
+                for (String domainIdString : domainIdsArray) {
+                    Long dId = Long.valueOf(domainIdString.trim());
+                    if (domainDao.isChildDomain(dId, caller.getDomainId())) {
+                        toRemove = false;

Review Comment:
   We could call it.remove() here instead of creating a variable and having to 
verify it later.



##########
server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java:
##########
@@ -730,20 +730,21 @@ public Pair<List<? extends VpcOffering>, Integer> 
listVpcOfferings(ListVPCOfferi
             ListIterator<VpcOfferingJoinVO> it = offerings.listIterator();
             while (it.hasNext()) {
                 VpcOfferingJoinVO offering = it.next();
-                
if(org.apache.commons.lang3.StringUtils.isNotEmpty(offering.getDomainId())) {
-                    boolean toRemove = true;
-                    String[] domainIdsArray = 
offering.getDomainId().split(",");
-                    for (String domainIdString : domainIdsArray) {
-                        Long dId = Long.valueOf(domainIdString.trim());
-                        if (domainDao.isChildDomain(dId, 
caller.getDomainId())) {
-                            toRemove = false;
-                            break;
-                        }
-                    }
-                    if (toRemove) {
-                        it.remove();
+                
if(org.apache.commons.lang3.StringUtils.isEmpty(offering.getDomainId())) {

Review Comment:
   ```suggestion
                   if 
(org.apache.commons.lang3.StringUtils.isEmpty(offering.getDomainId())) {
   ```



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -6614,25 +6614,26 @@ public Pair<List<? extends NetworkOffering>, Integer> 
searchForNetworkOfferings(
             ListIterator<NetworkOfferingJoinVO> it = offerings.listIterator();
             while (it.hasNext()) {
                 NetworkOfferingJoinVO offering = it.next();
-                if (StringUtils.isNotEmpty(offering.getDomainId())) {
-                    boolean toRemove = false;
-                    String[] domainIdsArray = 
offering.getDomainId().split(",");
-                    for (String domainIdString : domainIdsArray) {
-                        Long dId = Long.valueOf(domainIdString.trim());
-                        if (caller.getType() != Account.Type.ADMIN &&
-                                !_domainDao.isChildDomain(dId, 
caller.getDomainId())) {
-                            toRemove = true;
-                            break;
-                        }
-                        if (domainId != null && !_domainDao.isChildDomain(dId, 
domainId)) {
-                            toRemove = true;
-                            break;
-                        }
+                if (StringUtils.isEmpty(offering.getDomainId())) {
+                    continue;
+                }
+                boolean toRemove = true;
+                String[] domainIdsArray = offering.getDomainId().split(",");
+                for (String domainIdString : domainIdsArray) {
+                    Long dId = Long.valueOf(domainIdString.trim());
+                    if (caller.getType() != Account.Type.ADMIN &&
+                            _domainDao.isChildDomain(dId, 
caller.getDomainId())) {
+                        toRemove = false;

Review Comment:
   We could call `it.remove()` here instead of creating a variable and having 
to verify it later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to