yhs0092 opened a new issue, #3977:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3977
## 问题场景
业务从 Java-Chassis 1.3.11 升级到 2.8.9.
他们的配置文件里一直会配TLS的信任证书和身份证书, 自定义扩展了一个`SSLCustom`根据文件名生成文件全路径.
在Windows开发环境下, 证书不存在, 在 1.3.11
版本`org.apache.servicecomb.foundation.vertx.VertxTLSBuilder#isFileExists`方法只检查指定路径在磁盘上是否存在,
不存在就返回`false`不加载证书, 因此不会报错.
但升级 Java-Chassis 2.8.9 后, 新增了从ClassLoader加载 resource 的逻辑,
传入`D:\xxx\yyy\server.p12`这种文件路径会遇到文件URL解析错误:
```
Caused by: java.lang.IllegalArgumentException: name
at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:703)
at sun.misc.URLClassPath.findResource(URLClassPath.java:225)
at java.net.URLClassLoader$2.run(URLClassLoader.java:572)
at java.net.URLClassLoader$2.run(URLClassLoader.java:570)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findResource(URLClassLoader.java:569)
at java.lang.ClassLoader.getResource(ClassLoader.java:1089)
......
at
org.apache.servicecomb.foundation.vertx.VertxTLSBuilder.isFileExists(VertxTLSBuilder.java:179)
at
org.apache.servicecomb.foundation.vertx.VertxTLSBuilder.buildTCPSSLOptions(VertxTLSBuilder.java:116)
at
org.apache.servicecomb.foundation.vertx.VertxTLSBuilder.buildClientOptionsBase(VertxTLSBuilder.java:98)
at
org.apache.servicecomb.foundation.vertx.VertxTLSBuilder.buildHttpClientOptions(VertxTLSBuilder.java:91)
at
org.apache.servicecomb.foundation.vertx.VertxTLSBuilder.buildHttpClientOptions(VertxTLSBuilder.java:86)
at
org.apache.servicecomb.foundation.vertx.client.http.HttpClientOptionsSPI.createHttpClientOptions(HttpClientOptionsSPI.java:134)
```
这个异常看着令人费解, 以为是业务配了什么叫"name"的配置值,
但从实际的报错位置`sun.misc.URLClassPath.Loader#findResource`来看,
是表示`findResource`输入的`name`参数有问题, 解析不出合适的URL.
```java
URL findResource(final String name, boolean check) {
URL url;
try {
url = new URL(base, ParseUtil.encodePath(name, false));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("name");
}
// ....
```
## 期望
能否优化一下`VertxTLSBuilder.isFileExists`方法的逻辑, 不要直接抛出原始的异常, 最好是包装或者转换一下异常,
提醒业务是什么文件路径下找不到证书.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]