Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit a45551b

Browse files
author
Adam Lindenthal
committed
Merge pull request #138 from dadowns/master
Make hasEntity() work with a closed stream.
2 parents 5a94b0f + 0720b6d commit a45551b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,6 @@ public void setWorkers(MessageBodyWorkers workers) {
743743
* {@code false} otherwise.
744744
*/
745745
public boolean hasEntity() {
746-
entityContent.ensureNotClosed();
747-
748746
try {
749747
return !entityContent.isEmpty();
750748
} catch (IllegalStateException ex) {

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseCloseTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import org.glassfish.jersey.test.JerseyTest;
5050

5151
import org.junit.Test;
52+
53+
import static org.junit.Assert.assertFalse;
5254
import static org.junit.Assert.fail;
5355

5456
/**
@@ -160,10 +162,10 @@ public void testHasEntityAfterClose() {
160162
final Response response = target().path("simple").request().get(Response.class);
161163
response.close();
162164
try {
163-
response.hasEntity();
164-
fail("IllegalStateException expected when reading a buffered entity after response has been closed.");
165+
boolean hasEntity = response.hasEntity();
166+
assertFalse("Should return false when the connection is already closed", hasEntity);
165167
} catch (IllegalStateException ex) {
166-
// expected
168+
fail("IllegalStateException should have been caught inside hasEntity.");
167169
}
168170
}
169171
}

0 commit comments

Comments
 (0)