修复HttpConnection.reflectSetMethod反射在JDK9+权限问题(issue#4109@Github)

This commit is contained in:
Looly 2025-10-28 18:23:22 +08:00
parent a3e58451fc
commit edeb87c7f4
2 changed files with 13 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# 🚀Changelog # 🚀Changelog
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.8.42(2025-10-24) # 5.8.42(2025-10-28)
### 🐣新特性 ### 🐣新特性
* 【core 】 `ListUtil`增加`zip`方法pr#4052@Github * 【core 】 `ListUtil`增加`zip`方法pr#4052@Github
@ -14,6 +14,7 @@
* 【extra 】 修复`JschSessionPool.remove`逻辑错误问题。 * 【extra 】 修复`JschSessionPool.remove`逻辑错误问题。
* 【db 】 修复`Dialect.psForCount`未传入Wrapper导致大小写问题issue#ID39G9@Gitee)。 * 【db 】 修复`Dialect.psForCount`未传入Wrapper导致大小写问题issue#ID39G9@Gitee)。
* 【core 】 修复`PasswdStrength.check`indexOf逻辑问题pr#4114@Github)。 * 【core 】 修复`PasswdStrength.check`indexOf逻辑问题pr#4114@Github)。
* 【htp 】 修复`HttpConnection.reflectSetMethod`反射在JDK9+权限问题issue#4109@Github)。
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.8.41(2025-10-12) # 5.8.41(2025-10-12)

View File

@ -598,10 +598,11 @@ public class HttpConnection {
} }
/** /**
* 通过反射设置方法名首先设置HttpURLConnection本身的方法名再检查是否为代理类如果是设置带路对象的方法名 * 通过反射设置方法名首先设置HttpURLConnection本身的方法名再检查是否为代理类如果是设置代理对象的方法名
* @param method 方法名 * @param method 方法名
*/ */
private void reflectSetMethod(Method method){ private void reflectSetMethod(Method method){
try {
ReflectUtil.setFieldValue(this.conn, "method", method.name()); ReflectUtil.setFieldValue(this.conn, "method", method.name());
// HttpsURLConnectionImpl实现中使用了代理类需要修改被代理类的method方法 // HttpsURLConnectionImpl实现中使用了代理类需要修改被代理类的method方法
@ -609,6 +610,10 @@ public class HttpConnection {
if(null != delegate){ if(null != delegate){
ReflectUtil.setFieldValue(delegate, "method", method.name()); ReflectUtil.setFieldValue(delegate, "method", method.name());
} }
} catch (Exception e){
// ignore
// https://github.com/chinabugotech/hutool/issues/4109
}
} }
// --------------------------------------------------------------- Private Method end // --------------------------------------------------------------- Private Method end
} }