summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-08-13 23:14:33 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-08-13 23:14:33 +0000
commit1b49ba901499d0bd7e05da231c12b932c4e6c9e4 (patch)
treedd32746c350a178547dc3dd22c9a3830013e3497 /src/main/java/com
parentb9165d9262e054c2e9521ed72a0aba77fd7ae9f9 (diff)
Clone key before inserting into map.
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/map/MapStorage.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java b/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java
index 27934ef..e700bd7 100644
--- a/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java
@@ -322,15 +322,15 @@ class MapStorage<S extends Storable>
// Caller must hold upgrade or write lock.
private boolean doTryInsertNoLock(S storable) {
- Key<S> key = new Key<S>(storable, mFullComparator);
- S existing = mMap.get(key);
- if (existing != null) {
- return false;
- }
// Create a fresh copy to ensure that custom fields are not saved.
S copy = (S) storable.prepare();
storable.copyAllProperties(copy);
copy.markAllPropertiesClean();
+ Key<S> key = new Key<S>(copy, mFullComparator);
+ S existing = mMap.get(key);
+ if (existing != null) {
+ return false;
+ }
mMap.put(key, copy);
storable.markAllPropertiesClean();
return true;