Skip to content

Improve handling of LinkageErrors during LMAX Disruptor initializatio…#4124

Open
ramanathan1504 wants to merge 3 commits into
apache:2.xfrom
ramanathan1504:fix-log-disruptor-initialization-errors
Open

Improve handling of LinkageErrors during LMAX Disruptor initializatio…#4124
ramanathan1504 wants to merge 3 commits into
apache:2.xfrom
ramanathan1504:fix-log-disruptor-initialization-errors

Conversation

@ramanathan1504
Copy link
Copy Markdown
Contributor

FIxes #2250

Reference URLs

What was done

  • Added defensive LinkageError handling in DisruptorUtil when creating async logger exception handlers.
  • Added a shared error log helper to emit a clear classpath/version mismatch message for Disruptor linkage problems.
  • Guarded sequenceCallback.set(sequence) with a null check in RingBufferLogEventHandler4 to prevent NPE when callback is not initialized.

Copy link
Copy Markdown
Member

@vy vy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify logging

Copy link
Copy Markdown
Member

@vy vy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added defensive LinkageError handling in DisruptorUtil when creating async logger exception handlers.

I don't see that.

Guarded sequenceCallback.set(sequence) with a null check in RingBufferLogEventHandler4 to prevent NPE when callback is not initialized.

I don't see that either.

@github-project-automation github-project-automation Bot moved this from Approved to Changes requested in Log4j pull request tracker May 21, 2026
Comment on lines +58 to 66
final int version;
try {
Class.forName(
"com.lmax.disruptor.SequenceReportingEventHandler", true, DisruptorUtil.class.getClassLoader());
"com.lmax.disruptor.SequenceReportingEventHandler", false, DisruptorUtil.class.getClassLoader());
version = 3;
return 3;
} catch (final ClassNotFoundException e) {
return 4;
} catch (final ClassNotFoundException ignored) {
version = 4;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final int version;
try {
Class.forName(
"com.lmax.disruptor.SequenceReportingEventHandler", true, DisruptorUtil.class.getClassLoader());
"com.lmax.disruptor.SequenceReportingEventHandler", false, DisruptorUtil.class.getClassLoader());
version = 3;
return 3;
} catch (final ClassNotFoundException e) {
return 4;
} catch (final ClassNotFoundException ignored) {
version = 4;
}
int version = 4;
try {
Class.forName(
"com.lmax.disruptor.SequenceReportingEventHandler", false, DisruptorUtil.class.getClassLoader());
version = 3;
return 3;
} catch (final ClassNotFoundException ignored) {
// Do nothing
}

@ramanathan1504
Copy link
Copy Markdown
Contributor Author

ramanathan1504 commented May 21, 2026

Added defensive LinkageError handling in DisruptorUtil when creating async logger exception handlers.

I don't see that.

Guarded sequenceCallback.set(sequence) with a null check in RingBufferLogEventHandler4 to prevent NPE when callback is not initialized.

I don't see that either.

Forgot to mention this earlier @vy — for this PR, @ppkarwasz suggested that we do not need additional LinkageError handling here, since Log4j is already designed to handle it during the initialization stage. The main goal is just to provide better visibility to the user about what is happening.

That’s why I reverted the extra LinkageError handling from the earlier commit and only kept the logging message improvement.

dc9f81f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

Log disruptor initialization errors

2 participants