Refactor exception handling in the OSPF protocol

- removed unnecessary throws of Exception from methods
- converted throws of generic Exception to specific OspfParseException

Change-Id: I9d07167d92f221a234e9eba4c6082deb165afc0b
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
index 64cf9a7..f4e8255 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
@@ -16,6 +16,7 @@
 package org.onosproject.ospf.controller;
 
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.exceptions.OspfParseException;
 
 import java.util.List;
 
@@ -145,9 +146,8 @@
      * with a new sequence number.
      *
      * @param ospfInterface interface instance
-     * @throws Exception might throw exception
      */
-    void refreshArea(OspfInterface ospfInterface) throws Exception;
+    void refreshArea(OspfInterface ospfInterface);
 
     /**
      * Verifies no neighbor is in exchange process.
@@ -191,10 +191,8 @@
      * @param ospfLsa          LSA instance
      * @param isSelfOriginated true if the LSA is self originated else false
      * @param ospfInterface    interface instance
-     * @throws Exception might throws exception
      */
-    void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface)
-            throws Exception;
+    void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface);
 
     /**
      * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
@@ -202,9 +200,9 @@
      *
      * @param ospfLsa       LSA instance
      * @param ospfInterface interface instance
-     * @throws Exception might throws exception
+     * @throws OspfParseException might throws exception
      */
-    void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws Exception;
+    void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws OspfParseException;
 
     /**
      * Sets router sequence number for router LSA.
@@ -229,8 +227,7 @@
      * @param linkStateID       link state id to form the key
      * @param advertisingRouter advertising router to form the key
      * @return LSA wrapper instance which contains the LSA
-     * @throws Exception might throws exception
      */
-    LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception;
+    LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter);
 
 }
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
index 0e9f4d0..1c05ad5 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
@@ -243,16 +243,13 @@
      *
      * @param ospfMessage received OSPF message
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
      */
-    void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception;
+    void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx);
 
     /**
      * Represents an interface is up and connected.
-     *
-     * @throws Exception might throws exception
      */
-    void interfaceUp() throws Exception;
+    void interfaceUp();
 
     /**
      * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
index 9949146..460457f 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
@@ -17,6 +17,7 @@
 
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.exceptions.OspfParseException;
 
 /**
  * Representation of an OSPF message.
@@ -48,9 +49,9 @@
      * Reads from ChannelBuffer and initializes the type of LSA.
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
-    void readFrom(ChannelBuffer channelBuffer) throws Exception;
+    void readFrom(ChannelBuffer channelBuffer) throws OspfParseException;
 
     /**
      * Returns OSPFMessage as byte array.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
index 2d7121c..9a62fad 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
@@ -158,9 +158,8 @@
      * retransmission timer.
      *
      * @param ch netty channel instance
-     * @throws Exception might throw exception
      */
-    void badLSReq(Channel ch) throws Exception;
+    void badLSReq(Channel ch);
 
     /**
      * Gets the LS request list.
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
similarity index 100%
rename from protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
rename to protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java
new file mode 100644
index 0000000..db2cc81
--- /dev/null
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of the OSPF exception types.
+ */
+package org.onosproject.ospf.exceptions;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
index b598d86..7a74637 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
@@ -29,6 +29,7 @@
 import org.onosproject.ospf.controller.OspfNeighborState;
 import org.onosproject.ospf.controller.impl.OspfNbrImpl;
 import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
 import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
@@ -41,6 +42,7 @@
 import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -203,9 +205,9 @@
      * @param interfaceIp interface IP address
      * @param mask        interface network mask
      * @return NetworkLsa instance
-     * @throws Exception might throws exception
+     * @throws OspfParseException might throws exception
      */
-    public NetworkLsa buildNetworkLsa(Ip4Address interfaceIp, Ip4Address mask) throws Exception {
+    public NetworkLsa buildNetworkLsa(Ip4Address interfaceIp, Ip4Address mask) throws OspfParseException {
         // generate the Router-LSA for this Area.
         NetworkLsa networkLsa = new NetworkLsa();
         networkLsa.setAdvertisingRouter(routerId);
@@ -254,9 +256,9 @@
      *
      * @param ospfInterface Interface instance
      * @return routerLsa Router LSA instance
-     * @throws Exception might throws exception
+     * @throws OspfParseException might throws exception
      */
-    public RouterLsa buildRouterLsa(OspfInterface ospfInterface) throws Exception {
+    public RouterLsa buildRouterLsa(OspfInterface ospfInterface) throws OspfParseException {
         // generate the Router-LSA for this Area.
         RouterLsa routerLsa = new RouterLsa();
         routerLsa.setAdvertisingRouter(routerId);
@@ -480,17 +482,22 @@
      * @param linkStateID       link state id to form the key
      * @param advertisingRouter advertising router to form the key
      * @return lsa wrapper instance which contains the Lsa
-     * @throws Exception might throws exception
      */
-    public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception {
+    public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) {
         String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter;
         if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
                 lsType == OspfParameters.AS_OPAQUE_LSA) {
-            byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress();
-            int opaqueType = linkStateAsBytes[0];
-            int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1,
+            try {
+                byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress();
+
+                int opaqueType = linkStateAsBytes[0];
+                int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1,
                                                                      linkStateAsBytes.length));
-            lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter;
+                lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter;
+            } catch (UnknownHostException uhe) {
+                log.warn("Can't resolve host in Lsa wrapper", uhe);
+                return null;
+            }
         }
         return database.findLsa(lsType, lsaKey);
     }
@@ -524,9 +531,8 @@
      *
      * @param ospfLsa       OSPF LSA instance
      * @param ospfInterface OSPF interface instance
-     * @throws Exception on error
      */
-    public void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws Exception {
+    public void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) {
         //second param is false as lsa from network
         database.addLsa((LsaHeader) ospfLsa, false, ospfInterface);
     }
@@ -537,10 +543,8 @@
      * @param ospfLsa          OSPF LSA instance
      * @param isSelfOriginated true if the LSA is self originated. Else false
      * @param ospfInterface    OSPF interface instance
-     * @throws Exception on error
      */
-    public void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface)
-            throws Exception {
+    public void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface) {
         database.addLsa((LsaHeader) ospfLsa, isSelfOriginated, ospfInterface);
     }
 
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
index 7c1626b..be503c2 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
@@ -40,6 +40,7 @@
 import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
 import org.onosproject.ospf.controller.util.OspfEligibleRouter;
 import org.onosproject.ospf.controller.util.OspfInterfaceType;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
@@ -517,11 +518,9 @@
 
     /**
      * Represents an interface is up and connected.
-     *
-     * @throws Exception might throws exception
      */
     @Override
-    public void interfaceUp() throws Exception {
+    public void interfaceUp() {
         log.debug("OSPFInterfaceChannelHandler::interfaceUp...!!!");
         if (interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
             setState(OspfInterfaceState.POINT2POINT);
@@ -552,9 +551,8 @@
      * Gets called when a BDR was detected before the wait timer expired.
      *
      * @param ch channel instance
-     * @throws Exception might throws exception
      */
-    public void backupSeen(Channel ch) throws Exception {
+    public void backupSeen(Channel ch) {
         log.debug("OSPFInterfaceChannelHandler::backupSeen ");
         if (state() == OspfInterfaceState.WAITING) {
             electRouter(ch);
@@ -565,9 +563,8 @@
      * Gets called when no hello message received for particular period.
      *
      * @param ch channel instance
-     * @throws Exception might throws exception
      */
-    public void waitTimer(Channel ch) throws Exception {
+    public void waitTimer(Channel ch) {
         log.debug("OSPFInterfaceChannelHandler::waitTimer ");
         //According to RFC-2328 section 9.4
         if (state() == OspfInterfaceState.WAITING) {
@@ -579,9 +576,8 @@
      * Initiates DR election process.
      *
      * @param ch netty channel instance
-     * @throws Exception might throws exception
      */
-    public void callDrElection(Channel ch) throws Exception {
+    public void callDrElection(Channel ch) {
         log.debug("OSPFInterfaceChannelHandler::callDrElection ");
         //call when timer expired
         //no hello message received for particular interval
@@ -592,10 +588,8 @@
 
     /**
      * Neighbor change event is triggered when the router priority gets changed.
-     *
-     * @throws Exception might throws exception
      */
-    public void neighborChange() throws Exception {
+    public void neighborChange() {
         log.debug("OSPFInterfaceChannelHandler::neighborChange ");
         if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
                 state() == OspfInterfaceState.DROTHER) {
@@ -623,35 +617,38 @@
      *
      * @param ospfMessage received OSPF message
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
      */
     @Override
-    public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
         log.debug("OspfChannelHandler::processOspfMessage...!!!");
 
         if (!validateMessage(ospfMessage)) {
             return;
         }
 
-        switch (ospfMessage.ospfMessageType().value()) {
-            case OspfParameters.HELLO:
-                processHelloMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.DD:
-                processDdMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSREQUEST:
-                processLsRequestMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSUPDATE:
-                processLsUpdateMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSACK:
-                processLsAckMessage(ospfMessage, ctx);
-                break;
-            default:
-                log.debug("Unknown packet to process...!!!");
-                break;
+        try {
+            switch (ospfMessage.ospfMessageType().value()) {
+                case OspfParameters.HELLO:
+                    processHelloMessage(ospfMessage, ctx);
+                    break;
+                case OspfParameters.DD:
+                    processDdMessage(ospfMessage, ctx);
+                    break;
+                case OspfParameters.LSREQUEST:
+                    processLsRequestMessage(ospfMessage, ctx);
+                    break;
+                case OspfParameters.LSUPDATE:
+                    processLsUpdateMessage(ospfMessage, ctx);
+                    break;
+                case OspfParameters.LSACK:
+                    processLsAckMessage(ospfMessage, ctx);
+                    break;
+                default:
+                    log.debug("Unknown packet to process...!!!");
+                    break;
+            }
+        } catch (OspfParseException ope) {
+            log.debug("Error parsing packet", ope);
         }
     }
 
@@ -660,9 +657,8 @@
      *
      * @param ospfMessage OSPF message.
      * @return true if it is a valid else false.
-     * @throws Exception might throws exception
      */
-    private boolean validateMessage(OspfMessage ospfMessage) throws Exception {
+    private boolean validateMessage(OspfMessage ospfMessage) {
         boolean isValid = true;
         OspfPacketHeader header = (OspfPacketHeader) ospfMessage;
 
@@ -688,7 +684,7 @@
             }
 
             //According to RFC-2328 (8.2)
-            /**
+            /*
              * ABR should receive packets from backbone 0.0.0.0 as we are not acting as ABR
              * we are rejecting the packet.
              */
@@ -715,9 +711,8 @@
      *
      * @param ospfMessage OSPF message instance.
      * @param ctx         context instance.
-     * @throws Exception might throws exception
      */
-    void processHelloMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    void processHelloMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
         Channel channel = ctx.getChannel();
         log.debug("OspfChannelHandler::processHelloMessage...!!!");
         HelloPacket helloPacket = (HelloPacket) ospfMessage;
@@ -902,9 +897,8 @@
      *
      * @param ospfMessage OSPF message instance.
      * @param ctx         channel handler context instance
-     * @throws Exception might throws exception
      */
-    void processDdMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    void processDdMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
         log.debug("OspfChannelHandler::processDdMessage...!!!");
         Channel channel = ctx.getChannel();
         DdPacket ddPacket = (DdPacket) ospfMessage;
@@ -1075,9 +1069,8 @@
      *
      * @param ospfMessage OSPF message instance.
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
      */
-    void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
         log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
         Channel channel = ctx.getChannel();
         LsRequest lsrPacket = (LsRequest) ospfMessage;
@@ -1114,18 +1107,20 @@
                         // to verify length of the LSA
                         LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
                                                              lsRequest.ownRouterId());
-                        OspfLsa ospflsa = wrapper.ospfLsa();
-                        if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
-                            listItr.previous();
-                            break;
-                        }
-                        if (ospflsa != null) {
-                            lsupdate.addLsa(ospflsa);
-                            noLsa++;
+                        if (wrapper != null) {
+                            OspfLsa ospflsa = wrapper.ospfLsa();
+                            if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
+                                listItr.previous();
+                                break;
+                            }
+                            if (ospflsa != null) {
+                                lsupdate.addLsa(ospflsa);
+                                noLsa++;
 
-                            currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
-                        } else {
-                            nbr.badLSReq(channel);
+                                currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
+                            } else {
+                                nbr.badLSReq(channel);
+                            }
                         }
                     }
                     lsupdate.setNumberOfLsa(noLsa);
@@ -1149,9 +1144,9 @@
      *
      * @param ospfMessage OSPF message instance.
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
+     * @throws OspfParseException on parsing error
      */
-    void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws OspfParseException {
         log.debug("OspfChannelHandler::processLsUpdateMessage");
         LsUpdate lsUpdate = (LsUpdate) ospfMessage;
         String neighbourId = lsUpdate.routerId().toString();
@@ -1182,9 +1177,8 @@
      *
      * @param ospfMessage OSPF message instance.
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
      */
-    void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
         log.debug("OspfChannelHandler::processLsAckMessage");
         LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
         //check it is present in listOfNeighbors
@@ -1307,9 +1301,8 @@
      * Performs DR election.
      *
      * @param ch Netty Channel instance.
-     * @throws Exception might throws exception
      */
-    public void electRouter(Channel ch) throws Exception {
+    public void electRouter(Channel ch) {
 
         Ip4Address currentDr = dr();
         Ip4Address currentBdr = bdr();
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
index 3816806..8e8e5f3 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
@@ -78,9 +78,8 @@
      * Updates the processes configuration.
      *
      * @param ospfProcesses list of OSPF process instances
-     * @throws Exception might throws parse exception
      */
-    public void updateConfig(List<OspfProcess> ospfProcesses) throws Exception {
+    public void updateConfig(List<OspfProcess> ospfProcesses) {
         log.debug("Controller::UpdateConfig called");
         configPacket = new byte[OspfUtil.CONFIG_LENGTH];
         byte numberOfInterface = 0; // number of interfaces to configure
@@ -343,7 +342,7 @@
             try {
                 peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
                     @Override
-                    public void operationComplete(ChannelFuture future) throws Exception {
+                    public void operationComplete(ChannelFuture future) {
                         if (!future.isSuccess()) {
                             connectRetryCounter++;
                             log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
index 1a47a0c..5ac63b1 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
@@ -69,10 +69,8 @@
 
     /**
      * Initializes the interface map with interface details.
-     *
-     * @throws Exception might throws exception
      */
-    public void initializeInterfaceMap() throws Exception {
+    public void initializeInterfaceMap()  {
         for (OspfProcess process : processes) {
             for (OspfArea area : process.areas()) {
                 for (OspfInterface ospfInterface : area.ospfInterfaceList()) {
@@ -99,9 +97,8 @@
      * Updates the interface map with interface details.
      *
      * @param ospfProcesses updated process instances
-     * @throws Exception might throws exception
      */
-    public void updateInterfaceMap(List<OspfProcess> ospfProcesses) throws Exception {
+    public void updateInterfaceMap(List<OspfProcess> ospfProcesses) {
         for (OspfProcess ospfUpdatedProcess : ospfProcesses) {
             for (OspfArea updatedArea : ospfUpdatedProcess.areas()) {
                 for (OspfInterface ospfUpdatedInterface : updatedArea.ospfInterfaceList()) {
@@ -152,7 +149,7 @@
     /**
      * Initialize channel, start hello sender and initialize LSDB.
      */
-    private void initialize() throws Exception {
+    private void initialize() {
         log.debug("OspfChannelHandler initialize..!!!");
         if (configPacket != null) {
             log.debug("OspfChannelHandler initialize -> sentConfig packet of length ::"
@@ -163,7 +160,7 @@
     }
 
     @Override
-    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
+    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
         log.info("OSPF channelConnected from {}", evt.getChannel().getRemoteAddress());
         this.channel = evt.getChannel();
         initialize();
@@ -187,8 +184,7 @@
     }
 
     @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
-            e) throws Exception {
+    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
         log.debug("[exceptionCaught]: " + e.toString());
         if (e.getCause() instanceof ReadTimeoutException) {
             log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
@@ -213,8 +209,7 @@
     }
 
     @Override
-    public void messageReceived(ChannelHandlerContext ctx, MessageEvent
-            e) throws Exception {
+    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
         log.debug("OspfChannelHandler::messageReceived...!!!");
         Object message = e.getMessage();
         if (message instanceof List) {
@@ -239,10 +234,9 @@
      *
      * @param ospfMessage received OSPF message
      * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
      */
-    public void processOspfMessage(OspfMessage
-                                           ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    private void processOspfMessage(OspfMessage
+                                           ospfMessage, ChannelHandlerContext ctx) {
         log.debug("OspfChannelHandler::processOspfMessage...!!!");
         int interfaceIndex = ospfMessage.interfaceIndex();
         OspfInterface ospfInterface = ospfInterfaceMap.get(interfaceIndex);
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
index 621ebc3..0446e09 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
@@ -21,6 +21,7 @@
 import org.jboss.netty.handler.codec.frame.FrameDecoder;
 import org.onlab.packet.Ip4Address;
 import org.onosproject.ospf.controller.OspfMessage;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.ospfpacket.OspfMessageReader;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
@@ -37,7 +38,8 @@
     private static final Logger log = LoggerFactory.getLogger(OspfMessageDecoder.class);
 
     @Override
-    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
+    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer)
+              throws OspfParseException {
         log.debug("OspfMessageDecoder::Message received <:> length {}", buffer.readableBytes());
         if (!channel.isConnected()) {
             log.info("Channel is not connected.");
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
index 98b6a6d..c457725 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
@@ -32,7 +32,7 @@
     private static final Logger log = LoggerFactory.getLogger(OspfMessageEncoder.class);
 
     @Override
-    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
+    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) {
 
         byte[] byteMsg = (byte[]) msg;
         log.debug("Encoding ospfMessage of length {}", byteMsg.length);
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
index ff3f75b..0f7a91c 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
@@ -38,6 +38,7 @@
 import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
 import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
 import org.onosproject.ospf.controller.util.OspfInterfaceType;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
@@ -144,23 +145,23 @@
     /**
      * The list of LSAs that have to be flooded.
      */
-    private Map<String, OspfLsa> reTxList = new LinkedHashMap();
+    private Map<String, OspfLsa> reTxList = new LinkedHashMap<>();
 
     /**
      * The list of LSAs that have been flooded but not yet acknowledged on this adjacency.
      */
-    private Map<String, OspfLsa> pendingReTxList = new LinkedHashMap();
+    private Map<String, OspfLsa> pendingReTxList = new LinkedHashMap<>();
 
     /**
      * List of LSAs which are failed to received ACK.
      */
-    private Map failedTxList = new HashMap();
+    private Map failedTxList = new HashMap<>();
 
     /**
      * The complete list of LSAs that make up the area link-state database, at the moment the.
      * neighbor goes into Database Exchange state (EXCHANGE).
      */
-    private List<LsaHeader> ddSummaryList = new CopyOnWriteArrayList();
+    private List<LsaHeader> ddSummaryList = new CopyOnWriteArrayList<>();
 
     /**
      * LSA Request List from Neighbor.
@@ -283,9 +284,8 @@
      *
      * @param ospfMessage ospf message instance
      * @param channel     netty channel instance
-     * @throws Exception might throws exception
      */
-    public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception {
+    public void twoWayReceived(OspfMessage ospfMessage, Channel channel) {
         log.debug("OSPFNbr::twoWayReceived...!!!");
         stopInactivityTimeCheck();
         startInactivityTimeCheck();
@@ -367,10 +367,9 @@
      * @param neighborIsMaster neighbor is master or slave
      * @param payload          contains the LSAs to add in Dd Packet
      * @param ch               netty channel instance
-     * @throws Exception might throws exception
      */
     public void negotiationDone(OspfMessage ospfMessage,
-                                boolean neighborIsMaster, List payload, Channel ch) throws Exception {
+                                boolean neighborIsMaster, List payload, Channel ch) {
         stopRxMtDdTimer();
         OspfPacketHeader packet = (OspfPacketHeader) ospfMessage;
         DdPacket ddPacketForCheck = (DdPacket) packet;
@@ -461,9 +460,8 @@
      * Process the LSA Headers received in the last received Database Description OSPFMessage.
      *
      * @param ddPayload LSA headers to process
-     * @throws Exception might throws exception
      */
-    public void processLsas(List ddPayload) throws Exception {
+    public void processLsas(List ddPayload) {
         log.debug("OSPFNbr::processLsas...!!!");
         OspfLsa nextLsa;
         Iterator lsas = ddPayload.iterator();
@@ -503,9 +501,8 @@
      *
      * @param reason a string represents the mismatch reason
      * @return OSPF message instance
-     * @throws Exception might throws exception
      */
-    public OspfMessage seqNumMismatch(String reason) throws Exception {
+    public OspfMessage seqNumMismatch(String reason) {
         log.debug("OSPFNbr::seqNumMismatch...{} ", reason);
         stopRxMtDdTimer();
 
@@ -560,10 +557,9 @@
      * In addition, stop the possibly activated re transmission timer.
      *
      * @param ch netty channel instance
-     * @throws Exception on error
      */
     @Override
-    public void badLSReq(Channel ch) throws Exception {
+    public void badLSReq(Channel ch) {
         log.debug("OSPFNbr::badLSReq...!!!");
 
         if (state.getValue() >= OspfNeighborState.EXCHANGE.getValue()) {
@@ -622,10 +618,9 @@
      * @param neighborIsMaster true if neighbor is master else false
      * @param dataDescPkt      DdPacket instance
      * @param ch               netty channel instance
-     * @throws Exception might throws exception
      */
     public void processDdPacket(boolean neighborIsMaster, DdPacket dataDescPkt,
-                                Channel ch) throws Exception {
+                                Channel ch) {
         log.debug("OSPFNbr::neighborIsMaster.{}", neighborIsMaster);
 
         if (!neighborIsMaster) {
@@ -902,9 +897,9 @@
      * @param lsUpdPkt LS Update Packet received while Neighbor state was EXCHANGE or
      *                 LOADING
      * @param ch       netty channel instance
-     * @throws Exception might throws exception
+     * @throws OspfParseException on parsing error
      */
-    public void processLsUpdate(LsUpdate lsUpdPkt, Channel ch) throws Exception {
+    public void processLsUpdate(LsUpdate lsUpdPkt, Channel ch) throws OspfParseException {
         stopRxMtLsrTimer();
         log.debug("OSPFNbr::processLsUpdate...!!!");
 
@@ -946,10 +941,8 @@
 
     /***
      * Method gets called when no more ls request list and moving to FULL State.
-     *
-     * @throws Exception might throws exception
      */
-    public void loadingDone() throws Exception {
+    public void loadingDone() {
         stopRxMtLsrTimer();
         stopRxMtDdTimer();
         log.debug("OSPFNbr::loadingDone...!!!");
@@ -1051,12 +1044,12 @@
      * @param receivedViaFlooding received via flooding or not
      * @param ch                  channel instance
      * @param sourceIp            source of this Lsa
+     * @throws OspfParseException on parsing error
      * @return true to remove it from lsReqList else false
-     * @throws Exception might throws exception
      */
     public boolean processReceivedLsa(LsaHeader recLsa,
                                       boolean receivedViaFlooding, Channel ch, Ip4Address sourceIp)
-            throws Exception {
+                    throws OspfParseException {
         log.debug("OSPFNbr::processReceivedLsa(recLsa, receivedViaFlooding, ch)...!!!");
 
         //Validate the lsa checksum RFC 2328 13 (1)
@@ -1282,10 +1275,8 @@
     /**
      * RFC 2328 section 13.4
      * Processing self-originated LSAs.
-     *
-     * @throws Exception might throws exception
      */
-    public void processSelfOriginatedLsa() throws Exception {
+    public void processSelfOriginatedLsa() {
         ospfArea.refreshArea(ospfInterface);
     }
 
@@ -1349,10 +1340,8 @@
 
     /**
      * Called when neighbor is down.
-     *
-     * @throws Exception might throws exception
      */
-    public void neighborDown() throws Exception {
+    public void neighborDown() {
         log.debug("Neighbor Down {} and NeighborId {}", neighborIpAddr,
                   neighborId);
         stopInactivityTimeCheck();
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
index cb1829a..f98f54c 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
@@ -35,7 +35,7 @@
     }
 
     @Override
-    public ChannelPipeline getPipeline() throws Exception {
+    public ChannelPipeline getPipeline() {
         ChannelPipeline pipeline = Channels.pipeline();
         pipeline.addLast("encoder", new OspfMessageDecoder());
         pipeline.addLast("decoder", new OspfMessageEncoder());
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java
index 02a4fb1..94d232c 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java
@@ -22,6 +22,7 @@
 import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.controller.area.OspfAreaImpl;
 import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
@@ -97,7 +98,7 @@
      *
      * @param wrapper LSA wrapper instance
      */
-    private void processVerifyChecksum(LsaWrapper wrapper) throws Exception {
+    private void processVerifyChecksum(LsaWrapper wrapper) throws OspfParseException {
         ChecksumCalculator checkSum = new ChecksumCalculator();
         if (!checkSum.isValidLsaCheckSum(wrapper.ospfLsa(), ((LsaWrapperImpl) wrapper).lsaHeader().lsType(),
                                          OspfUtil.LSAPACKET_CHECKSUM_POS1,
@@ -116,7 +117,7 @@
      *
      * @param wrapper LSA wrapper instance
      */
-    private void processRefreshLsa(LsaWrapper wrapper) throws Exception {
+    private void processRefreshLsa(LsaWrapper wrapper) throws OspfParseException {
         if (wrapper.isSelfOriginated()) { //self originated
             //set the destination
             OspfInterface ospfInterface = wrapper.ospfInterface();
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
index 015f2dc..e530097 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
@@ -26,6 +26,7 @@
 import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 /**
  * Representation of link id value of link tlv of Traffic Engineering.
@@ -58,14 +59,14 @@
      * Reads bytes from channel buffer.
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         try {
             byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
             channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
             this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName());
-        } catch (Exception e) {
+        } catch (UnknownHostException e) {
             log.debug("Error::LinkId:: {}", e.getMessage());
             throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
                                          OspfErrorType.BAD_MESSAGE);
@@ -76,9 +77,9 @@
      * Returns instance as byte array.
      *
      * @return instance as bytes
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] asBytes() throws Exception {
+    public byte[] asBytes() throws OspfParseException {
         byte[] linkSubType = null;
 
         byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
@@ -92,9 +93,9 @@
      * Gets byte array of link id sub tlv body.
      *
      * @return gets the body as byte array
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws Exception {
+    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
         byte[] linkSubTypeBody = null;
         try {
             linkSubTypeBody = InetAddress.getByName(this.linkId).getAddress();
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
index 4b5c6f4..a1a2ac9 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
@@ -63,9 +63,9 @@
      * Reads from channel buffer.
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         try {
             int len = channelBuffer.readableBytes();
             byte[] tempByteArray = new byte[len];
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
index 92c3183..0214ccc 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
@@ -26,6 +26,7 @@
 import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -69,15 +70,15 @@
      * Reads bytes from channel buffer.
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) {
             try {
                 byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
                 channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
                 this.addLocalInterfaceIPAddress(InetAddress.getByAddress(tempByteArray).getHostName());
-            } catch (Exception e) {
+            } catch (UnknownHostException e) {
                 log.debug("Error::readFrom:: {}", e.getMessage());
                 throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
                                              OspfErrorType.BAD_MESSAGE);
@@ -89,9 +90,9 @@
      * Gets local interface ip address as byte array.
      *
      * @return local interface ip address as byte array
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] asBytes() throws Exception {
+    public byte[] asBytes() throws OspfParseException {
         byte[] linkSubType = null;
 
         byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
@@ -105,9 +106,9 @@
      * Gets byte array of local interface ip address.
      *
      * @return byte array of local interface ip address
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws Exception {
+    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
 
         List<Byte> linkSubTypeBody = new ArrayList<>();
 
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
index 07d1cdb..7aaf9d9 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
@@ -69,9 +69,9 @@
      * Reads bytes from channel buffer .
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) {
             try {
                 byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
@@ -89,9 +89,9 @@
      * Gets byte array of remote interface ip address .
      *
      * @return byte array of remote interface ip address
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] asBytes() throws Exception {
+    public byte[] asBytes() throws OspfParseException {
         byte[] linkSubType = null;
 
         byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
@@ -105,9 +105,9 @@
      * Gets byte array of remote interface ip address.
      *
      * @return byte array of remote interface ip address
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws Exception {
+    public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
         List<Byte> linkSubTypeBody = new ArrayList<>();
 
         for (String remoteAddress : this.remoteInterfaceAddress) {
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
index acc72e3..6521ab2 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
@@ -18,6 +18,7 @@
 import com.google.common.base.MoreObjects;
 import com.google.common.primitives.Bytes;
 import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.TlvHeader;
 import org.onosproject.ospf.protocol.lsa.linksubtype.AdministrativeGroup;
 import org.onosproject.ospf.protocol.lsa.linksubtype.LinkId;
@@ -66,9 +67,9 @@
      * Reads bytes from channel buffer .
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         while (channelBuffer.readableBytes() > 0) {
             TlvHeader tlvHeader = new TlvHeader();
             tlvHeader.setTlvType(channelBuffer.readUnsignedShort());
@@ -126,9 +127,9 @@
      * Gets link tlv as byte array.
      *
      * @return link tlv as byte array
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException if the packet can't be parsed
      */
-    public byte[] asBytes() throws Exception {
+    public byte[] asBytes() throws OspfParseException {
         byte[] lsaMessage = null;
 
         byte[] tlvHeader = getTlvHeaderAsByteArray();
@@ -142,9 +143,9 @@
      * Gets tlv body as byte array.
      *
      * @return tlv body as byte array
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
-    public byte[] getTlvBodyAsByteArray() throws Exception {
+    public byte[] getTlvBodyAsByteArray() throws OspfParseException {
 
         List<Byte> bodyLst = new ArrayList<>();
         for (LinkSubType tlv : subTlv) {
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
index 83bf918..8ac443b 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
@@ -71,9 +71,9 @@
      * Reads bytes from channel buffer .
      *
      * @param channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
-    public void readFrom(ChannelBuffer channelBuffer) throws Exception {
+    public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
         try {
             byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
             channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
index d87dfc5..b0fd4b6 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
@@ -131,9 +131,9 @@
      * Returns instance as bytes.
      *
      * @return instance as bytes
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] asBytes() throws Exception {
+    public byte[] asBytes() throws OspfParseException {
 
         byte[] lsaMessage = null;
         byte[] lsaHeader = getOpaqueLsaHeaderAsByteArray();
@@ -147,9 +147,9 @@
      * Gets the LSA body as byte array.
      *
      * @return the lsa body as byte array
-     * @throws Exception might throws exception while parsing packet
+     * @throws OspfParseException might throws exception while parsing packet
      */
-    public byte[] getLsaBodyAsByteArray() throws Exception {
+    public byte[] getLsaBodyAsByteArray() throws OspfParseException {
         List<Byte> bodyLst = new ArrayList<>();
         if (this.opaqueId() == 1) {
             for (TopLevelTlv tlv : this.topLevelValues) {
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
index b7ac7a8..e51672f 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
@@ -42,10 +42,10 @@
      *
      * @param channelBuffer channel buffer instance.
      * @return OSPF message instance.
-     * @throws Exception might throws exception while parsing buffer
+     * @throws OspfParseException might throws exception while parsing buffer
      */
     public OspfMessage readFromBuffer(ChannelBuffer channelBuffer)
-            throws Exception {
+            throws OspfParseException {
 
         try {
             OspfPacketHeader ospfHeader = getOspfHeader(channelBuffer);
@@ -97,7 +97,7 @@
      * @param channelBuffer channel buffer instance.
      * @return Ospf Header instance.
      */
-    private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) throws Exception {
+    private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) {
         OspfPacketHeader ospfPacketHeader = new OspfPacketHeader();
 
         // Determine OSPF version & Packet Type
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
index f346f45..bddb853 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
@@ -17,6 +17,7 @@
 
 import org.onosproject.ospf.controller.OspfLsa;
 import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
 import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
 import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
@@ -31,14 +32,19 @@
 import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
 import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
 import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
+import org.slf4j.Logger;
 
 import java.util.Arrays;
 
+import static org.slf4j.LoggerFactory.getLogger;
+
 /**
  * Calculates checksum for different types of OSPF packets.
  */
 public class ChecksumCalculator {
 
+    private static final Logger log = getLogger(ChecksumCalculator.class);
+
     /**
      * Converts given string to sixteen bits integer.
      * If hexasum is more than 16 bit value, needs to be reduced to 16 bit value.
@@ -98,11 +104,12 @@
      * @param lsType          lsa type
      * @param lsaChecksumPos1 lsa checksum position in packet
      * @param lsaChecksumPos2 lsa checksum position in packet
+     * @throws OspfParseException if packet can't be parsed
      * @return true if valid else false
-     * @throws Exception might throw exception while processing
      */
     public boolean isValidLsaCheckSum(OspfLsa ospfLsa, int lsType, int lsaChecksumPos1,
-                                      int lsaChecksumPos2) throws Exception {
+                                      int lsaChecksumPos2) throws OspfParseException {
+
         if (lsType == OspfLsaType.ROUTER.value()) {
             RouterLsa lsa = (RouterLsa) ospfLsa;
             return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
@@ -129,6 +136,7 @@
             return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
         }
 
+
         return false;
     }
 
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
index fa15cdb..182b827 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
@@ -26,6 +26,7 @@
 
 import javax.xml.bind.DatatypeConverter;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.security.SecureRandom;
 import java.util.Arrays;
 import java.util.Collections;
@@ -93,10 +94,8 @@
      * @param ip2  IP address
      * @param mask network mask
      * @return true if both are in same network else false
-     * @throws Exception might throws exception while parsing ip address
      */
-    public static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, Ip4Address mask)
-            throws Exception {
+    public static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, Ip4Address mask) {
 
         byte[] a1 = ip1.toOctets();
         byte[] a2 = ip2.toOctets();
@@ -195,9 +194,8 @@
      *
      * @param channelBuffer channel buffer instance
      * @return LSA header instance.
-     * @throws Exception might throws exception while parsing buffer
      */
-    public static LsaHeader readLsaHeader(ChannelBuffer channelBuffer) throws Exception {
+    public static LsaHeader readLsaHeader(ChannelBuffer channelBuffer) {
         //add all the LSA Headers - one header is of 20 bytes
         LsaHeader lsaHeader = null;
         if (channelBuffer.readableBytes() >= OspfUtil.LSA_HEADER_LENGTH) {
@@ -230,7 +228,11 @@
                 header.setLsType(tempBuffer.readByte());
                 byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
                 channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
-                header.setLinkStateId(InetAddress.getByAddress(tempByteArray).getHostName());
+                try {
+                    header.setLinkStateId(InetAddress.getByAddress(tempByteArray).getHostName());
+                } catch (UnknownHostException uhe) {
+                    log.warn("Can't look up host", uhe);
+                }
                 tempByteArray = new byte[OspfUtil.FOUR_BYTES];
                 channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
                 header.setAdvertisingRouter(Ip4Address.valueOf(tempByteArray));