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

StdSchedulerFactory ConcurrentModificationException reading system properties #474

Closed
davidmoten opened this issue Aug 7, 2019 · 2 comments

Comments

@davidmoten
Copy link
Contributor

davidmoten commented Aug 7, 2019

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:

/**
* 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

@davidmoten
Copy link
Contributor Author

/cc @SuperEvenSteven (sorry, typo earlier)

@davidmoten
Copy link
Contributor Author

I've submitted a PR #475 for this one

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