From 43ba5d203f2ad210a35614d46576384b8549b689 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Wed, 20 May 2020 12:15:07 +0300 Subject: [PATCH] Fix ConcurrentModificationException --- .../src/main/java/net/osmand/osm/MapPoiTypes.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java index 00f254c816..40923d98d8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java @@ -298,12 +298,18 @@ public class MapPoiTypes { if (!lastCategory.getKeyName().equals("Other")) { lastCategory.setTopVisible(true); } - categories.add(lastCategory); + addCategory(lastCategory); return lastCategory; } return otherCategory; } + private void addCategory(PoiCategory category) { + List copy = new ArrayList<>(categories); + copy.add(category); + categories = copy; + } + public PoiTranslator getPoiTranslator() { return poiTranslator; } @@ -348,7 +354,7 @@ public class MapPoiTypes { final Map allTypes = new LinkedHashMap(); final Map> categoryPoiAdditionalMap = new LinkedHashMap>(); final Map> abstractTypeAdditionalCategories = new LinkedHashMap>(); - this.categories.clear(); + this.categories = new ArrayList<>(); try { XmlPullParser parser = PlatformUtil.newXMLPullParser(); int tok; @@ -375,7 +381,7 @@ public class MapPoiTypes { lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(",")); lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories()); } - categories.add(lastCategory); + addCategory(lastCategory); } else if (name.equals("poi_filter")) { PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name")); tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));