mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Use CopyOnWriteArraySet for pingFailedListeners
To prevent java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:788) at java.util.HashMap$KeyIterator.next(HashMap.java:815) at org.jivesoftware.smackx.ping.PingManager.pingMyServer(PingManager.java:252) at org.kontalk.service.msgcenter.MessageCenterService$3.run(MessageCenterService.java:1114) at java.lang.Thread.run(Thread.java:818) Thanks to Daniele Ricci for reporting this.
This commit is contained in:
parent
bb3eeb9af0
commit
6cfdf2bc6f
1 changed files with 3 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2012-2015 Florian Schmaus
|
* Copyright 2012-2017 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,11 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.ping;
|
package org.jivesoftware.smackx.ping;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
@ -105,8 +104,7 @@ public final class PingManager extends Manager {
|
||||||
defaultPingInterval = interval;
|
defaultPingInterval = interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<PingFailedListener> pingFailedListeners = Collections
|
private final Set<PingFailedListener> pingFailedListeners = new CopyOnWriteArraySet<>();
|
||||||
.synchronizedSet(new HashSet<PingFailedListener>());
|
|
||||||
|
|
||||||
private final ScheduledExecutorService executorService;
|
private final ScheduledExecutorService executorService;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue