Sonar related fixes
- suppress SONAR warning for printing stack trace in CLI
- add string constants for the Sonar suppression identifiers
Change-Id: I03992f89675f9d074347042b7a196dbcc1036c28
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 a94a38b..e5382e1 100644
--- a/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
+++ b/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
@@ -15,8 +15,6 @@
*/
package org.onlab.netty;
-import static com.google.common.base.Preconditions.checkState;
-
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;
@@ -31,6 +29,9 @@
import com.google.common.base.Charsets;
+import static com.google.common.base.Preconditions.checkState;
+import static org.onlab.util.SonarSuppressionConstants.SONAR_SWITCH_FALLTHROUGH;
+
/**
* Decoder for inbound messages.
*/
@@ -54,7 +55,7 @@
}
@Override
- @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
+ @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning
protected void decode(
ChannelHandlerContext context,
ByteBuf buffer,
diff --git a/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java b/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
index b9709cc..77d4a40 100644
--- a/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
+++ b/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
@@ -15,10 +15,6 @@
*/
package org.onlab.netty;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
@@ -38,17 +34,7 @@
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
-import org.apache.commons.pool.KeyedPoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericKeyedObjectPool;
-import org.onosproject.store.cluster.messaging.Endpoint;
-import org.onosproject.store.cluster.messaging.MessagingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
@@ -64,6 +50,25 @@
import java.util.function.Consumer;
import java.util.function.Function;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.commons.pool.KeyedPoolableObjectFactory;
+import org.apache.commons.pool.impl.GenericKeyedObjectPool;
+import org.onosproject.store.cluster.messaging.Endpoint;
+import org.onosproject.store.cluster.messaging.MessagingService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+
+import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE;
+
/**
* Implementation of MessagingService based on <a href="http://netty.io/">Netty</a> framework.
*/
@@ -106,7 +111,7 @@
protected char[] ksPwd;
protected char[] tsPwd;
- @SuppressWarnings("squid:S1181")
+ @SuppressWarnings(SONAR_CATCH_THROWABLE)
// We really need to catch Throwable due to netty native epoll() handling
private void initEventLoopGroup() {
// try Epoll first and if that does work, use nio.