jdaugherty opened a new pull request, #16490: URL: https://github.com/apache/grails-core/pull/16490
## Summary Keep `GrailsMockHttpServletResponse.reset()` from selecting a character writer before the next response chooses its output mode. The reset implementation currently calls `getWriter()` to replace the bound `GrailsWebRequest`'s cached output. Spring 7 enforces the servlet restriction against using both a writer and an output stream, so a subsequent binary or CSV download fails with `IllegalStateException: getWriter() has already been called`, even when the test reset the response before invoking the controller. Clear the cached web-request output with `setOut(null)` instead. `GrailsWebRequest.getOut()` already resolves the current response's writer lazily when text output is actually requested. ## Regression coverage Add tests with a bound `GrailsWebRequest` for: - Binary output after resetting a fresh response. - Binary output after resetting a response previously used for text. - Text output after resetting a response previously used for binary data. - Replacing a cached web-request writer without writing to the previous writer. This was diagnosed in a real controller integration test: the query and CSV generation succeeded, but the mock response had already acquired a writer during `reset()` before the download reached its output-stream write. ## Verification - `:grails-test-core:codeStyle` and `validateRepositoryConventions` passed. - `:grails-test-suite-uber:testAll`: **638 passed, 4 skipped, 0 failures** across the main and isolated test tasks. - `git diff --check` passed. - Full-repository test verification is left to CI. -- 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]
