Mercurial > hg > monetdb-java
comparison tests/TLSTester.java @ 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 (15 months ago) |
parents | d74e850e2991 |
children | 06f532009fda |
comparison
equal
deleted
inserted
replaced
858:d74e850e2991 | 859:68994abe3e03 |
---|---|
126 return out.toByteArray(); | 126 return out.toByteArray(); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 private InputStream fetchData(String resource) throws IOException { | 130 private InputStream fetchData(String resource) throws IOException { |
131 URL url = new java.net.URI("http://" + serverHost + ":" + serverPort + resource).toURL; | 131 URL url; |
132 try { | |
133 // Note: as of Java version 20 java.net.URL(String) constructor is deprecated. | |
134 // https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/net/URL.html#%3Cinit%3E(java.lang.String) | |
135 url = new java.net.URI("http://" + serverHost + ":" + serverPort + resource).toURL(); | |
136 } catch (java.net.URISyntaxException | java.net.MalformedURLException e) { | |
137 throw new IOException(e.getMessage()); | |
138 } | |
132 URLConnection conn = url.openConnection(); | 139 URLConnection conn = url.openConnection(); |
133 conn.connect(); | 140 conn.connect(); |
134 return conn.getInputStream(); | 141 return conn.getInputStream(); |
135 } | 142 } |
136 | 143 |