Fix NPE in SouthboundUtils 23/86823/2
authorChandra Shekar S <chandra.shekar.s@ericsson.com>
Thu, 9 Jan 2020 10:30:23 +0000 (16:00 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 13 Jan 2020 06:32:38 +0000 (06:32 +0000)
JIRA: OVSDB-492

Add the null check to avoid the SouthboundUtils.compareDbVersionToMinVersion()
throwing the NPE.
By any chance if the method is getting triggered with one of the parameter as null,
throws the NPE.

Signed-off-by: Chandra Shekar S <chandra.shekar.s@ericsson.com>
Change-Id: Ibd29fe283fec7376baec56c0fbbb35529e157dbb

utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index e766b9d593b2cc703c1f252603ed512d994382b5..a85f3faf1bd8cd9895af1a1b3b4da70f5c555a0d 100644 (file)
@@ -1345,6 +1345,10 @@ public class SouthboundUtils {
     }
 
     public static boolean compareDbVersionToMinVersion(final String dbVersion, final String minVersion) {
+        if (dbVersion == null || minVersion == null) {
+            LOG.error("Invalid DB version {} or minVersion {}", dbVersion, minVersion);
+            return false;
+        }
         final Matcher dbVersionMatcher = PATTERN.matcher(dbVersion);
         final Matcher minVersionMatcher = PATTERN.matcher(minVersion);
         LOG.debug("dbVersion {}, minVersion {}", dbVersion, minVersion);