Skip to content

NPE in org.apache.logging.log4j.core.async.RingBufferLogEventHandler4.notifyCallback() #3706

Open
@verjan-isencia

Description

@verjan-isencia

Description

When using BasicAsyncLoggerContextSelector in log4j2 v2.24.3, when logging RingBufferLogEventHandler4.notifyCallback() is called, and it tries to use an instance variable sequenceCallback that is not set. I am using disruptor v3.4.4.202406060700, because according to the manifest file of log4j2-core, the accepted range of versions of disruptor is from 3.4 to 4 (excluded).

But it appears to me that the RingBufferLogEventHandler4 implementation is conceived for disruptor 4. There is a method defined to set the value of sequenceCallback:

/*
* Overrides a method from Disruptor 4.x. Do not remove.
*/

public void setSequenceCallback(final Sequence sequenceCallback) {
    this.sequenceCallback = sequenceCallback;
}

So I suspect this code is actually meant to work with disruptor 4. I am working in an OSGI environment, so the version range in the Manifest file is used to determine which version of disruptor to use. Adding disruptor v4.0.xx does not work as the build tool looks for packages with a version less then 4.

Configuration

Version: 2.24.3 (in combination with disruptor v3.4.4.202406060700)
Application Platform: OSGI
Operating system: Windows 11
JDK: OpenJDK 17

Logs

AsyncLogger error handling event seq=238, value='org.apache.logging.log4j.core.async.RingBufferLogEvent@6c16f29d': java.lang.NullPointerException: Cannot invoke "com.lmax.disruptor.Sequence.set(long)" because "this.sequenceCallback" is null
java.lang.NullPointerException: Cannot invoke "com.lmax.disruptor.Sequence.set(long)" because "this.sequenceCallback" is null
	at org.apache.logging.log4j.core.async.RingBufferLogEventHandler4.notifyCallback(RingBufferLogEventHandler4.java:67)
	at org.apache.logging.log4j.core.async.RingBufferLogEventHandler4.onEvent(RingBufferLogEventHandler4.java:61)
	at org.apache.logging.log4j.core.async.RingBufferLogEventHandler4.onEvent(RingBufferLogEventHandler4.java:31)
	at com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:168)
	at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125)
	at java.base/java.lang.Thread.run(Thread.java:833)

Reproduction

I suppose it will occur whenever using BasicAsyncLoggerContextSelector in log4j2 v2.24.3 combined with a disruptor version less then 4.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Waiting for user

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions