eclipse-ee4j / eclipse-ee4j/jersey

@Path regexp too greedy

Open
#3,039 5 comments 0 reactions 0 assignees View on GitHub
Component: core Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Imagine we have the following REST resource. We want the @GET method handle URLs like both "/1" and "/1/foo", so we use a regexp in @Path:

```
@GET
@Path("/{id}{name: (/\\w+)?}")
public String get(@PathParam("id") Long id, @PathParam("name") String name) {
LOG.log(Level.INFO, "GET {0} {1}", new Object[]{id, name});
return "Foo";
}

@DELETE
@Path("/{id}")
public void delete(@PathParam("id") Long id) {
LOG.log(Level.INFO, "DELETE {0}", id);
}
```

The @GET method works, but @DELETE gets broken (405 Method Not Allowed). Seems like @GET mapping shadows that of @DELETE, and the request is being routed to @GET handler despite HTTP method annotation.
#### Environment
Oracle JDK 1.8.0_31
GlassFish v4.1 b13 nightly 12-15-2014
#### Affected Versions
[2.13]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.