fix pr#4149@Github

This commit is contained in:
Looly
2025-11-25 15:16:42 +08:00
parent bd42686a65
commit 654db66ecb
4 changed files with 12 additions and 4 deletions

View File

@@ -24,6 +24,9 @@
* 【core 】 修复`Validator.isBetween`在高精度Number类型下存在精度丢失问题pr#4136@Github
* 【core 】 修复`FileNameUtil.extName`在特殊后缀判断逻辑过于宽松导致误判问题pr#4142@Github
* 【core 】 修复`TypeUtil.getClass`无法识别`GenericArrayType`问题pr#4138@Github
* 【core 】 修复`CreditCodeUtil.randomCreditCode`部分字母未使用问题pr#4149@Github
* 【core 】 修复`CacheableAnnotationAttribute`可能并发问题pr#4149@Github
* 【core 】 修复`URLUtil.url`未断开连接问题pr#4149@Github
-------------------------------------------------------------------------------------------------------------
# 5.8.41(2025-10-12)

View File

@@ -15,7 +15,7 @@ import java.lang.reflect.Method;
public class CacheableAnnotationAttribute implements AnnotationAttribute {
private volatile boolean valueInvoked;
private Object value;
private volatile Object value;
private boolean defaultValueInvoked;
private Object defaultValue;

View File

@@ -100,7 +100,7 @@ public class CreditCodeUtil {
//
for (int i = 0; i < 2; i++) {
int num = RandomUtil.randomInt(BASE_CODE_ARRAY.length - 1);
int num = RandomUtil.randomInt(BASE_CODE_ARRAY.length);
buf.append(Character.toUpperCase(BASE_CODE_ARRAY[num]));
}
for (int i = 2; i < 8; i++) {
@@ -108,7 +108,7 @@ public class CreditCodeUtil {
buf.append(BASE_CODE_ARRAY[num]);
}
for (int i = 8; i < 17; i++) {
int num = RandomUtil.randomInt(BASE_CODE_ARRAY.length - 1);
int num = RandomUtil.randomInt(BASE_CODE_ARRAY.length);
buf.append(BASE_CODE_ARRAY[num]);
}

View File

@@ -807,8 +807,9 @@ public class URLUtil extends URLEncodeUtil {
} else {
// 如果资源打在jar包中或来自网络使用网络请求长度
// issue#3226, 来自Spring的AbstractFileResolvingResource
URLConnection con = null;
try {
final URLConnection con = url.openConnection();
con = url.openConnection();
useCachesIfNecessary(con);
if (con instanceof HttpURLConnection) {
final HttpURLConnection httpCon = (HttpURLConnection) con;
@@ -817,6 +818,10 @@ public class URLUtil extends URLEncodeUtil {
return con.getContentLengthLong();
} catch (final IOException e) {
throw new IORuntimeException(e);
} finally {
if (con instanceof HttpURLConnection) {
((HttpURLConnection) con).disconnect();
}
}
}
}