Polish
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:
parent
8533c3d5ca
commit
485d0ed8be
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue