Commit 485d0ed8 authored by Brian Clozel's avatar Brian Clozel

Polish

Release allocated `DataBuffer` if an error happens during template
processing. Otherwise, this buffer will be automatically released when
written to the exchange.
parent 8533c3d5
...@@ -33,6 +33,7 @@ import reactor.core.publisher.Mono; ...@@ -33,6 +33,7 @@ import reactor.core.publisher.Mono;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.reactive.result.view.AbstractUrlBasedView; import org.springframework.web.reactive.result.view.AbstractUrlBasedView;
import org.springframework.web.reactive.result.view.View; import org.springframework.web.reactive.result.view.View;
...@@ -91,7 +92,8 @@ public class MustacheView extends AbstractUrlBasedView { ...@@ -91,7 +92,8 @@ public class MustacheView extends AbstractUrlBasedView {
writer.flush(); writer.flush();
} }
} }
catch (Throwable ex) { catch (Exception ex) {
DataBufferUtils.release(dataBuffer);
return Mono.error(ex); return Mono.error(ex);
} }
return exchange.getResponse().writeWith(Flux.just(dataBuffer)); return exchange.getResponse().writeWith(Flux.just(dataBuffer));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment