-
Notifications
You must be signed in to change notification settings - Fork 3k
Support overlapping paths on resource classes #47386
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
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clever, well done!
@FroMage do you also want to take a look at this?
...e/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java
Outdated
Show resolved
Hide resolved
cc @franz1981 as this one could potentially have a slight performance impact |
I have added few comments |
...e/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java
Outdated
Show resolved
Hide resolved
...e/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
Please @geoand wait to merge this till the comments are addressed or at least a round of profiling is performed 🙏 |
That's why I removed the |
...e/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java
Outdated
Show resolved
Hide resolved
...e/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
@franz1981 PTAL |
I would suggest to just return the match without allocating any list, but just the top match 🙏 |
This comment has been minimized.
This comment has been minimized.
@franz1981 no worries, I don't mind the back and forth as long as its not too nitpicky :) |
I now return an Iterator, which allows to try the next match. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a quick look at the patch and I have a small question: is the very common case where there is only one match fully optimized?
I think we should try to reduce allocations and logic to the minimum in this case.
Maybe it already is but it wasn't obvious so sorry if it's the case.
drafting this PR, I might be able to simplify more in the common case (where only one path matches). |
BTW, I'm not expecting things to go overcomplicated for very minor gains. I.e. maybe keeping the iterator makes sense but making sure that we don't allocate additional things given there's only one item. I will let you judge of finding the best compromise between readability and performance impact. |
@gsmet @franz1981 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I looked. I don't understand it anymore than the original implementation. But the test is valid, the improvement is there, and if it doesn't break anything, it's progress, so +1 from me 🤷 |
@franz1981 any final comments? |
Will take a look tomorrow morning 🙏 |
👌 |
@franz1981 Sorry for the ping, but it has been a few days since the last update. And I kind of want to get this off my plate :) |
@franz1981 is on PTO, so if he doesn't respond this week (which I fully expect him not to), I will just go ahead and merge this |
This comment has been minimized.
This comment has been minimized.
FYI: I rebased the PR onto main |
Status for workflow
|
This solves further problems in case when the paths are spread over multiple resource classes. Improves earlier PR: quarkusio#47386
This solves further problems in case when the paths are spread over multiple resource classes. Improves earlier PR: quarkusio#47386
Having partially matching paths on resource classes could lead to 404s, even though a matching resource method existed.
Lets take the example from #26496.
Calling
GET /base/123
would result in a 404./base/{id}
is a perfect match for that request, which result in theExtension
resource class being used.Quarkus-rest always only works on the basis of one resource class - the one with the best match.
I however believe that is not up to spec.
https://jakarta.ee/specifications/restful-ws/4.0/jakarta-restful-ws-spec-4.0.pdf
Chapter 3.5.2 Request Matching
Stage 1 only handles matching of the resource class path to the request uri -> both classes match.
Stage 2 figures out which of all resource methods in all matched resource classes matches against the request uri.
So basically, the current implementation results in Stage 1 only reporting one matching resource class, altough it should report 2.
This PR adds additional logic, so that all matching resource classes are remembered, and the handler chain is restarted if the current resource class does not contain a matchin sub resource method, or sub resource locator.
405 Method Not Allowed
#26496