Last two high priority findbugs errors
Change-Id: I180d9156b49c79980f2b2361ec062e5c1cda64a8
diff --git a/utils/misc/src/main/java/org/onlab/packet/IPv4.java b/utils/misc/src/main/java/org/onlab/packet/IPv4.java
index 28f6a48..574fd1a 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IPv4.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IPv4.java
@@ -32,13 +32,13 @@
public static final byte PROTOCOL_ICMP = 0x1;
public static final byte PROTOCOL_TCP = 0x6;
public static final byte PROTOCOL_UDP = 0x11;
- public static Map<Byte, Class<? extends IPacket>> protocolClassMap =
+ public static final Map<Byte, Class<? extends IPacket>> PROTOCOL_CLASS_MAP =
new HashMap<>();
static {
- IPv4.protocolClassMap.put(IPv4.PROTOCOL_ICMP, ICMP.class);
- IPv4.protocolClassMap.put(IPv4.PROTOCOL_TCP, TCP.class);
- IPv4.protocolClassMap.put(IPv4.PROTOCOL_UDP, UDP.class);
+ IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_ICMP, ICMP.class);
+ IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_TCP, TCP.class);
+ IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_UDP, UDP.class);
}
protected byte version;
@@ -390,8 +390,8 @@
}
IPacket payload;
- if (IPv4.protocolClassMap.containsKey(this.protocol)) {
- final Class<? extends IPacket> clazz = IPv4.protocolClassMap
+ if (IPv4.PROTOCOL_CLASS_MAP.containsKey(this.protocol)) {
+ final Class<? extends IPacket> clazz = IPv4.PROTOCOL_CLASS_MAP
.get(this.protocol);
try {
payload = clazz.newInstance();
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index 3a0e926..b6a76d0 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -15,18 +15,20 @@
*/
package org.onlab.util;
-import com.google.common.base.Strings;
-import com.google.common.primitives.UnsignedLongs;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadFactory;
+import com.google.common.base.Strings;
+import com.google.common.primitives.UnsignedLongs;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
public abstract class Tools {
private Tools() {
@@ -94,7 +96,10 @@
* @return file contents
*/
public static List<String> slurp(File path) {
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
+ try {
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8));
+
List<String> lines = new ArrayList<>();
String line;
while ((line = br.readLine()) != null) {