Skip to content

Commit 61d4815

Browse files
committed
compare null to non-null or not-empty-string
1 parent 7c8ef78 commit 61d4815

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

utils/src/com/cloud/utils/net/NetUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,12 @@ public static boolean isSameIsolationId(String one, String other)
14061406
{
14071407
return true;
14081408
}
1409+
if ((one == null || other == null)
1410+
&&
1411+
!(one == null && other == null))
1412+
{
1413+
return false;
1414+
}
14091415
// check 'untagged'
14101416
if (VLAN_UNTAGGED.equalsIgnoreCase(one) && VLAN_UNTAGGED.equalsIgnoreCase(other))
14111417
{

utils/test/com/cloud/utils/net/NetUtilsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,6 @@ public void testGetLocalIPString() {
178178
public void testSameIsolationId() {
179179
assertTrue(NetUtils.isSameIsolationId("1", "vlan://1"));
180180
assertTrue(NetUtils.isSameIsolationId("", null));
181+
assertFalse(NetUtils.isSameIsolationId("bla", null));
181182
}
182183
}

0 commit comments

Comments
 (0)