ConcurrentModificationException iterating over System.getProperties().entrySet()
Description
Environment
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
Windows 7
Activity
Show:
Nathan Voxland July 27, 2015 at 7:02 PM
Added clone() call

Paul Illingworth June 29, 2015 at 11:58 AM
Have updated to 3.3.2 and have seen the issue again.
"Cloning" by initialising a HashSet() with the properties doesn't fix the problem as this simply calls Collections#addAll() which then iterates over the properties.
A solution would be to call clone() on the system Properties object as this is synchronised.
Nathan Voxland November 20, 2014 at 10:10 PM
Cloned set for 3.3.1
Have seen this once (and only once) after running for months without issue.
Caused by: java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1167)
at liquibase.changelog.ChangeLogParameters.<init>(ChangeLogParameters.java:37)
at liquibase.Liquibase.<init>(Liquibase.java:106)
at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:346)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:297)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1504)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 14 more
I guess the System.getProperties() needs to be copied or clone() before iterating over as it is possible for the System properties to change at any time. clone on a Hashtable is synchronized so should be ok.