File tree 2 files changed +13
-2
lines changed
log4j-core/src/main/java/org/apache/logging/log4j/core/async
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 36
36
import org .apache .logging .log4j .core .util .Log4jThreadFactory ;
37
37
import org .apache .logging .log4j .core .util .Throwables ;
38
38
import org .apache .logging .log4j .message .Message ;
39
- import org .apache .logging .log4j .util .LoaderUtil ;
40
39
41
40
/**
42
41
* Helper class for async loggers: AsyncLoggerDisruptor handles the mechanics of working with the LMAX Disruptor, and
@@ -54,7 +53,11 @@ class AsyncLoggerDisruptor extends AbstractLifeCycle {
54
53
private static EventHandler <RingBufferLogEvent > createEventHandler () {
55
54
if (DisruptorUtil .DISRUPTOR_MAJOR_VERSION == 3 ) {
56
55
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 ();
58
61
} catch (final ReflectiveOperationException | LinkageError e ) {
59
62
LOGGER .warn ("Failed to create event handler for LMAX Disruptor 3.x, trying version 4.x." , e );
60
63
}
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