ppkarwasz commented on code in PR #1961:
URL: https://github.com/apache/logging-log4j2/pull/1961#discussion_r1392551829
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java:
##########
@@ -82,35 +84,31 @@ static int calculateRingBufferSize(final String
propertyName) {
}
static ExceptionHandler<RingBufferLogEvent>
getAsyncLoggerExceptionHandler() {
- final String cls =
PropertiesUtil.getProperties().getStringProperty("AsyncLogger.ExceptionHandler");
- if (cls == null) {
- return new AsyncLoggerDefaultExceptionHandler();
- }
+ ExceptionHandler<RingBufferLogEvent> handler = null;
try {
- @SuppressWarnings("unchecked")
- final Class<? extends ExceptionHandler<RingBufferLogEvent>> klass =
- (Class<? extends ExceptionHandler<RingBufferLogEvent>>)
Loader.loadClass(cls);
- return klass.newInstance();
- } catch (final Exception ignored) {
- LOGGER.debug("Invalid AsyncLogger.ExceptionHandler value: error
creating {}: ", cls, ignored);
- return new AsyncLoggerDefaultExceptionHandler();
+ handler =
Review Comment:
I added a version of `newCheckedInstanceOfProperty` that takes a
`Supplier<T>` as additional parameter to provide a default value.
However in `3.x` we should probably consider returning `Optional<T>`: this
way we can always call `Optional#orElseGet(Supplier<T>)` without the need of
two versions of each method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]