I'm using Spring-sync as an implementation of RFC 6902 (JSON Patch)
. The client side sends me a JsonNode
representing the operations to apply on the server object.
My code is as following :
@PatchMapping(path = "/profile/{userId}")
public ResponseEntity<Void> patchUserProfile(@PathVariable Integer userId, @RequestBody JsonNode patchJsonNode) {
JsonPatchMaker jsonPatchMaker = new JsonPatchMaker();
Patch patch = jsonPatchMaker.fromJsonNode(patchJsonNode);
UserProfileDto originalUserProfileDto = ...
UserProfileDto patchedUser = patch.apply(originalUserProfileDto, UserProfileDto.class);
userService.save(patchedUser);
return ResponseEntity.status(HttpStatus.OK).body(null);
}
I have an unexpected Java ClassCastException
telling me that the object cannot be cast to its same type !!?? How this can be possible ?
Below the stack trace :
java.lang.ClassCastException: com.roufid.api.dto.user.UserProfileDto cannot be cast to com.roufid.api.dto.user.UserProfileDto
Note : My class is loaded by the same classloader
and it's Serializable
.
I'm using :
- Spring Sync : 1.0.0.M1