Improve handling of LinkageErrors during LMAX Disruptor initializatio…#4124
Improve handling of LinkageErrors during LMAX Disruptor initializatio…#4124ramanathan1504 wants to merge 3 commits into
Conversation
…n and add tests for error logging
vy
left a comment
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
| 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 | |
| } |
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. |
FIxes #2250
Reference URLs
What was done
LinkageErrorhandling inDisruptorUtilwhen creating async logger exception handlers.sequenceCallback.set(sequence)with a null check inRingBufferLogEventHandler4to prevent NPE when callback is not initialized.