-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fragment cache not cleared on forward error dispatch #189
Comments
Hmm, well that's no good. I'll try reproduce it but from your explanation on the other issue it looks like that fragment collection is surviving between the original exception and the rendering of the error page, causing the original exception to happen again. I might need to think of something as alternative to that fragment cache... 🤔 |
Notes to future self: Had a think about this and there aren't any hooks that I can think of for using to clear the fragment cache. Thymeleaf's context object, in a web environment, uses an I tried to see if there were any hooks in Thymeleaf for being able to manage this myself. The template start/end looked promising, but a single So I'll need to think of something else. The first idea was to do away with the cache completely. This should work but I know some features like deeply-nested layout hierarchies currently rely on the cache as a mechanism for passing fragments across templates when there's no obvious link between them, eg: child template defines a "content" section and isn't used in the parent template but the "grandparent" template. |
Does counting the template depth work? You don't need to remember what the first template was as long as there are the same number of start/end events. |
Definitely something to look into. Seems Thymeleaf even has a |
OK, I've got a fix for this which will be part of the upcoming 2.5.0 release, but for now is available in the current 2.5.0-SNAPSHOT version available on the Maven Central snapshots repository. (I managed to recreate the problem in a personal project, then applied the snapshot version and it went away.) I've written some unit tests for always returning a fresh fragment collection/cache when it looks like we're processing a new layout (by checking the |
See thymeleaf/thymeleaf#750
That problem was solved by adding code to delete the
LayoutDialect::FragmentCollection
attribute before returning theerror
view.The text was updated successfully, but these errors were encountered: