diff --git a/extensions/auth/opa/tests/src/intTest/java/org/apache/polaris/extension/auth/opa/test/OpaTestResource.java b/extensions/auth/opa/tests/src/intTest/java/org/apache/polaris/extension/auth/opa/test/OpaTestResource.java index 0bc0385b94..3a3f3cd9dd 100644 --- a/extensions/auth/opa/tests/src/intTest/java/org/apache/polaris/extension/auth/opa/test/OpaTestResource.java +++ b/extensions/auth/opa/tests/src/intTest/java/org/apache/polaris/extension/auth/opa/test/OpaTestResource.java @@ -21,6 +21,7 @@ import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import java.io.OutputStream; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -32,8 +33,8 @@ public class OpaTestResource implements QuarkusTestResourceLifecycleManager { private static GenericContainer opa; - private int mappedPort; + @SuppressWarnings({"resource", "HttpUrlsUsage"}) @Override public Map start() { try { @@ -55,7 +56,7 @@ public Map start() { opa.start(); } - mappedPort = opa.getMappedPort(8181); + int mappedPort = opa.getMappedPort(8181); String containerHost = opa.getHost(); String baseUrl = "http://" + containerHost + ":" + mappedPort; @@ -92,7 +93,7 @@ public Map start() { private void loadRegoPolicy(String baseUrl, String policyName, String regoPolicy) { // Hardcode the policy directly instead of loading through QuarkusTestProfile try { - URL url = new URL(baseUrl + "/v1/policies/" + policyName); + URL url = URI.create(baseUrl + "/v1/policies/" + policyName).toURL(); System.out.println("Uploading policy to: " + url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); @@ -125,7 +126,7 @@ private void loadRegoPolicy(String baseUrl, String policyName, String regoPolicy @Override public void stop() { - // Don't stop the container to allow reuse across tests - // Container will be cleaned up when the JVM exits + // Quarkus takes care of reusing the test resource across tests + opa.stop(); } }