Hi guys:
So I'll be honest, I took a look at the JSR311 spec around this and I'm not
spec-ologist but it feels like this should work. Seems that if there's a
regex in my @Path annotation then things don't work quite as I expected.
Here's a small test
@Path("/test")
public class TestResource {
@GET
@Path("/{one: abc.*}")
public Response firstMethod(@PathParam("one") String one) {
System.out.println("one");
System.out.println(one);
return Response.noContent().build(); // 204
}
@GET
@Path("/{one: (?!abc).*}")
public Response secondMethod(@PathParam("one") String one) {
System.out.println("two");
System.out.println(one);
return Response.notModified().build(); // 304
}
@POST
@Path("/{one}")
public Response thirdMethod(@PathParam("one") String one) {
System.out.println("three");
System.out.println(one);
return Response.ok().build(); // 200
}
}
And the following results for various requests:
GET
http://localhost:9998/test/abc123 -> 204
GET
http://localhost:9998/test/fred -> 304
POST
http://localhost:9998/test/fred -> 405!! <- NOT 200
This doesn't seem right. As an aside, I noticed that if I set
"secondMethod" to:
@GET
@Path("/{one}")
public Response secondMethod(@PathParam("one") String one) {
Things work as expected.
Now, I'll be honest, I'm not exactly a regex expert either and I'm having a
hard time with this. Is there a more correct way to say "does not match
'abc'"? I've tried a few combinations including [^a][^b][^c].*
Is this expected behavior or is this a bug? Like I said, I have a solution
to go forward with, just thought it was worth raising your attention to...
Thanks
Andy O