Ray Milkey

Fix Sonar critical flagged bugs

Change-Id: I60e9f72a1a66f65366d7dbc5335922e75097c9f3
...@@ -276,6 +276,7 @@ public class ApplicationManager ...@@ -276,6 +276,7 @@ public class ApplicationManager
276 } 276 }
277 277
278 // Invokes the specified function, if not null. 278 // Invokes the specified function, if not null.
279 + @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
279 private void invokeHook(Runnable hook, ApplicationId appId) { 280 private void invokeHook(Runnable hook, ApplicationId appId) {
280 if (hook != null) { 281 if (hook != null) {
281 try { 282 try {
......
...@@ -70,9 +70,7 @@ public class OFOpticalSwitch13 extends AbstractOpenFlowSwitch implements OpenFlo ...@@ -70,9 +70,7 @@ public class OFOpticalSwitch13 extends AbstractOpenFlowSwitch implements OpenFlo
70 try { 70 try {
71 sendHandshakeOFExperimenterPortDescRequest(); 71 sendHandshakeOFExperimenterPortDescRequest();
72 } catch (IOException e) { 72 } catch (IOException e) {
73 - log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}, {}", 73 + log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}", e);
74 - getStringId(), e.getMessage());
75 - e.printStackTrace();
76 } 74 }
77 } 75 }
78 76
......
...@@ -96,8 +96,7 @@ public class OfOpticalSwitchImplLinc13 ...@@ -96,8 +96,7 @@ public class OfOpticalSwitchImplLinc13
96 sendHandshakeOFExperimenterPortDescRequest(); 96 sendHandshakeOFExperimenterPortDescRequest();
97 } catch (IOException e) { 97 } catch (IOException e) {
98 log.error("LINC-OE exception while sending experimenter port desc:", 98 log.error("LINC-OE exception while sending experimenter port desc:",
99 - e.getMessage()); 99 + e);
100 - e.printStackTrace();
101 } 100 }
102 } 101 }
103 102
......
...@@ -111,7 +111,7 @@ final class XmlConfigParser { ...@@ -111,7 +111,7 @@ final class XmlConfigParser {
111 try { 111 try {
112 editcfg.save(stringWriter); 112 editcfg.save(stringWriter);
113 } catch (ConfigurationException e) { 113 } catch (ConfigurationException e) {
114 - e.printStackTrace(); 114 + log.error("createControllersConfig()", e);
115 } 115 }
116 String s = stringWriter.toString() 116 String s = stringWriter.toString()
117 .replaceAll("<controller>", 117 .replaceAll("<controller>",
......
...@@ -65,6 +65,7 @@ public final class GrpcDeviceUtils { ...@@ -65,6 +65,7 @@ public final class GrpcDeviceUtils {
65 return MastershipRole.STANDBY; 65 return MastershipRole.STANDBY;
66 case UNRECOGNIZED: 66 case UNRECOGNIZED:
67 log.warn("Unrecognized MastershipRole gRPC message: {}", role); 67 log.warn("Unrecognized MastershipRole gRPC message: {}", role);
68 + return MastershipRole.NONE;
68 default: 69 default:
69 return MastershipRole.NONE; 70 return MastershipRole.NONE;
70 } 71 }
......
...@@ -71,6 +71,29 @@ public class RouteDistinguisher implements Comparable<RouteDistinguisher> { ...@@ -71,6 +71,29 @@ public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
71 } 71 }
72 72
73 @Override 73 @Override
74 + public boolean equals(Object obj) {
75 + if (this == obj) {
76 + return true;
77 + }
78 +
79 + if (obj instanceof RouteDistinguisher) {
80 +
81 + RouteDistinguisher that = (RouteDistinguisher) obj;
82 +
83 + if (this.routeDistinguisher == that.routeDistinguisher) {
84 + return true;
85 + }
86 + }
87 +
88 + return false;
89 + }
90 +
91 + @Override
92 + public int hashCode() {
93 + return Long.hashCode(routeDistinguisher);
94 + }
95 +
96 + @Override
74 public String toString() { 97 public String toString() {
75 return MoreObjects.toStringHelper(getClass()) 98 return MoreObjects.toStringHelper(getClass())
76 .add("routeDistinguisher", routeDistinguisher) 99 .add("routeDistinguisher", routeDistinguisher)
......
...@@ -802,7 +802,7 @@ public class DefaultOvsdbClient ...@@ -802,7 +802,7 @@ public class DefaultOvsdbClient
802 operations.add(portInsert); 802 operations.add(portInsert);
803 803
804 // update the bridge table 804 // update the bridge table
805 - Condition condition = ConditionUtil.equals("_uuid", UUID.uuid(bridgeUuid)); 805 + Condition condition = ConditionUtil.isEqual("_uuid", UUID.uuid(bridgeUuid));
806 Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port")); 806 Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port"));
807 List<Condition> conditions = new ArrayList<>(Arrays.asList(condition)); 807 List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
808 List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation)); 808 List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
...@@ -875,7 +875,7 @@ public class DefaultOvsdbClient ...@@ -875,7 +875,7 @@ public class DefaultOvsdbClient
875 } 875 }
876 876
877 List<Condition> conditions = Lists.newArrayList(); 877 List<Condition> conditions = Lists.newArrayList();
878 - Condition condition = ConditionUtil.equals(childColumnName, UUID.uuid(childUuid)); 878 + Condition condition = ConditionUtil.isEqual(childColumnName, UUID.uuid(childUuid));
879 conditions.add(condition); 879 conditions.add(condition);
880 Delete del = new Delete(childTableSchema, conditions); 880 Delete del = new Delete(childTableSchema, conditions);
881 operations.add(del); 881 operations.add(del);
...@@ -898,7 +898,7 @@ public class DefaultOvsdbClient ...@@ -898,7 +898,7 @@ public class DefaultOvsdbClient
898 TableSchema tableSchema = dbSchema.getTableSchema(tableName); 898 TableSchema tableSchema = dbSchema.getTableSchema(tableName);
899 899
900 List<Condition> conditions = Lists.newArrayList(); 900 List<Condition> conditions = Lists.newArrayList();
901 - Condition condition = ConditionUtil.equals(columnName, UUID.uuid(uuid)); 901 + Condition condition = ConditionUtil.isEqual(columnName, UUID.uuid(uuid));
902 conditions.add(condition); 902 conditions.add(condition);
903 903
904 Update update = new Update(tableSchema, row, conditions); 904 Update update = new Update(tableSchema, row, conditions);
...@@ -944,7 +944,7 @@ public class DefaultOvsdbClient ...@@ -944,7 +944,7 @@ public class DefaultOvsdbClient
944 mutations.add(mutation); 944 mutations.add(mutation);
945 945
946 List<Condition> conditions = Lists.newArrayList(); 946 List<Condition> conditions = Lists.newArrayList();
947 - Condition condition = ConditionUtil.equals("_uuid", 947 + Condition condition = ConditionUtil.isEqual("_uuid",
948 UUID.uuid(parentUuid)); 948 UUID.uuid(parentUuid));
949 conditions.add(condition); 949 conditions.add(condition);
950 950
......
...@@ -37,7 +37,7 @@ public final class ConditionUtil { ...@@ -37,7 +37,7 @@ public final class ConditionUtil {
37 * @param data column value 37 * @param data column value
38 * @return Condition 38 * @return Condition
39 */ 39 */
40 - public static Condition equals(String columnName, Object data) { 40 + public static Condition isEqual(String columnName, Object data) {
41 Object value = TransValueUtil.getFormatData(data); 41 Object value = TransValueUtil.getFormatData(data);
42 return new Condition(columnName, Function.EQUALS, value); 42 return new Condition(columnName, Function.EQUALS, value);
43 } 43 }
......
...@@ -156,6 +156,7 @@ public class IGMP extends BasePacket { ...@@ -156,6 +156,7 @@ public class IGMP extends BasePacket {
156 * 156 *
157 * @return the serialized IGMP message 157 * @return the serialized IGMP message
158 */ 158 */
159 + @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
159 @Override 160 @Override
160 public byte[] serialize() { 161 public byte[] serialize() {
161 byte [] data = new byte[8915]; 162 byte [] data = new byte[8915];
......
...@@ -137,6 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor { ...@@ -137,6 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor {
137 * Feedback policy that delays the caller's thread until the executor's work 137 * Feedback policy that delays the caller's thread until the executor's work
138 * queue falls below a threshold, then runs the job on the caller's thread. 138 * queue falls below a threshold, then runs the job on the caller's thread.
139 */ 139 */
140 + @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
140 private static final class CallerFeedbackPolicy implements RejectedExecutionHandler { 141 private static final class CallerFeedbackPolicy implements RejectedExecutionHandler {
141 142
142 private final BlockingBoolean underLoad = new BlockingBoolean(false); 143 private final BlockingBoolean underLoad = new BlockingBoolean(false);
......
...@@ -54,6 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> { ...@@ -54,6 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> {
54 } 54 }
55 55
56 @Override 56 @Override
57 + @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
57 protected void decode( 58 protected void decode(
58 ChannelHandlerContext context, 59 ChannelHandlerContext context,
59 ByteBuf buffer, 60 ByteBuf buffer,
......