Browse Source

Polishing.

Reuse definitive path flag without recompile the expression.

See #2270
2.3.x
Mark Paluch 5 years ago
parent
commit
c5238bc5fb
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 5
      src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java

5
src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java

@ -156,13 +156,14 @@ public class JsonProjectingMethodInterceptorFactory implements MethodInterceptor @@ -156,13 +156,14 @@ public class JsonProjectingMethodInterceptorFactory implements MethodInterceptor
return isCollectionResult && !(nested instanceof Collection) ? result : nested;
}
type = isCollectionResult && JsonPath.isPathDefinite(jsonPath)
boolean definitePath = JsonPath.isPathDefinite(jsonPath);
type = isCollectionResult && definitePath
? ResolvableType.forClassWithGenerics(List.class, type)
: type;
List<?> result = (List<?>) context.read(jsonPath, new ResolvableTypeRef(type));
if (isCollectionResult && JsonPath.isPathDefinite(jsonPath)) {
if (isCollectionResult && definitePath) {
result = (List<?>) result.get(0);
}

Loading…
Cancel
Save