diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java index 82be0de51e3..40d7a0a1a1c 100644 --- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java +++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java @@ -36,7 +36,6 @@ Licensed to the Apache Software Foundation (ASF) under one import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,7 +46,7 @@ public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader private final String hostName; - private final Optional suppliedPort; + private final Integer suppliedPort; private final AMSNetId targetAmsNetId; @@ -75,7 +74,7 @@ public ADSPlcConnection(String hostName, AMSNetId targetAmsNetId, AMSPort target public ADSPlcConnection(String hostName, Integer port, AMSNetId targetAmsNetId, AMSPort targetAmsPort, AMSNetId sourceAmsNetId, AMSPort sourceAmsPort) { this.hostName = hostName; - this.suppliedPort = Optional.ofNullable(port); + this.suppliedPort = port; this.targetAmsNetId = targetAmsNetId; this.targetAmsPort = targetAmsPort; this.sourceAmsNetId = sourceAmsNetId; @@ -123,7 +122,7 @@ protected void initChannel(Channel channel) throws Exception { } }); // Start the client. - ChannelFuture f = bootstrap.connect(serverInetAddress, suppliedPort.orElse(TCP_PORT)).sync(); + ChannelFuture f = bootstrap.connect(serverInetAddress, suppliedPort != null ? suppliedPort : TCP_PORT).sync(); f.awaitUninterruptibly(); // Wait till the session is finished initializing. channel = f.channel();