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

FeignException uses request and response but doesn't use a response body #1467

Closed

Conversation

vitalijr2
Copy link
Collaborator

@vitalijr2 vitalijr2 commented Jul 23, 2021

Simplifying of FeignException: it uses request and response objects but does not use a response body as byte array.

It is breaking changes if any extension use the methods content. contentUTF8, responseBody or responseHeaders.
FeignException and DecodeException have new constructors.

These changers start from the discussion #1452

P.S.
I like the idea to make FeignException more simplier. But I have not found how to do it without breaking changes.

@vitalijr2 vitalijr2 changed the title FeingException uses request and response but doen't use a response body FeingException uses request and response but dosn't use a response body Jul 23, 2021
@vitalijr2 vitalijr2 changed the title FeingException uses request and response but dosn't use a response body FeingException uses request and response but doesn't use a response body Jul 23, 2021
@vitalijr2 vitalijr2 changed the title FeingException uses request and response but doesn't use a response body FeignException uses request and response but doesn't use a response body Jul 23, 2021
Copy link
Member

@velo velo left a comment

Choose a reason for hiding this comment

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

Overall I liked the change, but, due to feign nature, we CAN'T just remove public/protected methods/constructors. At least not in minor releases.

Please bring them back, mark as deprecated and we may nuke on feign 12...

private Request request;

protected FeignException(int status, String message, Throwable cause) {
Copy link
Member

Choose a reason for hiding this comment

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

I HATE this class!

That said, it's not safe to remove the extra constructors, as people may be using it.

Bring them back, and feel free to deprecate them all

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in the commit 2523ef1

*
* @return an Optional wrapping the response body.
*/
public Optional<ByteBuffer> responseBody() {
Copy link
Member

Choose a reason for hiding this comment

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

as with the original constructors... we need to keep the old methods for compatibility.

Please bring them all back, not sure if they got deleted or just sorted, keeping them on their original position makes this more reviewable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in the commit 2523ef1

@@ -271,149 +203,130 @@ static FeignException errorExecuting(Request request, IOException cause) {
}

public static class FeignClientException extends FeignException {
public FeignClientException(int status, String message, Request request, byte[] body,
Copy link
Member

Choose a reason for hiding this comment

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

anything public, needs to be kept, add @deprected to them, but keep them in place

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in the commit 2523ef1

@velo
Copy link
Member

velo commented Jul 26, 2021

I like the idea to make FeignException more simplier. But I have not found how to do it without breaking changes.

I feel ya

@vitalijr2 vitalijr2 force-pushed the feature/simplify-feignexception branch from 0d53583 to 2c46bb3 Compare July 27, 2021 06:39
@vitalijr2
Copy link
Collaborator Author

vitalijr2 commented Aug 2, 2021

The Snyk upgraded jackson's version in c88b65a and the build was successful. But then I update my branch and it fell for jdk14 only.
Unfortunately I can see what is wrong.

@vitalijr2 vitalijr2 marked this pull request as draft August 3, 2021 13:50
@vitalijr2
Copy link
Collaborator Author

Today I tried to return unit-tests for response body methods. I thought that all these methods should be deprecated. But I found that they are required as a response could have a non-repeatable body so:

  • we could not made an exception message without touching a response body
  • we could not get a response body from exception if a response has non-repeatable body as we just read it when created new exception.

@vitalijr2 vitalijr2 closed this Aug 5, 2021
@vitalijr2
Copy link
Collaborator Author

vitalijr2 commented Aug 5, 2021

It requires a different approach, perhaps we need to transfer everything to factory methods.

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.

None yet

2 participants