fix that JsonObjectBuilder.remove removes to much in certain cases #1798
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This looks like a really small bug, but is has a huge impact:
ThingMerged
events the payloadvalue
can get "lost" before persisting a merge because of this bugHere an inline policy is removed from the to-be-persisted JSON:
ditto/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/serializer/ThingMongoEventAdapter.java
Lines 51 to 53 in d008959
The JsonPointer to be removed is
/value/_policy
- if this_policy
however does not exist and if thevalue
does not even contain aJsonObject
(which can be the case when using "merge", e.g. only updating one specific path to e.g. a JsonNumber), then the current implementation ofImmutableJsonObjectBuilder.remove
will remove thevalue
from the event.That leads to the event missing its
value
in persistence and that leads to much pain and suffering when replaying events for that persistence actor, throwing exceptions on deserialization if thevalue
is missing.