Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ConcurrentModificationException for getStats Op #23

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/main/java/net/spy/memcached/MemcachedClient.java
Expand Up @@ -1710,18 +1710,20 @@ public Map<SocketAddress, Map<String, String>> getStats() {
@Override
public Map<SocketAddress, Map<String, String>> getStats(final String arg) {
final Map<SocketAddress, Map<String, String>> rv =
new HashMap<SocketAddress, Map<String, String>>();
new ConcurrentHashMap<SocketAddress, Map<String, String>>();

CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final MemcachedNode n,
final CountDownLatch latch) {
final SocketAddress sa = n.getSocketAddress();
rv.put(sa, new HashMap<String, String>());
rv.put(sa, new HashMap<String, String>(0));
return opFact.stats(arg, new StatsOperation.Callback() {
private final Map<String,String> data =
new HashMap<String,String>();
@Override
public void gotStat(String name, String val) {
rv.get(sa).put(name, val);
data.put(name, val);
}

@Override
Expand All @@ -1730,6 +1732,9 @@ public void receivedStatus(OperationStatus status) {
if (!status.isSuccess()) {
getLogger().warn("Unsuccessful stat fetch: %s", status);
}
else {
rv.put(sa, data);
}
}

@Override
Expand Down