From 485d0ed8bed45a46851ed9c286d81977800272a3 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 14 Sep 2017 10:06:34 +0200 Subject: [PATCH] Polish Release allocated `DataBuffer` if an error happens during template processing. Otherwise, this buffer will be automatically released when written to the exchange. --- .../boot/web/reactive/result/view/MustacheView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java b/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java index 6d66cb96b8..05e1feb35d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java @@ -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));