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

Add onError callback to DeferredResult #1463

Closed
wants to merge 1 commit into from
Closed

Add onError callback to DeferredResult #1463

wants to merge 1 commit into from

Conversation

violetagg
Copy link
Member

Issue: SPR-15614

@rstoyanchev rstoyanchev self-assigned this Jun 23, 2017
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

Everything looks good, thanks for the extensive PR! I'm only wondering about that one change to "no-op" calls to ResponseBodyEmitter#completeWithError.

@@ -209,7 +211,7 @@ public void complete() {

@Override
public void completeWithError(Throwable failure) {
this.deferredResult.setErrorResult(failure);
// no-op
}
Copy link
Contributor

@rstoyanchev rstoyanchev Jun 23, 2017

Choose a reason for hiding this comment

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

Couldn't we leave this as it was before? It is true that the PR removed the internal use of the method within the try-catch of ResponseBodyEmitter#sendInternal and that any errors from the container side should work as expected but a controller could also call completeWithError and the change eliminates the option to complete with error from the application side unrelated to write issues (and regression for some apps).

If a container and an application thread both try to setErrorResult at the same time DeferredResult will only accept the first. We can document to not do that after a write failure which could be one reason for a close timing. Other than application vs container side setErrorResult should be quite rare. If it does happen I'm not sure there is much we can do and in any case it implies the response is not usable.

@violetagg
Copy link
Member Author

I agree. I updated the change.

@rstoyanchev
Copy link
Contributor

Merged, thanks!

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.

2 participants