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

Enhance route duplication detection by including param and header predicates #5469

Merged
merged 4 commits into from Apr 11, 2024

Conversation

minwoox
Copy link
Member

@minwoox minwoox commented Feb 19, 2024

Motivation:
In route duplication detection, it's essential to consider param and header predicates alongside other route conditions.

Modification:

  • Introduce Route.hasDuplicateRouteCondition() method to encapsulate route condition comparison logic previously handled in Routers.
    • Centralizing this logic improves maintainability and ensures consistency when adding more fields to Route class.

Result:

  • Routes with differing predicates, including param and header predicates, are correctly identified as non-duplicates.

…dicates.

Motivation:
In route duplication detection, it's essential to consider param and header predicates alongside other route conditions.

Modification:
- Introduce `Route.hasDuplicateRouteCondition()` method to encapsulate route condition comparison logic previously handled in `Routers`.
  - Centralizing this logic improves maintainability and ensures consistency when adding more fields to `Route` class.

Result:
- Routes with differing predicates, including param and header predicates, are correctly identified as non-duplicates.
@minwoox minwoox added the defect label Feb 19, 2024
@minwoox minwoox added this to the 1.28.0 milestone Feb 19, 2024
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: Patch coverage is 81.25000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 74.12%. Comparing base (900002d) to head (b6ce573).
Report is 23 commits behind head on main.

❗ Current head b6ce573 differs from pull request most recent head c76863b. Consider uploading reports for the commit c76863b to get more accurate results

Files Patch % Lines
...java/com/linecorp/armeria/server/DefaultRoute.java 78.12% 3 Missing and 4 partials ⚠️
.../com/linecorp/armeria/server/RoutingPredicate.java 84.61% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5469      +/-   ##
============================================
- Coverage     74.13%   74.12%   -0.02%     
- Complexity    20991    20997       +6     
============================================
  Files          1818     1818              
  Lines         77233    77252      +19     
  Branches       9856     9858       +2     
============================================
+ Hits          57256    57261       +5     
- Misses        15309    15320      +11     
- Partials       4668     4671       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Left a minor suggestion, but looks good overall 👍

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.

👍 👍

// No overlap in supported methods.
return false;
}
if (!consumes.isEmpty() &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Q) If consumes is empty, it can consume any media type. In the following situation, should we assume that the two consumes are duplicate?

  • this.consumes = [JSON]
  • others.consumes = []

Copy link
Member Author

@minwoox minwoox Apr 8, 2024

Choose a reason for hiding this comment

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

That's a good point. I think that it was a bug, and we should treat them as the same.
I'll address this in a separate PR because it might introduce unexpected behavior changes.

// No overlap in consume types.
return false;
}
if (!produces.isEmpty() && produces.stream().noneMatch(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Just a naming nit. 🙇

* assert route.hasDuplicateRouteCondition(other);
* }</pre>
*/
boolean hasDuplicateRouteCondition(Route other);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe hasConflicts()?

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

👍👍

@jrhee17 jrhee17 merged commit 3255f67 into line:main Apr 11, 2024
14 of 16 checks passed
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

4 participants