- protected NetconfServerSession getSession(
- NetconfServerSessionListener sessionListener, Channel channel,
- NetconfHelloMessage message) {
- Optional<NetconfHelloMessageAdditionalHeader> additionalHeader = message
- .getAdditionalHeader();
-
- NetconfHelloMessageAdditionalHeader parsedHeader;
- if (additionalHeader.isPresent()) {
- parsedHeader = additionalHeader.get();
- } else {
-
- parsedHeader = new NetconfHelloMessageAdditionalHeader(UNKNOWN,
- getHostName(channel.localAddress()).getValue(),
- getHostName(channel.localAddress()).getKey(), "tcp",
- "client");
-
- }
-
- LOG.debug("Additional header from hello parsed as {} from {}",
- parsedHeader, additionalHeader);
-
- return new NetconfServerSession(sessionListener, channel,
- getSessionPreferences().getSessionId(), parsedHeader);
+ protected NetconfServerSession getSession(final NetconfServerSessionListener sessionListener, final Channel channel,
+ final NetconfHelloMessage message) {
+ final var additionalHeader = message.getAdditionalHeader();
+ final var parsedHeader = additionalHeader.orElseGet(() -> {
+ final var hostName = getHostName(channel.localAddress());
+ return new NetconfHelloMessageAdditionalHeader(UNKNOWN, hostName.getValue(), hostName.getKey(), "tcp",
+ "client");
+ });
+
+ LOG.debug("Additional header from hello parsed as {} from {}", parsedHeader, additionalHeader);
+ return new NetconfServerSession(sessionListener, channel, sessionId, parsedHeader);