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

Merged
merged 4 commits into from
Jun 17, 2025
Merged

Better arn parsing #6163

merged 4 commits into from
Jun 17, 2025

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

@RanVaknin RanVaknin added this pull request to the merge queue Jun 17, 2025
Merged via the queue into master with commit fbdc7d3 Jun 17, 2025
24 of 26 checks passed
Copy link

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 17, 2025
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