Skip to content

Commit

Permalink
Add doOnDiscard hook for streaming mode
Browse files Browse the repository at this point in the history
Potential fix for issue reported at
reactor/reactor-netty#1746
  • Loading branch information
rstoyanchev committed Aug 12, 2021
1 parent 7b80f4f commit 77a562d
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,18 @@ public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType eleme
}

if (isStreamingMediaType(contentType)) {
return message.writeAndFlushWith(body.map(buffer -> {
Hints.touchDataBuffer(buffer, hints, logger);
return Mono.just(buffer).doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
}));
return message
.writeAndFlushWith(body.map(buffer -> {
Hints.touchDataBuffer(buffer, hints, logger);
return Mono.just(buffer).doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
}))
.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
}

if (logger.isDebugEnabled()) {
body = body.doOnNext(buffer -> Hints.touchDataBuffer(buffer, hints, logger));
}
return message.writeWith(body);
return message.writeWith(body).doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
}

@Nullable
Expand Down

0 comments on commit 77a562d

Please sign in to comment.