Yuta HIGUCHI

fix some of findbugs issues

Change-Id: I20aa54af16f3a1e3323d735fe53cc26c03d5e52e
......@@ -399,7 +399,7 @@ public class GossipHostStore
}
// Auxiliary extension to allow location to mutate.
private class StoredHost extends DefaultHost {
private static final class StoredHost extends DefaultHost {
private Timestamped<HostLocation> location;
/**
......
......@@ -269,7 +269,7 @@ public class SimpleHostStore
}
// Auxiliary extension to allow location to mutate.
private class StoredHost extends DefaultHost {
private static final class StoredHost extends DefaultHost {
private HostLocation location;
/**
......
......@@ -32,7 +32,7 @@ public final class ChassisId {
* @param value the value to use.
*/
public ChassisId(String value) {
this.value = Long.valueOf(value, 16);
this.value = Long.parseLong(value, 16);
}
/**
......
......@@ -379,7 +379,7 @@ public class DHCP extends BasePacket {
// 300
int optionsLength = 0;
for (final DHCPOption option : this.options) {
if (option.getCode() == 0 || option.getCode() == 255) {
if (option.getCode() == 0 || option.getCode() == ((byte) 255)) {
optionsLength += 1;
} else {
optionsLength += 2 + (0xff & option.getLength());
......
......@@ -438,7 +438,7 @@ public class IPv4 extends BasePacket {
int result = 0;
for (int i = 0; i < 4; ++i) {
result |= Integer.valueOf(octets[i]) << (3 - i) * 8;
result |= Integer.parseInt(octets[i]) << (3 - i) * 8;
}
return result;
}
......@@ -471,7 +471,7 @@ public class IPv4 extends BasePacket {
int result = 0;
for (int i = 0; i < 4; ++i) {
result = ipAddress >> (3 - i) * 8 & 0xff;
sb.append(Integer.valueOf(result).toString());
sb.append(result);
if (i != 3) {
sb.append(".");
}
......
......@@ -14,7 +14,7 @@ public final class HexString {
*/
public static String toHexString(final byte[] bytes) {
int i;
StringBuilder ret = new StringBuilder();
StringBuilder ret = new StringBuilder(bytes.length * 3 - 1);
String tmp;
for (i = 0; i < bytes.length; i++) {
if (i > 0) {
......@@ -31,22 +31,22 @@ public final class HexString {
public static String toHexString(final long val, final int padTo) {
char[] arr = Long.toHexString(val).toCharArray();
String ret = "";
StringBuilder ret = new StringBuilder(padTo * 3 - 1);
// prepend the right number of leading zeros
int i = 0;
for (; i < (padTo * 2 - arr.length); i++) {
ret += "0";
ret.append('0');
if ((i % 2) != 0) {
ret += ":";
ret.append(':');
}
}
for (int j = 0; j < arr.length; j++) {
ret += arr[j];
ret.append(arr[j]);
if ((((i + j) % 2) != 0) && (j < (arr.length - 1))) {
ret += ":";
ret.append(':');
}
}
return ret;
return ret.toString();
}
public static String toHexString(final long val) {
......
......@@ -163,6 +163,7 @@ public class NettyMessagingService implements MessagingService {
handlers.putIfAbsent(type, handler);
}
@Override
public void unregisterHandler(String type) {
handlers.remove(type);
}
......@@ -242,7 +243,7 @@ public class NettyMessagingService implements MessagingService {
}
}
private class WriteTask implements Runnable {
private static class WriteTask implements Runnable {
private final InternalMessage message;
private final Channel channel;
......