reiern70 opened a new pull request, #1696: URL: https://github.com/apache/wicket/pull/1696
`RequestCycle` follows a `ReplaceHandlerException` (`AbortWithHttpErrorCodeException`, `RestartResponseException`, `RedirectToUrlException` and the like) only while a request handler executes. One thrown while the request is mapped, before there is a handler, goes to the `onException` listeners and the exception mapper like any other exception, and ends on the error page or as a 500. That is how the 400 for an ajax request without a base url (WICKET-4841) got lost. `ServletWebRequest#getClientUrl()` throws it, but since WICKET-5071 `BookmarkableMapper` and `PageInstanceMapper` call `getClientUrl()` while they map the request, so for an ajax request it is first called during mapping and the client gets a 500. The test added with WICKET-4841 only checks the exception `getClientUrl()` throws, so it kept passing. #1673, which answers a malformed base url the same way, runs into the same problem: with this change it does answer 400. The change routes an exception thrown by `resolveRequestHandler()` through the same code `execute()` already uses for one thrown by a handler, including dropping the scheduled handler when the exception asks for it. Tests: - `RequestCycleListenerTest#replaceExceptionDuringMapping` mirrors the existing replace-during-response cases in `basicOperations`, with and without dropping the scheduled handler. - `RequestCycleListenerTest#exceptionDuringMappingIsMapped`: any other exception thrown while mapping still goes to the listeners and the exception mapper. - `ServletWebRequestTest#ajaxRequestWithoutBaseUrlAnswersBadRequest` sends an ajax request without a base url through `WicketTester` and checks the status the client gets. It fails on master. **Behaviour change.** An application that throws a flow exception from a request mapper, or from anything a mapper calls, now has it followed: a `RestartResponseException` renders its page, a `RedirectToUrlException` redirects, an `AbortWithHttpErrorCodeException` answers its status code. Its `onException` listeners and its exception mapper no longer see these exceptions, and `onRequestHandlerResolved` is called for the replacement handler. Any other exception thrown while mapping is handled as before. Suggested migration guide wording: *A `ReplaceHandlerException` (`RestartResponseException`, `RedirectToUrlException`, `AbortWithHttpErrorCodeException`, …) thrown while a request is mapped is now followed, as it always was while a request handler executes. Before, it was handed to `IRequestCycleListener#onException` and the `IExceptionMapper` and usually ended on the error page. An application whose mapper throws one and relied on the error page has to throw a different exception instead.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
