Closed ros3cin closed 2 years ago
Thanks for reporting this. I have tests for this deserialization use case and they are all green, so I am trying to figure out what's different in your example. You were right with the reason for this exception, the assignability check in class UnsafeObjectFieldAccessorImpl
, line 81, fails. I will try to figure out why.
Probably it might have something to do that the new instance uses the AppClassLoader
while the field.getType() uses the RestartClassLoader
.
Could you please provide the JSON you want to deserialize, or even better, a failing test? What is your environment (Java Version, Spring Boot version, Spring HATEOAS version)?
O.N T.H.E S.P.O.T, @toedter !
As I saw it was a class loader related to the dev-tools, I removed the dependency and tried again, and it worked!
I'm in a hurry now, but I'll give you the info you asked (tools versions and a failing test) ASAP. By the way, by failing test, you mean a zipped example where the problem happens?
Thanks!
Java: 17 Spring Boot: 2.6.4 Spring HATEOAS: 1.4.1 HATEOAS JSON API: 1.3.0
payload
{
"data": {
"attributes": {
"increment": 1
},
"relationships": {
"subject": {
"data": {
"type": "products",
"id": "2"
}
}
},
"type": "increases"
}
}
Thanks, I try to recreate that behavior using dev-tools => no success so far. A zipped example project that demonstrates this behavior would also help :)
Since I cannot recreate this behaviour locally, I close this issue. Please re-open if necessary.
Hi! I have two simple models.
The
Increase
model is not persisted, it only represents an action. The other model, on the other hand, is persisted.What I'm trying to do it sending a POST with the
Increase
data, having it deserialized so I can access the id of theProduct
and proceed with further code. But I'm getting this error.As far as I could investigate, for some weird reason, the created
Product
instance (on the JsonApiEntityModelDeserializer.java line 125) is somewhat different from the inferred generic type. Some debug output below, comparing both objects.