BUG-185 : fixed NPE. 73/4073/1
authorDana Kutenicsova <dkutenic@cisco.com>
Wed, 8 Jan 2014 14:31:18 +0000 (15:31 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 8 Jan 2014 14:31:18 +0000 (15:31 +0100)
Change-Id: Ic2c2e64628815c61a95226bdcab9b22a2d0b0209
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPObjectComparator.java

index 2bc654f417943601ef94c1d05046a044f53667eb..d8932eec7825c4a7951da77eac3cfcd0c8736dbd 100644 (file)
@@ -56,7 +56,8 @@ final class BGPObjectComparator implements Comparator<PathAttributes> {
                // - we assume that all nexthops are accessible
 
                // 2. prefer path with higher LOCAL_PREF
-               if (!o1.getLocalPref().equals(o2.getLocalPref())) {
+               if ((o1.getLocalPref() != null || o2.getLocalPref() != null)
+                               && (o1.getLocalPref() != null && !o1.getLocalPref().equals(o2.getLocalPref()))) {
                        return o1.getLocalPref().getPref().compareTo(o2.getLocalPref().getPref());
                }
 
@@ -87,7 +88,8 @@ final class BGPObjectComparator implements Comparator<PathAttributes> {
                }
 
                // 6. prefer the path with the lowest multi-exit discriminator (MED)
-               if (!o1.getMultiExitDisc().equals(o2.getMultiExitDisc())) {
+               if ((o1.getMultiExitDisc() != null || o2.getMultiExitDisc() != null)
+                               && (o1.getMultiExitDisc() != null && !o1.getMultiExitDisc().equals(o2.getMultiExitDisc()))) {
                        return o2.getMultiExitDisc().getMed().compareTo(o1.getMultiExitDisc().getMed());
                }