From dc206e1889f8eabadb12f0ddf7e94431573685bc Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Thu, 25 Jul 2013 15:36:54 -0400 Subject: [PATCH] Switch to ConcurrentHashMap for jobs table to allow multiple accessors --- main/src/com/google/refine/importing/ImportingManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/src/com/google/refine/importing/ImportingManager.java b/main/src/com/google/refine/importing/ImportingManager.java index 35e0bb1ea..9cbd2fc6d 100644 --- a/main/src/com/google/refine/importing/ImportingManager.java +++ b/main/src/com/google/refine/importing/ImportingManager.java @@ -44,6 +44,7 @@ import java.util.Properties; import java.util.Set; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.io.FileUtils; import org.json.JSONException; @@ -82,7 +83,7 @@ public class ImportingManager { static private RefineServlet servlet; static private File importDir; - final static private Map jobs = new HashMap(); + final static private Map jobs = new ConcurrentHashMap(); // Mapping from format to label, e.g., "text" to "Text files", "text/xml" to "XML files" final static public Map formatToRecord = new HashMap(); @@ -288,12 +289,11 @@ public class ImportingManager { static private void cleanUpStaleJobs() { long now = System.currentTimeMillis(); - for (Long id : new HashSet(jobs.keySet())) { + for (Long id : jobs.keySet()) { ImportingJob job = jobs.get(id); if (job != null && !job.updating && now - job.lastTouched > s_stalePeriod) { job.dispose(); jobs.remove(id); - logger.info("Disposed " + id); } }