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

Request field added to FeignException #1039

Merged
merged 3 commits into from
Aug 26, 2019
Merged

Request field added to FeignException #1039

merged 3 commits into from
Aug 26, 2019

Conversation

finnetrolle
Copy link
Contributor

@finnetrolle finnetrolle commented Aug 18, 2019

Fixes: #845

Request field added to FeignException. Other exceptions changed too except Encode Exception (Request is null here)

Copy link
Member

@kdavisk6 kdavisk6 left a comment

Choose a reason for hiding this comment

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

@finnetrolle

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.

@kdavisk6 kdavisk6 added the feedback provided Feedback has been provided to the author label Aug 21, 2019
@finnetrolle
Copy link
Contributor Author

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?

@kdavisk6
Copy link
Member

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
@finnetrolle
Copy link
Contributor Author

done

Copy link
Member

@kdavisk6 kdavisk6 left a comment

Choose a reason for hiding this comment

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

@finnetrolle

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");
Copy link
Member

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"

Copy link
Contributor Author

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! )

@finnetrolle
Copy link
Contributor Author

done

Copy link
Member

@kdavisk6 kdavisk6 left a comment

Choose a reason for hiding this comment

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

@finnetrolle

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.

@kdavisk6 kdavisk6 added ready to merge Will be merged if no other member ask for changes and removed feedback provided Feedback has been provided to the author labels Aug 23, 2019
@kdavisk6 kdavisk6 merged commit d3665e4 into OpenFeign:master Aug 26, 2019
velo pushed a commit that referenced this pull request Oct 7, 2024
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
velo pushed a commit that referenced this pull request Oct 8, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Will be merged if no other member ask for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Url field in FeignException
2 participants