Skip to content

Make server build fail when duplicate route and fail handler.#6499

Merged
minwoox merged 5 commits intoline:mainfrom
chickenchickenlove:251115-no-issue
Nov 19, 2025
Merged

Make server build fail when duplicate route and fail handler.#6499
minwoox merged 5 commits intoline:mainfrom
chickenchickenlove:251115-no-issue

Conversation

@chickenchickenlove
Copy link
Copy Markdown
Contributor

@chickenchickenlove chickenchickenlove commented Nov 15, 2025

Motivation:

RejectRouterHandler.FAIL does not work as intended.

Modifications:

  • The call site that calls rejectionHandler.handleDuplicateRoute(virtualHost, route, existingRoute) catchIllegalStateException and throw it.
  • Fix false alert in ContextPathTest. (ContextPathTest already has duplicated route with RejectRouterHandler.FAIL, but it just warn not fail. )

Result:

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 15, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.16%. Comparing base (8150425) to head (ebb1bb9).
⚠️ Report is 235 commits behind head on main.

Files with missing lines Patch % Lines
.../linecorp/armeria/server/RejectedRouteHandler.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6499      +/-   ##
============================================
- Coverage     74.46%   74.16%   -0.30%     
- Complexity    22234    23028     +794     
============================================
  Files          1963     2064     +101     
  Lines         82437    86262    +3825     
  Branches      10764    11313     +549     
============================================
+ Hits          61385    63979    +2594     
- Misses        15918    16882     +964     
- Partials       5134     5401     +267     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 75 to 79
} catch (IllegalStateException shouldFailException) {
throw shouldFailException;
} catch (Exception e) {
logger.warn("Unexpected exception from a {}:",
RejectedRouteHandler.class.getSimpleName(), e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I personally prefer removing these catch clauses and changing the signature of handleDuplicateRoute. But since that was a breaking change, I'm fine with the current change. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think of introducing a new exception (e.g. DuplicateRouteException) instead of using IllegalStateException? This might prevent rethrowing an IllegalStateException which is raised from a user-defined handler.

Copy link
Copy Markdown
Contributor Author

@chickenchickenlove chickenchickenlove Nov 17, 2025

Choose a reason for hiding this comment

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

@minwoox
Sounds good. I prefer to do so as well!
Let me make new commits based on your comments! 🙇‍♂️

Copy link
Copy Markdown
Contributor

@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.

👍 👍 👍

import com.linecorp.armeria.client.DuplicateRouteException;
import com.linecorp.armeria.common.HttpResponse;

public class RejectRouterHandlerTest {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
public class RejectRouterHandlerTest {
class RejectRouterHandlerTest {

@ikhoon ikhoon added the defect label Nov 18, 2025
@ikhoon ikhoon added this to the 1.34.0 milestone Nov 18, 2025
Copy link
Copy Markdown
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.

Thanks, @chickenchickenlove 👍👍

Copy link
Copy Markdown
Contributor

@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.

Still, looks great. Thanks!

@minwoox minwoox merged commit 623ee06 into line:main Nov 19, 2025
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.

RejectRouterHandler.FAIL does not work as intended.

4 participants