Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBootMockMvcBuilderCustomizer can crash cryptically while collecting data that it would have discarded anyway #40500

Closed
dsyer opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@dsyer
Copy link
Member

dsyer commented Apr 24, 2024

If your @Controller method puts something in the ModelAndView map that throws an exception from its toString() (e.g. easy to do with anything in @RequestScope) a MockMvc test will, rather mysteriously, fail on that endpoint. It turns out that SpringBootMockMvcBuilderCustomizer is collecting "lines" of diagnostic data that it will eventually discard because DEBUG logging is off by default, but one of those lines contains the model map exposed via toString(), so it blows up before it has a chance to even decide whether it is discarding. It would be better to catch the exception and maybe report that as part of the diagnostics? Or maybe not even collect the data if it is going to be discarded anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants