From 5178b2c7a5eb876f06912753e8251836bc3f1051 Mon Sep 17 00:00:00 2001 From: old driver Date: Mon, 17 May 2021 15:10:15 +0800 Subject: [PATCH] make Slf4JLoggerFactory be singleton (#11253) Motivation: The current initialization of Slf4JLoggerFactory is not singleton. Modification: Use Slf4JLoggerFactory.INSTANCE to initialize Slf4JLoggerFactory. Result: The instance of Slf4JLoggerFactory became a singleton. --- .../io/netty/util/internal/logging/InternalLoggerFactory.java | 2 +- .../java/io/netty/util/internal/logging/Slf4JLoggerFactory.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java b/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java index 80e1567c89..7ad7db8a01 100644 --- a/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java +++ b/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java @@ -59,7 +59,7 @@ public abstract class InternalLoggerFactory { private static InternalLoggerFactory useSlf4JLoggerFactory(String name) { try { - InternalLoggerFactory f = new Slf4JLoggerFactory(true); + InternalLoggerFactory f = Slf4JLoggerFactory.INSTANCE_WITH_NOP_CHECK; f.newInstance(name).debug("Using SLF4J as the default logging framework"); return f; } catch (LinkageError ignore) { diff --git a/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java b/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java index c7a6ed2fc0..512b7b5351 100644 --- a/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java +++ b/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java @@ -30,6 +30,8 @@ public class Slf4JLoggerFactory extends InternalLoggerFactory { @SuppressWarnings("deprecation") public static final InternalLoggerFactory INSTANCE = new Slf4JLoggerFactory(); + static final InternalLoggerFactory INSTANCE_WITH_NOP_CHECK = new Slf4JLoggerFactory(true); + /** * @deprecated Use {@link #INSTANCE} instead. */