Use arrow cases in mdsal-replicate-netty 45/101345/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 29 May 2022 21:22:52 +0000 (23:22 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 29 May 2022 21:22:52 +0000 (23:22 +0200)
Ditch explicit breaks and use arrow cases instead.

Change-Id: Id3a3c6deab7b6137f7c965e9bd0d08454a4970b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
replicate/mdsal-replicate-netty/src/main/java/org/opendaylight/mdsal/replicate/netty/SinkRequestHandler.java
replicate/mdsal-replicate-netty/src/main/java/org/opendaylight/mdsal/replicate/netty/SourceRequestHandler.java

index 6d0d13080de370dd3240ed8c7bfd21432122cf33..759472cef3c364f4aed3a6b46739f990b36b64f8 100644 (file)
@@ -61,21 +61,14 @@ final class SinkRequestHandler extends SimpleChannelInboundHandler<ByteBuf> {
         final Channel channel = ctx.channel();
         LOG.trace("Channel {} received message type {}", channel, msgType);
         switch (msgType) {
-            case Constants.MSG_EMPTY_DATA:
-                handleEmptyData();
-                break;
-            case Constants.MSG_DTC_CHUNK:
-                chunks.add(msg.retain());
-                break;
-            case Constants.MSG_DTC_APPLY:
-                handleDtcApply();
-                break;
-            case Constants.MSG_PING:
+            case Constants.MSG_EMPTY_DATA -> handleEmptyData();
+            case Constants.MSG_DTC_CHUNK -> chunks.add(msg.retain());
+            case Constants.MSG_DTC_APPLY -> handleDtcApply();
+            case Constants.MSG_PING -> {
                 LOG.trace("Received PING from Source, sending PONG");
                 ctx.channel().writeAndFlush(Constants.PONG);
-                break;
-            default:
-                throw new IllegalStateException("Unexpected message type " + msgType);
+            }
+            default -> throw new IllegalStateException("Unexpected message type " + msgType);
         }
     }
 
index 8928dbadd3e65974b072a93a925c258a9fde77ae..d2f8fd503d44faa99d1c7ee1a412c7c245f4c3a7 100644 (file)
@@ -59,13 +59,11 @@ final class SourceRequestHandler extends SimpleChannelInboundHandler<ByteBuf> {
         final Channel channel = ctx.channel();
         LOG.trace("Channel {} received message type {}", channel, msgType);
         switch (msgType) {
-            case Constants.MSG_SUBSCRIBE_REQ:
-                subscribe(channel, msg);
-                break;
-            case Constants.MSG_PONG:
-                break;
-            default:
-                throw new IllegalStateException("Unexpected message type " + msgType);
+            case Constants.MSG_SUBSCRIBE_REQ -> subscribe(channel, msg);
+            case Constants.MSG_PONG -> {
+                // No-op
+            }
+            default -> throw new IllegalStateException("Unexpected message type " + msgType);
         }
     }