diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2008-08-13 23:14:33 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2008-08-13 23:14:33 +0000 |
commit | 1b49ba901499d0bd7e05da231c12b932c4e6c9e4 (patch) | |
tree | dd32746c350a178547dc3dd22c9a3830013e3497 /src | |
parent | b9165d9262e054c2e9521ed72a0aba77fd7ae9f9 (diff) |
Clone key before inserting into map.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/map/MapStorage.java | 10 |
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;
|