Skip to content

Handle invalid HTTP received from server - #323

Merged
codefromthecrypt merged 1 commit into
OpenFeign:masterfrom
carlossg:invalid-http
Jan 27, 2016
Merged

codefromthecrypt merged 1 commit into
OpenFeign:masterfrom
carlossg:invalid-http

Conversation

@carlossg

Copy link
Copy Markdown
Contributor

If response was empty it caused a NPE

java.lang.NullPointerException: reason
  at feign.Util.checkNotNull(Util.java:104)
  at feign.Response.<init>(Response.java:49)
  at feign.Response.create(Response.java:60)
  at feign.Client$Default.convertResponse(Client.java:171)
  at feign.Client$Default.execute(Client.java:72)
  at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:95)
  at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:74)
  at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:94)

@cloudbees-pull-request-builder

Copy link
Copy Markdown

NetflixOSS » feign » feign-pull-requests #204 SUCCESS
This pull request looks good

@codefromthecrypt

Copy link
Copy Markdown

thx for the PR.. so in this case, we are wrong, I think. It is valid (albeit super weird) to have an empty reason. It smells of error, though! http://tools.ietf.org/html/rfc7230#section-3.1.2

This is hard to test as I'm not sure we could get MockWebServer to return a null reason either..

Regardless, I might throw an IOException instead, as we are assuming there is a transport problem.

Comment thread core/src/main/java/feign/Client.java Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so basically, just throw an IOE here.

@carlossg

Copy link
Copy Markdown
Contributor Author

In my case the server is returning nothing through the connection due to server error. I haven't checked but I guess java.net is also returning status code -1 per the javadocs

Returns null if none could be discerned from the responses (the result was not valid HTTP).

https://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html#getResponseMessage()

Returns -1 if no code can be discerned from the response (i.e., the response is not valid HTTP).

https://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html#getResponseCode()

Any exception is fine

If response was empty it caused a NPE
@carlossg

Copy link
Copy Markdown
Contributor Author

updated and rebased

@cloudbees-pull-request-builder

Copy link
Copy Markdown

NetflixOSS » feign » feign-pull-requests #205 SUCCESS
This pull request looks good

codefromthecrypt pushed a commit that referenced this pull request Jan 27, 2016
Handle invalid HTTP received from server
@codefromthecrypt
codefromthecrypt merged commit 715e72b into OpenFeign:master Jan 27, 2016
@codefromthecrypt codefromthecrypt added this to the 8.14.3 milestone Feb 3, 2016
velo pushed a commit that referenced this pull request Oct 8, 2024
Handle invalid HTTP received from server
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

Successfully merging this pull request may close these issues.

3 participants