* Clone System properties before iterating to avoid

ConcurrentModificationException (ticket #680)
This commit is contained in:
zzz
2012-08-06 14:45:37 +00:00
parent 91e61dbd5c
commit 1ab8200c7f
7 changed files with 23 additions and 15 deletions

View File

@ -516,7 +516,8 @@ public class I2PAppContext {
* @return set of Strings containing the names of defined system properties
*/
public Set getPropertyNames() {
Set names = new HashSet(System.getProperties().keySet());
// clone to avoid ConcurrentModificationException
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
if (_overrideProps != null)
names.addAll(_overrideProps.keySet());
return names;
@ -531,8 +532,8 @@ public class I2PAppContext {
* @since 0.8.4
*/
public Properties getProperties() {
Properties rv = new Properties();
rv.putAll(System.getProperties());
// clone to avoid ConcurrentModificationException
Properties rv = (Properties) System.getProperties().clone();
rv.putAll(_overrideProps);
return rv;
}