Skip to content

Commit

Permalink
Removed deprecated URL constructor usage (#1102)
Browse files Browse the repository at this point in the history
Signed-off-by: dhoard <[email protected]>
  • Loading branch information
dhoard authored Dec 19, 2024
1 parent 3f90ac2 commit 5f20082
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
Expand Down Expand Up @@ -120,7 +121,7 @@ public static HttpResponse sendRequest(HttpRequest httpRequest) throws IOExcepti
*/
public static HttpResponse sendRequest(
HttpRequest httpRequest, int connectTimeout, int readTimeout) throws IOException {
URL url = new URL(httpRequest.url());
URL url = URI.create(httpRequest.url()).toURL();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

connection.setConnectTimeout(connectTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import io.prometheus.jmx.common.util.Precondition;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.util.function.Function;
import java.util.function.Supplier;

Expand Down Expand Up @@ -53,7 +53,7 @@ public String apply(String value) {
}

try {
new URL(value);
URI.create(value).toURL();
return value;
} catch (MalformedURLException e) {
throw supplier.get();
Expand Down

0 comments on commit 5f20082

Please sign in to comment.