Skip to content

Commit b120443

Browse files
Separate leak detection logging from buffer release logic
Co-authored-by: FabianMeiswinkel <19165014+FabianMeiswinkel@users.noreply.github.com>
1 parent ff57b2a commit b120443

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/http/ReactorNettyClient.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,13 @@ public Mono<ByteBuf> body() {
354354
bodyIntern().doOnDiscard(
355355
ByteBuf.class,
356356
buf -> {
357-
if (leakDetectionDebuggingEnabled && buf.refCnt() > 0) {
357+
if (leakDetectionDebuggingEnabled) {
358358
buf.touch("ReactorNettyHttpResponse.body - onDiscard - refCnt: " + buf.refCnt());
359359
logger.info("ReactorNettyHttpResponse.body - onDiscard - refCnt: {}", buf.refCnt());
360360
}
361-
ReferenceCountUtil.safeRelease(buf);
361+
if (buf.refCnt() > 0) {
362+
ReferenceCountUtil.safeRelease(buf);
363+
}
362364
})
363365
)
364366
.aggregate()
@@ -418,11 +420,13 @@ private void releaseOnNotSubscribedResponse(ReactorNettyResponseState reactorNet
418420

419421
body()
420422
.doOnNext(buf -> {
421-
if (leakDetectionDebuggingEnabled && buf.refCnt() > 0) {
423+
if (leakDetectionDebuggingEnabled) {
422424
buf.touch("ReactorNettyHttpResponse.releaseOnNotSubscribedResponse - refCnt: " + buf.refCnt());
423425
logger.info("ReactorNettyHttpResponse.releaseOnNotSubscribedResponse - refCnt: {}", buf.refCnt());
424426
}
425-
ReferenceCountUtil.safeRelease(buf);
427+
if (buf.refCnt() > 0) {
428+
ReferenceCountUtil.safeRelease(buf);
429+
}
426430
})
427431
.subscribe(v -> {}, ex -> {}, () -> {});
428432
}

0 commit comments

Comments
 (0)