Skip to content

Handle top-level collections without entity lookup in MappingRedisConverter #2168 #3146

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
@@ -109,6 +109,7 @@
* @author Greg Turnquist
* @author Mark Paluch
* @author Golam Mazid Sajib
* @author Leehyoungwoo
* @since 1.7
*/
public class MappingRedisConverter implements RedisConverter, InitializingBean {
@@ -404,6 +405,17 @@ public void write(Object source, RedisData sink) {
return;
}

if (source instanceof Collection) {
writeCollection(
sink.getKeyspace(),
"",
(List<?>) source,
TypeInformation.of(Object.class),
sink
);
return;
}

RedisPersistentEntity<?> entity = mappingContext.getPersistentEntity(source.getClass());

if (!customConversions.hasCustomWriteTarget(source.getClass())) {
Original file line number Diff line number Diff line change
@@ -1997,9 +1997,8 @@ void readGenericEntity() {
assertThat(generic.entity.name).isEqualTo("hello");
}

@Test // DATAREDIS-1175
@EnabledOnJre(JRE.JAVA_8)
// FIXME: https://github.com/spring-projects/spring-data-redis/issues/2168
@Test // GH-2168
// @EnabledOnJre(JRE.JAVA_8)
void writePlainList() {

List<Object> source = Arrays.asList("Hello", "stream", "message", 100L);