6565import java .lang .reflect .Method ;
6666import java .security .AccessControlException ;
6767import java .util .Collection ;
68+ import java .util .Enumeration ;
6869import java .util .Locale ;
6970import java .util .Properties ;
7071
@@ -469,19 +470,20 @@ public void initialize() throws SchedulerException {
469470 }
470471 }
471472
472- initialize (overrideWithSysProps (props ));
473+ initialize (overrideWithSysProps (props , getLog () ));
473474 }
474475
475476 /**
476477 * Add all System properties to the given <code>props</code>. Will override
477478 * any properties that already exist in the given <code>props</code>.
478479 */
479- private Properties overrideWithSysProps (Properties props ) {
480+ // Visible for testing
481+ static Properties overrideWithSysProps (Properties props , Logger log ) {
480482 Properties sysProps = null ;
481483 try {
482484 sysProps = System .getProperties ();
483485 } catch (AccessControlException e ) {
484- getLog () .warn (
486+ log .warn (
485487 "Skipping overriding quartz properties with System properties " +
486488 "during initialization because of an AccessControlException. " +
487489 "This is likely due to not having read/write access for " +
@@ -492,7 +494,17 @@ private Properties overrideWithSysProps(Properties props) {
492494 }
493495
494496 if (sysProps != null ) {
495- props .putAll (sysProps );
497+ // Use the propertyNames to iterate to avoid
498+ // a possible ConcurrentModificationException
499+ Enumeration <?> en = sysProps .propertyNames ();
500+ while (en .hasMoreElements ()) {
501+ Object name = en .nextElement ();
502+ Object value = sysProps .get (name );
503+ if (name instanceof String && value instanceof String ) {
504+ // Properties javadoc discourages use of put so we use setProperty
505+ props .setProperty ((String ) name , (String ) value );
506+ }
507+ }
496508 }
497509
498510 return props ;
0 commit comments