From cd79e6e5f8e2d826176bae04f0497e7a7875878a Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 20 Dec 2023 22:53:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgraalvm=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E6=89=93=E5=8C=85=E4=BD=BF=E7=94=A8http=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=A2=AB=E8=BD=AC=E4=B8=BAfile=E5=8D=8F=E8=AE=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/main/java/cn/hutool/core/util/URLUtil.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d3039357..0e3e5b044 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * 【core 】 修复时间戳转Bean时异常问题(issue#I8NMP7@Gitee) * 【core 】 修复PostgreSQL使用upsert字段大小写问题问题(issue#I8PB4X@Gitee) * 【extra 】 修复TinyPinyinEngine可能的空指针问题(issue#3437@Github) +* 【core 】 修复graalvm原生打包使用http工具被转为file协议问题(issue#I8PY3Y@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.23(2023-11-12) diff --git a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java index a66463e67..f4d384a61 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java @@ -147,6 +147,14 @@ public class URLUtil extends URLEncodeUtil { try { return new URL(null, url, handler); } catch (MalformedURLException e) { + // issue#I8PY3Y + if(e.getMessage().contains("Accessing an URL protocol that was not enabled")){ + // Graalvm打包需要手动指定参数开启协议: + // --enable-url-protocols=http + // --enable-url-protocols=https + throw new UtilException(e); + } + // 尝试文件路径 try { return new File(url).toURI().toURL();