Skip to content

Resolve element type from NodeType before falling back to reflection. #2842

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>3.2.3-SNAPSHOT</version>
<version>3.2.x-2838-SNAPSHOT</version>

<name>Spring Data Redis</name>
<description>Spring Data module for Redis</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,20 @@ private void flattenElement(String propertyPrefix, Object source, Map<String, Ob
} else if (element.isContainerNode()) {
doFlatten(propertyPrefix, element.fields(), resultMap);
} else {
resultMap.put(propertyPrefix, new DirectFieldAccessFallbackBeanWrapper(element)
.getPropertyValue("_value"));

switch (element.getNodeType()) {
case STRING -> resultMap.put(propertyPrefix, element.textValue());
case NUMBER -> resultMap.put(propertyPrefix, element.numberValue());
case BOOLEAN -> resultMap.put(propertyPrefix, element.booleanValue());
case BINARY -> {
try {
resultMap.put(propertyPrefix, element.binaryValue());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
default -> resultMap.put(propertyPrefix, new DirectFieldAccessFallbackBeanWrapper(element).getPropertyValue("_value"));
}
}
}

Expand Down