damiancarrillo/agave-web-framework — Issue #3: URI paths are not being treated as distinct
Author: damiancarrillo
Created: 2011-11-14 03:35:26+00:00
State: open

Two handler methods with the following paths are treated as being ambiguous:

* `@Route("/something")`
* `@Route("/something/${specialization}")`

Internally, the HandlerRegistryImpl is treating a request to `http://localhost/something` as a match to `http://localhost/something/` whereas it should have matched the first method.

The following test in `HandlerRegistryTest` illustrates the problem:

```java
@Test
public void testMatches_withOverloadedHandlerDescriptors() throws Exception {
registry.addDescriptor(new HandlerMethodDescriptorImpl(new HandlerIdentifierImpl(
"/overloaded",
SampleHandler.class.getName(),
"overloaded")));

registry.addDescriptor(new HandlerMethodDescriptorImpl(new HandlerIdentifierImpl(
"/overloaded/${param}",
SampleHandler.class.getName(),
"overloaded")));

context.checking(new Expectations() {{
allowing(request).getServletPath();
will(returnValue("/overloaded/blah"));

allowing(request).getMethod();
will(returnValue("GET"));
}});

HandlerMethodDescriptor descriptor = registry.findMatch(request);
Assert.assertNotNull(descriptor);
Assert.assertEquals("/overloaded/${param}", descriptor.getPattern().toString());

context.checking(new Expectations() {{
allowing(request).getServletPath();
will(returnValue("/overloaded"));

allowing(request).getMethod();
will(returnValue("GET"));
}});

descriptor = registry.findMatch(request);
Assert.assertNotNull(descriptor);
Assert.assertEquals("/overloaded", descriptor.getPattern().toString()); // Fails
}
```

It's worth nothing that the `HandlerScanner` does not take not of the parameterized types in its `visitMethod` method.