Protect joins map with mutex - fixes issue #652

This commit is contained in:
Tom Morris 2013-03-03 09:36:43 -05:00
parent 0dfd7d7112
commit eba03fc69e

View File

@ -99,27 +99,33 @@ public class InterProjectModel {
computeJoin(join); computeJoin(join);
_joins.put(key, join); synchronized (_joins) {
_joins.put(key, join);
}
} }
return _joins.get(key); return _joins.get(key);
} }
public void flushJoinsInvolvingProject(long projectID) { public void flushJoinsInvolvingProject(long projectID) {
for (Entry<String, ProjectJoin> entry : _joins.entrySet()) { synchronized (_joins) {
ProjectJoin join = entry.getValue(); for (Entry<String, ProjectJoin> entry : _joins.entrySet()) {
if (join.fromProjectID == projectID || join.toProjectID == projectID) { ProjectJoin join = entry.getValue();
_joins.remove(entry.getKey()); if (join.fromProjectID == projectID || join.toProjectID == projectID) {
_joins.remove(entry.getKey());
}
} }
} }
} }
public void flushJoinsInvolvingProjectColumn(long projectID, String columnName) { public void flushJoinsInvolvingProjectColumn(long projectID, String columnName) {
for (Entry<String, ProjectJoin> entry : _joins.entrySet()) { synchronized (_joins) {
ProjectJoin join = entry.getValue(); for (Entry<String, ProjectJoin> entry : _joins.entrySet()) {
if (join.fromProjectID == projectID && join.fromProjectColumnName.equals(columnName) || ProjectJoin join = entry.getValue();
join.toProjectID == projectID && join.toProjectColumnName.equals(columnName)) { if (join.fromProjectID == projectID && join.fromProjectColumnName.equals(columnName) ||
_joins.remove(entry.getKey()); join.toProjectID == projectID && join.toProjectColumnName.equals(columnName)) {
_joins.remove(entry.getKey());
}
} }
} }
} }