armeria
armeria copied to clipboard
Implement @Attribute Injection.
Motivation:
- In the past, users could get a value from
ServiceRequestContext
by usingServiceRequestContext.attr(key)
. however, if it were possible to inject values which inServiceRequestContext
into method parameters using any annotation, users would be able to use it more conveniently.
Modifications:
- New annotation.
@Attribute
is added. - Make new field
rawType
inAnnotatedValueResolver
to validate type cast. - New methods
ofAttribute()
andattributeResolver()
are added toAnnotatedValueResolver
to get values fromServiceRequestContext
and inject them method parameters. -
findName()
inAnnotatedElementNameUtil
method have been merged into a single method. (refactoring for internal use) - Add test codes.
- Add document explaining how to use the
@Attribute
annotation.
Result:
- Closes https://github.com/line/armeria/issues/5514
- Users can inject values from the
ServiceRequestContext
into method parameters using the@Attribute
annotation withoutServiceRequestContext.attr(key)
.
๐ Build Scanยฎ (commit: 70d76cbf08b48afc81bda8e38f5bea134748b57b)
Job name | Status | Build Scanยฎ |
---|---|---|
build-windows-latest-jdk-19 | โ | https://ge.armeria.dev/s/lu7vfihw5qooe |
build-self-hosted-unsafe-jdk-8 | โ | https://ge.armeria.dev/s/bockuhidf4g3s |
build-self-hosted-unsafe-jdk-19-snapshot-blockhound | โ | https://ge.armeria.dev/s/4qbeilnrztoqq |
build-self-hosted-unsafe-jdk-17-min-java-17-coverage | โ | https://ge.armeria.dev/s/jv2vv4gi2bf34 |
build-self-hosted-unsafe-jdk-17-min-java-11 | โ (failure) | https://ge.armeria.dev/s/bdumqrgjh34h4 |
build-self-hosted-unsafe-jdk-17-leak | โ | https://ge.armeria.dev/s/fo7wwfesfgic6 |
build-self-hosted-unsafe-jdk-11 | โ | https://ge.armeria.dev/s/3enumq5mr3v7i |
build-macos-12-jdk-19 | โ | https://ge.armeria.dev/s/m5xpss23od44i |
Codecov Report
Attention: Patch coverage is 90.62500%
with 3 lines
in your changes are missing coverage. Please review.
Project coverage is 74.11%. Comparing base (
b8eb810
) to head (1d0b6c7
). Report is 190 commits behind head on main.
:exclamation: Current head 1d0b6c7 differs from pull request most recent head 70d76cb. Consider uploading reports for the commit 70d76cb to get more accurate results
Files | Patch % | Lines |
---|---|---|
...rnal/server/annotation/AnnotatedValueResolver.java | 90.00% | 1 Missing and 2 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #5547 +/- ##
============================================
+ Coverage 73.95% 74.11% +0.16%
- Complexity 20115 21019 +904
============================================
Files 1730 1819 +89
Lines 74161 77418 +3257
Branches 9465 9891 +426
============================================
+ Hits 54847 57380 +2533
- Misses 14837 15385 +548
- Partials 4477 4653 +176
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@trustin nim, There are two failed build list.
-
build-self-hosted-unsafe-jdk-19-snapshot-blockhound
:./gradlew: No such file or directory
error occurs. -
build-windows-latest-jdk-19
: because failed to upload Artifact. (403 Return) I think it seems not related with this PR. What do you think? Please let me know your opinion. ๐โโ๏ธ
Thank you for taking the time to see me even on a holiday. I've learned a lot thanks to you. ๐โโ๏ธ
Left a couple more super nit comments, still looks good for merging ๐
@jrhee17 nim, thanks for your review. When you have free time, please review again ๐โโ๏ธ
Re-requesting review sounds like a bug. https://github.com/line/armeria/actions/runs/8796330970/job/24138993146?pr=5547#step:2:10 It seems that component-owners plugin takes the case into account though. https://github.com/dyladan/component-owners/blob/cdaadffde64c918909ee081e3fe044b8910f56c2/src/main.ts#L64-L65
Re-requesting review sounds like a bug. https://github.com/line/armeria/actions/runs/8796330970/job/24138993146?pr=5547#step:2:10 It seems that component-owners plugin takes the case into account though. https://github.com/dyladan/component-owners/blob/cdaadffde64c918909ee081e3fe044b8910f56c2/src/main.ts#L64-L65
@ikhoon nim, Thanks for your comment. By the way, i lost your approve again ๐ข... after commit suggestion from @minwoox nim.
@ikhoon nim, @minwoox nim, sorry to bother you. I lost you guys approve ๐ข when you have free time, please take a look again ๐โโ๏ธ...
Oops! Sorry but would you mind resolving the merge conflict, @chickenchickenlove ?
@trustin nim, thanks for you to notify me ๐โโ๏ธ I made new commit to resolve conflict. I guess this PR cause the conflict. ๐ค I updated the PR description as well.
Thanks a lot for updating the PR description and resolving the merge conflict, @chickenchickenlove! :bow::bow::bow:
@jrhee17 @minwoox PTAL