Skip to content

Conversation

@chickenchickenlove
Copy link
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

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 (89f8410).
⚠️ Report is 232 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.31%     
- Complexity    22234    23027     +793     
============================================
  Files          1963     2064     +101     
  Lines         82437    86262    +3825     
  Branches      10764    11313     +549     
============================================
+ Hits          61385    63974    +2589     
- Misses        15918    16885     +967     
- Partials       5134     5403     +269     

☔ 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
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
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
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
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
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 {

* <p>This exception is raised when multiple routes share an identical path
* and thus cannot be uniquely distinguished.</p>
*/
public final class DuplicateRouteException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should place this in the server-side package?

* <p>This exception is raised when multiple routes share an identical path
* and thus cannot be uniquely distinguished.</p>
*/
public final class DuplicateRouteException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public final class DuplicateRouteException extends RuntimeException {
@UnstableApi
public final class DuplicateRouteException extends RuntimeException {

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