mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user