Skip to content

Allow ErrorDecoder.decode(...) to return null which signals that no ... - #481

Closed
rfalke wants to merge 2 commits into
OpenFeign:masterfrom
rfalke:error-decode-may-return-null
Closed

rfalke wants to merge 2 commits into
OpenFeign:masterfrom
rfalke:error-decode-may-return-null

Conversation

@rfalke

@rfalke rfalke commented Oct 25, 2016

Copy link
Copy Markdown
Contributor

... exception should be thrown. This allows to react to non-200 statuses not only with an
exception but also to return it in the return object.

…xception

should be thrown. This allows to react to non-200 statuses not only with an
exception but also to return it in the return object.

@spencergibb spencergibb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You have make many changes that are not related to your purpose, please revert them.

}

protected IOException logIOException(String configKey, Level logLevel, IOException ioe, long elapsedTime) {
protected void logIOException(String configKey, Level logLevel, IOException ioe, long elapsedTime) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this change? It breaks an API?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. The return value is unused.
  2. The method is neither a command nor a query.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

not good enough reasons, as this would break people who are extending this regardless.

a good enough reason is that this method was exposed protected, but not yet released! (unless I'm mistaken) This means that no one would have been able to extend it yet, so we wouldn't be breaking anyone.

* be asked to decode the response.
*/
public Exception decode(String methodKey, Response response);
Exception decode(String methodKey, Response response);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change visibility?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interface methods are public by default. The 'public' is redundant here. The IDE flagged this.

I will re-add it if the code style guide requires it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it is more about making distracting change in the middle of a request, not about some style guide ruling. please be considerate to the time it takes to figure out what is actually needed or not.

Exception decode(String methodKey, Response response);

public static class Default implements ErrorDecoder {
class Default implements ErrorDecoder {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same here. They are also redundant.

* href="https://tools.ietf.org/html/rfc2616#section-14.37">Retry-After format</a>
*/
static class RetryAfterDecoder {
class RetryAfterDecoder {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same.

}
}

Object decodeWithDecoder(Response response) throws Throwable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why move this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So that is nearer to the one-and-only caller.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

changes like this make it hard to see what actual change is intended. This is far more important than what is visually appealing to any of us. In other words, please try not to move things around for the sake of moving them. It makes it much harder for us to figure out what might accidentally become broken.

// ensure the request is set. TODO: remove in Feign 10
response.toBuilder().request(request).build();
}
return decodeResponse(response);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving this to another method just makes it harder to see what you are actually changing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The old method was already big. Too big for my taste. Even the new decodeResponse() is on the upper limit for my taste.

@rfalke

rfalke commented Oct 26, 2016

Copy link
Copy Markdown
Contributor Author

Just tell me which changes should be reverted and I will do so.

public void decoderCanThrowUnwrappedExceptionInDecode404Mode() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
thrown.expect(NoSuchElementException.class);
thrown.expectCause(isA(NoSuchElementException.class));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

was this needed?

@codefromthecrypt codefromthecrypt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please revert everything style related as well everything that arbitrarily moves or refactors methods. Then, add a test to show that what situation you described works. At the moment, this is mostly distracting code.

@rfalke

rfalke commented Nov 7, 2016

Copy link
Copy Markdown
Contributor Author

Is superseded by #487 and #488.

@rfalke rfalke closed this Nov 7, 2016
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