Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-05-28 15:58:58 -0400
committerjmisinco2014-05-28 16:18:22 -0400
commitc6c2915a3a537f47fb364e7d828d90971feb29d6 (patch)
tree1d40365bb2c955713eeccf38c6d09cfb1532d048 /plugins/org.eclipse.osee.framework.core.message/src/org
parentb96346fb56e09fe5fd370cc0409cc7fe4f1e3654 (diff)
downloadorg.eclipse.osee-c6c2915a3a537f47fb364e7d828d90971feb29d6.tar.gz
org.eclipse.osee-c6c2915a3a537f47fb364e7d828d90971feb29d6.tar.xz
org.eclipse.osee-c6c2915a3a537f47fb364e7d828d90971feb29d6.zip
bug: Hashmap.get concurrency issue in BranchRow
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message/src/org')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
index c24c127274..ae6860cdc8 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.message;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
@@ -138,7 +137,7 @@ public final class BranchRow {
private static final String SELECT_BRANCH_GUID_BY_ID = "select branch_guid from osee_branch where branch_id = ?";
// Temporary cache till all code uses branch uuid. Remove after 0.17.0
- private static final Map<Long, String> longToGuidCache = new HashMap<Long, String>(50);
+ private static final ConcurrentHashMap<Long, String> longToGuidCache = new ConcurrentHashMap<Long, String>(50);
/**
* Temporary method till all code uses branch uuid. Remove after 0.17.0
@@ -150,7 +149,7 @@ public final class BranchRow {
DatabaseService.getDatabaseService().runPreparedQueryFetchObject("", SELECT_BRANCH_GUID_BY_ID, branchUuid);
Conditions.checkExpressionFailOnTrue(!Strings.isValid(guid), "Error getting branch_guid for branch: [%d]",
branchUuid);
- longToGuidCache.put(branchUuid, guid);
+ longToGuidCache.putIfAbsent(branchUuid, guid);
}
return guid;
}
@@ -158,7 +157,7 @@ public final class BranchRow {
// Temporary cache till all code uses branch uuid. Remove after 0.17.0
private static final String SELECT_BRANCH_ID_BY_GUID = "select branch_id from osee_branch where branch_guid = ?";
// Temporary cache till all code uses branch uuid. Remove after 0.17.0
- private static final Map<String, Long> guidToLongCache = new HashMap<String, Long>(50);
+ private static final ConcurrentHashMap<String, Long> guidToLongCache = new ConcurrentHashMap<String, Long>(50);
/**
* Temporary method till all code uses branch uuid. Remove after 0.17.0
@@ -174,7 +173,7 @@ public final class BranchRow {
branchGuid);
Conditions.checkExpressionFailOnTrue(longId <= 0, "Error getting branch_id for branch: [%s]", branchGuid);
}
- guidToLongCache.put(branchGuid, longId);
+ guidToLongCache.putIfAbsent(branchGuid, longId);
}
return longId;
}

Back to the top