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

Adding handling for stream exhaustion in Netty. #585

Closed
wants to merge 1 commit into from

Conversation

nmittler
Copy link
Member

No description provided.

@nmittler
Copy link
Member Author

@ejona86 PTAL

@@ -184,14 +183,13 @@ public void cancelBufferedStreamShouldChangeClientStreamStatus() throws Exceptio

assertTrue(createPromise.isSuccess());
verify(stream).transportReportStatus(eq(Status.CANCELLED), eq(true),
any(Metadata.Trailers.class));
any(Metadata.Trailers.class));
Copy link
Member

Choose a reason for hiding this comment

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

Are these whitespace changes necessary? It seems they are fine as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

No .... it seems that the IDE's config for whitespace in this case is imperfect. It's probably more effort than it's worth to revert and there aren't may occurrences of this.

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that each IDE (even version) formats it differently, so you get constant churn. The constant useless churn that adds noise is what I have issue with. I'm thinking there should be a ban on full-file reformatting.

As a further example, the newline between the io.grpc and io.netty imports is minor but also improper, and so later we will have another PR that will fix it. The only way to stop the cycle it to stop committing useless code reformatting like here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reverted the formatting.

Agreed that full-file formatting is rather evil and should be avoided. I generally don't use it but must have in this case.

@nmittler
Copy link
Member Author

@ejona86 PTAL

+ "Initiating graceful shutdown of the connection.");
try {
super.close(ctx, ctx.newPromise());
} catch (Exception ce) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we just add throws Exception to createStream() and write()? That seems more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@nmittler nmittler force-pushed the streams_exhausted branch 2 times, most recently from 086f594 to 2f263ff Compare July 20, 2015 23:08
@nmittler
Copy link
Member Author

@ejona86 PTAL

promise.setFailure(e);
try {
super.close(ctx, ctx.newPromise());
} catch (Exception ce) {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't what I was encouraging when I was suggesting to add "throws Exception" to createStream() and write().

Instead, I was suggesting that this } catch (Exception ce) { doesn't need to be here at all, because write() can throws Exception. I do think the super.close() needs to be back where it was in createStream().

The changes for propagating StatusException further seem like a step backward. I liked it more with how it was before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Writes in Netty do not typically throw. Instead they fail the promise with the exception. We should be following that pattern.

I'll revert the code to the previous version.

@nmittler
Copy link
Member Author

@ejona86 PTAL ... I've reverted the exception handling logic in createStream.

try {
super.close(ctx, ctx.newPromise());
} catch (Exception ce) {
// Promise was already failed. Just absorb.
Copy link
Member

Choose a reason for hiding this comment

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

In no way is the promise guaranteed to have failed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I follow ... we call promise.setFailure(e) above.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. But this exception is being lost. We should really propagate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we ever move to java 7, this looks very similar to suppressed exceptions in the try-with clause. You might consider adding a todo to use e.addSuppressed(ce); if we ever expect to upgrade.

Copy link
Member

Choose a reason for hiding this comment

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

Except that our method signature should simply "throws Exception". The only reason we have this exception is because Netty's close() has "throws Exception", and I see no reason why we shouldn't propagate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough ... done.

@nmittler
Copy link
Member Author

@ejona86 PTAL

@ejona86
Copy link
Member

ejona86 commented Jul 27, 2015

@nmittler LGTM

@nmittler
Copy link
Member Author

cherry-picked as 9f7cb80

@nmittler nmittler closed this Aug 21, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants