Closed j-mew-s closed 7 months ago
You are essentially asking Jackson to map "" to a "Empty" object, which it cannot do, because "" is not valid JSON.
Unirest has a method for this case called .asEmpty()
, which has no body at all. I would recommend that
Thank you for your quick response, I'll give that a try.
Describe the bug Receiving a successful response (I tried 200 and 204) with no body fails deserialization. I guess this might just be a Jackson or Java Http Client issue, but it feels like a pretty basic thing. There's a fair chance I've configured something wrong! It seems that with the Apache client, the response entity was set to null, whereas now it's set to empty string (as highlighted in the migration notes).
The impact is that previously in the
ObjectResponse
constructor, thegetBody
call would be skipped due to the Optional.empty, and ultimately Jackson wouldn't try to map anything. When it does, it falls over.To Reproduce build.gradle.kts
TestMain.kt
stack trace
Expected behavior No parsing exception when a 204 response has no body.
Environmental Data: see gradle file