Skip to content

Commit

Permalink
FIX: Concurrency problem in locator allNodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
brido4125 committed Jul 3, 2024
1 parent 715f73a commit b677f40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/spy/memcached/ArcusKetamaNodeLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -66,7 +67,7 @@ public ArcusKetamaNodeLocator(List<MemcachedNode> nodes) {
public ArcusKetamaNodeLocator(List<MemcachedNode> nodes,
ArcusKetamaNodeLocatorConfiguration conf) {
super();
allNodes = nodes;
allNodes = new CopyOnWriteArrayList<>(nodes);
ketamaNodes = new TreeMap<>();
config = conf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -65,7 +66,7 @@ public class ArcusReplKetamaNodeLocator extends SpyObject implements NodeLocator

public ArcusReplKetamaNodeLocator(List<MemcachedNode> nodes) {
super();
allNodes = nodes;
allNodes = new CopyOnWriteArrayList<>(nodes);
ketamaGroups = new TreeMap<>();
allGroups = new HashMap<>();

Expand Down

0 comments on commit b677f40

Please sign in to comment.