Fix NPE in SimpleMapCache 34/50034/2
authorLorand Jakab <lojakab@cisco.com>
Wed, 4 Jan 2017 21:34:10 +0000 (23:34 +0200)
committerLorand Jakab <lojakab@cisco.com>
Fri, 13 Jan 2017 05:12:25 +0000 (07:12 +0200)
This was causing a serious performance regression too, introduced with
Gerrit c/46778, "Make SimpleMapCache simple again".

Change-Id: I531a5f103322f5389b20197895a381aceef79fa5
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java
mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCacheTest.java

index b698c7fb5d62e334a7637bd211e9e4d5635cdff5..a2e88fcf4245c044651c351854e654b65c16a2c9 100644 (file)
@@ -108,7 +108,7 @@ public class SimpleMapCache implements ILispMapCache {
         SimpleImmutableEntry<Eid, Map<String, ?>> daoEntry = dao.getBestPair(MaskUtil.normalize(eid));
         if (daoEntry != null) {
             if (xtrId != null) {
-                ILispDAO xtrIdTable = getXtrIdTable(eid, (ILispDAO) daoEntry.getValue().get(SubKeys.XTRID_RECORDS));
+                ILispDAO xtrIdTable = (ILispDAO) daoEntry.getValue().get(SubKeys.XTRID_RECORDS);
                 if (xtrIdTable != null) {
                     return xtrIdTable.getSpecific(xtrId, SubKeys.RECORD);
                 }
index b88a3c7d5053682f08dddaa8c858c1bb7afbf1b0..b57b70d77b46bce1aa0f58e9f9e56babc1481427 100644 (file)
@@ -269,13 +269,11 @@ public class SimpleMapCacheTest {
         final Map<String, Object> mapMock = Mockito.mock(Map.class);
         final SimpleImmutableEntry<Eid, Map<String, ?>> mapPair = new SimpleImmutableEntry<>(
                 NORMALIZED_EID_IPV4_PREFIX_DST, mapMock);
-        final ILispDAO xtrIdRecordsMock = Mockito.mock(ILispDAO.class);
         final MappingData mappingData = new MappingData(getDefaultMappingRecordBuilder().build());
 
         Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
         Mockito.when(tableMock.getBestPair(NORMALIZED_EID_IPV4_PREFIX_DST)).thenReturn(mapPair);
-        Mockito.when(mapMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdRecordsMock);
-        Mockito.when(xtrIdRecordsMock.getSpecific(EID_IPV4_PREFIX_DST, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
+        Mockito.when(mapMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
         Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD))
                 .thenReturn(mappingData);       // second invocation