File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
log4j-core/src/main/java/org/apache/logging/log4j/core/async Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 3636import org .apache .logging .log4j .core .util .Log4jThreadFactory ;
3737import org .apache .logging .log4j .core .util .Throwables ;
3838import org .apache .logging .log4j .message .Message ;
39- import org .apache .logging .log4j .util .LoaderUtil ;
4039
4140/**
4241 * Helper class for async loggers: AsyncLoggerDisruptor handles the mechanics of working with the LMAX Disruptor, and
@@ -54,7 +53,11 @@ class AsyncLoggerDisruptor extends AbstractLifeCycle {
5453 private static EventHandler <RingBufferLogEvent > createEventHandler () {
5554 if (DisruptorUtil .DISRUPTOR_MAJOR_VERSION == 3 ) {
5655 try {
57- return LoaderUtil .newInstanceOf ("org.apache.logging.log4j.core.async.RingBufferLogEventHandler" );
56+ return (EventHandler <RingBufferLogEvent >)
57+ // Avoid using `LoaderUtil`, which might choose an incorrect class loader – see #2768.
58+ Class .forName ("org.apache.logging.log4j.core.async.RingBufferLogEventHandler" )
59+ .getConstructor ()
60+ .newInstance ();
5861 } catch (final ReflectiveOperationException | LinkageError e ) {
5962 LOGGER .warn ("Failed to create event handler for LMAX Disruptor 3.x, trying version 4.x." , e );
6063 }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <entry xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xmlns =" https://logging.apache.org/xml/ns"
4+ xsi : schemaLocation =" https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+ type =" fixed" >
6+ <issue id =" 2768" link =" https://github.com/apache/logging-log4j2/pull/2768" />
7+ <description format =" asciidoc" >Fix `ClassCastException` in LMAX Disruptor 3 initialization</description >
8+ </entry >
You can’t perform that action at this time.
0 commit comments