fix some warnings in common modules

This commit is contained in:
BinaryWang
2016-09-01 10:18:24 +08:00
parent 66cd7cda43
commit 6f297ae95a
30 changed files with 185 additions and 178 deletions

View File

@@ -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<>();
///////////////////////
// 微信端推送过来的事件类型
///////////////////////

View File

@@ -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;
}