Add profile to enable error-prone
- Execute following to manually run error-prone analysis in addition to
regular static analysis:
mvn clean verify -P error-prone -T 1C
https://code.google.com/p/error-prone/
- Fix for detected error.
Change-Id: I32fe106e3b5dcfe1a08d1f284b1470a7c866dfb2
diff --git a/pom.xml b/pom.xml
index 95939cc..eeb61fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -770,5 +770,43 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>error-prone</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <compilerArgs combine.children="append">
+ <!-- FIXME -Xlint:-path required when using findbugs + error-prone -->
+ <arg>-Xlint:-path</arg>
+ </compilerArgs>
+ <!-- Turn on error-prone -->
+ <compilerId>javac-with-errorprone</compilerId>
+ <forceJavacCompilerUse>true</forceJavacCompilerUse>
+ </configuration>
+ <dependencies combine.children="append">
+ <dependency>
+ <groupId>com.google.errorprone</groupId>
+ <artifactId>error_prone_core</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-javac</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-javac-errorprone</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFMessageEncoder.java b/src/main/java/net/floodlightcontroller/core/internal/OFMessageEncoder.java
index d61f17e..29916c8 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFMessageEncoder.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFMessageEncoder.java
@@ -48,7 +48,7 @@
}
ChannelBuffer buf = ChannelBuffers.buffer(size);
- ;
+
for (OFMessage ofm : msglist) {
ofm.writeTo(buf);
}
diff --git a/src/main/java/org/openflow/protocol/OFMessage.java b/src/main/java/org/openflow/protocol/OFMessage.java
index 237e8ac..578e95b 100644
--- a/src/main/java/org/openflow/protocol/OFMessage.java
+++ b/src/main/java/org/openflow/protocol/OFMessage.java
@@ -58,7 +58,7 @@
protected synchronized ConcurrentHashMap<String, Object> getMessageStore() {
if (storage == null) {
- storage = new ConcurrentHashMap<String, Object>();;
+ storage = new ConcurrentHashMap<String, Object>();
}
return storage;
}
diff --git a/src/test/java/net/onrc/onos/core/packet/PacketTest.java b/src/test/java/net/onrc/onos/core/packet/PacketTest.java
index 3e872da..4bc893a 100644
--- a/src/test/java/net/onrc/onos/core/packet/PacketTest.java
+++ b/src/test/java/net/onrc/onos/core/packet/PacketTest.java
@@ -1,8 +1,7 @@
package net.onrc.onos.core.packet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.*;
import org.junit.Before;
import org.junit.Test;
@@ -110,8 +109,8 @@
ARP arp = (ARP) pkt;
ARP newArp = (ARP) newPkt;
newArp.setSenderProtocolAddress(new byte[]{1, 2, 3, 4});
- assertEquals(false, newArp.getSenderProtocolAddress()
- .equals(arp.getSenderProtocolAddress()));
+ assertThat(newArp.getSenderProtocolAddress(),
+ not(equalTo(arp.getSenderProtocolAddress())));
assertEquals(false, newPkt.equals(pkt));
}