eclipse-ee4j / eclipse-ee4j/jersey
Jersey picks wrong method when regular expressions are used
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
A JAX-RS interface has an existing method
```
@PUT
@Consumes("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
@Path("/models/{model}/data/{dataset}")
public DataSetId uploadData(@PathParam("model") ModelId id, @PathParam("dataset") DataSetId qualifier, LocationData data);
```
This method works just fine.
Now, I add a new method:
```
@GET
@Path("/models/{model}/data/{dataset}{path:(/[A-Za-z0-9]+/[A-Za-z0-9]+)*}{element:(/[A-Za-z0-9]+)?}")
public List getDirectChildren(@PathParam("model") ModelId id, @PathParam("dataset") DataSetId qualifier, @PathParam("path") List path, @PathParam("element") LevelId query);
```
This method also works as expected.
However, now when I try using the first method, I receive a 405:
```
INFO: 1 * Server responded with a response on thread http-bio-8181-exec-1
1 < 405
1 < Allow: GET,OPTIONS
```
What appears to be happening is that the call that was originally processed by uploadData(...) is now being sent to getDirectChildren(...). Both methods do match the same path (when "path" and "element" params are absent), but one of them is a PUT whereas the other one is a GET.
The expected behavior is for Jersey to still honor GET vs PUT when the resource path is ambiguous.
#### Affected Versions
[2.23.1]
Contributor guide
Assessment
This issue has not been assessed yet.