Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerError for GET requests with an empty body #642

Closed
cbeer opened this issue Feb 9, 2016 · 4 comments
Closed

NullPointerError for GET requests with an empty body #642

cbeer opened this issue Feb 9, 2016 · 4 comments

Comments

@cbeer
Copy link

cbeer commented Feb 9, 2016

We're seeing a NullPointerError for GET requests that have an empty body:

java.lang.NullPointerException
    at com.jayway.restassured.internal.support.CloseHTTPClientConnectionInputStreamWrapper.read(CloseHTTPClientConnectionInputStreamWrapper.java:49)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.Reader.read(Reader.java:140)

Here's the line in our code where things break:

https://github.com/w3c/ldp-testsuite/blob/master/src/main/java/org/w3/ldp/testsuite/mapper/RdfObjectMapper.java#L48

Tracing my way through rest-assured, it looks like the NPE error is initially caused here:

https://github.com/jayway/rest-assured/blob/master/rest-assured/src/main/groovy/com/jayway/restassured/internal/RequestSpecificationImpl.groovy#L1969

And propagates through to:
https://github.com/jayway/rest-assured/blob/master/rest-assured/src/main/groovy/com/jayway/restassured/internal/RestAssuredResponseOptionsGroovyImpl.groovy#L182-L188

@johanhaleby
Copy link
Collaborator

Thanks for pointing out. Do you think it will help if we just replace null with empty string?

@cbeer
Copy link
Author

cbeer commented Feb 10, 2016

Makes sense to me, and that would match the behavior of asString and asByteArray.

@johanhaleby
Copy link
Collaborator

I've fixed this in master now. Thanks for a very detailed issue report. I've published a new snapshot: 2.8.1-SNAPSHOT. Please try it out after having added the following repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

@cbeer
Copy link
Author

cbeer commented Feb 11, 2016

👍 thanks, the snapshot release fixes our problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants