Skip to content

Commit c373d27

Browse files
authored
Update creation of URL to avoid deprecation message (#2851)
1 parent b8cbe41 commit c373d27

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.io.InputStream;
2323
import java.io.OutputStream;
2424
import java.net.HttpURLConnection;
25-
import java.net.URL;
25+
import java.net.URI;
2626
import java.nio.charset.StandardCharsets;
2727
import java.nio.file.Files;
2828
import java.nio.file.Path;
@@ -54,7 +54,7 @@ public static void main(String[] args) {
5454
}
5555

5656
public static void checkVersion() {
57-
int major = Runtime.getRuntime().version().feature();
57+
int major = Runtime.version().feature();
5858
if (major < 21 || major > 23) {
5959
throw new IllegalStateException(
6060
"java version must be between 21 and 23, your version: " + major);
@@ -89,12 +89,12 @@ public void run(Path destination) throws IOException, NoSuchAlgorithmException {
8989
}
9090
}
9191

92-
URL url =
93-
new URL(
92+
URI uri =
93+
URI.create(
9494
"https://raw.githubusercontent.com/gradle/gradle/v"
9595
+ wrapperVersion
9696
+ "/gradle/wrapper/gradle-wrapper.jar");
97-
System.err.println("Downloading gradle-wrapper.jar from " + url);
97+
System.err.println("Downloading gradle-wrapper.jar from " + uri);
9898

9999
// Zero-copy save the jar to a temp file
100100
Path temp = Files.createTempFile(destination.getParent(), ".gradle-wrapper", ".tmp");
@@ -103,7 +103,7 @@ public void run(Path destination) throws IOException, NoSuchAlgorithmException {
103103
int retryDelay = 30;
104104
HttpURLConnection connection;
105105
while (true) {
106-
connection = (HttpURLConnection) url.openConnection();
106+
connection = (HttpURLConnection) uri.toURL().openConnection();
107107
try {
108108
connection.connect();
109109
} catch (IOException e) {

0 commit comments

Comments
 (0)