-
Notifications
You must be signed in to change notification settings - Fork 877
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
Include provided ARN string in Exception message. Enforce NPE. #3691
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good. Thanks for improving logging while preserving the same behaviour.
I noticed that tests in
@belugabehr please also update those tests to take your changes in account. Thanks! |
@belugabehr let us know if you want to keep working in this PR. |
@debora-ito Other priorities keeping me from finishing - but my intent is to see it through. Thanks for the patience. |
8a4ce99
to
c351026
Compare
@L-Applin Updated. Thanks. |
@L-Applin @debora-ito Any updates? |
SonarCloud Quality Gate failed.
|
246e5f4
to
a9194a2
Compare
e0f6c16
to
d998b70
Compare
Hey, sorry for all the SPAM on this PR. It's been so long since I've looked at this that I am falling into the same traps I fell into months ago. I think the proposed solution is optimal. Users are told that their ARNs are not valid, and then they can dive into the cause to get the details of why. The issue here is that there is another Exception that gets thrown from the Resource parsing code. The resource parsing code is only handled the resource string, not the entire ARN, so it cannot emit a proper exception with the ARN present. |
if (resource.isEmpty()) { | ||
throw new IllegalArgumentException("Malformed ARN - no resource specified"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this on purpose as it is duplicative. The resource is further parsed (and validated) in the Resource parsing code.
Motivation and Context
I recently had a complicated unit test that was failing to produce a valid ARN. However, the Exception message from parsing the ARN did not provide the value it was attempting to parse, so it was made more difficult to troubleshoot.
Modifications
IllegalArgumentException
with the details of the failed parsing inside anotherIllegalArgumentException
which contains the value of the ARN being parsed.Testing
Added additional unit tests to cover these cases
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License