Skip to content

Conversation

@olivierlemasle
Copy link
Contributor

Fixes issue #825

@auhlig
Copy link
Member

auhlig commented Sep 21, 2016

Hey @olivierlemasle,
I'm surprised the tests didn't reveal this earlier.
Is only the httpclient affected?

Thanks for fixing!

@auhlig auhlig added the bug label Sep 21, 2016
@olivierlemasle
Copy link
Contributor Author

Is only the httpclient affected?

I've tested this request with Jersey2 (no issue) and with okhttp (I encountered an issue but it seems to be unrelated and I've not investigated yet).

@auhlig
Copy link
Member

auhlig commented Sep 22, 2016

Thanks for sharing the info.

@auhlig
Copy link
Member

auhlig commented Sep 22, 2016

Looks good to you @vinodborole ?

@vinodborole
Copy link
Contributor

@auhlig added a comment

@auhlig
Copy link
Member

auhlig commented Sep 22, 2016

Agreed. null-check makes sense @vinodborole. Could you update the implementation @olivierlemasle? Thanks in advance.

@olivierlemasle
Copy link
Contributor Author

Do you mean remove the null check, @auhlig ?
i.e. remove || entity.getContent() == null ?

@auhlig
Copy link
Member

auhlig commented Sep 23, 2016

I think Vinod meant moving that logic to a separate function. Right, @vinodborole ?

@olivierlemasle
Copy link
Contributor Author

@auhlig @vinodborole I've updated the commit.

@Override
public <T> T readEntity(Class<T> typeToReadAs) {
HttpEntity entity = response.getEntity();
if (entity == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use checkNotNull(entity) here, this will make it more compact and readable, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because checkNotNull(entity) would throw a NullPointerException if entity == null, which is exactly the issue #825. The goal of this pull request is to accept without error the case where entity == null, e.g. for HEAD requests.

For example, in Jersey2 connector, readEntity will return null for a HEAD request.

@vinodborole
Copy link
Contributor

LGTM, @auhlig your take?

@auhlig
Copy link
Member

auhlig commented Sep 27, 2016

Thanks for explaining @olivierlemasle .

LGTM too, Vinod.

@auhlig auhlig added this to the 3.0.3 Release milestone Sep 27, 2016
@auhlig auhlig merged commit 9f8effb into ContainX:master Sep 27, 2016
@olivierlemasle olivierlemasle deleted the fix-825 branch September 27, 2016 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants