question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to register a custom ExceptionHandler without initializing java.util.logging

See original GitHub issue

We use the disruptor library heavily in log4j2 for fully asynchronous logging. Unfortunately, there are some edge cases which may result in a deadlock on initialization. See LOG4J2-2965 with a reproducer here: https://github.com/apache/logging-log4j2/pull/447

Ideally we would be able to provide a custom exception handler that avoids initializing the FatalExceptionHandler (thus JUL) unnecessarily: https://github.com/LMAX-Exchange/disruptor/blob/2d4762336e2ad6d475dcf0310a980c50fd5bff0b/src/main/java/com/lmax/disruptor/FatalExceptionHandler.java#L26-L28

This could be done by lazily creating the FatalExceptionHandler if no other handler has been provided when the ring buffer is started, although there are subtler approaches to reduce code change, for example wrapping the FatalExceptionHandler Logger instance within a static inner class to delay initialization until the logger field is first accessed based on jls-12.4.2.

Would you accept a contribution as described above? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Palmrcommented, Apr 29, 2021

@carterkozak v3.4.4 (https://github.com/LMAX-Exchange/disruptor/releases/tag/3.4.4) has now been released, it should be making its way out to maven central in the next few hours.

Hope that helps you & Log4j 👍

1reaction
Palmrcommented, Apr 25, 2021

The current master branch/pending 4.0 release currently has no schedule for getting release, it’s on a “when it’s done” timeline.

If you/Log4J are looking for this to be fixed sooner rather than later I’d be happy to merge it on to the 3.4 branch and get that released, within the next week perhaps?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Make Custom Exceptions in Java - Stack Abuse
Overview. In this article, we'll cover the process of creating custom both checked and unchecked exceptions in Java.
Read more >
How to log exceptions in Java? - Stack Overflow
It will log stacktraces of exceptions and their cause for you. For example: import java.util.logging.Level; import java.util.logging.Logger; [.
Read more >
Java Logging Basics - The Ultimate Guide To Logging - Loggly
This section presents Java logging basics, including how to create logs, popular logging frameworks, how to create some of the best log layouts,...
Read more >
Spring MVC Exception Handling - @ControllerAdvice ...
All we need is to annotate these methods with @ExceptionHandler annotation. This annotation takes Exception class as argument. So if we have ...
Read more >
Exception Handling in Java - Baeldung
Certainly, whether we can read the file or not, we want to make sure that we do the appropriate cleanup! Let's try this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found