Skip to content

Commit

Permalink
Merge branch '0.8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Mar 14, 2019
2 parents 42f0b52 + 32be1c7 commit 0560154
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/reactor/netty/ByteBufFlux.java
Expand Up @@ -256,10 +256,23 @@ public final Flux<String> asString(Charset charset) {
*/
public ByteBufMono aggregate() {
return Mono.using(alloc::compositeBuffer,
b -> this.reduce(b, (prev, next) -> prev.addComponent(next.retain()))
b -> this.reduce(b,
(prev, next) -> {
if (prev.refCnt() > 0) {
return prev.addComponent(next.retain());
}
else {
return prev;
}
})
.doOnNext(cbb -> cbb.writerIndex(cbb.capacity()))
.filter(ByteBuf::isReadable),
ByteBuf::release).as(ByteBufMono::new);
b -> {
if (b.refCnt() > 0) {
b.release();
}
})
.as(ByteBufMono::new);
}

/**
Expand Down

0 comments on commit 0560154

Please sign in to comment.