Recently while working with feign client in a spring boot application (which in my case is not a web app) I see that the client is not able to de-serialize the object correctly . As pointed to me by by a colleague - it turned out to be due to the HAL module registration is conditional guarded by @ConditionalOnWebApplication on spring auto configuration of hateos
On knowing this there is solutions that could be put in place which would overcome this
- We can add a decoder to the feign client which contains the ObjectMapper which has the registered HAL module (small piece of code but still extra work)
- Convert to a web application - which i feel is not a good solution at all and should'nt be done in the gist of making things work out of box.
So now knowing this has any one encountered this ? I feel having a feign client for Jpa rest resource is a valid scenario.
Below is an example of the server response which is a Paged. Note the meta-data content in below response received (has one result) but with out the fix when i try to read the content of paged resource it would turns out to be null/empty
{
"_embedded": {
"emails": [{
"id": "1a5edced-c165-4209-9d1c-9549b6841d13",
"tenantId": "a56982a6-6e12-4fe6-95d1-b735cedda2dc",
"email": "whatever@whatever.com",
"_links": {
"self": {
"href": "http://10.190.224.138:8086/emails/1a5edced-c165-4209-9d1c- 9549b6841d13"
},
"email": {
"href": "http://10.190.224.138:8086/emails/1a5edced-c165-4209-9d1c-9549b6841d13"
}
}
}]
},
"_links": {
"self": {
"href": "http://10.190.224.138:8086/emails/search/whatssss?email=whatever%40whatever.com"
}
},
"page": {
"size": 20,
"totalElements": 1,
"totalPages": 1,
"number": 0
}
}