Ray Milkey

Fix Sonar critical flagged bugs

Change-Id: I60e9f72a1a66f65366d7dbc5335922e75097c9f3
......@@ -276,6 +276,7 @@ public class ApplicationManager
}
// Invokes the specified function, if not null.
@java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
private void invokeHook(Runnable hook, ApplicationId appId) {
if (hook != null) {
try {
......
......@@ -70,9 +70,7 @@ public class OFOpticalSwitch13 extends AbstractOpenFlowSwitch implements OpenFlo
try {
sendHandshakeOFExperimenterPortDescRequest();
} catch (IOException e) {
log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}, {}",
getStringId(), e.getMessage());
e.printStackTrace();
log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}", e);
}
}
......
......@@ -96,8 +96,7 @@ public class OfOpticalSwitchImplLinc13
sendHandshakeOFExperimenterPortDescRequest();
} catch (IOException e) {
log.error("LINC-OE exception while sending experimenter port desc:",
e.getMessage());
e.printStackTrace();
e);
}
}
......
......@@ -111,7 +111,7 @@ final class XmlConfigParser {
try {
editcfg.save(stringWriter);
} catch (ConfigurationException e) {
e.printStackTrace();
log.error("createControllersConfig()", e);
}
String s = stringWriter.toString()
.replaceAll("<controller>",
......
......@@ -65,6 +65,7 @@ public final class GrpcDeviceUtils {
return MastershipRole.STANDBY;
case UNRECOGNIZED:
log.warn("Unrecognized MastershipRole gRPC message: {}", role);
return MastershipRole.NONE;
default:
return MastershipRole.NONE;
}
......
......@@ -71,9 +71,32 @@ public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof RouteDistinguisher) {
RouteDistinguisher that = (RouteDistinguisher) obj;
if (this.routeDistinguisher == that.routeDistinguisher) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return Long.hashCode(routeDistinguisher);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("routeDistinguisher", routeDistinguisher)
.toString();
}
}
\ No newline at end of file
}
......
......@@ -802,7 +802,7 @@ public class DefaultOvsdbClient
operations.add(portInsert);
// update the bridge table
Condition condition = ConditionUtil.equals("_uuid", UUID.uuid(bridgeUuid));
Condition condition = ConditionUtil.isEqual("_uuid", UUID.uuid(bridgeUuid));
Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port"));
List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
......@@ -875,7 +875,7 @@ public class DefaultOvsdbClient
}
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals(childColumnName, UUID.uuid(childUuid));
Condition condition = ConditionUtil.isEqual(childColumnName, UUID.uuid(childUuid));
conditions.add(condition);
Delete del = new Delete(childTableSchema, conditions);
operations.add(del);
......@@ -898,7 +898,7 @@ public class DefaultOvsdbClient
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals(columnName, UUID.uuid(uuid));
Condition condition = ConditionUtil.isEqual(columnName, UUID.uuid(uuid));
conditions.add(condition);
Update update = new Update(tableSchema, row, conditions);
......@@ -944,7 +944,7 @@ public class DefaultOvsdbClient
mutations.add(mutation);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals("_uuid",
Condition condition = ConditionUtil.isEqual("_uuid",
UUID.uuid(parentUuid));
conditions.add(condition);
......
......@@ -37,7 +37,7 @@ public final class ConditionUtil {
* @param data column value
* @return Condition
*/
public static Condition equals(String columnName, Object data) {
public static Condition isEqual(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Condition(columnName, Function.EQUALS, value);
}
......
......@@ -156,6 +156,7 @@ public class IGMP extends BasePacket {
*
* @return the serialized IGMP message
*/
@java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
@Override
public byte[] serialize() {
byte [] data = new byte[8915];
......
......@@ -137,6 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor {
* Feedback policy that delays the caller's thread until the executor's work
* queue falls below a threshold, then runs the job on the caller's thread.
*/
@java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
private static final class CallerFeedbackPolicy implements RejectedExecutionHandler {
private final BlockingBoolean underLoad = new BlockingBoolean(false);
......@@ -173,4 +174,4 @@ public final class BoundedThreadPool extends ThreadPoolExecutor {
}
}
}
}
\ No newline at end of file
}
......
......@@ -54,6 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> {
}
@Override
@java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
protected void decode(
ChannelHandlerContext context,
ByteBuf buffer,
......