ONOS-4505: Bug Fixes

Change-Id: Ia030aa3aff9e2ad34a5e27fbe4ba088dda65bfa7
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
old mode 100755
new mode 100644
index 8a58269..3c66bf8
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
@@ -45,7 +45,6 @@
     private IsisLsdbAge lsdbAge = null;
 
 
-
     private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
     private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
 
@@ -80,6 +79,7 @@
     public void setL2LspSeqNo(int l2LspSeqNo) {
         this.l2LspSeqNo = l2LspSeqNo;
     }
+
     /**
      * Returns the LSDB LSP key.
      *
@@ -96,6 +96,7 @@
         return lspKey.toString();
     }
 
+
     /**
      * Returns the neighbor L1 database information.
      *
@@ -218,7 +219,12 @@
             byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]};
             lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort());
         }
-        DefaultLspWrapper lspWrapper = new DefaultLspWrapper();
+
+        DefaultLspWrapper lspWrapper = (DefaultLspWrapper) findLsp(lspdu.isisPduType(), lspdu.lspId());
+        if (lspWrapper == null) {
+            lspWrapper = new DefaultLspWrapper();
+        }
+
         lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
         lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
         lspWrapper.setLsPdu(lspdu);
@@ -228,8 +234,8 @@
         lspWrapper.setIsisInterface(isisInterface);
         lspWrapper.setLsdbAge(lsdbAge);
         addLsp(lspWrapper, lspdu.lspId());
-        log.debug("Added LSp In LSDB: {}", lspWrapper);
 
+        log.debug("Added LSp In LSDB: {}", lspWrapper);
         return true;
     }
 
@@ -270,7 +276,6 @@
                       lspWrapper.lsPdu().isisPduType(),
                       binNumber, lspWrapper.remainingLifetime());
         }
-
         return false;
     }
 
@@ -344,4 +349,4 @@
                 break;
         }
     }
-}
+}
\ No newline at end of file