From 6df846b6e6a21b3fd541841481fcc07d77bc8b5c Mon Sep 17 00:00:00 2001 From: James McMullan Date: Tue, 28 May 2024 09:11:36 -0400 Subject: [PATCH] HPCC4J-605 Connection: Improve Invalid URL Error Message - Added explicit check for underscores in hostname Signed-off-by: James McMullan James.McMullan@lexisnexis.com --- .../hpccsystems/ws/client/utils/Connection.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java index a28da183d..6b831f177 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/utils/Connection.java @@ -287,7 +287,22 @@ public static boolean isSslProtocol(String protocol) */ public Connection(String connectionstring) throws MalformedURLException { - URL theurl = new URL(connectionstring); + URL theurl = null; + try + { + theurl = new URL(connectionstring); + } + catch (MalformedURLException e) + { + if (connectionstring.contains("_")) + { + throw new MalformedURLException("Invalid URL: Check hostname for invalid underscores: '" + connectionstring + "': " + e.getMessage()); + } + else + { + throw e; + } + } setProtocol(theurl.getProtocol());