-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Using quartz 2.3.1 I get the following exception occasionally on startup of a webapp in Tomcat.
java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1387)
at java.util.Hashtable.putAll(Hashtable.java:523)
at org.quartz.impl.StdSchedulerFactory.overrideWithSysProps(StdSchedulerFactory.java:495)
at org.quartz.impl.StdSchedulerFactory.initialize(StdSchedulerFactory.java:472)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1552)
This is due to StdSchedulerFactory.overrideWithSysProps which looks like this:
quartz/quartz-core/src/main/java/org/quartz/impl/StdSchedulerFactory.java
Lines 475 to 496 in 1ba8447
| /** | |
| * Add all System properties to the given <code>props</code>. Will override | |
| * any properties that already exist in the given <code>props</code>. | |
| */ | |
| private Properties overrideWithSysProps(Properties props) { | |
| Properties sysProps = null; | |
| try { | |
| sysProps = System.getProperties(); | |
| } catch (AccessControlException e) { | |
| getLog().warn( | |
| "Skipping overriding quartz properties with System properties " + | |
| "during initialization because of an AccessControlException. " + | |
| "This is likely due to not having read/write access for " + | |
| "java.util.PropertyPermission as required by java.lang.System.getProperties(). " + | |
| "To resolve this warning, either add this permission to your policy file or " + | |
| "use a non-default version of initialize().", | |
| e); | |
| } | |
| if (sysProps != null) { | |
| props.putAll(sysProps); | |
| } |
By calling putAll the entrySet() iterator is used on System.getProperties() which is not a thread-safe way of traversing System properties.
The fix would be to instead traverse the System properties by using the Enumeration propertyNames() and calling getProperty on each property name.
Happy to provide PR.
CC @SuperEventSteven
Metadata
Metadata
Assignees
Labels
No labels