Skip to content

Commit

Permalink
Lower the logging level to DEBUG
Browse files Browse the repository at this point in the history
Related to #944
  • Loading branch information
violetagg committed Jan 14, 2020
1 parent 88cbf01 commit 083be1e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/main/java/reactor/netty/ByteBufFlux.java
Expand Up @@ -37,8 +37,8 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxOperator;
import reactor.core.publisher.Mono;

import static io.netty.util.ReferenceCountUtil.safeRelease;
import reactor.util.Logger;
import reactor.util.Loggers;

/**
* A decorating {@link Flux} {@link NettyInbound} with various {@link ByteBuf} related
Expand Down Expand Up @@ -266,18 +266,16 @@ public final ByteBufMono aggregate() {
CompositeByteBuf output = alloc.compositeBuffer();
return doOnNext(ByteBuf::retain)
.collectList()
.doOnDiscard(ByteBuf.class, b -> {
if (b.refCnt() > 0) {
safeRelease(b);
}
})
.doOnDiscard(ByteBuf.class, ByteBufFlux::safeRelease)
.handle((list, sink) -> {
if (!list.isEmpty()) {
try {
output.addComponents(true, list);
}
catch(IllegalReferenceCountException e) {
// buffers in the list were released
if (log.isDebugEnabled()) {
log.debug("", e);
}
}
}
if (output.isReadable()) {
Expand All @@ -287,11 +285,7 @@ public final ByteBufMono aggregate() {
sink.complete();
}
})
.doFinally(signalType -> {
if (output.refCnt() > 0) {
safeRelease(output);
}
});
.doFinally(signalType -> safeRelease(output));
})
.as(ByteBufMono::maybeFuse);
}
Expand Down Expand Up @@ -359,4 +353,19 @@ static ByteBufFlux maybeFuse(Flux<ByteBuf> source, ByteBufAllocator allocator) {
};

final static int MAX_CHUNK_SIZE = 1024 * 512; //500k

final static Logger log = Loggers.getLogger(ByteBufFlux.class);

static void safeRelease(ByteBuf byteBuf) {
if (byteBuf.refCnt() > 0) {
try {
byteBuf.release();
}
catch (IllegalReferenceCountException e) {
if (log.isDebugEnabled()) {
log.debug("", e);
}
}
}
}
}

0 comments on commit 083be1e

Please sign in to comment.