Skip to content

Commit fe8ecea

Browse files
Gordiychuknormanmaurer
authored andcommitted
Http2FrameLogger avoid hex dump of the ByteBufs when log disabled
Motivation: Currentry logger create hex dump even if log write will not apply. It's unecessary GC overhead. Modifications: Restore optimization from #3492 Result: Fixes #7025
1 parent 732b145 commit fe8ecea

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameLogger.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.netty.channel.ChannelHandlerAdapter;
2121
import io.netty.channel.ChannelHandlerContext;
2222
import io.netty.handler.logging.LogLevel;
23+
import io.netty.util.internal.StringUtil;
2324
import io.netty.util.internal.UnstableApi;
2425
import io.netty.util.internal.logging.InternalLogLevel;
2526
import io.netty.util.internal.logging.InternalLogger;
@@ -132,6 +133,10 @@ public void logUnknownFrame(Direction direction, ChannelHandlerContext ctx, byte
132133
}
133134

134135
private String toString(ByteBuf buf) {
136+
if (!logger.isEnabled(level)) {
137+
return StringUtil.EMPTY_STRING;
138+
}
139+
135140
if (level == InternalLogLevel.TRACE || buf.readableBytes() <= BUFFER_LENGTH_THRESHOLD) {
136141
// Log the entire buffer.
137142
return ByteBufUtil.hexDump(buf);

0 commit comments

Comments
 (0)