Allow delaying first output until processing completely finishes
See original GitHub issueStreamlined execution flow causes a partially rendered template containing the error page with HTTP status code 200 on exceptions at view layer. This behavior is nonsatisfying for such a common use-case.
The servlet dispatcher should forward to the error page with HTTP status code 500 as it was the case in Thymeleaf < 3 already.
Based on the discussion here you need to write your own implementation of ITemplateEngine
when using Thymeleaf in conjunction with Spring MVC which is an ugly workaround.
Maybe putting a flag into SpringTemplateEngine
to make it configurable could be a better solution.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:12
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Proper way to wait for one function to finish before continuing?
For the second function, you can use async/await a function where you will await for the first function to complete before proceeding with...
Read more >Operating Systems: CPU Scheduling
A scheduling system allows one process to use the CPU while another is waiting for I/O, thereby making full use of otherwise lost...
Read more >Coding Timers and Delays in Arduino : 8 Steps - Instructables
1. Here is how NOT to code a delay in a sketch.
int led = 13;bool ledOn;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT); // initialize the digital...
Read more >Foreground and background processing—ArcMap
You will notice a brief delay on the first tool execution as the background process is started.
Read more >Python sleep(): How to Add Time Delays to Your Code
There are two ways to do this: Use time.sleep() as before. Use Event.wait() from the threading module. Let's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been implemented by means of a flag called
producePartialOutputWhileProcessing
, with default valuetrue
, that can be configured with its corresponding setter and getter method both at theThymeleafViewResolver
(for an application-wide setting) and atThymeleafView
objects (for template-specific setting).When set to
false
, Thymeleaf will buffer the entire produced output until processing completely finishes and only then output it as a single chunk to the web server’s output buffers.First (very informal) tests with very large HTML documents show no significative difference in time-to-last-result times with concurrent load = 1, but obviously huge differences in time-to-first-result times and memory consumption, so this should turn the web server very sensitive to increases in concurrent load.
I am not even arguing which one is better and am fine with Thymeleaf defaulting to streaming and having a strong opinion that this is the better approach. All I’m arguing is, that there should be an easy way to get back to the “old mode” of exception handling (i.e. exceptions trigger a forward to the error page under all circumstances) as that allows users to decouple both problems: if they were fine with in-memory rendering on TL2, they probably are with TL3 for a start. People starting with Thymeleaf 3 don’t have to be bothered with this. But migrations could now move to TL3 first and then spend dedicated time to tackle this problem. As it stands today, projects running into this problem will have a hard time to move to TL3 (or Spring Boot 2.0 transitively) at all.