Skip to content

Commit c6c4d15

Browse files
fixed ConcurrentModificationException that got thrown when attempting to load a sketch.properties that contains a platform specific property that was not the last element in the generated map
1 parent d3367d1 commit c6c4d15

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/src/processing/app/Settings.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,18 @@ public void load(File additions) {
9494
// check for platform-specific properties in the defaults
9595
String platformExt = "." + Platform.getName();
9696
int platformExtLength = platformExt.length();
97+
HashMap<String,String> tmpMap = new HashMap<>();
9798
for (String key : table.keySet()) {
9899
if (key.endsWith(platformExt)) {
99100
// this is a key specific to a particular platform
100101
String actualKey = key.substring(0, key.length() - platformExtLength);
101102
String value = get(key);
102-
table.put(actualKey, value);
103+
//if the key is specific to this platform and is not the last property then attempting to append it to the map will throw a ConcurrentModificationException
104+
//to avoid this we append it to a temporary map that can then be safely merged after the loop is complete
105+
tmpMap.put(actualKey, value);
103106
}
104107
}
108+
table.putAll(tmpMap);
105109
}
106110

107111

0 commit comments

Comments
 (0)