Committed by
Gerrit Code Review
Last two high priority findbugs errors
Change-Id: I180d9156b49c79980f2b2361ec062e5c1cda64a8
Showing
2 changed files
with
17 additions
and
12 deletions
| ... | @@ -32,13 +32,13 @@ public class IPv4 extends BasePacket { | ... | @@ -32,13 +32,13 @@ public class IPv4 extends BasePacket { |
| 32 | public static final byte PROTOCOL_ICMP = 0x1; | 32 | public static final byte PROTOCOL_ICMP = 0x1; |
| 33 | public static final byte PROTOCOL_TCP = 0x6; | 33 | public static final byte PROTOCOL_TCP = 0x6; |
| 34 | public static final byte PROTOCOL_UDP = 0x11; | 34 | public static final byte PROTOCOL_UDP = 0x11; |
| 35 | - public static Map<Byte, Class<? extends IPacket>> protocolClassMap = | 35 | + public static final Map<Byte, Class<? extends IPacket>> PROTOCOL_CLASS_MAP = |
| 36 | new HashMap<>(); | 36 | new HashMap<>(); |
| 37 | 37 | ||
| 38 | static { | 38 | static { |
| 39 | - IPv4.protocolClassMap.put(IPv4.PROTOCOL_ICMP, ICMP.class); | 39 | + IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_ICMP, ICMP.class); |
| 40 | - IPv4.protocolClassMap.put(IPv4.PROTOCOL_TCP, TCP.class); | 40 | + IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_TCP, TCP.class); |
| 41 | - IPv4.protocolClassMap.put(IPv4.PROTOCOL_UDP, UDP.class); | 41 | + IPv4.PROTOCOL_CLASS_MAP.put(IPv4.PROTOCOL_UDP, UDP.class); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | protected byte version; | 44 | protected byte version; |
| ... | @@ -390,8 +390,8 @@ s */ | ... | @@ -390,8 +390,8 @@ s */ |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | IPacket payload; | 392 | IPacket payload; |
| 393 | - if (IPv4.protocolClassMap.containsKey(this.protocol)) { | 393 | + if (IPv4.PROTOCOL_CLASS_MAP.containsKey(this.protocol)) { |
| 394 | - final Class<? extends IPacket> clazz = IPv4.protocolClassMap | 394 | + final Class<? extends IPacket> clazz = IPv4.PROTOCOL_CLASS_MAP |
| 395 | .get(this.protocol); | 395 | .get(this.protocol); |
| 396 | try { | 396 | try { |
| 397 | payload = clazz.newInstance(); | 397 | payload = clazz.newInstance(); | ... | ... |
| ... | @@ -15,18 +15,20 @@ | ... | @@ -15,18 +15,20 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onlab.util; | 16 | package org.onlab.util; |
| 17 | 17 | ||
| 18 | -import com.google.common.base.Strings; | ||
| 19 | -import com.google.common.primitives.UnsignedLongs; | ||
| 20 | -import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
| 21 | - | ||
| 22 | import java.io.BufferedReader; | 18 | import java.io.BufferedReader; |
| 23 | import java.io.File; | 19 | import java.io.File; |
| 24 | -import java.io.FileReader; | 20 | +import java.io.FileInputStream; |
| 25 | import java.io.IOException; | 21 | import java.io.IOException; |
| 22 | +import java.io.InputStreamReader; | ||
| 23 | +import java.nio.charset.StandardCharsets; | ||
| 26 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 27 | import java.util.List; | 25 | import java.util.List; |
| 28 | import java.util.concurrent.ThreadFactory; | 26 | import java.util.concurrent.ThreadFactory; |
| 29 | 27 | ||
| 28 | +import com.google.common.base.Strings; | ||
| 29 | +import com.google.common.primitives.UnsignedLongs; | ||
| 30 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
| 31 | + | ||
| 30 | public abstract class Tools { | 32 | public abstract class Tools { |
| 31 | 33 | ||
| 32 | private Tools() { | 34 | private Tools() { |
| ... | @@ -94,7 +96,10 @@ public abstract class Tools { | ... | @@ -94,7 +96,10 @@ public abstract class Tools { |
| 94 | * @return file contents | 96 | * @return file contents |
| 95 | */ | 97 | */ |
| 96 | public static List<String> slurp(File path) { | 98 | public static List<String> slurp(File path) { |
| 97 | - try (BufferedReader br = new BufferedReader(new FileReader(path))) { | 99 | + try { |
| 100 | + BufferedReader br = new BufferedReader( | ||
| 101 | + new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)); | ||
| 102 | + | ||
| 98 | List<String> lines = new ArrayList<>(); | 103 | List<String> lines = new ArrayList<>(); |
| 99 | String line; | 104 | String line; |
| 100 | while ((line = br.readLine()) != null) { | 105 | while ((line = br.readLine()) != null) { | ... | ... |
-
Please register or login to post a comment