For spring-boot 2.2.0.M4 (spring-data version 3.2.0.RC1), JsonPatch add operation is not properly working with a nested list

Exemple:

@Entity
@Table(name = "entities")
public class entity {
  UUID id;
  Foo foo;
}

public class Foo {
  List<String> nestedList;
}

The following PATCH request on entity/{entityId}

[
    {
        "op": "add",
        "path": "foo/nestedList/-",
        "value": "bar"
    }
]

throws "No property - found for type String! Traversed path: entity.foo.bar."

In file org.springframework.data.rest.webmvc.json.patch.SpelPath, the following line seems to lead to this error :

return typeInformation.isCollectionLike() ? this.skipWith("-".equals(segment) ? "$[true]" : String.format("[%s]", segment)) : this.nested(segment);

Indeed, typeInformation should be related to the parent list but is set with the the type of object Foo, as a result, 'this.nested(segment)' is called instead of returning '$[true]'

error in logs:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property - found for type String! Traversed path: Entity.foo.bar.
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:342) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:314) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_192]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.mapping.PropertyPath.nested(PropertyPath.java:214) ~[spring-data-commons-2.2.0.RC1.jar:2.2.0.RC1]
    at org.springframework.data.rest.webmvc.json.patch.SpelPath$TypedSpelPath$SpelExpressionBuilder.nested(SpelPath.java:529) ~[spring-data-rest-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
    ... 138 common frames omitted

Comment From: bclozel

Could you report this issue against the Spring Data project? https://jira.spring.io/projects/DATACMNS/issues

This issue tracker is for Spring Framework issues only. Thanks!