Skip to content

Commit 06ad21b

Browse files
Leehyoungwoochristophstrobl
authored andcommitted
Skip metadata lookup for top-level collections in MappingRedisConverter.
Closes: #2168 Original Pull Request: #3146 Signed-off-by: dlguddn3024 <[email protected]>
1 parent 02aa3b0 commit 06ad21b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
* @author Greg Turnquist
110110
* @author Mark Paluch
111111
* @author Golam Mazid Sajib
112+
* @author Leehyoungwoo
112113
* @since 1.7
113114
*/
114115
public class MappingRedisConverter implements RedisConverter, InitializingBean {
@@ -402,6 +403,17 @@ public void write(@Nullable Object source, RedisData sink) {
402403
return;
403404
}
404405

406+
if (source instanceof Collection) {
407+
writeCollection(
408+
sink.getKeyspace(),
409+
"",
410+
(List<?>) source,
411+
TypeInformation.of(Object.class),
412+
sink
413+
);
414+
return;
415+
}
416+
405417
RedisPersistentEntity<?> entity = mappingContext.getPersistentEntity(source.getClass());
406418

407419
if (!customConversions.hasCustomWriteTarget(source.getClass())) {

src/test/java/org/springframework/data/redis/core/convert/MappingRedisConverterUnitTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,9 +1997,8 @@ void readGenericEntity() {
19971997
assertThat(generic.entity.name).isEqualTo("hello");
19981998
}
19991999

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

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

0 commit comments

Comments
 (0)