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

auth: Use async version of getRequestMetadata #3758

Merged
merged 1 commit into from
Nov 17, 2017

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Nov 16, 2017

This avoids using DelayedStream and a thread hop when the credentials
are known immediately.

This is dependent on #3757.

@ejona86 ejona86 force-pushed the auth-async branch 2 times, most recently from e8ce453 to ef49437 Compare November 16, 2017 18:05
try {
lastHeaders = toHeaders(metadata);
} catch (Throwable t) {
applier.fail(Status.UNAUTHENTICATED.withCause(t));
Copy link
Contributor

Choose a reason for hiding this comment

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

If you put try-catch outside of synchronized, you should be able to call applier.fail() without holding the lock.

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.

firstNonNull(callOptions.getExecutor(), appExecutor), applier);
try {
creds.applyRequestMetadata(method, effectiveAttrsBuilder.build(),
firstNonNull(callOptions.getExecutor(), appExecutor), applier);
Copy link
Contributor

Choose a reason for hiding this comment

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

applyRequestMetadata() is not supposed to throw. Errors should be passed to the applier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this is user-provided code, I don't feel like that negates the need to handle exceptions from the call. It's too easy for a NPE or similar to leak through. I've adding a message to the status to make it clearer the code did something wrong.

@ejona86
Copy link
Member Author

ejona86 commented Nov 17, 2017

I'm going to need to rebase on top of #3757. When I do that I'll also update the Statuses to make sure they descriptions.

This avoids using DelayedStream and a thread hop when the credentials
are known immediately.
@ejona86 ejona86 merged commit 6bab82e into grpc:master Nov 17, 2017
@ejona86 ejona86 deleted the auth-async branch November 17, 2017 19:52
@carl-mastrangelo carl-mastrangelo added this to the 1.9 milestone Nov 30, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants