Skip to content

Commit c5238bc

Browse files
committed
Polishing.
Reuse definitive path flag without recompile the expression. See #2270
1 parent 44bdb71 commit c5238bc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ public Object invoke(@SuppressWarnings("null") MethodInvocation invocation) thro
156156
return isCollectionResult && !(nested instanceof Collection) ? result : nested;
157157
}
158158

159-
type = isCollectionResult && JsonPath.isPathDefinite(jsonPath)
159+
boolean definitePath = JsonPath.isPathDefinite(jsonPath);
160+
type = isCollectionResult && definitePath
160161
? ResolvableType.forClassWithGenerics(List.class, type)
161162
: type;
162163

163164
List<?> result = (List<?>) context.read(jsonPath, new ResolvableTypeRef(type));
164165

165-
if (isCollectionResult && JsonPath.isPathDefinite(jsonPath)) {
166+
if (isCollectionResult && definitePath) {
166167
result = (List<?>) result.get(0);
167168
}
168169

0 commit comments

Comments
 (0)