Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes an ordering bug in RESTEasy Reactive runtime handler assembly where @WithFormRead request filters were moved after the body handler but ended up reversed due to backward iteration and append order.
Changes:
- Preserve the original relative order of
@WithFormReadrequest filters when relocating them after body handling. - Add a regression test that verifies multiple
@WithFormReadfilters execute according to theirpriorityvalues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java | Adjusts filter relocation logic to keep @WithFormRead filters in the same order they had before being moved. |
| extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/WithFormReadFilterPriorityTest.java | Adds a regression test ensuring @WithFormRead filters run in increasing priority order. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for (int i = handlers.size() - 2; i >= 0; i--) { | ||
| var serverRestHandler = handlers.get(i); | ||
| if (serverRestHandler instanceof ResourceRequestFilterHandler resourceRequestFilterHandler) { | ||
| if (resourceRequestFilterHandler.isWithFormRead()) { | ||
| readBodyRequestFilters.add(handlers.remove(i)); | ||
| readBodyRequestFilters.add(0, handlers.remove(i)); |
|
Taken, For the record on the cost, the list only ever holds the Same verification as before, on and with the |
…y handler The filters are collected while walking the handler list backwards, because they are removed by index as we go, but the collected list was then appended as it was. That reversed them, so priorities were applied in reverse order. Insert each match at the front instead, which is what the existing comment already says should happen.
…ront Addresses review feedback: add(0, ..) on an ArrayList shifts elements on every insert. Collect with a plain append and flip the list once before appending it back.
ea21c97 to
d052944
Compare
Status for workflow
|
RuntimeResourceDeploymentmoves@WithFormReadrequest filters to the end of the handler list once the body handler is in place. It walks the list backwards, because it removes by index as it goes, but it then appended the collected filters in that same backwards order, so the filters ended up reversed and priorities were applied in reverse.The fix inserts each match at the front of the collected list instead, which keeps the order the handlers were already in. That is what the comment on the block already said should happen.
Added a test with three
@WithFormReadfilters atUSER + 100,USER + 200andUSER + 300that each append their name to a header, in the style of the existingReadBodyRequestFilterTest. With the fix it getsfirst/second/third; without it the same test getsthird/second/first.ReadBodyRequestFilterTest,ImpliedReadBodyRequestFilterTest,WithFormBodyTestandAnotherValidNonBlockingFiltersTeststill pass, 13 tests in total.