Skip to content

Commit

Permalink
Fix 11394 (apache#11395)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored and win120a committed Feb 9, 2023
1 parent d8c2481 commit bce27c8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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;
Expand All @@ -42,7 +41,7 @@
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);

Expand Down Expand Up @@ -84,7 +83,7 @@ public SerializeSecurityManager(FrameworkModel frameworkModel) {
}
}

public void registerInterface(Class<?> clazz) {
public synchronized void registerInterface(Class<?> clazz) {
Set<Class<?>> markedClass = new HashSet<>();
markedClass.add(clazz);

Expand Down Expand Up @@ -213,16 +212,18 @@ protected void addToAllow(String className) {

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;
}
}

0 comments on commit bce27c8

Please sign in to comment.