Skip to content

Commit

Permalink
fix pmd warn
Browse files Browse the repository at this point in the history
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
  • Loading branch information
yunfeiyanggzq committed Jul 27, 2020
1 parent d74c0bc commit 0ddd0e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private boolean notValidRequest(Long id, int count) {
}

private boolean notValidRequest(String address, Long id, int count) {
return address == null || address.equals("") || id == null || id <= 0 || count <= 0;
return address == null || "".equals(address) || id == null || id <= 0 || count <= 0;
}

private TokenResult badRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class CurrentConcurrencyManager {
*/
private static final ConcurrentHashMap<Long, AtomicInteger> NOW_CALLS_MAP = new ConcurrentHashMap<Long, AtomicInteger>();

@SuppressWarnings("PMD.ThreadPoolCreationRule")
private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("sentinel-cluster-concurrency-record-task", true));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import com.alibaba.csp.sentinel.cluster.flow.statistic.concurrent.CurrentConcurrencyManager;
import com.alibaba.csp.sentinel.cluster.flow.statistic.concurrent.TokenCacheNode;
import com.alibaba.csp.sentinel.cluster.server.connection.ConnectionManager;
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory;
import com.alibaba.csp.sentinel.log.RecordLog;
import com.alibaba.csp.sentinel.util.AssertUtil;
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -63,6 +65,10 @@ public class RegularExpireStrategy implements ExpireStrategy {
*/
private ConcurrentLinkedHashMap<Long, TokenCacheNode> localCache;

@SuppressWarnings("PMD.ThreadPoolCreationRule")
private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("regular clear expired token thread"));


public RegularExpireStrategy() {
}
Expand All @@ -71,7 +77,6 @@ public RegularExpireStrategy() {
public void removeExpireKey(ConcurrentLinkedHashMap localCache) {
AssertUtil.isTrue(localCache != null, " local cache can't be null");
this.localCache = localCache;
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(new MyTask(), 0, executeRate, TimeUnit.MILLISECONDS);
}

Expand Down

0 comments on commit 0ddd0e5

Please sign in to comment.