Fix issues found by FindBugs: BC_UNCONFIRMED_CAST

http://findbugs.sourceforge.net/bugDescriptions.html#BC_UNCONFIRMED_CAST

Change-Id: Ibd1019db95d85b316854be230473c716016d4275
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
index ae4202a..99c8769 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
@@ -107,7 +107,8 @@
 
     @Override
     public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
-        if (msg.getType().equals(OFType.PACKET_IN)) {
+        if (msg.getType().equals(OFType.PACKET_IN) &&
+            (msg instanceof OFPacketIn)) {
             OFPacketIn pi = (OFPacketIn) msg;
 
             Ethernet eth = IFloodlightProviderService.bcStore.
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
index ff3268e..4f6451e 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
@@ -133,15 +133,12 @@
 
     @Override
     public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
-        switch (msg.getType()) {
-            case FLOW_REMOVED:
-                OFFlowRemoved flowMsg = (OFFlowRemoved) msg;
-                FlowEntryId id = new FlowEntryId(flowMsg.getCookie());
-                log.debug("Got flow entry removed from {}: {}", sw.getId(), id);
-                // TODO: Inform the Forwarding module that a flow has expired
-                break;
-            default:
-                break;
+        if (msg.getType().equals(OFType.FLOW_REMOVED) &&
+            (msg instanceof OFFlowRemoved)) {
+            OFFlowRemoved flowMsg = (OFFlowRemoved) msg;
+            FlowEntryId id = new FlowEntryId(flowMsg.getCookie());
+            log.debug("Got flow entry removed from {}: {}", sw.getId(), id);
+            // TODO: Inform the Forwarding module that a flow has expired
         }
 
         return Command.CONTINUE;
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
index 18a5753..56e4231 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -1079,7 +1079,8 @@
             log.trace("Received BARRIER_REPLY from : {}", sw.getId());
         }
 
-        if (msg.getType() != OFType.BARRIER_REPLY) {
+        if ((msg.getType() != OFType.BARRIER_REPLY) ||
+            !(msg instanceof OFBarrierReply)) {
             log.error("Unexpected reply message : {}", msg.getType());
             return Command.CONTINUE;
         }
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
index 7989aaa..c12cf7e 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -779,9 +779,16 @@
     public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
         switch (msg.getType()) {
             case PACKET_IN:
-                return this.handlePacketIn(sw.getId(), (OFPacketIn) msg, cntx);
+                if (msg instanceof OFPacketIn) {
+                    return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
+                                               cntx);
+                }
+                break;
             case PORT_STATUS:
-                return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
+                if (msg instanceof OFPortStatus) {
+                    return this.handlePortStatus(sw.getId(), (OFPortStatus) msg);
+                }
+                break;
             default:
                 break;
         }