Skip to content

Commit ea9cd8c

Browse files
committed
Use URI.created().toURL() instead of new URL()
- URI.created().toURL() is available since Java 1.4 - new URL() (constructor) is deprecated in Java 20 Signed-off-by: Arthit Suriyawongkul <[email protected]>
1 parent abdae87 commit ea9cd8c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test/java/org/spdx/tools/LatestSchemaVersionTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
/**
2+
* SPDX-FileContributor: Arthit Suriyawongkul
3+
* SPDX-FileCopyrightText: 2025 SPDX contributors
4+
* SPDX-FileType: SOURCE
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
17
package org.spdx.tools;
28

39
import java.io.IOException;
4-
import java.net.URL;
10+
import java.net.URI;
511
import java.nio.file.Files;
612
import java.nio.file.Path;
713
import java.nio.file.Paths;
@@ -33,9 +39,7 @@ public void testLatestSpdxSchemaVersionIsUpToDate() throws IOException {
3339
// Step 2: Compare the content of the file with the content from the URL
3440
String localSchemaContent = Files.readString(schemaFilePath);
3541
String remoteSchemaUrl = "https://spdx.org/schema/" + version + "/spdx-json-schema.json";
36-
String remoteSchemaContent = IOUtils.toString(new URL(remoteSchemaUrl), "UTF-8");
37-
38-
// Step 3: Assert if the contents match
42+
String remoteSchemaContent = IOUtils.toString(URI.create(remoteSchemaUrl).toURL(), "UTF-8");
3943
assertEquals("The local SPDX schema file does not match the remote schema content.",
4044
localSchemaContent.trim(), remoteSchemaContent.trim());
4145
}

0 commit comments

Comments
 (0)