Skip to content

Better arn parsing #6163

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Better arn parsing #6163

wants to merge 4 commits into from

Conversation

RanVaknin
Copy link
Contributor

Motivation and Context

Addresses #6108 .

Currently the SDK uses exceptions as control flow for arn parsing. This is an anti pattern in Java and can cause performance overhead.

Modifications

This PR adds another arn parsing method tryFromString(arn) that would return an Optional of Arn when the arn is valid, and an empty when it is invalid - this avoids the hot path of throwing exceptions as control flow.

Testing

Unit tests:

  • Valid ARNs
  • Invalid ARNs
  • Exception throwing ARNs (valid ARNs missing a partition or service)

@RanVaknin RanVaknin requested a review from a team as a code owner June 6, 2025 18:14
Copy link
Contributor

@davidh44 davidh44 left a comment

Choose a reason for hiding this comment

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

Looks good, just need a a changelog

Copy link
Contributor

@zoewangg zoewangg left a comment

Choose a reason for hiding this comment

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

Don't we need to update account ID code path to use this new method?

@RanVaknin
Copy link
Contributor Author

Don't we need to update account ID code path to use this new method?

Separate internal Arn class used in endpoints logic already returns Optional
https://github.com/aws/aws-sdk-java-v2/blob/master/codegen/src/main/resources/software/amazon/awssdk/codegen/rules/Arn.java.resource#L26

@RanVaknin RanVaknin force-pushed the rvaknin/better-arn-parsing branch from b5c8985 to 0b61c58 Compare June 9, 2025 20:15
Copy link

sonarqubecloud bot commented Jun 9, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

3 participants