DATAREDIS-955 - Fix collection initialization when reading nested structures with same name.
We now make sure to not falsely populate instances with null values from nested structures. Original pull request: #452.
This commit is contained in:
committed by
Mark Paluch
parent
0a6e40f66d
commit
db2e3bcae6
@@ -229,4 +229,15 @@ public class ConversionTestEntities {
|
||||
|
||||
UUID uuid;
|
||||
}
|
||||
|
||||
static class Outer {
|
||||
|
||||
List<Inner> inners;
|
||||
List<String> values;
|
||||
}
|
||||
|
||||
static class Inner {
|
||||
|
||||
List<String> values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1863,6 +1863,32 @@ public class MappingRedisConverterUnitTests {
|
||||
assertThat(write(source).getBucket(), isBucket().containingUtf8String("uuid", source.uuid.toString()));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-955
|
||||
public void readInnerListShouldNotInfluenceOuterWithSameName() {
|
||||
|
||||
Map<String, String> source = new LinkedHashMap<>();
|
||||
source.put("inners.[0].values.[0]", "i-1");
|
||||
source.put("inners.[0].values.[1]", "i-2");
|
||||
source.put("values.[0]", "o-1");
|
||||
source.put("values.[1]", "o-2");
|
||||
|
||||
Outer outer = read(Outer.class, source);
|
||||
assertThat(outer.values, is(equalTo(Arrays.asList("o-1", "o-2"))));
|
||||
assertThat(outer.inners.get(0).values, is(equalTo(Arrays.asList("i-1", "i-2"))));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-955
|
||||
public void readInnerListShouldNotInfluenceOuterWithSameNameWhenNull() {
|
||||
|
||||
Map<String, String> source = new LinkedHashMap<>();
|
||||
source.put("inners.[0].values.[0]", "i-1");
|
||||
source.put("inners.[0].values.[1]", "i-2");
|
||||
|
||||
Outer outer = read(Outer.class, source);
|
||||
assertThat(outer.values, is(nullValue()));
|
||||
assertThat(outer.inners.get(0).values, is(equalTo(Arrays.asList("i-1", "i-2"))));
|
||||
}
|
||||
|
||||
private RedisData write(Object source) {
|
||||
|
||||
RedisData rdo = new RedisData();
|
||||
|
||||
Reference in New Issue
Block a user