Skip to content

fix: Error when decorating duplicate generic method - Tracing #572

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

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Mar 20, 2024

Please provide the issue number

Issue number: #571

Summary

Decorating a generic method with Tracing utility and calling that method more than once with different T would cause an exception, because the T that we cache would mismatch the new T resulting in System.InvalidCastException.

Changes

The fix is to change the cache key to use the full method name coming from the target method that was decorated, this will take into account the T, return T and T parameters making the key unique.
Added tests to validate generic method decoration.

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

…er which is more precise and avoids collision when decorating generic methods with tracing attribute. Add tests.
@auto-assign auto-assign bot requested review from amirkaws and sliedig March 20, 2024 14:17
@boring-cyborg boring-cyborg bot added area/common Core Powertools utility tests labels Mar 20, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 20, 2024
@github-actions github-actions bot added the bug Unexpected, reproducible and unintended software behaviour label Mar 20, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@amirkaws amirkaws left a comment

Choose a reason for hiding this comment

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

LGTM

@hjgraca hjgraca merged commit 15efb4c into aws-powertools:develop Mar 20, 2024
@hjgraca hjgraca deleted the fix-tracing-duplicate-generic-method-decorator branch March 20, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/common Core Powertools utility bug Unexpected, reproducible and unintended software behaviour size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants