Skip to content

[HTTP-Client] 204 deserialization error #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SentryMan opened this issue May 1, 2024 · 3 comments · Fixed by #430
Closed

[HTTP-Client] 204 deserialization error #426

SentryMan opened this issue May 1, 2024 · 3 comments · Fixed by #430
Assignees
Milestone

Comments

@SentryMan
Copy link
Collaborator

[Essentially Copied from discord]

Suppose an api call to a server results in a 204. .GET().as(MyBean.class) tries to deserialise the body (of which is empty), resulting in an error during deserialization

What I would've expected is:

  1. Just don't deserialise when it's a 204 or you know the body is empty in the first place.
  2. Only deserialise when .body() is called. That way it's down to the implementation to know when it should and shouldn't expect a body. So for example, in a 204, I shouldn't call .body() but in other scenarios I should probably expect the body to be present.
@SentryMan SentryMan changed the title [HTTP -Client] 204 deserialization error [HTTP-Client] 204 deserialization error May 1, 2024
@rob-bygrave
Copy link
Contributor

How does it become a 204? Does the status code get set by the response or is null returned from a method or something else? What does the controller code look like for this case?

@rob-bygrave
Copy link
Contributor

Oh, this is for HttpClient .... getting a response status code 204 ... oh.

@rbygrave
Copy link
Contributor

rbygrave commented May 7, 2024

Example stack trace:

Caused by: java.io.EOFException: End of input at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1457)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:558)
    at com.google.gson.stream.JsonReader.peek(JsonReader.java:433)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:378)
    at io.avaje.http.client.gson.GsonBodyAdapter$Reader.read(GsonBodyAdapter.java:111)
    ... 42 more

rbygrave added a commit that referenced this issue May 7, 2024
…reading content (#430)

* httpclient: #427 Fix support for 204 no response body for HttpClient reading content

* Update test NimaProcessorTest to use release 21
@rbygrave rbygrave added this to the 2.5 milestone May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants