Fix Sonar critical flagged bugs
Change-Id: I60e9f72a1a66f65366d7dbc5335922e75097c9f3
diff --git a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index 80a5ca7..8fe804c 100644
--- a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -276,6 +276,7 @@
}
// 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 {
diff --git a/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitch13.java b/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitch13.java
index 5c6ce36..c7409e9 100644
--- a/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitch13.java
+++ b/drivers/src/main/java/org/onosproject/driver/handshaker/OFOpticalSwitch13.java
@@ -70,9 +70,7 @@
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);
}
}
diff --git a/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java b/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java
index adcbb50..5f8c82f 100644
--- a/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java
+++ b/drivers/src/main/java/org/onosproject/driver/handshaker/OfOpticalSwitchImplLinc13.java
@@ -96,8 +96,7 @@
sendHandshakeOFExperimenterPortDescRequest();
} catch (IOException e) {
log.error("LINC-OE exception while sending experimenter port desc:",
- e.getMessage());
- e.printStackTrace();
+ e);
}
}
diff --git a/drivers/src/main/java/org/onosproject/driver/netconf/XmlConfigParser.java b/drivers/src/main/java/org/onosproject/driver/netconf/XmlConfigParser.java
index 55826a2..5443097 100644
--- a/drivers/src/main/java/org/onosproject/driver/netconf/XmlConfigParser.java
+++ b/drivers/src/main/java/org/onosproject/driver/netconf/XmlConfigParser.java
@@ -111,7 +111,7 @@
try {
editcfg.save(stringWriter);
} catch (ConfigurationException e) {
- e.printStackTrace();
+ log.error("createControllersConfig()", e);
}
String s = stringWriter.toString()
.replaceAll("<controller>",
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java
index 7045b0c..aaf1e0b 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java
@@ -65,6 +65,7 @@
return MastershipRole.STANDBY;
case UNRECOGNIZED:
log.warn("Unrecognized MastershipRole gRPC message: {}", role);
+ return MastershipRole.NONE;
default:
return MastershipRole.NONE;
}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
index 37632ad..36be714 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
@@ -71,9 +71,32 @@
}
@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
+}
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 0ede4a4..16d9673 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -802,7 +802,7 @@
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 @@
}
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 @@
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 @@
mutations.add(mutation);
List<Condition> conditions = Lists.newArrayList();
- Condition condition = ConditionUtil.equals("_uuid",
+ Condition condition = ConditionUtil.isEqual("_uuid",
UUID.uuid(parentUuid));
conditions.add(condition);
diff --git a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java
index 527b8bf..28e9084 100644
--- a/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java
+++ b/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java
@@ -37,7 +37,7 @@
* @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);
}
diff --git a/utils/misc/src/main/java/org/onlab/packet/IGMP.java b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
index 594b79d..cabd252 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IGMP.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
@@ -156,6 +156,7 @@
*
* @return the serialized IGMP message
*/
+ @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
@Override
public byte[] serialize() {
byte [] data = new byte[8915];
diff --git a/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java b/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
index 9eef660..4364345 100644
--- a/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
+++ b/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
@@ -137,6 +137,7 @@
* 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 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java b/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
index af52a41..a94a38b 100644
--- a/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
+++ b/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
@@ -54,6 +54,7 @@
}
@Override
+ @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
protected void decode(
ChannelHandlerContext context,
ByteBuf buffer,