Skip to content

Commit 485d0ed

Browse files
committed
Polish
Release allocated `DataBuffer` if an error happens during template processing. Otherwise, this buffer will be automatically released when written to the exchange.
1 parent 8533c3d commit 485d0ed

File tree

1 file changed

+3
-1
lines changed
  • spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view

1 file changed

+3
-1
lines changed

spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import org.springframework.core.io.Resource;
3535
import org.springframework.core.io.buffer.DataBuffer;
36+
import org.springframework.core.io.buffer.DataBufferUtils;
3637
import org.springframework.http.MediaType;
3738
import org.springframework.web.reactive.result.view.AbstractUrlBasedView;
3839
import org.springframework.web.reactive.result.view.View;
@@ -91,7 +92,8 @@ protected Mono<Void> renderInternal(Map<String, Object> model, MediaType content
9192
writer.flush();
9293
}
9394
}
94-
catch (Throwable ex) {
95+
catch (Exception ex) {
96+
DataBufferUtils.release(dataBuffer);
9597
return Mono.error(ex);
9698
}
9799
return exchange.getResponse().writeWith(Flux.just(dataBuffer));

0 commit comments

Comments
 (0)