From 9761c7f0b7b2a18ae74d945102184022d3d79640 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 3 Mar 2021 17:35:23 -0500 Subject: [PATCH] Make custom converter compatible with latest S-D The latest changes in the `MappingMongoConverter` resolves the target type from the document. That type is a `GenericMessage`. The `GenericConversionService` doesn't match such a target type for the `MessageReadConverter implements Converter>` and fail. * Change the `MessageReadConverter` generic type into the `GenericMessage` for matching data in the collection --- .../ConfigurableMongoDbMessageGroupStoreTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java index fe10c4f986..66ad3cc39f 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.integration.store.MessageStore; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.support.GenericMessage; import org.springframework.util.StopWatch; /** @@ -189,14 +190,12 @@ public class ConfigurableMongoDbMessageGroupStoreTests extends AbstractMongoDbMe } @ReadingConverter - public static class MessageReadConverter implements Converter> { + public static class MessageReadConverter implements Converter> { @Override @SuppressWarnings("unchecked") - public Message convert(Document source) { - return MessageBuilder.withPayload(source.get("payload")) - .copyHeaders((Map) source.get("headers")) - .build(); + public GenericMessage convert(Document source) { + return new GenericMessage<>(source.get("payload"), (Map) source.get("headers")); } }