Skip to content

Eliminate Per-Operation Lambdas for Constant Pool Overflow Fix#7150

Merged
S-Saranya1 merged 16 commits into
masterfrom
somepal/fix-constant-pool-overflow-issue
Jul 21, 2026
Merged

Eliminate Per-Operation Lambdas for Constant Pool Overflow Fix#7150
S-Saranya1 merged 16 commits into
masterfrom
somepal/fix-constant-pool-overflow-issue

Conversation

@S-Saranya1

@S-Saranya1 S-Saranya1 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

The interceptor-to-pipeline-stages migration PR #7017 introduced two inline lambdas per operation in generated service clients for endpoint and auth scheme resolution. Each lambda adds ~8-16 constant pool entries to the class file. For services with a large number of operations (800+), this adds enough constant pool entries to push the generated async client class past the JVM's hard 65,535 entry limit, causing a compilation failure:
too many constants

PR #7111 provided a short-term fix using factory methods, reducing the cost to ~2-3 entries per operation. This PR implements the long-term fix to eliminate per-operation lambdas entirely, reducing the constant pool cost from resolvers to zero per operation.

Modifications

  • The resolver methods (resolveEndpoint, resolveAuthSchemeOptions) need the operation name to function. Previously this was passed via lambda capture. Now they read it directly from ExecutionAttributes (where it's already stored via .withOperationName()), removing the need for per-operation lambdas.
  • Replaced the 1-arg AuthSchemeOptionsResolver.resolve(SdkRequest) with resolve(SdkRequest, ExecutionAttributes) as the sole abstract method. This enables method references (this::resolveAuthSchemeOptions) directly. The interface is @SdkProtectedApi
  • Replaced all per-operation lambdas and factory method calls in JsonProtocolSpec, QueryProtocolSpec, and XmlProtocolSpec with shared method references (this::resolveEndpoint, this::resolveAuthSchemeOptions).
  • Updated resolveAuthSchemeOptions to read all inputs (auth scheme provider, region, SigV4a region set, endpoint provider) from executionAttributes instead of clientConfiguration, ensuring request-level plugin overrides are respected.
  • Removed the factory methods (authSchemeResolver, endpointResolver) from generated clients — no longer needed.
  • Removed @FunctionalInterface from EndpointResolver to allow future interface evolution.
  • Added japicmp exclusion for the removed 1-arg method.

Testing

  • Updated AuthSchemeResolutionStageTest and GeneratePreSignUrlInterceptorTest (EC2) to match the new interface signature.
  • Updated all codegen fixture files (24 files) to reflect the new generated output.
  • Added AuthSchemeProviderOverrideTest (S3) to verify request-level plugin overrides for auth scheme provider and region are respected.
  • Verified EndpointOverrideConfigurationTest passes — confirms per-request endpoint provider overrides still work correctly.
  • Full CI build passes (codegen tests, sdk-core unit tests, service compilation, integration tests).

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 July 15, 2026 03:01
@S-Saranya1 S-Saranya1 added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Jul 15, 2026
@S-Saranya1
S-Saranya1 requested a review from davidh44 July 16, 2026 21:24
@S-Saranya1 S-Saranya1 removed the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Jul 17, 2026
@S-Saranya1 S-Saranya1 changed the title Fix constant pool overflow issue Eliminate Per-Operation Lambdas for Constant Pool Overflow Fix Jul 17, 2026
Comment on lines +233 to +234


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.

nit extra newlines

@S-Saranya1 S-Saranya1 added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Jul 20, 2026
@S-Saranya1 S-Saranya1 mentioned this pull request Jul 20, 2026
12 tasks
@S-Saranya1
S-Saranya1 added this pull request to the merge queue Jul 21, 2026
Merged via the queue into master with commit 4482690 Jul 21, 2026
13 of 14 checks passed
@github-actions

Copy link
Copy Markdown

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 Jul 21, 2026
@S-Saranya1
S-Saranya1 deleted the somepal/fix-constant-pool-overflow-issue branch July 21, 2026 15:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants