From 1b49ba901499d0bd7e05da231c12b932c4e6c9e4 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 13 Aug 2008 23:14:33 +0000 Subject: Clone key before inserting into map. --- src/main/java/com/amazon/carbonado/repo/map/MapStorage.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/repo/map') 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 // Caller must hold upgrade or write lock. private boolean doTryInsertNoLock(S storable) { - Key key = new Key(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 key = new Key(copy, mFullComparator); + S existing = mMap.get(key); + if (existing != null) { + return false; + } mMap.put(key, copy); storable.markAllPropertiesClean(); return true; -- cgit v1.2.3