diff --git a/build.xml b/build.xml index 3acd1ecf9e03b716194b449a40844da847343bdc..79d64b1f1c29c68f6cfd490e8e6a9942f1463856 100644 --- a/build.xml +++ b/build.xml @@ -67,6 +67,8 @@ <include name="jython-2.5.2.jar"/> <include name="libthrift-0.7.0.jar"/> <include name="guava-13.0.1.jar" /> + <include name="findbugs-annotations-2.0.1.jar" /> + <include name="findbugs-jsr305-2.0.1.jar" /> </patternset> <path id="classpath"> @@ -283,7 +285,8 @@ <mkdir dir="${findbugs.results}"/> <findbugs home="${findbugs.home}" output="xml" - outputFile="${findbugs.results}/results.xml" > + excludeFilter="${basedir}/findbugs-exclude.xml" + outputFile="${findbugs.results}/results.xml" reportLevel='high'> <sourcePath path="${source}" /> <sourcePath path="${thrift.out.dir}" /> <class location="${build}" /> @@ -298,6 +301,7 @@ <mkdir dir="${findbugs.results}"/> <findbugs home="${findbugs.home}" output="html" + excludeFilter="${basedir}/findbugs-exclude.xml" outputFile="${findbugs.results}/results.html" > <sourcePath path="${source}" /> <sourcePath path="${thrift.out.dir}" /> diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb2e5f327c1d1c56d911e9c3f38351b233727cce --- /dev/null +++ b/findbugs-exclude.xml @@ -0,0 +1,23 @@ +<FindBugsFilter> + <!--- Checks disabled on generated code --> + <Match> + <!-- don't complain about switch statements / external representation exposed + by generated parser files --> + <Class name="~net\.bigdb\.(query|yang)\.parser\..*(Lexer|Parser)" /> + <Bug pattern="SF_SWITCH_NO_DEFAULT,EI_EXPOSE_REP" /> + </Match> + + <!-- checks disabled because of too many false positives --> + <Match> + <!-- BC_UNFIRMED_CAST complains about too many pseudo violations, where + we know an object is of a specific type (e.g., by checking the type field + of an openflow message --> + <Bug pattern="BC_UNCONFIRMED_CAST" /> + </Match> + + <!-- checks disabled because they are just not important --> + <Match> + <!-- RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE is not an important check --> + <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" /> + </Match> +</FindBugsFilter> diff --git a/lib/findbugs-annotations-2.0.1.jar b/lib/findbugs-annotations-2.0.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..8a0204fc28d78a15a848f8d2d4af467e52bb43c8 Binary files /dev/null and b/lib/findbugs-annotations-2.0.1.jar differ diff --git a/lib/findbugs-jsr305-2.0.1.jar b/lib/findbugs-jsr305-2.0.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..43807b02f35db48dc302b4ade0c72b2141d65cbb Binary files /dev/null and b/lib/findbugs-jsr305-2.0.1.jar differ diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index 37de44e2626cc791fa42bcefe4d79e603b82fcc9..ba31a3adf9b680e0ad48d715c57dbf0d602b2021 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -234,6 +234,9 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { while ((iSrcDaps < srcDaps.length) && (iDstDaps < dstDaps.length)) { SwitchPort srcDap = srcDaps[iSrcDaps]; SwitchPort dstDap = dstDaps[iDstDaps]; + + // srcCluster and dstCluster here cannot be null as + // every switch will be at least in its own L2 domain. Long srcCluster = topology.getL2DomainId(srcDap.getSwitchDPID()); Long dstCluster = @@ -241,9 +244,7 @@ public class Forwarding extends ForwardingBase implements IFloodlightModule { int srcVsDest = srcCluster.compareTo(dstCluster); if (srcVsDest == 0) { - if (!srcDap.equals(dstDap) && - (srcCluster != null) && - (dstCluster != null)) { + if (!srcDap.equals(dstDap)) { Route route = routingEngine.getRoute(srcDap.getSwitchDPID(), (short)srcDap.getPort(), diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 3462c562f5f5c2344e315e8d0115ba152fcedac5..f35a556f621a38fdad5d442c5ec7ca63a0268edd 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -187,7 +187,7 @@ public class LinkDiscoveryManager implements IOFMessageListener, * Flag to indicate if automatic port fast is enabled or not. Default is set * to false -- Initialized in the init method as well. */ - public final boolean AUTOPORTFAST_DEFAULT = false; + protected boolean AUTOPORTFAST_DEFAULT = false; protected boolean autoPortFastFeature = AUTOPORTFAST_DEFAULT; /** @@ -2046,7 +2046,7 @@ public class LinkDiscoveryManager implements IOFMessageListener, log.debug("Event history size set to {}", EVENT_HISTORY_SIZE); // Set the autoportfast feature to false. - this.autoPortFastFeature = false; + this.autoPortFastFeature = AUTOPORTFAST_DEFAULT; // We create this here because there is no ordering guarantee this.linkDiscoveryAware = new ArrayList<ILinkDiscoveryListener>(); diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java index 385d268260502d6feac7bb64455cbee117292787..8ddd7722949105ac42f215e9d57fb14c15e97bb9 100644 --- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java +++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java @@ -47,7 +47,6 @@ import java.util.concurrent.ConcurrentHashMap; import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.module.FloodlightModuleContext; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockThreadPoolService; import net.floodlightcontroller.devicemanager.IDevice; import net.floodlightcontroller.devicemanager.IDeviceListener; diff --git a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java index 359f9f4fd39a17b8739cd76a5611ac144a7e16c4..5de211420fb9c5dd2a810eed6e31d942404395ca 100644 --- a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java +++ b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java @@ -30,7 +30,6 @@ import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleException; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.packet.ARP; import net.floodlightcontroller.packet.Data; import net.floodlightcontroller.packet.Ethernet; diff --git a/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java b/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java index 43ae3951cf20437bd668d544579ed7b6e1457232..a66fac238c5448d92abc5108a7df193aafe4a085 100644 --- a/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java +++ b/src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java @@ -24,7 +24,6 @@ import java.util.ListIterator; import net.floodlightcontroller.core.IListener.Command; import net.floodlightcontroller.core.module.FloodlightModuleContext; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockThreadPoolService; import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.counter.SimpleCounter; diff --git a/src/test/java/net/floodlightcontroller/flowcache/PortDownReconciliationTest.java b/src/test/java/net/floodlightcontroller/flowcache/PortDownReconciliationTest.java index 639136ad5027a90c7eb0cffb3fdfc9346765eee3..8407ee3605e1ac650903c87a9c9e012adf29a027 100644 --- a/src/test/java/net/floodlightcontroller/flowcache/PortDownReconciliationTest.java +++ b/src/test/java/net/floodlightcontroller/flowcache/PortDownReconciliationTest.java @@ -56,7 +56,6 @@ import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.module.FloodlightModuleContext; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockThreadPoolService; import net.floodlightcontroller.devicemanager.IEntityClassifierService; import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier; diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java index 38be5d82861fb516630b3f582d1309c66ea5f3f4..78fb6112d0d08a927090f6d35cf924a328db8d69 100644 --- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java +++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java @@ -29,7 +29,6 @@ import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.module.FloodlightModuleContext; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockThreadPoolService; import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier; import net.floodlightcontroller.devicemanager.test.MockDeviceManager; diff --git a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java index f21fc73d968700b8bdc3cf479313dd6595deb86c..7311ac1aadd75dd13a19637f97a7edf7ff0e552b 100644 --- a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java +++ b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java @@ -52,7 +52,6 @@ import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.module.FloodlightModuleContext; -import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockThreadPoolService; import net.floodlightcontroller.counter.CounterStore; import net.floodlightcontroller.counter.ICounterStoreService;