Fix Sonar critical flagged bugs

Change-Id: I60e9f72a1a66f65366d7dbc5335922e75097c9f3
This commit is contained in:
Ray Milkey 2015-12-18 09:27:03 -08:00
parent 0fce040435
commit 676249ca1a
11 changed files with 38 additions and 13 deletions

View File

@ -276,6 +276,7 @@ public class ApplicationManager
} }
// Invokes the specified function, if not null. // 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) { private void invokeHook(Runnable hook, ApplicationId appId) {
if (hook != null) { if (hook != null) {
try { try {

View File

@ -70,9 +70,7 @@ public class OFOpticalSwitch13 extends AbstractOpenFlowSwitch implements OpenFlo
try { try {
sendHandshakeOFExperimenterPortDescRequest(); sendHandshakeOFExperimenterPortDescRequest();
} catch (IOException e) { } catch (IOException e) {
log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}, {}", log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}", e);
getStringId(), e.getMessage());
e.printStackTrace();
} }
} }

View File

@ -96,8 +96,7 @@ public class OfOpticalSwitchImplLinc13
sendHandshakeOFExperimenterPortDescRequest(); sendHandshakeOFExperimenterPortDescRequest();
} catch (IOException e) { } catch (IOException e) {
log.error("LINC-OE exception while sending experimenter port desc:", log.error("LINC-OE exception while sending experimenter port desc:",
e.getMessage()); e);
e.printStackTrace();
} }
} }

View File

@ -111,7 +111,7 @@ final class XmlConfigParser {
try { try {
editcfg.save(stringWriter); editcfg.save(stringWriter);
} catch (ConfigurationException e) { } catch (ConfigurationException e) {
e.printStackTrace(); log.error("createControllersConfig()", e);
} }
String s = stringWriter.toString() String s = stringWriter.toString()
.replaceAll("<controller>", .replaceAll("<controller>",

View File

@ -65,6 +65,7 @@ public final class GrpcDeviceUtils {
return MastershipRole.STANDBY; return MastershipRole.STANDBY;
case UNRECOGNIZED: case UNRECOGNIZED:
log.warn("Unrecognized MastershipRole gRPC message: {}", role); log.warn("Unrecognized MastershipRole gRPC message: {}", role);
return MastershipRole.NONE;
default: default:
return MastershipRole.NONE; return MastershipRole.NONE;
} }

View File

@ -70,6 +70,29 @@ public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
return ((Long) (this.getRouteDistinguisher())).compareTo((Long) (rd.getRouteDistinguisher())); return ((Long) (this.getRouteDistinguisher())).compareTo((Long) (rd.getRouteDistinguisher()));
} }
@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 @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(getClass()) return MoreObjects.toStringHelper(getClass())

View File

@ -802,7 +802,7 @@ public class DefaultOvsdbClient
operations.add(portInsert); operations.add(portInsert);
// update the bridge table // 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")); Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port"));
List<Condition> conditions = new ArrayList<>(Arrays.asList(condition)); List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation)); List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
@ -875,7 +875,7 @@ public class DefaultOvsdbClient
} }
List<Condition> conditions = Lists.newArrayList(); List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals(childColumnName, UUID.uuid(childUuid)); Condition condition = ConditionUtil.isEqual(childColumnName, UUID.uuid(childUuid));
conditions.add(condition); conditions.add(condition);
Delete del = new Delete(childTableSchema, conditions); Delete del = new Delete(childTableSchema, conditions);
operations.add(del); operations.add(del);
@ -898,7 +898,7 @@ public class DefaultOvsdbClient
TableSchema tableSchema = dbSchema.getTableSchema(tableName); TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList(); List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals(columnName, UUID.uuid(uuid)); Condition condition = ConditionUtil.isEqual(columnName, UUID.uuid(uuid));
conditions.add(condition); conditions.add(condition);
Update update = new Update(tableSchema, row, conditions); Update update = new Update(tableSchema, row, conditions);
@ -944,7 +944,7 @@ public class DefaultOvsdbClient
mutations.add(mutation); mutations.add(mutation);
List<Condition> conditions = Lists.newArrayList(); List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.equals("_uuid", Condition condition = ConditionUtil.isEqual("_uuid",
UUID.uuid(parentUuid)); UUID.uuid(parentUuid));
conditions.add(condition); conditions.add(condition);

View File

@ -37,7 +37,7 @@ public final class ConditionUtil {
* @param data column value * @param data column value
* @return Condition * @return Condition
*/ */
public static Condition equals(String columnName, Object data) { public static Condition isEqual(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data); Object value = TransValueUtil.getFormatData(data);
return new Condition(columnName, Function.EQUALS, value); return new Condition(columnName, Function.EQUALS, value);
} }

View File

@ -156,6 +156,7 @@ public class IGMP extends BasePacket {
* *
* @return the serialized IGMP message * @return the serialized IGMP message
*/ */
@java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
@Override @Override
public byte[] serialize() { public byte[] serialize() {
byte [] data = new byte[8915]; byte [] data = new byte[8915];

View File

@ -137,6 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor {
* Feedback policy that delays the caller's thread until the executor's work * 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. * 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 static final class CallerFeedbackPolicy implements RejectedExecutionHandler {
private final BlockingBoolean underLoad = new BlockingBoolean(false); private final BlockingBoolean underLoad = new BlockingBoolean(false);

View File

@ -54,6 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> {
} }
@Override @Override
@java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
protected void decode( protected void decode(
ChannelHandlerContext context, ChannelHandlerContext context,
ByteBuf buffer, ByteBuf buffer,