[JERSEY-1841] ClientResponse.hasEntity() should not throw a NullPointerException Created: 11/Apr/13  Updated: 14/Nov/13  Resolved: 11/Nov/13

Status: Resolved
Project: jersey
Component/s: core
Affects Version/s: 1.17
Fix Version/s: 1.18

Type: Bug Priority: Major
Reporter: CodingFabian Assignee: Miroslav Fuksa
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: 1 hour
Original Estimate: 3 hours

Issue Links:
Related
is related to JERSEY-1672 ClientResponse.close() should not thr... Resolved

 Description   

Similar to JERSEY-1672, the hasEntity method throws a null pointer exception when entity is null (like for a 500 response).
When you have filters which look at possible JSON entities, it would be great to not get a null pointer.

The workaround is to check for getEntityInputStream() != null first, which is kind of awkward.



 Comments   
Comment by Miroslav Fuksa [ 07/Nov/13 ]

Hi,

can you please provide more details? I cannot reproduce the NPE. I tried with 500 and 204 responses and never get NPE in ClientResponse.hasEntity(). I have tested it against 1.17 and with latest snapshot version. Exception stack trace and code example would help. The best would be simple maven project with test simulating the bug. Thanks.

I have the same problem with JERSEY-1672 as I cannot reproduce it.

Comment by Miroslav Fuksa [ 11/Nov/13 ]

I cannot reproduce the issue (I would need exception stack trace at least).

Generated at Wed Jul 29 16:16:22 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.