From 6bf1d1ede400cd6fa50059373af0e62a16d32c3a Mon Sep 17 00:00:00 2001 From: Claudio Guidi Date: Thu, 16 Jan 2025 16:08:37 +0100 Subject: [PATCH 1/2] added UnresolvableAddressException in socket channel creation --- .../main/java/jolie/net/SocketCommChannelFactory.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java b/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java index 5114b39ec..79a8b8778 100644 --- a/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java +++ b/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java @@ -26,6 +26,8 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.channels.SocketChannel; +import java.nio.channels.UnresolvedAddressException; + import jolie.net.ext.CommChannelFactory; import jolie.net.ports.OutputPort; @@ -42,7 +44,13 @@ public SocketCommChannelFactory( CommCore commCore ) { @Override public CommChannel createChannel( URI location, OutputPort port ) throws IOException { - SocketChannel channel = SocketChannel.open( new InetSocketAddress( location.getHost(), location.getPort() ) ); + + SocketChannel channel = null; + try { + channel = SocketChannel.open( new InetSocketAddress( location.getHost(), location.getPort() ) ); + } catch( UnresolvedAddressException e ) { + throw new IOException( "Unable to resolve address" ); + } SocketCommChannel ret = null; try { ret = new SocketCommChannel( channel, location, port.getProtocol() ); From aad8655a7973b949e75823988dbccaca8fcf8e3a Mon Sep 17 00:00:00 2001 From: Fabrizio Montesi Date: Fri, 17 Jan 2025 08:59:15 +0100 Subject: [PATCH 2/2] Improve error message --- jolie/src/main/java/jolie/net/SocketCommChannelFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java b/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java index 79a8b8778..e772e005b 100644 --- a/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java +++ b/jolie/src/main/java/jolie/net/SocketCommChannelFactory.java @@ -49,7 +49,7 @@ public CommChannel createChannel( URI location, OutputPort port ) try { channel = SocketChannel.open( new InetSocketAddress( location.getHost(), location.getPort() ) ); } catch( UnresolvedAddressException e ) { - throw new IOException( "Unable to resolve address" ); + throw new IOException( "Unable to resolve address: " + location.toString(), e ); } SocketCommChannel ret = null; try {