Skip to content

Commit

Permalink
[TUBEMQ-127] Fixed a bug & minor changes (apache#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
viviel authored May 19, 2020
1 parent 5f4c4e0 commit c4380d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ public PartitionSelectResult pushSelect() {
protected boolean isPartitionInUse(String partitionKey, long usedToken) {
if (partitionMap.containsKey(partitionKey)) {
Long curToken = partitionUsedMap.get(partitionKey);
if (curToken != null && curToken == usedToken) {
return true;
}
return curToken != null && curToken == usedToken;
}
return false;
}
Expand Down Expand Up @@ -310,9 +308,7 @@ public boolean bookPartition(String partitionKey) {
Integer isReged = partRegisterBookMap.get(partitionKey);
if (isReged == null) {
isReged = partRegisterBookMap.putIfAbsent(partitionKey, 1);
if (isReged == null) {
return true;
}
return isReged == null;
}
return false;
}
Expand Down Expand Up @@ -628,8 +624,7 @@ public ConcurrentLinkedQueue<Partition> getPartitionByBroker(BrokerInfo brokerIn

public void resumeTimeoutConsumePartitions(long allowedPeriodTimes) {
if (!partitionUsedMap.isEmpty()) {
List<String> partKeys = new ArrayList<>();
partKeys.addAll(partitionUsedMap.keySet());
List<String> partKeys = new ArrayList<>(partitionUsedMap.keySet());
for (String keyId : partKeys) {
Long oldTime = partitionUsedMap.get(keyId);
if (oldTime != null && System.currentTimeMillis() - oldTime > allowedPeriodTimes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.Serializable;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -55,7 +56,7 @@ public boolean contains(Object o) {

@Override
public Iterator<E> iterator() {
return map.keySet().iterator();
return new ArrayList<>(map.keySet()).iterator();
}

@Override
Expand Down

0 comments on commit c4380d2

Please sign in to comment.