Committed by
Gerrit Code Review
Bug fix: Removing an non-existing key from map should be a noop
Change-Id: I1a89327ab6b0a498fe403f17cbdb8783c41954a6
Showing
1 changed file
with
7 additions
and
3 deletions
... | @@ -151,9 +151,13 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> { | ... | @@ -151,9 +151,13 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> { |
151 | !versionMatch.matches(currentValue == null ? null : currentValue.version())) { | 151 | !versionMatch.matches(currentValue == null ? null : currentValue.version())) { |
152 | return Result.ok(new UpdateResult<>(false, mapName, key, currentValue, currentValue)); | 152 | return Result.ok(new UpdateResult<>(false, mapName, key, currentValue, currentValue)); |
153 | } else { | 153 | } else { |
154 | - if (value == null && currentValue != null) { | 154 | + if (value == null) { |
155 | - getMap(mapName).remove(key); | 155 | + if (currentValue == null) { |
156 | - return Result.ok(new UpdateResult<>(true, mapName, key, currentValue, null)); | 156 | + return Result.ok(new UpdateResult<>(false, mapName, key, null, null)); |
157 | + } else { | ||
158 | + getMap(mapName).remove(key); | ||
159 | + return Result.ok(new UpdateResult<>(true, mapName, key, currentValue, null)); | ||
160 | + } | ||
157 | } | 161 | } |
158 | Versioned<byte[]> newValue = new Versioned<>(value, ++nextVersion); | 162 | Versioned<byte[]> newValue = new Versioned<>(value, ++nextVersion); |
159 | getMap(mapName).put(key, newValue); | 163 | getMap(mapName).put(key, newValue); | ... | ... |
-
Please register or login to post a comment