-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Request field added to FeignException #1039
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting this PR. I have one request regarding the changes to FeignException
constructor. To make it clearer that Request
is optional, we can have 2 constructors, one that resembles the original, where the internal Request
is null
, and your new overloaded version, that accepts a request and verifies that it is not null:
protected FeignException(int status, String message, Throwable cause) {
this.request = null;
}
protected FeignException(int status, String message, Request request, Throwable cause) {
checkNotNull(request);
}
This makes our intention clearer and doesn't require as many changes to the test cases, pushing nulls
around.
Thank you for your feedback. I thought about making old constructors @deprecated... Do you think the good way is to deprecate them or just return as is? |
The older constructors are still relevant and there are additional use cases where we may want to allow exceptions without a request. That being said, there is no need for deprecation, just additional options. |
…ors are defended from null in request argument
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more small notes.
First, please update the error message, see my other note.
Second, Can you add a test case that verifies that a NPE is thrown when using a variation of the constructor that requires a Request
?
super(message, cause); | ||
this.status = status; | ||
this.content = content; | ||
this.request = checkNotNull(request, "request"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a real message here. This will result in an NPE with a message of "request". Can you change to read something like "request is required"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just grep project to check how checkNotNull invokes and made same. But ok, changed! )
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've approved this PR and marked it ready to merge. If there are no additional comments from any of the other maintainers in the next few days this PR will be merged. Thank you for supporting this project and taking the time to contribute.
Fixes #845 This change allows Feign Exceptions to be created with the original request as an optional parameter. Changes include: * Request field added to FeignException * New constructors are defended from null in request argument * Tests to check null instead of request, null message updated
Fixes #845 This change allows Feign Exceptions to be created with the original request as an optional parameter. Changes include: * Request field added to FeignException * New constructors are defended from null in request argument * Tests to check null instead of request, null message updated
Fixes: #845
Request field added to FeignException. Other exceptions changed too except Encode Exception (Request is null here)