You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Receive an InboundJaxrsResponse after a HTTP call (a Response).
Call Response.hasEntity() returns TRUE (calls EntityInputStream.isEmpty() which checks if there is an input stream, and it has more bytes)
Call Response.bufferEntity() returns TRUE (this will replace the InputStream in InboundMessageContext.EntityContent with a ByteArrayOutputStream)
Read the entity (this will read the full ByteArrayOutputStream, setting its offset to the latest byte)
Call Response.hasEntity() returns FALSE (the implementation EntityInputStream.isEmpty() sees that input is not null or closed, but the offset is at the last byte. This offset at the end of the stream causes the check in.read() to return -1, making the check assume that there are 0 bytes in the stream (while in reality there are 0 more bytes in the stream)).
I've tested the behaviour with Wiremock.
A potential fixes could be: On InboundJaxrsResponse.hasEntity() first checking if (buffered) and if so resetting the stream by calling entityContent.reset() (similar to what is done for reads).
The text was updated successfully, but these errors were encountered:
Version: Jersey-client 2.29.1
Scenario:
InboundJaxrsResponse
after a HTTP call (a Response).Response.hasEntity()
returns TRUE (callsEntityInputStream.isEmpty()
which checks if there is an input stream, and it has more bytes)Response.bufferEntity()
returns TRUE (this will replace theInputStream
inInboundMessageContext.EntityContent
with aByteArrayOutputStream
)ByteArrayOutputStream
, setting its offset to the latest byte)Response.hasEntity()
returns FALSE (the implementationEntityInputStream.isEmpty()
sees thatinput
is not null or closed, but the offset is at the last byte. This offset at the end of the stream causes the checkin.read()
to return -1, making the check assume that there are 0 bytes in the stream (while in reality there are 0 more bytes in the stream)).I've tested the behaviour with Wiremock.
A potential fixes could be: On
InboundJaxrsResponse.hasEntity()
first checking if (buffered) and if so resetting the stream by callingentityContent.reset()
(similar to what is done for reads).The text was updated successfully, but these errors were encountered: