Skip to content

Commit

Permalink
HPCC4J-605 Connection: Improve Invalid URL Error Message
Browse files Browse the repository at this point in the history
- Added explicit check for underscores in hostname

Signed-off-by: James McMullan [email protected]
  • Loading branch information
jpmcmu committed May 28, 2024
1 parent 58e2f45 commit 6df846b
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 6df846b

Please sign in to comment.