Skip to content

Skip auth scheme and endpoint resolution if already resolved by old interceptors#7012

Merged
S-Saranya1 merged 5 commits into
feature/master/core-interceptors-migrationfrom
somepal/skip-resolution-if-already-resolved
Jun 3, 2026
Merged

Skip auth scheme and endpoint resolution if already resolved by old interceptors#7012
S-Saranya1 merged 5 commits into
feature/master/core-interceptors-migrationfrom
somepal/skip-resolution-if-already-resolved

Conversation

@S-Saranya1
Copy link
Copy Markdown
Contributor

@S-Saranya1 S-Saranya1 commented Jun 2, 2026

Motivation and Context

When new core + old service, auth scheme and endpoint resolution would happen twice (once by old interceptors, once by pipeline stages). This adds unnecessary overhead, updating it to only resolve once.

Modifications

  • AuthSchemeResolutionStage: Skip resolution if auth scheme is already resolved (scheme ID is not "unset"). Still re-resolves identity to respect credential overrides.
  • EndpointResolutionStage: Skip resolution if RESOLVED_ENDPOINT is already set.

Testing

  • Added unit tests for AuthSchemeResolutionStage (skip when resolved, proceed when "unset").
  • Added unit test for EndpointResolutionStage (skip when endpoint already set).

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@S-Saranya1 S-Saranya1 requested a review from a team as a code owner June 2, 2026 20:44
// Skip resolution if auth scheme was already resolved by an old service interceptor.
SelectedAuthScheme<?> existing = executionAttributes.getAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME);
if (existing != null && !"unset".equals(existing.authSchemeOption().schemeId())) {
updateIdentityOnExistingScheme(existing, identityProviders, executionAttributes);
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.

Can we add some comments here explaining why we are doing 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.

Added the comments

IdentityProviders identityProviders = updateIdentityProvidersIfNeeded(executionAttributes, sdkRequest);

// Skip resolution if auth scheme was already resolved by an old service interceptor.
SelectedAuthScheme<?> existing = executionAttributes.getAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME);
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.

Let's add some tests

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.

Added tests for both auth and endpoint resolution

@S-Saranya1 S-Saranya1 merged commit 437f380 into feature/master/core-interceptors-migration Jun 3, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 3, 2026
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.

2 participants