diff --git a/core/trino-main/src/main/java/io/trino/connector/CatalogPruneTask.java b/core/trino-main/src/main/java/io/trino/connector/CatalogPruneTask.java index b4fd82c7113f..0dccf39a35ce 100644 --- a/core/trino-main/src/main/java/io/trino/connector/CatalogPruneTask.java +++ b/core/trino-main/src/main/java/io/trino/connector/CatalogPruneTask.java @@ -39,7 +39,6 @@ import org.weakref.jmx.Nested; import java.net.URI; -import java.net.URISyntaxException; import java.util.List; import java.util.Set; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -183,11 +182,7 @@ private URI getHttpUri(ServiceDescriptor descriptor) { String url = descriptor.getProperties().get(httpsRequired ? "https" : "http"); if (url != null) { - try { - return new URI(url); - } - catch (URISyntaxException ignored) { - } + return URI.create(url); } return null; } diff --git a/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java b/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java index 6d1ea0247eee..b5f1e3b9876c 100644 --- a/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java +++ b/core/trino-main/src/main/java/io/trino/failuredetector/HeartbeatFailureDetector.java @@ -47,7 +47,6 @@ import java.net.ConnectException; import java.net.SocketTimeoutException; import java.net.URI; -import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -266,11 +265,7 @@ private URI getHttpUri(ServiceDescriptor descriptor) { String url = descriptor.getProperties().get(httpsRequired ? "https" : "http"); if (url != null) { - try { - return new URI(url); - } - catch (URISyntaxException ignored) { - } + return URI.create(url); } return null; } diff --git a/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java b/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java index a11e018d3396..15d229ca7e5a 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java @@ -40,7 +40,6 @@ import org.weakref.jmx.Managed; import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -387,11 +386,7 @@ private static URI getHttpUri(ServiceDescriptor descriptor, boolean httpsRequire { String url = descriptor.getProperties().get(httpsRequired ? "https" : "http"); if (url != null) { - try { - return new URI(url); - } - catch (URISyntaxException ignored) { - } + return URI.create(url); } return null; } diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestImpersonation.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestImpersonation.java index a27efea1b56e..ce15a13fd249 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestImpersonation.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestImpersonation.java @@ -24,7 +24,6 @@ import org.testng.annotations.Test; import java.net.URI; -import java.net.URISyntaxException; import static com.google.common.collect.Iterables.getOnlyElement; import static io.trino.tests.product.TestGroups.HDFS_IMPERSONATION; @@ -89,13 +88,7 @@ private static String getTableLocation(QueryExecutor executor, String tableName) { String location = getOnlyElement(executor.executeQuery(format("SELECT DISTINCT regexp_replace(\"$path\", '/[^/]*$', '') FROM %s", tableName)).column(1)); if (location.startsWith("hdfs://")) { - try { - URI uri = new URI(location); - return uri.getPath(); - } - catch (URISyntaxException e) { - throw new RuntimeException(e); - } + return URI.create(location).getPath(); } return location; }