Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions grails-doc/src/en/guide/upgrading/upgrading90x.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ The route is now set before the Grails interceptors run, so that a failure in on
An interceptor whose `before()` returns `false`, to render a 403 or to redirect, stopped the request before its route was set, so the request was reported with a `uri` of `UNKNOWN`, or `REDIRECTION` for a redirect.
It is now reported under the route of the action, so a dashboard or alert keyed on those `uri` values sees those requests move.

* *On Undertow, a request reads as its own dispatch again once a forward returns.*
Undertow left a request reading as a forward once a forward to a path had returned, as Tomcat and Jetty do not.
Spring Framework 7.1's observation filter then took an asynchronous request that had forwarded, for example to an error controller, for a plain one, and reported its failure twice.
`grails-undertow` now restores the dispatcher type when the forward returns, so a filter that reads `getDispatcherType()` once its chain has returned sees `REQUEST` or `ASYNC` rather than `FORWARD`, as it does on Tomcat and Jetty.

* *`http.server.requests.active` is no longer registered by default.*
Spring Boot 4.2 makes this long task timer opt-in.
A dashboard or alert that reads it sets `management.metrics.observations.include-active-long-task-timer` to `true`, which replaces `management.metrics.observations.ignored-meters`.
Expand Down
1 change: 1 addition & 0 deletions grails-skills/upgrade/skills/grails-upgrade/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Grails 9 moves from Spring Boot 4.1 and Spring Framework 7.0, which Grails 8 use
- **Nested `@Configuration` classes in tests.** The Spring TestContext Framework now adds a static nested `@Configuration` class of a test's superclasses and enclosing classes to the test's application context, where it ignored such a class unless its class hierarchy declared `@ContextConfiguration`. Grails 8 already logs a warning for each one it ignores, so a test run on Grails 8 shows the affected tests. Remove the `@Configuration` annotation, or move the class to a top-level class, if the test should not load it.
- **`bootBuildImage` builds on Ubuntu 26.04.** The default builder is `paketobuildpacks/ubuntu-resolute-builder`, in place of `paketobuildpacks/builder-noble-java-tiny`, and images are based on Ubuntu 26.04 instead of 24.04. With no `builder` configured, the run image is `paketobuildpacks/ubuntu-resolute-run-tiny:latest`, which still has no shell; with one configured, it is the run image of the builder, which for `ubuntu-resolute-builder` has a shell. The builder no longer pins the version of the run image, so set both `builder` and `runImage` to specific versions for repeatable images, or set `builder` to `paketobuildpacks/builder-noble-java-tiny` to keep the previous one.
- **An exception an action throws is recorded as an error on the HTTP server observation.** When an error view answered, as the `"500"(view: '/error')` mapping of a generated application does, `http.server.requests` tagged the 500 with `error` and `exception` values of `none`, and tracing did not see a failure. A `500` mapping to a controller tagged it with `GrailsWrappedRuntimeException` and with the `uri` of that controller. Both now report the exception the action threw, an `Error` such as a failed `assert` included, and the route of the action, and the span of the request is marked as failed. These requests were already counted with `outcome=SERVER_ERROR`, but an alert that counts a non-`none` `error` value sees more server errors than before, and a dashboard that reads the `uri` of an error controller finds those failures under the routes of the actions. A client error is not recorded, and neither is a failure inside `g:include`. After a forward to an error controller, the `jakarta.servlet.error.exception` request attribute holds the exception the action threw rather than a `GrailsWrappedRuntimeException`, for a filter that reads it once the chain has returned; inside the error controller it still holds the wrapper. The route is now set before the Grails interceptors run, so a request an interceptor's `before()` stops by returning `false`, to render a 403 or to redirect, is reported under the route of the action, where it was reported with a `uri` of `UNKNOWN`, or `REDIRECTION` for a redirect; a dashboard or alert keyed on those `uri` values sees those requests move.
- **On Undertow, a request reads as its own dispatch again once a forward returns.** Undertow left a request reading as a forward once a forward to a path had returned, so Spring Framework 7.1's observation filter took an asynchronous request that had forwarded, for example to an error controller, for a plain one and reported its failure twice. `grails-undertow` now restores the dispatcher type when the forward returns, as Tomcat and Jetty do: a filter that reads `getDispatcherType()` once its chain has returned sees `REQUEST` or `ASYNC` rather than `FORWARD`.
- **`http.server.requests.active` is no longer registered by default.** Spring Boot 4.2 makes this long task timer opt-in. A dashboard or alert that reads it sets `management.metrics.observations.include-active-long-task-timer` to `true`, which replaces `management.metrics.observations.ignored-meters`.
- **`spring-boot-starter-amqp` no longer means RabbitMQ.** It is now the starter for generic AMQP 1.0. An application that uses RabbitMQ through `spring-boot-starter-amqp` or `spring-boot-starter-amqp-test` changes to `spring-boot-starter-rabbitmq` or `spring-boot-starter-rabbitmq-test`, and any import of `org.springframework.boot.amqp.autoconfigure` to `org.springframework.boot.rabbitmq.autoconfigure`. RabbitMQ over AMQP 1.0 has `spring-boot-starter-amqp-rabbitmq`.
- **The Spring Security plugin no longer saves the requests browsers send on their own.** A denied request for `/apple-touch-icon.png`, `/manifest.json` or the `/.well-known/appspecific/com.chrome.devtools.json` that Chrome DevTools sends used to be saved, so a login redirected to it instead of to the page the user asked for. The plugin now ignores these paths, with `grails.plugin.springsecurity.requestCache.ignoredPatterns`. An application that secures a page at one of these paths and wants a login to return to it leaves the path out of that list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

package issue11102

import org.springframework.http.HttpStatus
import org.springframework.web.context.request.async.DeferredResult
import org.springframework.web.context.request.async.WebAsyncManager
import org.springframework.web.context.request.async.WebAsyncUtils
import org.springframework.web.server.ResponseStatusException
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.servlet.view.InternalResourceView

Expand Down Expand Up @@ -64,6 +66,19 @@ class FailingController {
throw new StackOverflowError('answered by the error controller')
}

def answeredByFailingController() {
throw new IndexOutOfBoundsException('answered by an error controller that fails')
}

def answeredByControllerFailingWithServerError() {
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByControllerFailingWithServerErrorAfterStartingAsync() {
startAsyncThatTimesOut()
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByForwardingController() {
throw new ArithmeticException('answered by an error controller that forwards')
}
Expand Down Expand Up @@ -141,6 +156,14 @@ class FailingController {
render status: 500, text: 'Answered by the error controller'
}

def failingErrorHandler() {
throw new IllegalArgumentException('the error controller failed as well')
}

def errorHandlerFailingWithServerError() {
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, 'the error controller failed with a server error')
}

def forwardingErrorHandler() {
forward(action: 'errorHandler')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class UrlMappings {
"500"(controller: 'failing', action: 'errorHandler', exception: StackOverflowError)
"500"(controller: 'failing', action: 'forwardingErrorHandler', exception: ArithmeticException)
"500"(controller: 'failing', action: 'includingErrorHandler', exception: NoSuchElementException)
"500"(controller: 'failing', action: 'failingErrorHandler', exception: IndexOutOfBoundsException)
"500"(controller: 'failing', action: 'errorHandlerFailingWithServerError', exception: IllegalMonitorStateException)
"500"(view:'/error')
"404"(controller: 'failing', action: 'notFoundHandler')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,33 @@ class FailedActionObservationSpec extends Specification implements HttpClientSup
'the error view, for an Error' | '/failing/answeredByViewForAnError' | '/failing/answeredByViewForAnError' | 'An error has occurred' || 'AssertionError'
'an error controller, for an Error' | '/failing/answeredByControllerForAnError' | '/failing/answeredByControllerForAnError' | 'Answered by the error controller' || 'StackOverflowError'
'an error controller that forwards' | '/failing/answeredByForwardingController' | '/failing/answeredByForwardingController' | 'Answered by the error controller' || 'ArithmeticException'
'an error controller that fails' | '/failing/answeredByFailingController' | '/failing/answeredByFailingController' | 'An error has occurred' || 'IndexOutOfBoundsException'
'the error view, after an include' | '/failing/failsAfterInclude' | '/failing/failsAfterInclude' | 'An error has occurred' || 'IllegalStateException'
'an error controller, after an include' | '/failing/failsAfterIncludeAnsweredByController' | '/failing/failsAfterIncludeAnsweredByController' | 'Answered by the error controller' || 'UnsupportedOperationException'
'an error controller, after an interceptor failed' | '/failing/failsInInterceptor' | '/failing/failsInInterceptor' | 'Answered by the error controller' || 'UnsupportedOperationException'
}

void 'a failed action is reported once with its own exception when its error controller fails with a server error Spring MVC resolves, #when'() {
when:
def response = http([(REQUEST_HEADER): path], path)

then: 'Spring MVC answered the failure of the error controller'
response.assertStatus(503)

and: 'the observation stopped with what the action threw, and the handlers heard of it once'
// Not its route: the container's error page that answers the 503 of an asynchronous request is dispatched to
// before the observation stops, and sets its own (spring-projects/spring-framework#37675)
new PollingConditions(timeout: 30).eventually {
assert STOPPED[path]?.last() == 'IllegalMonitorStateException'
}
NOTIFIED[path] == ['IllegalMonitorStateException']

where:
when | path
'on a request dispatch' | '/failing/answeredByControllerFailingWithServerError'
'after the action started async' | '/failing/answeredByControllerFailingWithServerErrorAfterStartingAsync'
}

void 'a failure #handler answers inside an include is not the failure of the page that included it'() {
when:
def response = http([(REQUEST_HEADER): path], path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/
package issue12688

import org.springframework.http.HttpStatus
import org.springframework.web.context.request.async.DeferredResult
import org.springframework.web.context.request.async.WebAsyncManager
import org.springframework.web.context.request.async.WebAsyncUtils
import org.springframework.web.server.ResponseStatusException
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.servlet.view.InternalResourceView

Expand Down Expand Up @@ -63,6 +65,19 @@ class FailingController {
throw new StackOverflowError('answered by the error controller')
}

def answeredByFailingController() {
throw new IndexOutOfBoundsException('answered by an error controller that fails')
}

def answeredByControllerFailingWithServerError() {
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByControllerFailingWithServerErrorAfterStartingAsync() {
startAsyncThatTimesOut()
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByForwardingController() {
throw new ArithmeticException('answered by an error controller that forwards')
}
Expand Down Expand Up @@ -124,6 +139,14 @@ class FailingController {
render status: 500, text: 'Answered by the error controller'
}

def failingErrorHandler() {
throw new IllegalArgumentException('the error controller failed as well')
}

def errorHandlerFailingWithServerError() {
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, 'the error controller failed with a server error')
}

def forwardingErrorHandler() {
forward(action: 'errorHandler')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class UrlMappings {
"500"(controller: 'failing', action: 'errorHandler', exception: StackOverflowError)
"500"(controller: 'failing', action: 'forwardingErrorHandler', exception: ArithmeticException)
"500"(controller: 'failing', action: 'includingErrorHandler', exception: NoSuchElementException)
"500"(controller: 'failing', action: 'failingErrorHandler', exception: IndexOutOfBoundsException)
"500"(controller: 'failing', action: 'errorHandlerFailingWithServerError', exception: IllegalMonitorStateException)
"413"(controller: 'upload', action: 'tooLarge')
"404"(view: '/notFound')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,32 @@ class JettyFailedActionObservationSpec extends Specification implements HttpClie
'the error view, for an Error' | '/failing/answeredByViewForAnError' | '/failing/answeredByViewForAnError' | 'An error has occurred' || 'AssertionError'
'an error controller, for an Error' | '/failing/answeredByControllerForAnError' | '/failing/answeredByControllerForAnError' | 'Answered by the error controller' || 'StackOverflowError'
'an error controller that forwards' | '/failing/answeredByForwardingController' | '/failing/answeredByForwardingController' | 'Answered by the error controller' || 'ArithmeticException'
'an error controller that fails' | '/failing/answeredByFailingController' | '/failing/answeredByFailingController' | 'An error has occurred' || 'IndexOutOfBoundsException'
'the error view, after an include' | '/failing/failsAfterInclude' | '/failing/failsAfterInclude' | 'An error has occurred' || 'IllegalStateException'
'an error controller, after an include' | '/failing/failsAfterIncludeAnsweredByController' | '/failing/failsAfterIncludeAnsweredByController' | 'Answered by the error controller' || 'UnsupportedOperationException'
}

void 'a failed action is reported once with its own exception when its error controller fails with a server error Spring MVC resolves, #when'() {
when:
def response = http([(REQUEST_HEADER): path], path)

then: 'Spring MVC answered the failure of the error controller'
response.assertStatus(503)

and: 'the observation stopped with what the action threw, and the handlers heard of it once'
// Not its route: the container's error page that answers the 503 of an asynchronous request is dispatched to
// before the observation stops, and sets its own (spring-projects/spring-framework#37675)
new PollingConditions(timeout: 30).eventually {
assert STOPPED[path]?.last() == 'IllegalMonitorStateException'
}
NOTIFIED[path] == ['IllegalMonitorStateException']

where:
when | path
'on a request dispatch' | '/failing/answeredByControllerFailingWithServerError'
'after the action started async' | '/failing/answeredByControllerFailingWithServerErrorAfterStartingAsync'
}

void 'a failure #handler answers inside an include is not the failure of the page that included it'() {
when:
def response = http([(REQUEST_HEADER): path], path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/
package undertowapp

import org.springframework.http.HttpStatus
import org.springframework.web.context.request.async.DeferredResult
import org.springframework.web.context.request.async.WebAsyncManager
import org.springframework.web.context.request.async.WebAsyncUtils
import org.springframework.web.server.ResponseStatusException
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.servlet.view.InternalResourceView

Expand Down Expand Up @@ -63,6 +65,19 @@ class FailingController {
throw new StackOverflowError('answered by the error controller')
}

def answeredByFailingController() {
throw new IndexOutOfBoundsException('answered by an error controller that fails')
}

def answeredByControllerFailingWithServerError() {
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByControllerFailingWithServerErrorAfterStartingAsync() {
startAsyncThatTimesOut()
throw new IllegalMonitorStateException('answered by an error controller that fails with a server error')
}

def answeredByForwardingController() {
throw new ArithmeticException('answered by an error controller that forwards')
}
Expand Down Expand Up @@ -124,6 +139,14 @@ class FailingController {
render status: 500, text: 'Answered by the error controller'
}

def failingErrorHandler() {
throw new IllegalArgumentException('the error controller failed as well')
}

def errorHandlerFailingWithServerError() {
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, 'the error controller failed with a server error')
}

def forwardingErrorHandler() {
forward(action: 'errorHandler')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class UrlMappings {
"500"(controller: 'failing', action: 'errorHandler', exception: StackOverflowError)
"500"(controller: 'failing', action: 'forwardingErrorHandler', exception: ArithmeticException)
"500"(controller: 'failing', action: 'includingErrorHandler', exception: NoSuchElementException)
"500"(controller: 'failing', action: 'failingErrorHandler', exception: IndexOutOfBoundsException)
"500"(controller: 'failing', action: 'errorHandlerFailingWithServerError', exception: IllegalMonitorStateException)
"500"(controller: 'errorPage', action: 'handle', exception: StaticInitFailure)
"413"(controller: 'upload', action: 'tooLarge')
"404"(view: '/notFound')
Expand Down
Loading
Loading