From 318b1fc6c5ae34f74761bc37a81691084d12db2a Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 6 Sep 2022 13:27:15 +0300 Subject: [PATCH] Improve error reporting for https access when quarkus.ssl.native=false Removing the catch for `com.oracle.svm.core.jdk.UnsupportedFeatureError` as it appears like it's never caught any more. --- docs/src/main/asciidoc/native-and-ssl.adoc | 2 +- .../java/io/quarkus/restclient/runtime/RestClientBase.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/src/main/asciidoc/native-and-ssl.adoc b/docs/src/main/asciidoc/native-and-ssl.adoc index 56d7a579c132e..da303ad9d6f5f 100644 --- a/docs/src/main/asciidoc/native-and-ssl.adoc +++ b/docs/src/main/asciidoc/native-and-ssl.adoc @@ -151,7 +151,7 @@ The native executable tests will fail with the following error: [source] ---- -Caused by: java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.. +Caused by: java.lang.IllegalArgumentException: https://stage.code.quarkus.io/api requires SSL support but it is disabled. You probably have set quarkus.ssl.native to false. ---- This error is the one you obtain when trying to use SSL while it was not explicitly enabled in your native executable. diff --git a/extensions/resteasy-classic/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java b/extensions/resteasy-classic/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java index 07146f1251873..fab97f03429f5 100644 --- a/extensions/resteasy-classic/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java +++ b/extensions/resteasy-classic/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java @@ -313,13 +313,12 @@ private void configureBaseUrl(RestClientBuilder builder) { try { builder.baseUrl(new URL(baseUrl)); } catch (MalformedURLException e) { - throw new IllegalArgumentException("The value of URL was invalid " + baseUrl, e); - } catch (Exception e) { - if ("com.oracle.svm.core.jdk.UnsupportedFeatureError".equals(e.getClass().getCanonicalName())) { + if (e.getMessage().contains( + "It must be enabled by adding the --enable-url-protocols=https option to the native-image command")) { throw new IllegalArgumentException(baseUrl + " requires SSL support but it is disabled. You probably have set quarkus.ssl.native to false."); } - throw e; + throw new IllegalArgumentException("The value of URL was invalid " + baseUrl, e); } }