Fix ConcurrentModificationException

This commit is contained in:
Nazar-Kutz 2020-05-20 14:10:07 +03:00
parent 0b5db53bc5
commit 62c114f36e

View file

@ -353,7 +353,7 @@ public class MapPoiTypes {
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
this.categories = new ArrayList<>();
List<PoiCategory> categoriesList = new ArrayList<>();
try {
XmlPullParser parser = PlatformUtil.newXMLPullParser();
int tok;
@ -365,12 +365,11 @@ public class MapPoiTypes {
PoiType lastType = null;
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>();
String lastPoiAdditionalCategory = null;
List<PoiCategory> categoriesCopy = new ArrayList<>(categories);
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (tok == XmlPullParser.START_TAG) {
String name = parser.getName();
if (name.equals("poi_category")) {
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categories.size());
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categoriesList.size());
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
@ -381,7 +380,7 @@ public class MapPoiTypes {
lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories());
}
categoriesCopy.add(lastCategory);
categoriesList.add(lastCategory);
} else if (name.equals("poi_filter")) {
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
@ -483,7 +482,7 @@ public class MapPoiTypes {
}
}
}
categories = categoriesCopy;
categories = categoriesList;
is.close();
} catch (IOException e) {
log.error("Unexpected error", e); //$NON-NLS-1$