Path Clash Detection
The annotated routing module detects potential path conflicts at startup and warns you when two or more interceptors (@Before, @BeforeMatched, @After, @AfterMatched) share the same path.
What Gets Checked
Path clash detection applies to interceptor routes:
@Before@BeforeMatched@After@AfterMatched
HTTP method routes (@Get, @Post, etc.) are not checked because Javalin handles method-based routing natively.
How Clashes Are Detected
Two paths can clash when:
- They have different parameter names at the same depth (e.g.,
/users/{id}vs/users/{userId}) - A wildcard parameter
<param>overlaps with specific paths - Curly braces
{param}and angle brackets<param>at the same position (note:<param>is more permissive as it matches across slashes)
Example Warning
[WARN] Detected clashing BEFORE handler paths: [/api/*]. These paths match the same requests.How It Works Internally
The path clash detection uses an internal canPathsClash function to determine whether two paths could match the same request. It compares paths segment by segment:
- Two static segments clash only if they are identical (
/usersvs/users) - A parameterized segment (
{id}) can match any static segment, so/users/{id}and/users/meare considered potentially clashing - A wildcard segment (
<param>) matches anything including slashes, so it clashes with all segments at the same depth
At startup, the plugin scans all interceptor routes and logs warnings for any paths that appear more than once for the same route type:
[WARN] Detected clashing BEFORE handler paths: [/api/*]. These paths match the same requests.