mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-31 09:12:11 +00:00
DATAES-797 - Fix MappingElasticsearchConverter recursive descent when reading Map objects.
Original PR: #437
This commit is contained in:
parent
60cbb67877
commit
4876a0e3ab
@ -288,6 +288,8 @@ public class MappingElasticsearchConverter
|
||||
|
||||
if (value instanceof List) {
|
||||
target.add(readValue(value, property, property.getTypeInformation().getActualType()));
|
||||
} else if (value instanceof Map) {
|
||||
target.add(readMapValue((Map<String, Object>) value, property, property.getTypeInformation().getActualType()));
|
||||
} else {
|
||||
target.add(readEntity(computeGenericValueTypeForRead(property, value), (Map<String, Object>) value));
|
||||
}
|
||||
|
@ -677,6 +677,24 @@ public class MappingElasticsearchConverterUnitTests {
|
||||
assertThat(wrapper.getSchemaLessObject()).isEqualTo(mapWithSimpleValues);
|
||||
}
|
||||
|
||||
@Test // DATAES-797
|
||||
void readGenericListWithMaps() {
|
||||
Map<String, Object> simpleMap = new HashMap<>();
|
||||
simpleMap.put("int", 1);
|
||||
|
||||
List<Map<String, Object>> listWithSimpleMap = new ArrayList<>();
|
||||
listWithSimpleMap.add(simpleMap);
|
||||
|
||||
Map<String, List<Map<String, Object>>> mapWithSimpleList = new HashMap<>();
|
||||
mapWithSimpleList.put("someKey", listWithSimpleMap);
|
||||
|
||||
Document document = Document.create();
|
||||
document.put("schemaLessObject", mapWithSimpleList);
|
||||
|
||||
SchemaLessObjectWrapper wrapper = mappingElasticsearchConverter.read(SchemaLessObjectWrapper.class, document);
|
||||
assertThat(wrapper.getSchemaLessObject()).isEqualTo(mapWithSimpleList);
|
||||
}
|
||||
|
||||
private String pointTemplate(String name, Point point) {
|
||||
return String.format(Locale.ENGLISH, "\"%s\":{\"lat\":%.1f,\"lon\":%.1f}", name, point.getX(), point.getY());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user