codeconsole commented on PR #16237:
URL: https://github.com/apache/grails-core/pull/16237#issuecomment-6304602477
@jdaugherty Thanks for round 4. The four notes are answered in their
threads. Since the approved head (a30f1d48bc) there are 24 commits, and several
change what round 4 verified, so they need a look before merge:
- **Problems.** `respond` no longer negotiates the type of a `ProblemDetail`
itself. It hands the problem to the return value handler of Spring MVC's
handler adapter (4223262ac3). So `ResponseBodyAdvice` beans scoped to the
controller and `ErrorResponse.Interceptor` beans apply, the status-mismatch
warning is Spring MVC's, and an `Accept` header Spring MVC cannot read fails
with its `HttpMediaTypeNotAcceptableException` for a status that is not an
error status, which its resolver answers with 406.
- Without `jackson-dataformat-xml`, a problem is written in JSON, and
`ProblemXml` and `ProblemBeans` are gone (6eb92d4045).
- `respond` takes an `ErrorResponse` (6711b33cc7), and web unit tests get
Spring MVC's handler adapter (eb33d5c098).
- The title and detail of a validation problem are resolved with the
application's messages (6f0e233cd5). Its default detail failed to parse on Java
17 and 21, which is what TestLens reported for 308382daa9; e8df1c38a2 fixes it.
- **JSON and XML through Spring MVC's response body handler.** With
`grails.web.rendering.json.spring`, and for a `jsonConfiguration`, `respond`
writes through Spring MVC's `RequestResponseBodyMethodProcessor`, so
`ResponseBodyAdvice` applies to all of it (713e9cecf8). With
`grails.web.rendering.xml.spring`, so do the ordinary beans it writes with
Spring's XML converter, and the writer bridge that path used is gone
(c89dd8d5c6).
- These bodies are UTF-8, and JSON is `application/json`, as Spring MVC
writes them, whatever `grails.converters.encoding` says.
- The action's `@JsonView` selects the properties written, other than a
problem's or a named configuration's (2edf529636).
- The prefix is read once per converter (c974ef9d70), fallbacks to the
legacy converter are reported per type and reason (b6a8045065), and binding
takes the mapper Spring MVC reads a `@RequestBody` with (20d80ce341).
- **Actions can return what a Spring MVC handler method returns**
(31f7b7753b). A `ResponseEntity` or another `HttpEntity`, `HttpHeaders`, a
`ProblemDetail`, an `ErrorResponse`, a `StreamingResponseBody` or a
`ResponseBodyEmitter` is written by the return value handlers of Spring MVC's
handler adapter, with the `ResponseBodyAdvice` that applies to the controller
and the action's `@JsonView` and `@ResponseStatus`, also from an error page's
action. Grails 8 wrote none of these, so they are written whatever the settings.
- The value of an action annotated `@ResponseBody`, or of a controller
annotated so, also through `@RestController`, is written as the body only with
the new `grails.controllers.responseBody`, `false` in Grails 9 and planned
`true` in Grails 10 (25a4633b5f), so a Grails 9 action annotated so still
renders its view by default.
- A `CompletableFuture`, `DeferredResult` or `Callable` such an action
returns is processed with the handler adapter's executor, timeout and
interceptors.
- **New opt-in, `grails.exceptionresolver.springHandlers`.** It is `false`
in Grails 9 and planned `true` in Grails 10. The `@ExceptionHandler` methods of
the controller and of the `@ControllerAdvice` beans scoped to it, Spring Boot's
`spring.mvc.problemdetails.enabled` handler among them, resolve the exceptions
actions throw, ahead of the Grails exception resolver (8ad6ea28f0). It also
finds the action of a URL a URL converter names, such as `show-book` with the
hyphenated one (30ba287d04).
- **Settings.** The keys and defaults of the new switches are in
`grails.config.Settings` (1fd9e1d73a, 25a4633b5f).
- The guides now plan `grails.converters.json.legacy` to change in Grails
10 together with the other two JSON settings (932df60b6b), so that Grails 10
does not default to strict binding next to a lenient `request.JSON`. That
changes the release plan agreed in round 2, so please confirm it.
- **Also:**
- null keys and key order of map associations as Jackson writes them
(c302ac4ae1);
- a test of the XML encoder's lookup of grails-xml (fc5c6e8f2e);
- a contract test that fails where Jackson adds a method the gated writers
do not forward (e30e151af7);
- the `spring-json-respond` example, which tests these end to end over
HTTP (085f56036b);
- the review notes: 1a57d26dab and 308382daa9, besides the two above.
- **Follow-up.** Grails' negotiation picks the format of renderers, views
and `withFormat`, and Spring MVC's the type of what it writes. Resolving Grails
formats through Spring MVC's negotiation is #16698, for Grails 10.
The module tests of each change, the `spring-json-respond` example on Java
21 and 25, and the web suites (`grails-web-common`, `grails-web-url-mappings`,
`grails-url-mappings`, `grails-async`, `grails-rest-transforms`, `grails-xml`,
`grails-views-gson`, `grails-openapi`, `grails-controllers`,
`grails-test-suite-web`) pass locally; CI on e8df1c38a2 is running.
--
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]