Yuta HIGUCHI

fix some of findbugs issues

Change-Id: I20aa54af16f3a1e3323d735fe53cc26c03d5e52e
...@@ -399,7 +399,7 @@ public class GossipHostStore ...@@ -399,7 +399,7 @@ public class GossipHostStore
399 } 399 }
400 400
401 // Auxiliary extension to allow location to mutate. 401 // Auxiliary extension to allow location to mutate.
402 - private class StoredHost extends DefaultHost { 402 + private static final class StoredHost extends DefaultHost {
403 private Timestamped<HostLocation> location; 403 private Timestamped<HostLocation> location;
404 404
405 /** 405 /**
......
...@@ -269,7 +269,7 @@ public class SimpleHostStore ...@@ -269,7 +269,7 @@ public class SimpleHostStore
269 } 269 }
270 270
271 // Auxiliary extension to allow location to mutate. 271 // Auxiliary extension to allow location to mutate.
272 - private class StoredHost extends DefaultHost { 272 + private static final class StoredHost extends DefaultHost {
273 private HostLocation location; 273 private HostLocation location;
274 274
275 /** 275 /**
......
...@@ -32,7 +32,7 @@ public final class ChassisId { ...@@ -32,7 +32,7 @@ public final class ChassisId {
32 * @param value the value to use. 32 * @param value the value to use.
33 */ 33 */
34 public ChassisId(String value) { 34 public ChassisId(String value) {
35 - this.value = Long.valueOf(value, 16); 35 + this.value = Long.parseLong(value, 16);
36 } 36 }
37 37
38 /** 38 /**
......
...@@ -379,7 +379,7 @@ public class DHCP extends BasePacket { ...@@ -379,7 +379,7 @@ public class DHCP extends BasePacket {
379 // 300 379 // 300
380 int optionsLength = 0; 380 int optionsLength = 0;
381 for (final DHCPOption option : this.options) { 381 for (final DHCPOption option : this.options) {
382 - if (option.getCode() == 0 || option.getCode() == 255) { 382 + if (option.getCode() == 0 || option.getCode() == ((byte) 255)) {
383 optionsLength += 1; 383 optionsLength += 1;
384 } else { 384 } else {
385 optionsLength += 2 + (0xff & option.getLength()); 385 optionsLength += 2 + (0xff & option.getLength());
......
...@@ -438,7 +438,7 @@ public class IPv4 extends BasePacket { ...@@ -438,7 +438,7 @@ public class IPv4 extends BasePacket {
438 438
439 int result = 0; 439 int result = 0;
440 for (int i = 0; i < 4; ++i) { 440 for (int i = 0; i < 4; ++i) {
441 - result |= Integer.valueOf(octets[i]) << (3 - i) * 8; 441 + result |= Integer.parseInt(octets[i]) << (3 - i) * 8;
442 } 442 }
443 return result; 443 return result;
444 } 444 }
...@@ -471,7 +471,7 @@ public class IPv4 extends BasePacket { ...@@ -471,7 +471,7 @@ public class IPv4 extends BasePacket {
471 int result = 0; 471 int result = 0;
472 for (int i = 0; i < 4; ++i) { 472 for (int i = 0; i < 4; ++i) {
473 result = ipAddress >> (3 - i) * 8 & 0xff; 473 result = ipAddress >> (3 - i) * 8 & 0xff;
474 - sb.append(Integer.valueOf(result).toString()); 474 + sb.append(result);
475 if (i != 3) { 475 if (i != 3) {
476 sb.append("."); 476 sb.append(".");
477 } 477 }
......
...@@ -14,7 +14,7 @@ public final class HexString { ...@@ -14,7 +14,7 @@ public final class HexString {
14 */ 14 */
15 public static String toHexString(final byte[] bytes) { 15 public static String toHexString(final byte[] bytes) {
16 int i; 16 int i;
17 - StringBuilder ret = new StringBuilder(); 17 + StringBuilder ret = new StringBuilder(bytes.length * 3 - 1);
18 String tmp; 18 String tmp;
19 for (i = 0; i < bytes.length; i++) { 19 for (i = 0; i < bytes.length; i++) {
20 if (i > 0) { 20 if (i > 0) {
...@@ -31,22 +31,22 @@ public final class HexString { ...@@ -31,22 +31,22 @@ public final class HexString {
31 31
32 public static String toHexString(final long val, final int padTo) { 32 public static String toHexString(final long val, final int padTo) {
33 char[] arr = Long.toHexString(val).toCharArray(); 33 char[] arr = Long.toHexString(val).toCharArray();
34 - String ret = ""; 34 + StringBuilder ret = new StringBuilder(padTo * 3 - 1);
35 // prepend the right number of leading zeros 35 // prepend the right number of leading zeros
36 int i = 0; 36 int i = 0;
37 for (; i < (padTo * 2 - arr.length); i++) { 37 for (; i < (padTo * 2 - arr.length); i++) {
38 - ret += "0"; 38 + ret.append('0');
39 if ((i % 2) != 0) { 39 if ((i % 2) != 0) {
40 - ret += ":"; 40 + ret.append(':');
41 } 41 }
42 } 42 }
43 for (int j = 0; j < arr.length; j++) { 43 for (int j = 0; j < arr.length; j++) {
44 - ret += arr[j]; 44 + ret.append(arr[j]);
45 if ((((i + j) % 2) != 0) && (j < (arr.length - 1))) { 45 if ((((i + j) % 2) != 0) && (j < (arr.length - 1))) {
46 - ret += ":"; 46 + ret.append(':');
47 } 47 }
48 } 48 }
49 - return ret; 49 + return ret.toString();
50 } 50 }
51 51
52 public static String toHexString(final long val) { 52 public static String toHexString(final long val) {
......
...@@ -163,6 +163,7 @@ public class NettyMessagingService implements MessagingService { ...@@ -163,6 +163,7 @@ public class NettyMessagingService implements MessagingService {
163 handlers.putIfAbsent(type, handler); 163 handlers.putIfAbsent(type, handler);
164 } 164 }
165 165
166 + @Override
166 public void unregisterHandler(String type) { 167 public void unregisterHandler(String type) {
167 handlers.remove(type); 168 handlers.remove(type);
168 } 169 }
...@@ -242,7 +243,7 @@ public class NettyMessagingService implements MessagingService { ...@@ -242,7 +243,7 @@ public class NettyMessagingService implements MessagingService {
242 } 243 }
243 } 244 }
244 245
245 - private class WriteTask implements Runnable { 246 + private static class WriteTask implements Runnable {
246 247
247 private final InternalMessage message; 248 private final InternalMessage message;
248 private final Channel channel; 249 private final Channel channel;
......