Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resteasy vs Resteasy Reactive: Inconsistent behavior in path resolution when there's a trailing slash at the path #26016

Closed
brunobastosg opened this issue Jun 8, 2022 · 4 comments · Fixed by #26101
Assignees
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@brunobastosg
Copy link

Describe the bug

Given the following resource (notice the trailing / after /world):

@Path("/hello")
public class GreetingResource {

	@GET
	@Path("/world/") // this extra / at the end is intentional
	@Produces(MediaType.TEXT_PLAIN)
	public String helloWorld() {
		return "Hello World!";
	}
	
}

Using quarkus-resteasy:

curl -X GET -i http://localhost:8080/hello/world => returns 200 OK
curl -X GET -i http://localhost:8080/hello/world/ => returns 200 OK (notice the extra / at the end)

Using quarkus-resteasy-reactive:

curl -X GET -i http://localhost:8080/hello/world => returns 404 NOT FOUND
curl -X GET -i http://localhost:8080/hello/world/ => returns 200 OK (notice the extra / at the end)

Expected behavior

Behavior should be consistent Either both of them return 200 for the request without the trailing slash, or both of them return 404.

Actual behavior

Resteasy returns 200 for requests made with and without the trailing slash.

Resteasy Reactive returns 404 for the request made with no trailing slash and 200 when there's a trailing slash.

How to Reproduce?

  1. Create two Quarkus projects
  2. Add the dependency quarkus-resteasy to one of them and quarkus-resteasy-reactive to the other
  3. Create the following resource in both:
@Path("/hello")
public class GreetingResource {
	@GET
	@Path("/world/")
	@Produces(MediaType.TEXT_PLAIN)
	public String hello() {
		return "Hello World!";
	}
}
  1. Make requests to /hello/world with and without the trailing slash

Output of uname -a or ver

Microsoft Windows [version 10.0.19043.1706]

Output of java -version

java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: D:\apache-maven-3.8.1\bin.. Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_301\jre Default locale: pt_BR, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@brunobastosg brunobastosg added the kind/bug Something isn't working label Jun 8, 2022
@quarkus-bot quarkus-bot bot added area/rest env/windows Impacts Windows machines labels Jun 8, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 8, 2022

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jun 9, 2022

I am not sure what the proper handling is here... My feeling is that RESTEasy Reactive does the right thing. WDYT @stuartwdouglas ?

@geoand geoand removed the env/windows Impacts Windows machines label Jun 9, 2022
@technical-debt-collector
Copy link
Contributor

Having googled for a bit, it sure looks like most people consider "/resource/" and "/resource" to be two different things.
But the latest JAX-RS specification (3.0) seems to say otherwise:
bilde
Point 4 essentially implies that two different resource paths with a trailing slash as the only difference are equivalent.

Looks like it's been this way since 1.0 too, someone on StackOverflow pointed out this exact thing in 2013 as well: https://stackoverflow.com/a/15215730

geoand added a commit to geoand/quarkus that referenced this issue Jun 14, 2022
RESTEasy Classic already behaves properly, so we should follow this patterns

Fixes: quarkusio#26016
@geoand
Copy link
Contributor

geoand commented Jun 14, 2022

Indeed point 4 seems pretty unambiguous (although I am surprised the TCK does not test it...)

In any case, #26101 takes care of it

geoand added a commit to geoand/quarkus that referenced this issue Jun 14, 2022
RESTEasy Classic already behaves properly, so we should follow this patterns

Fixes: quarkusio#26016
@geoand geoand self-assigned this Jun 14, 2022
gastaldi added a commit that referenced this issue Jun 14, 2022
Make RESTEasy Reactive path matching more spec compliant
@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants