shwstppr commented on a change in pull request #5471:
URL: https://github.com/apache/cloudstack/pull/5471#discussion_r712850506



##########
File path: 
vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
##########
@@ -839,10 +849,79 @@ private static void createPortGroup(String 
physicalNetwork, String networkName,
         }
     }
 
-    public static boolean isSpecMatch(DVPortgroupConfigInfo 
currentDvPortgroupInfo, DVPortgroupConfigSpec newDvPortGroupSpec) {
+    private static boolean eitherObjectNull(Object obj1, Object obj2) {
+        return (obj1 == null && obj2 != null) || (obj1 != null && obj2 == 
null);
+    }
+
+    private static boolean areBoolPoliciesDifferent(BoolPolicy currentPolicy, 
BoolPolicy newPolicy) {
+        return eitherObjectNull(currentPolicy, newPolicy) ||
+                (newPolicy != null && newPolicy.isValue() != 
currentPolicy.isValue());

Review comment:
       @sureshanaparti 
   Four cases:
   
   1. currentPolicy is null, newPolicy is not null       <- Will be handled by 
`eitherObjectNull`
   2. currentPolicy is not null, newPolicy is null       <- Will be handled by 
`eitherObjectNull`
   3. currentPolicy is null, newPolicy is null             <- Will fail 
`newPolicy != null` check in second part of the condition
   4. currentPolicy is not null, newPolicy is not null <- Should be handled by 
`newPolicy.isValue() != currentPolicy.isValue()`
   
   Actually I added null check of both vars initially but IntelliJ suggested 
simplification and I guess it was right




-- 
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