diff --git a/contrib/dataimporthandler/CHANGES.txt b/contrib/dataimporthandler/CHANGES.txt index 4a01a8b9c68..f9e17b27833 100644 --- a/contrib/dataimporthandler/CHANGES.txt +++ b/contrib/dataimporthandler/CHANGES.txt @@ -234,6 +234,9 @@ Bug Fixes 25.SOLR-1090: DataImportHandler should load the data-config.xml using UTF-8 encoding. (Rui Pereira, shalin) +26.SOLR-1146: ConcurrentModificationException in DataImporter.getStatusMessages + (Walter Ferrara, Noble Paul via shalin) + Documentation ---------------------- diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java index 358eb6d046a..c891366aafd 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java @@ -382,12 +382,17 @@ public class DataImporter { @SuppressWarnings("unchecked") Map getStatusMessages() { + //this map object is a Collections.synchronizedMap(new LinkedHashMap()). if we + // synchronize on the object it must be safe to iterate through the map Map statusMessages = (Map) retrieve(STATUS_MSGS); Map result = new LinkedHashMap(); if (statusMessages != null) { - for (Object o : statusMessages.entrySet()) { - Map.Entry e = (Map.Entry) o; - result.put((String) e.getKey(), e.getValue().toString()); + synchronized (statusMessages) { + for (Object o : statusMessages.entrySet()) { + Map.Entry e = (Map.Entry) o; + //the toString is taken because some of the Objects create the data lazily when toString() is called + result.put((String) e.getKey(), e.getValue().toString()); + } } } return result; diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java index b6101ed12cc..7bfc77c4793 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java @@ -48,7 +48,7 @@ public class DocBuilder { private DataConfig.Entity root; @SuppressWarnings("unchecked") - private Map statusMessages = new LinkedHashMap(); + private Map statusMessages = Collections.synchronizedMap(new LinkedHashMap()); public Statistics importStatistics = new Statistics();