Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix that JsonObjectBuilder.remove removes to much in certain cases #1798

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private ImmutableJsonObjectBuilder remove(final JsonPointer pointer) {
rootObject = rootObject.remove(nextPointerLevel);
set(JsonFactory.newField(jsonField.getKey(), rootObject,
jsonField.getDefinition().orElse(null)));
} else {
} else if (nextPointerLevel.isEmpty()) {
fields.remove(jsonField.getKeyName());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public void removeWithJsonPointerWorksAsExpected() {
.set(robert)
.set(cersei)
.remove(JsonFactory.newPointer(fooKey, bazKey))
.remove(JsonFactory.newPointer(robert.getKey(), JsonKey.of("non-existing")))
.build();

assertThat(actualJsonObject).isEqualTo(expectedJsonObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.eclipse.ditto.things.service.persistence.serializer;

import org.apache.pekko.actor.ExtendedActorSystem;
import org.eclipse.ditto.base.model.signals.events.Event;
import org.eclipse.ditto.base.model.signals.events.GlobalEventRegistry;
import org.eclipse.ditto.base.service.config.DittoServiceConfig;
Expand All @@ -25,8 +26,6 @@
import org.eclipse.ditto.things.model.signals.events.ThingMerged;
import org.eclipse.ditto.things.service.common.config.DefaultThingConfig;

import org.apache.pekko.actor.ExtendedActorSystem;

/**
* EventAdapter for {@link Event}s persisted into pekko-persistence event-journal. Converts Event to MongoDB
* BSON objects and vice versa.
Expand All @@ -48,7 +47,7 @@ public ThingMongoEventAdapter(final ExtendedActorSystem system) {

@Override
protected JsonObjectBuilder performToJournalMigration(final Event<?> event, final JsonObject jsonObject) {
if (event instanceof ThingMerged) {
if (event instanceof ThingMerged thingMerged && thingMerged.getResourcePath().isEmpty()) {
return super.performToJournalMigration(event, jsonObject)
.remove(POLICY_IN_THING_MERGED_VALUE_PAYLOAD); // remove the policy entries from thing merged payload
} else {
Expand Down
Loading