Deleted Redundent Files
[iotcloud.git] / src2 / java / iotcloud / PendingTransaction.java
index 3d39e12559ac3270d1e9c35cb05187215ae904d8..c3c41c553b4f80b06078c787f4fd2a7c994e1f6c 100644 (file)
@@ -27,16 +27,23 @@ class PendingTransaction {
      */
     public void addKV(KeyValue newKV) {
 
+        KeyValue rmKV = null;
+
         // Make sure there are no duplicates
         for (KeyValue kv : keyValueUpdateSet) {
             if (kv.getKey().equals(newKV.getKey())) {
 
                 // Remove key if we are adding a newer version of the same key
-                keyValueUpdateSet.remove(kv);
+                rmKV = kv;
                 break;
             }
         }
 
+        // Remove key if we are adding a newer version of the same key
+        if (rmKV != null) {
+            keyValueUpdateSet.remove(rmKV);
+        }
+
         // Add the key to the hash set
         keyValueUpdateSet.add(newKV);
     }