-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
make synchronized #4923
make synchronized #4923
Conversation
Making |
@aikebah what I believe is happening is during execution on multi-module project - while module 1 is cycling over the suppression rules, module 2 triggers a reload on the suppression rules which causes module 1's execution to throw the concurrent modification exception. We have only been seeing this error in the CI on |
So either we synchronize on the protected void analyzeDependency(Dependency dependency, Engine engine) throws AnalysisException {
List<SuppressionRule> suppressions = new ArrayList<>();
suppressions.addAll(rules.list());
if (suppressions.isEmpty()) {
return;
}
for (SuppressionRule rule : suppressions) {
... Thoughts? |
calling analyzeDependency happens a lot (once for each dependency), so copying the rules for each dependency would likely cause a tremendous amount of wasted CPU cycles and memory. My gut feel would be that we're best off by changing the rules to a synchronized List and synchronizing the iteration on that same list as per https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#synchronizedList-java.util.List- |
at second thought: why would the same JVM reload it... I think the answer lies in 'different submodule with different suppressionFile configuration', which would mean we want to fully prevent that reload from happening while the entire analysis runs. That would call for a ThreadLocal rules list instead of a singleton, assuming that we process the entire analysis of a certain module within the same thread. |
The reload is happening even with the same suppression file - |
After thinking through this a bit more - I'm going to remove the singleton on the rules and add a new mechanism to store objects throughout the execution. |
Given run 3231291349 there is a
ConcurrentModificationException
:This PR adds synchronization...