mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
2cadd59600
commit
74071035e1
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.17.M1 (2023-03-31)
|
||||
# 5.8.17.M1 (2023-04-01)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 SerializeUtil.deserialize增加白名单类,避免RCE vulnerability(issue#3021@Github)
|
||||
@ -17,7 +17,6 @@
|
||||
### 🐞Bug修复
|
||||
* 【core 】 CollUtil.split优化切割列表参数判断,避免OOM(pr#3026@Github)
|
||||
* 【core 】 修复FileUtil.move传入相同目录或子目录丢失源目录的问题(pr#3032@Github)
|
||||
* 【core 】 修复MapUtil.computeIfAbsent可能存在的并发问题(issue#I6RVMY@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.16 (2023-03-26)
|
||||
|
@ -221,7 +221,9 @@ public class ZipReader implements Closeable {
|
||||
try {
|
||||
ZipEntry zipEntry;
|
||||
while (null != (zipEntry = in.getNextEntry())) {
|
||||
consumer.accept(checkZipBomb(zipEntry));
|
||||
consumer.accept(zipEntry);
|
||||
// 检查ZipBomb放在读取内容之后,以便entry中的信息正常读取
|
||||
checkZipBomb(zipEntry);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
|
@ -1483,8 +1483,12 @@ public class MapUtil {
|
||||
if (JdkUtil.IS_JDK8) {
|
||||
V value = map.get(key);
|
||||
if (null == value) {
|
||||
//map.putIfAbsent(key, mappingFunction.apply(key));
|
||||
value = map.computeIfAbsent(key, mappingFunction);
|
||||
map.putIfAbsent(key, mappingFunction.apply(key));
|
||||
value = map.get(key);
|
||||
|
||||
// 判空后调用依旧无法解决死循环问题
|
||||
// 见:Issue2349Test
|
||||
//value = map.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
return value;
|
||||
} else {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.hutool.core.map;
|
||||
|
||||
import cn.hutool.core.util.JdkUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
@ -69,6 +71,19 @@ public class SafeConcurrentHashMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
|
||||
@Override
|
||||
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
|
||||
return MapUtil.computeIfAbsent(this, key, mappingFunction);
|
||||
if (JdkUtil.IS_JDK8) {
|
||||
V value = get(key);
|
||||
if (null == value) {
|
||||
putIfAbsent(key, mappingFunction.apply(key));
|
||||
value = get(key);
|
||||
|
||||
// 判空后调用依旧无法解决死循环问题
|
||||
// 见:Issue2349Test
|
||||
//value = map.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
return value;
|
||||
} else {
|
||||
return super.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user