Ray Milkey
Committed by Gerrit Code Review

Last two high priority findbugs errors

Change-Id: I180d9156b49c79980f2b2361ec062e5c1cda64a8
......@@ -32,13 +32,13 @@ public class IPv4 extends BasePacket {
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 @@ s */
}
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();
......
......@@ -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 @@ public abstract class Tools {
* @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) {
......