changeset 859:68994abe3e03

Also catch java.net.URISyntaxException and java.net.MalformedURLException and convert them to an IOException.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 01 Feb 2024 14:32:05 +0100 (14 months ago)
parents d74e850e2991
children ae5834c3eb06
files tests/TLSTester.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/TLSTester.java
+++ b/tests/TLSTester.java
@@ -128,7 +128,14 @@ public class TLSTester {
 	}
 
 	private InputStream fetchData(String resource) throws IOException {
-		URL url = new java.net.URI("http://" + serverHost + ":" + serverPort + resource).toURL;
+		URL url;
+		try {
+			// Note: as of Java version 20 java.net.URL(String) constructor is deprecated.
+			// https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/net/URL.html#%3Cinit%3E(java.lang.String)
+			url = new java.net.URI("http://" + serverHost + ":" + serverPort + resource).toURL();
+		} catch (java.net.URISyntaxException | java.net.MalformedURLException e) {
+			throw new IOException(e.getMessage());
+		}
 		URLConnection conn = url.openConnection();
 		conn.connect();
 		return conn.getInputStream();