This commit is contained in:
Albumen Kevin 2023-01-30 17:33:45 +08:00 committed by GitHub
parent 83a8c00800
commit f1b3e55b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -27,7 +27,6 @@ import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -42,7 +41,7 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_IO_EX
import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_INTERRUPTED;
public class SerializeSecurityManager {
private final Set<String> allowedPrefix = new LinkedHashSet<>();
private final Set<String> allowedPrefix = new ConcurrentHashSet<>();
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SerializeSecurityManager.class);
@ -84,7 +83,7 @@ public class SerializeSecurityManager {
}
}
public void registerInterface(Class<?> clazz) {
public synchronized void registerInterface(Class<?> clazz) {
Set<Class<?>> markedClass = new HashSet<>();
markedClass.add(clazz);
@ -213,16 +212,18 @@ public class SerializeSecurityManager {
public void registerListener(AllowClassNotifyListener listener) {
listeners.add(listener);
listener.notify(checkStatus, allowedPrefix);
listener.notify(checkStatus, getAllowedPrefix());
}
private void notifyListeners() {
for (AllowClassNotifyListener listener : listeners) {
listener.notify(checkStatus, allowedPrefix);
listener.notify(checkStatus, getAllowedPrefix());
}
}
protected Set<String> getAllowedPrefix() {
return allowedPrefix;
Set<String> set = new ConcurrentHashSet<>();
set.addAll(allowedPrefix);
return set;
}
}