Skip to content

retrofit2 extra > NullPointerException on handling "204 No-Content" http response #1568

Closed
@anton-fedorov

Description

@anton-fedorov

Hello,

It seems that AsyncHttpClientCall.java:255 creates response body to map to OkHttp only if there was actually response in AsyncHttp call.

This unfortunately leads to NullPointerException if you try to parse 204 HTTP Response (No Content).

This happens due to the fact that Retrofit's OkHttpCall.java#L202 tries access rawBody w/o any null checks.

Would it make sense to have okHttpBody = ResponseBody.create(contentType, new byte[0]) in case if response was 204/205?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions