Skip to content

Commit cc4eaf1

Browse files
committed
fix MigrateThingDefinition wot validation issue
1 parent 0c80cf3 commit cc4eaf1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/ThingPersistenceActor.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.apache.pekko.japi.pf.ReceiveBuilder;
2525
import org.apache.pekko.persistence.RecoveryCompleted;
2626
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
27+
import org.eclipse.ditto.base.model.exceptions.DittoInternalErrorException;
28+
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
2729
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeExceptionBuilder;
2830
import org.eclipse.ditto.base.model.headers.DittoHeaders;
2931
import org.eclipse.ditto.base.model.headers.LiveChannelTimeoutStrategy;
@@ -151,14 +153,26 @@ public void onQuery(final Command<?> command, final WithDittoHeaders response) {
151153
public void onStagedQuery(final Command<?> command, final CompletionStage<WithDittoHeaders> response,
152154
@Nullable final StartedSpan startedSpan) {
153155
final ActorRef sender = getSender();
154-
response.thenAccept(r -> {
155-
doOnQuery(command, r, sender);
156+
response.handle((r, throwable) -> {
157+
if (throwable != null ) {
158+
final DittoRuntimeException exception = DittoRuntimeException.asDittoRuntimeException(throwable, t ->
159+
DittoInternalErrorException.newBuilder()
160+
.cause(t)
161+
.dittoHeaders(command.getDittoHeaders())
162+
.build()
163+
);
164+
notifySender(sender, exception);
165+
} else {
166+
doOnQuery(command, r, sender);
167+
}
156168
if (startedSpan != null) {
157169
startedSpan.finish();
158170
}
171+
return null;
159172
});
160173
}
161174

175+
162176
private void doOnQuery(final Command<?> command, final WithDittoHeaders response, final ActorRef sender) {
163177
if (response.getDittoHeaders().didLiveChannelConditionMatch()) {
164178
final var liveChannelTimeoutStrategy = response.getDittoHeaders()

0 commit comments

Comments
 (0)