From eba03fc69e20c743fc7d587a4ca1387004bd12c5 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Sun, 3 Mar 2013 09:36:43 -0500 Subject: [PATCH] Protect joins map with mutex - fixes issue #652 --- .../com/google/refine/InterProjectModel.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/main/src/com/google/refine/InterProjectModel.java b/main/src/com/google/refine/InterProjectModel.java index 8212157b4..7a2da820b 100644 --- a/main/src/com/google/refine/InterProjectModel.java +++ b/main/src/com/google/refine/InterProjectModel.java @@ -99,27 +99,33 @@ public class InterProjectModel { computeJoin(join); - _joins.put(key, join); + synchronized (_joins) { + _joins.put(key, join); + } } return _joins.get(key); } public void flushJoinsInvolvingProject(long projectID) { - for (Entry entry : _joins.entrySet()) { - ProjectJoin join = entry.getValue(); - if (join.fromProjectID == projectID || join.toProjectID == projectID) { - _joins.remove(entry.getKey()); + synchronized (_joins) { + for (Entry entry : _joins.entrySet()) { + ProjectJoin join = entry.getValue(); + if (join.fromProjectID == projectID || join.toProjectID == projectID) { + _joins.remove(entry.getKey()); + } } } } public void flushJoinsInvolvingProjectColumn(long projectID, String columnName) { - for (Entry entry : _joins.entrySet()) { - ProjectJoin join = entry.getValue(); - if (join.fromProjectID == projectID && join.fromProjectColumnName.equals(columnName) || - join.toProjectID == projectID && join.toProjectColumnName.equals(columnName)) { - _joins.remove(entry.getKey()); + synchronized (_joins) { + for (Entry entry : _joins.entrySet()) { + ProjectJoin join = entry.getValue(); + if (join.fromProjectID == projectID && join.fromProjectColumnName.equals(columnName) || + join.toProjectID == projectID && join.toProjectColumnName.equals(columnName)) { + _joins.remove(entry.getKey()); + } } } }