mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
c72ff2c292
commit
29a561fbcf
@ -20,6 +20,7 @@
|
|||||||
* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
|
* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
|
||||||
* 【json 】 修复json中byte[]无法转换问题(issue#I59LW4@Gitee)
|
* 【json 】 修复json中byte[]无法转换问题(issue#I59LW4@Gitee)
|
||||||
* 【core 】 修复NumberUtil.isXXX未判空问题(issue#2350@Github)
|
* 【core 】 修复NumberUtil.isXXX未判空问题(issue#2350@Github)
|
||||||
|
* 【core 】 修复Singleton中ConcurrentHashMap在JDK8下的bug引起的可能的死循环问题(issue#2349@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -52,7 +52,15 @@ public final class Singleton {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T get(String key, Func0<T> supplier) {
|
public static <T> T get(String key, Func0<T> supplier) {
|
||||||
return (T) POOL.computeIfAbsent(key, (k)-> supplier.callWithRuntimeException());
|
//return (T) POOL.computeIfAbsent(key, (k)-> supplier.callWithRuntimeException());
|
||||||
|
// issues#2349
|
||||||
|
// ConcurrentHashMap.computeIfAbsent在某些情况下会导致死循环问题,此处采用Dubbo的解决方案
|
||||||
|
Object value = POOL.get(key);
|
||||||
|
if(null == value){
|
||||||
|
POOL.putIfAbsent(key, supplier.callWithRuntimeException());
|
||||||
|
value = POOL.get(key);
|
||||||
|
}
|
||||||
|
return (T) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user