From 3673133bc121cd0ba8d09f210615418e3114425a Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 11 Dec 2017 08:52:18 +0100 Subject: Clean Sonar warnings in JvppReplyConsumer Change-Id: Ic664d0da1f3f253ee7d698c651354015792cc278 Signed-off-by: Marek Gradzki --- .../common/translate/util/JvppReplyConsumer.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java index 9fe9162c5..1674dc9ee 100644 --- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java +++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java @@ -47,7 +47,7 @@ public interface JvppReplyConsumer { * Should be used in case of calls where it's not clear which write crud operation respective * call represents, for ex. setRouting */ - default > REP getReplyForWrite(@Nonnull Future future, + default > R getReplyForWrite(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType) throws WriteFailedException { @@ -59,7 +59,7 @@ public interface JvppReplyConsumer { * Should be used in case of calls where it's not clear which write crud operation respective * call represents, for ex. setRouting */ - default > REP getReplyForWrite(@Nonnull Future future, + default > R getReplyForWrite(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnegative final int timeoutInSeconds) throws WriteFailedException { @@ -76,7 +76,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing create operation */ - default > REP getReplyForCreate(@Nonnull Future future, + default > R getReplyForCreate(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject data) throws WriteFailedException.CreateFailedException { @@ -86,7 +86,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing create operation */ - default > REP getReplyForCreate(@Nonnull Future future, + default > R getReplyForCreate(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject data, @Nonnegative final int timeoutInSeconds) @@ -104,7 +104,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing update operation */ - default > REP getReplyForUpdate(@Nonnull Future future, + default > R getReplyForUpdate(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject dataBefore, @Nonnull final DataObject dataAfter) @@ -115,7 +115,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing update operation */ - default > REP getReplyForUpdate(@Nonnull Future future, + default > R getReplyForUpdate(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnull final DataObject dataBefore, @Nonnull final DataObject dataAfter, @@ -134,7 +134,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing delete operation */ - default > REP getReplyForDelete(@Nonnull Future future, + default > R getReplyForDelete(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType) throws WriteFailedException.DeleteFailedException { return getReplyForDelete(future, replyType, JvppReplyTimeoutHolder.getTimeout()); @@ -143,7 +143,7 @@ public interface JvppReplyConsumer { /** * Consumes reply for jvpp call representing delete operation */ - default > REP getReplyForDelete(@Nonnull Future future, + default > R getReplyForDelete(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnegative final int timeoutInSeconds) throws WriteFailedException.DeleteFailedException { @@ -156,13 +156,13 @@ public interface JvppReplyConsumer { } } - default > REP getReplyForRead(@Nonnull Future future, + default > R getReplyForRead(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType) throws ReadFailedException { return getReplyForRead(future, replyType, JvppReplyTimeoutHolder.getTimeout()); } - default > REP getReplyForRead(@Nonnull Future future, + default > R getReplyForRead(@Nonnull Future future, @Nonnull final InstanceIdentifier replyType, @Nonnegative final int timeoutInSeconds) throws ReadFailedException { @@ -175,12 +175,12 @@ public interface JvppReplyConsumer { } } - default > REP getReply(@Nonnull Future future) + default > R getReply(@Nonnull Future future) throws TimeoutException, VppBaseCallException { return getReply(future, JvppReplyTimeoutHolder.getTimeout()); } - default > REP getReply(@Nonnull Future future, + default > R getReply(@Nonnull Future future, @Nonnegative final int timeoutInSeconds) throws TimeoutException, VppBaseCallException { try { @@ -192,7 +192,7 @@ public interface JvppReplyConsumer { } catch (ExecutionException e) { // Execution exception could generally contains any exception // when using exceptions instead of return codes just rethrow it for processing on corresponding place - if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) { + if (e.getCause() instanceof VppBaseCallException) { throw (VppBaseCallException) (e.getCause()); } throw new IllegalStateException(e); @@ -206,6 +206,10 @@ public interface JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(JvppReplyTimeoutHolder.class); private static Optional timeout = Optional.empty(); + private JvppReplyTimeoutHolder() { + throw new UnsupportedOperationException("Utility class cannot be instantiated."); + } + public static void setupTimeout(@Nonnegative final int jvppTimeout) { if (timeout.isPresent()) { // do not fail on reconfigure, to not disturb restarts -- cgit 1.2.3-korg