Fix DynamicSentinelProperty synchronized listener set iterator race-condition problem (#2519)

This commit is contained in:
howiekang 2022-01-01 11:06:16 +08:00 committed by GitHub
parent 8724a7c0a1
commit 02cfe40f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -15,15 +15,14 @@
*/
package com.alibaba.csp.sentinel.property;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.alibaba.csp.sentinel.log.RecordLog;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
public class DynamicSentinelProperty<T> implements SentinelProperty<T> {
protected Set<PropertyListener<T>> listeners = Collections.synchronizedSet(new HashSet<PropertyListener<T>>());
protected Set<PropertyListener<T>> listeners = new CopyOnWriteArraySet<>();
private T value = null;
public DynamicSentinelProperty() {