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/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) {