Skip to content
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

java.util.ConcurrentModificationException in DefaultDockerClientConfig.replaceProperties #2274

Open
lyndsey-ferguson opened this issue Dec 13, 2023 · 0 comments

Comments

@lyndsey-ferguson
Copy link

We are seeing an occasional exception when calling DefaultDockerClientConfig.createDefaultConfigBuilder():

java.util.ConcurrentModificationException: (No message provided)    
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)    
at com.github.dockerjava.core.DefaultDockerClientConfig.replaceProperties(DefaultDockerClientConfig.java:133)    
at com.github.dockerjava.core.DefaultDockerClientConfig.replaceProperties(DefaultDockerClientConfig.java:128)    
at com.github.dockerjava.core.DefaultDockerClientConfig.loadIncludedDockerProperties(DefaultDockerClientConfig.java:121)    
at com.github.dockerjava.core.DefaultDockerClientConfig.createDefaultConfigBuilder(DefaultDockerClientConfig.java:217)    
at com.github.dockerjava.core.DefaultDockerClientConfig.createDefaultConfigBuilder(DefaultDockerClientConfig.java:210) 

I think this is an inherent problem in how the code works. It is replacing values for a Properties() instance as it is iterating over it with an "enhanced for" loop using an iterator created via the property's keySet() method.

That causes a problem:

If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined.

For each KEY in the keySet, we call properties.setProperty with the KEY and the matching string ${KEYVALUE} for the value given by a replacements Properties instance. That is to say, we are replacing each property that has an entry in the replacements.

Here is where the Hashtable is being modified while it is being iterated on (and not using the remove method) in this code:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant