Release allocated `DataBuffer` if an error happens during template
processing. Otherwise, this buffer will be automatically released when
written to the exchange.
This commit is contained in:
Brian Clozel 2017-09-14 10:06:34 +02:00
parent 8533c3d5ca
commit 485d0ed8be
1 changed files with 3 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import reactor.core.publisher.Mono;
import org.springframework.core.io.Resource;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.result.view.AbstractUrlBasedView;
import org.springframework.web.reactive.result.view.View;
@ -91,7 +92,8 @@ public class MustacheView extends AbstractUrlBasedView {
writer.flush();
}
}
catch (Throwable ex) {
catch (Exception ex) {
DataBufferUtils.release(dataBuffer);
return Mono.error(ex);
}
return exchange.getResponse().writeWith(Flux.just(dataBuffer));