Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

HttpResponse.getEntity(Class<T> type) Throws NullPointerException When Response Has no Body #13

Closed
PaulSzyller opened this issue Nov 15, 2018 · 0 comments · Fixed by #28

Comments

@PaulSzyller
Copy link

HttpResponse response = httpClient.post(...)

// response had empty body, entity is null
assert response.getEntity() == null

// this will throw a NullPointerException
String entityString = response.getEntity(String.class)

And the stacktrace:

java.lang.NullPointerException: null
        at com.budjb.httprequests.converter.EntityConverterManager.read(EntityConverterManager.java:175)
        at com.budjb.httprequests.HttpResponse.getEntity(HttpResponse.java:162)
        at com.budjb.httprequests.HttpResponse$getEntity.call(Unknown Source)
        ...
budjb pushed a commit that referenced this issue May 21, 2020
@budjb budjb closed this as completed in #28 May 21, 2020
budjb added a commit that referenced this issue May 21, 2020
* Fix NullPointerException when sending a null entity (#14).

* Prevent getting a response entity that does not exist from throwing an exception (#13).

* Throw a URISyntaxException instead of a NullPointerException when a URI is not absolute (#12)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant