mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
fix: LocalConstant 改用 ConcurrentHashMap 保证线程安全,LzTool 方法名拼写修正
- LocalConstant: HashMap → ConcurrentHashMap,put() 改用 putIfAbsent 消除 check-then-act 竞态 - LzTool: 私有方法 setDateAndComplate → setDateAndComplete(拼写修正,仅内部调用)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package cn.qaiu.vx.core.util;
|
package cn.qaiu.vx.core.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vertx 上下文外的本地容器 为不在vertx线程的方法传递数据
|
* vertx 上下文外的本地容器 为不在vertx线程的方法传递数据
|
||||||
@@ -10,11 +10,10 @@ import java.util.Map;
|
|||||||
* @author <a href="https://qaiu.top">QAIU</a>
|
* @author <a href="https://qaiu.top">QAIU</a>
|
||||||
*/
|
*/
|
||||||
public class LocalConstant {
|
public class LocalConstant {
|
||||||
private static final Map<String, Object> LOCAL_CONST = new HashMap<>();
|
private static final Map<String, Object> LOCAL_CONST = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static Map<String, Object> put(String k, Object v) {
|
public static Map<String, Object> put(String k, Object v) {
|
||||||
if (LOCAL_CONST.containsKey(k)) return LOCAL_CONST;
|
LOCAL_CONST.putIfAbsent(k, v);
|
||||||
LOCAL_CONST.put(k, v);
|
|
||||||
return LOCAL_CONST;
|
return LOCAL_CONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,12 +290,12 @@ public class LzTool extends PanBase {
|
|||||||
if (location0 == null) {
|
if (location0 == null) {
|
||||||
fail(downUrl + " -> 直链获取失败2, 可能分享已失效");
|
fail(downUrl + " -> 直链获取失败2, 可能分享已失效");
|
||||||
} else {
|
} else {
|
||||||
setDateAndComplate(location0);
|
setDateAndComplete(location0);
|
||||||
}
|
}
|
||||||
}).onFailure(handleFail(downUrl));
|
}).onFailure(handleFail(downUrl));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setDateAndComplate(location);
|
setDateAndComplete(location);
|
||||||
})
|
})
|
||||||
.onFailure(handleFail(downUrl));
|
.onFailure(handleFail(downUrl));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -304,7 +304,7 @@ public class LzTool extends PanBase {
|
|||||||
}).onFailure(handleFail(url));
|
}).onFailure(handleFail(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDateAndComplate(String location0) {
|
private void setDateAndComplete(String location0) {
|
||||||
// 分享时间 提取url中的时间戳格式:lanzoui.com/abc/abc/yyyy/mm/dd/
|
// 分享时间 提取url中的时间戳格式:lanzoui.com/abc/abc/yyyy/mm/dd/
|
||||||
String regex = "(\\d{4}/\\d{1,2}/\\d{1,2})";
|
String regex = "(\\d{4}/\\d{1,2}/\\d{1,2})";
|
||||||
Matcher matcher = Pattern.compile(regex).matcher(location0);
|
Matcher matcher = Pattern.compile(regex).matcher(location0);
|
||||||
|
|||||||
Reference in New Issue
Block a user