Simplify upgradeCodecFactory() 39/111139/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 28 Mar 2024 13:32:26 +0000 (14:32 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 1 Apr 2024 15:13:40 +0000 (15:13 +0000)
The lamda we return here is a simple if-else return.

JIRA: NETCONF-1248
Change-Id: Ia772eba569ccf9c0559abfab086772dbf31dce1b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
transport/transport-http/src/main/java/org/opendaylight/netconf/transport/http/ServerChannelInitializer.java

index 642fd6fa1ff7472fb966a974927547bc62bed1e5..0ce9d516232cd1adf29cf1eef9c264940962e36b 100644 (file)
@@ -150,13 +150,8 @@ class ServerChannelInitializer extends ChannelInitializer<Channel> implements Ht
 
     private static HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory(
             final Http2ConnectionHandler connectionHandler) {
-        return protocol -> {
-            if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
-                return new Http2ServerUpgradeCodec(connectionHandler);
-            } else {
-                return null;
-            }
-        };
+        return protocol -> AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)
+            ? new Http2ServerUpgradeCodec(connectionHandler) : null;
     }
 
     private static ChannelHandler serverHandler(final RequestDispatcher dispatcher) {