Skip to content
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

Merged
merged 7 commits into from
Feb 8, 2023

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Jan 30, 2023

Motivation:

When an annotation is applied to Kotlin data class, Kotlin compiler constructor parameters with the annotation and adds the fields as well.

data class ExampleQueries(
    @Param
    val application: String,
    @Param
    val topic: String,
    @Param
    val group: String,
)

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:

  • Check both httpElementName and anntationType() 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.

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.
@ikhoon ikhoon added the defect label Jan 30, 2023
@ikhoon ikhoon added this to the 1.22.0 milestone Jan 30, 2023
Copy link
Contributor

@jrhee17 jrhee17 left a 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 👍

Comment on lines 127 to 128
o1Name += o1.annotationType().getName();
o2Name += o2.annotationType().getName();
Copy link
Contributor

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

Copy link
Member

@minwoox minwoox 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!
I left a question. 😄

Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Thanks, @ikhoon!

Copy link
Contributor

@jrhee17 jrhee17 left a 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 🙇 🙇 🙇 )

@ikhoon ikhoon merged commit e971022 into line:master Feb 8, 2023
@ikhoon ikhoon deleted the dedup-parameters branch February 8, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants