mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
fix some warnings in common modules
This commit is contained in:
@@ -61,7 +61,7 @@ public class WxConsts {
|
||||
/**
|
||||
* 群发反馈消息代码所对应的文字描述
|
||||
*/
|
||||
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<String, String>();
|
||||
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<>();
|
||||
///////////////////////
|
||||
// 微信端推送过来的事件类型
|
||||
///////////////////////
|
||||
|
||||
@@ -25,7 +25,7 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
|
||||
/**
|
||||
* 消息id->消息时间戳的map
|
||||
*/
|
||||
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<String, Long>();
|
||||
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 后台清理线程是否已经开启
|
||||
@@ -56,7 +56,7 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
|
||||
}
|
||||
|
||||
protected void checkBackgroundProcessStarted() {
|
||||
if (backgroundProcessStarted.getAndSet(true)) {
|
||||
if (this.backgroundProcessStarted.getAndSet(true)) {
|
||||
return;
|
||||
}
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@@ -64,11 +64,11 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
Thread.sleep(clearPeriod);
|
||||
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
|
||||
Long now = System.currentTimeMillis();
|
||||
for (Map.Entry<String, Long> entry : msgId2Timestamp.entrySet()) {
|
||||
if (now - entry.getValue() > timeToLive) {
|
||||
msgId2Timestamp.entrySet().remove(entry);
|
||||
for (Map.Entry<String, Long> entry : WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
|
||||
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
|
||||
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
|
||||
return false;
|
||||
}
|
||||
checkBackgroundProcessStarted();
|
||||
Long timestamp = msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
|
||||
Long timestamp = this.msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
|
||||
return timestamp != null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user