1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 547398 - Fix ConcurrentModificationException in ToolChainManager

- fix references of orderedToolChains list in for loops to use
  array copy

Change-Id: Id6ad9ae5e680ed581a2b3ceddf2bfc19b68dcccd
This commit is contained in:
Jeff Johnston 2019-05-16 11:53:29 -04:00
parent bdb0da6b73
commit 4028d882fe

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2015 QNX Software Systems and others. * Copyright (c) 2015, 2019 QNX Software Systems and others.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -117,7 +117,7 @@ public class ToolChainManager implements IToolChainManager {
.node("order"); //$NON-NLS-1$ .node("order"); //$NON-NLS-1$
prefs.put("n", Integer.toString(orderedToolChains.size())); //$NON-NLS-1$ prefs.put("n", Integer.toString(orderedToolChains.size())); //$NON-NLS-1$
int i = 0; int i = 0;
for (IToolChain toolChain : orderedToolChains) { for (IToolChain toolChain : orderedToolChains.toArray(new IToolChain[0])) {
prefs.put(Integer.toString(i) + ".type", toolChain.getTypeId()); //$NON-NLS-1$ prefs.put(Integer.toString(i) + ".type", toolChain.getTypeId()); //$NON-NLS-1$
prefs.put(Integer.toString(i) + ".id", toolChain.getId()); //$NON-NLS-1$ prefs.put(Integer.toString(i) + ".id", toolChain.getId()); //$NON-NLS-1$
i++; i++;
@ -191,7 +191,7 @@ public class ToolChainManager implements IToolChainManager {
init(); init();
List<IToolChain> tcs = new ArrayList<>(); List<IToolChain> tcs = new ArrayList<>();
if (orderedToolChains != null) { if (orderedToolChains != null) {
for (IToolChain toolChain : orderedToolChains) { for (IToolChain toolChain : orderedToolChains.toArray(new IToolChain[0])) {
boolean matches = true; boolean matches = true;
for (Map.Entry<String, String> property : properties.entrySet()) { for (Map.Entry<String, String> property : properties.entrySet()) {
String tcProperty = toolChain.getProperty(property.getKey()); String tcProperty = toolChain.getProperty(property.getKey());