From 9bf91aee37ddb8b973d2b91f37d7b1f442f7c69f Mon Sep 17 00:00:00 2001 From: "tomasz.kowalczewski" Date: Sat, 13 Feb 2021 23:10:57 +0100 Subject: [PATCH] FastThreadLocal only makes sens when accessed by thread we control (it needs to be a FastThreadLocalThread). --- .../pl/tkowalcz/tjahzi/log4j2/ByteBufferDestinations.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/loki-log4j2-appender/src/main/java/pl/tkowalcz/tjahzi/log4j2/ByteBufferDestinations.java b/loki-log4j2-appender/src/main/java/pl/tkowalcz/tjahzi/log4j2/ByteBufferDestinations.java index c357c1d..b2b0cfa 100644 --- a/loki-log4j2-appender/src/main/java/pl/tkowalcz/tjahzi/log4j2/ByteBufferDestinations.java +++ b/loki-log4j2-appender/src/main/java/pl/tkowalcz/tjahzi/log4j2/ByteBufferDestinations.java @@ -1,6 +1,5 @@ package pl.tkowalcz.tjahzi.log4j2; -import io.netty.util.concurrent.FastThreadLocal; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.layout.ByteBufferDestination; import org.apache.logging.log4j.core.layout.ByteBufferDestinationHelper; @@ -10,12 +9,7 @@ import java.util.function.BiConsumer; public class ByteBufferDestinations implements ByteBufferDestination { - private static final FastThreadLocal THREAD_LOCAL = new FastThreadLocal<>() { - @Override - protected ByteBufferDestinations initialValue() throws Exception { - return new ByteBufferDestinations(); - } - }; + private static final ThreadLocal THREAD_LOCAL = ThreadLocal.withInitial(ByteBufferDestinations::new); /** * 10kb should be enough for everyone. Even in case of 1000s of threads we will allocate at most 10s of MB of buffers.