-
Notifications
You must be signed in to change notification settings - Fork 926
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
Fix a bug where duplicate parameters are shown in DocService #4645
Conversation
Motivation: When an annotation is applied to Kotlin data class, Kotlin compiler constructor parameters with the annotation and add the fields as well. ```kt data class ExampleQueries( @param val application: String, @param val topic: String, @param val group: String, ) ``` Annotated services extracts both the fields from the constructor and fields using reflection. The problem was reported by line#3454 and fixed by line#3461. Howerver, there is a bug in detect duplicate. See for the detail. line#3454 (comment) Modifications: - Check both `httpElementName` and `anntationType()` if they are not equal to provide a consistent comparision. Result: You no longer see duplicate parameters in `DocService` when parameter annotations for a request object are added to Kotlin data class.
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.
Changes look good apart from the CI failure 👍
kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/DataClassDocServiceTest.kt
Outdated
Show resolved
Hide resolved
kotlin/src/test/kotlin/com/linecorp/armeria/server/kotlin/DataClassDocServiceTest.kt
Outdated
Show resolved
Hide resolved
o1Name += o1.annotationType().getName(); | ||
o2Name += o2.annotationType().getName(); |
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.
It seems like o1.annotationType()
can be null
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.
Looks good!
I left a question. 😄
.../main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedBeanFactoryRegistry.java
Outdated
Show resolved
Hide resolved
.../main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedBeanFactoryRegistry.java
Show resolved
Hide resolved
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.
Thanks, @ikhoon!
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.
Thanks @ikhoon ! 🙇 👍 🚀 (and @KarboniteKream who reported the issue 🙇 🙇 🙇 )
Motivation:
When an annotation is applied to Kotlin data class, Kotlin compiler constructor parameters with the annotation and adds the fields as well.
Annotated services extract both the fields from the constructor and fields using reflection. The problem was reported by #3454 and fixed by #3461. However, there is a bug in detecting duplicates.
See for the detail. #3454 (comment)
Modifications:
httpElementName
andanntationType()
if they are not equal to provide a consistent comparison.Result:
You no longer see duplicate parameters in
DocService
when parameter annotations for a request object are added to Kotlin data class.