-
Notifications
You must be signed in to change notification settings - Fork 831
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
ConcurrentModificationException in ConfigUtil #6732
Comments
I may be wrong, but to me it seems that making |
This is unusual because its in the static initialization block of DebugConfig, which is only called once at startup. We could do something like We could also wrap the iteration with in a try / catch. We could also find a way to iterate over the keys in a way that avoid concurrent modification exceptions. According to the
This suggests that something like |
@jack-berg how about using ConcurrentHashMap to store a copy of the properties for iteration? also AFAIK static block runs once when the class is loaded. I suppose |
@harshitrjpt : Theoretically no, but honestly Android might be doing some things here we don't have really insight about. |
Would also vouch for a copy System.getProperties().entrySet().stream().toArray()...
// or
Set.copyOf(properties.entrySet()) That should make iterating safe but ofc we wouldn't know about any changes to the list. Don't know if we necessarily need to. |
It seems like we have no choice but to accept the possibility of changes between when we read the keyset and read the values. |
ref: https://stackoverflow.com/a/52447030/4910370 I think copy the key set is a good idea. |
Describe the bug
There is a
ConcurrentModificationException
thrown while callingbuild()
onLongGaugeBuilder
.Steps to reproduce
not yet
What did you expect to see?
No exception thrown
What did you see instead?
ConcurrentModificationException
What version and what artifacts are you using?
Artifacts: see
*.gradle.kts
excerpt belowVersion: 1.42.1
How did you reference these artifacts?
Environment
Compiler: JDK 17 - Temurin
OS: Ubuntu (unknown version)
Runtime (if different from JDK above): Android runtime (ART)
OS (if different from OS compiled on): Android
Additional context
The text was updated successfully, but these errors were encountered: