This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch fix/3706_disruptor-tccl
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 53c81d6cc67fe25a091cd2fde241b68047b513e0
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Wed Jun 25 10:00:41 2025 +0200

    fix: correctly detect Disruptor major version
    
    Ensure the Disruptor version is detected using the classloader that loaded 
`DisruptorUtil`, rather than the thread-context classloader. The previous 
implementation relied on `LoaderUtil.isClassAvailable`, which may fail in 
environments where the Disruptor classes aren't visible to the thread-context 
classloader.
---
 .../apache/logging/log4j/core/async/DisruptorUtil.java    | 15 +++++++++++++--
 src/changelog/.2.x.x/3706_disruptor-tccl.xml              | 13 +++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
index bdd21bd4ef..f115e2ae37 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
@@ -50,8 +50,19 @@ final class DisruptorUtil {
     static final boolean ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL = 
PropertiesUtil.getProperties()
             
.getBooleanProperty("AsyncLoggerConfig.SynchronizeEnqueueWhenQueueFull", true);
 
-    static final int DISRUPTOR_MAJOR_VERSION =
-            
LoaderUtil.isClassAvailable("com.lmax.disruptor.SequenceReportingEventHandler") 
? 3 : 4;
+    static final int DISRUPTOR_MAJOR_VERSION = detectDisruptorMajorVersion();
+
+    // TODO: replace with LoaderUtil.isClassAvailable() when TCCL is removed
+    // See: https://github.com/apache/logging-log4j2/issues/3706
+    private static int detectDisruptorMajorVersion() {
+        try {
+            Class.forName(
+                    "com.lmax.disruptor.SequenceReportingEventHandler", true, 
DisruptorUtil.class.getClassLoader());
+            return 3;
+        } catch (final ClassNotFoundException e) {
+            return 4;
+        }
+    }
 
     private DisruptorUtil() {}
 
diff --git a/src/changelog/.2.x.x/3706_disruptor-tccl.xml 
b/src/changelog/.2.x.x/3706_disruptor-tccl.xml
new file mode 100644
index 0000000000..7d7a1a3002
--- /dev/null
+++ b/src/changelog/.2.x.x/3706_disruptor-tccl.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+           https://logging.apache.org/xml/ns
+           https://logging.apache.org/xml/ns/log4j-changelog-0.xsd";
+       type="fixed">
+  <issue id="3758" 
link="https://github.com/apache/logging-log4j2/issues/3758"/>
+  <description format="asciidoc">
+    Move `jspecify.version` Maven property and `java8-tests` profile from 
`log4j-bom` to `log4j-parent`, since the
+    former gets trimmed before deployment.
+  </description>
+</entry>

Reply via email to