Skip to content

Commit

Permalink
Merge #2528 into 1.1.0-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Oct 6, 2022
2 parents 9962168 + 9662c6f commit e7f547e
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 32 deletions.
Expand Up @@ -54,7 +54,9 @@ public void channelActive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionOpened(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -68,7 +70,9 @@ public void channelInactive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionClosed(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down Expand Up @@ -111,7 +115,9 @@ else if (msg instanceof DatagramPacket) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -137,7 +143,9 @@ else if (msg instanceof DatagramPacket) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -151,7 +159,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
recordException(ctx, remoteAddress != null ? remoteAddress : ctx.channel().remoteAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand Down
Expand Up @@ -348,8 +348,10 @@ protected static final class PoolFactory<T extends Connection> {
Double.parseDouble(System.getProperty(ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE, "0"));
if (getPermitsSamplingRate > 1d) {
DEFAULT_POOL_GET_PERMITS_SAMPLING_RATE = 0;
log.warn("Invalid configuration [" + ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE + "=" + getPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy in not enabled.");
if (log.isWarnEnabled()) {
log.warn("Invalid configuration [" + ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE + "=" + getPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy in not enabled.");
}
}
else {
DEFAULT_POOL_GET_PERMITS_SAMPLING_RATE = getPermitsSamplingRate;
Expand All @@ -362,8 +364,10 @@ protected static final class PoolFactory<T extends Connection> {
Double.parseDouble(System.getProperty(ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE, "0"));
if (returnPermitsSamplingRate > 1d) {
DEFAULT_POOL_RETURN_PERMITS_SAMPLING_RATE = 0;
log.warn("Invalid configuration [" + ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE + "=" + returnPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy is enabled.");
if (log.isWarnEnabled()) {
log.warn("Invalid configuration [" + ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE + "=" + returnPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy is enabled.");
}
}
else {
DEFAULT_POOL_RETURN_PERMITS_SAMPLING_RATE = returnPermitsSamplingRate;
Expand Down
Expand Up @@ -136,7 +136,9 @@ void record(long resolveTimeStart, String status, SocketAddress remoteAddress) {
status);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down
Expand Up @@ -400,7 +400,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
.eventLoop()
.schedule(enableAutoReadTask, 1, TimeUnit.SECONDS)
.addListener(future -> {
if (!future.isSuccess()) {
if (!future.isSuccess() && log.isDebugEnabled()) {
log.debug(format(ctx.channel(), "Cannot enable auto-read"), future.cause());
}
});
Expand All @@ -419,7 +419,9 @@ void enableAutoReadTask(Channel channel) {

static void forceClose(Channel child, Throwable t) {
child.unsafe().closeForcibly();
log.warn(format(child, "Failed to register an accepted channel: {}"), child, t);
if (log.isWarnEnabled()) {
log.warn(format(child, "Failed to register an accepted channel: {}"), child, t);
}
}
}

Expand Down
Expand Up @@ -388,7 +388,9 @@ else if (alloc instanceof UnpooledByteBufAllocator) {
MicrometerEventLoopMeterRegistrar.INSTANCE.registerMetrics(channel.eventLoop());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down
Expand Up @@ -204,12 +204,16 @@ static void setChannelOptions(Channel channel, Map<ChannelOption<?>, ?> options,
}
try {
if (!channel.config().setOption((ChannelOption<Object>) e.getKey(), e.getValue())) {
log.warn(format(channel, "Unknown channel option '{}' for channel '{}'"), e.getKey(), channel);
if (log.isWarnEnabled()) {
log.warn(format(channel, "Unknown channel option '{}' for channel '{}'"), e.getKey(), channel);
}
}
}
catch (Throwable t) {
log.warn(format(channel, "Failed to set channel option '{}' with value '{}' for channel '{}'"),
e.getKey(), e.getValue(), channel, t);
if (log.isWarnEnabled()) {
log.warn(format(channel, "Failed to set channel option '{}' with value '{}' for channel '{}'"),
e.getKey(), e.getValue(), channel, t);
}
}
}
}
Expand Down
Expand Up @@ -120,8 +120,10 @@ public NettyOutbound send(Publisher<? extends ByteBuf> source) {
return Mono.error(e);
}
if (HttpUtil.getContentLength(outboundHttpMessage(), -1) == 0) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(msg));
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(msg));
}
msg.release();
return FutureMono.from(channel().writeAndFlush(newFullBodyMessage(Unpooled.EMPTY_BUFFER)));
}
Expand Down Expand Up @@ -154,8 +156,10 @@ public NettyOutbound sendObject(Object message) {
throw e;
}
if (HttpUtil.getContentLength(outboundHttpMessage(), -1) == 0) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(b));
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(b));
}
b.release();
return channel().writeAndFlush(newFullBodyMessage(Unpooled.EMPTY_BUFFER));
}
Expand Down
Expand Up @@ -95,14 +95,18 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
recordWrite(address);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
});
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -127,7 +131,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -140,7 +146,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
recordException(ctx);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand Down
Expand Up @@ -73,7 +73,9 @@ public void channelActive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionOpened(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -87,7 +89,9 @@ public void channelInactive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionClosed(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down Expand Up @@ -125,7 +129,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
ops.method().name(), ops.status().codeAsText().toString());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
// ops.hostAddress() == null when request decoding failed, in this case
Expand All @@ -140,7 +146,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -151,7 +159,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
finally {
Expand Down Expand Up @@ -190,7 +200,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -208,7 +220,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand Down
Expand Up @@ -123,7 +123,7 @@ final class WebsocketServerOperations extends HttpServerOperations
// This change is needed after the Netty change https://github.com/netty/netty/pull/11966
channel.read();
}
else {
else if (log.isDebugEnabled()) {
log.debug(format(channel, "Cannot bind WebsocketServerOperations after the handshake."));
}
});
Expand Down

0 comments on commit e7f547e

Please sign in to comment.