apache / apache/logging-log4j2

Builder definitions in final Appender implementations unncessarily use Generics on Builder class

Open
#3,368 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

**Log4j 2.24**

_Not technically a bug??? But not a feature-request either...just pointing it out...if no interest in changing this from L4J team go ahead and close it_

The appender Builders (ConsoleAppender.Builder, FileAppender.Builder, etc) have been generically defiined.

For example:

```
/**
* Builds ConsoleAppender instances.
* @param The type to build
*/
public static class Builder>
extends AbstractOutputStreamAppender.Builder
implements org.apache.logging.log4j.core.util.Builder {
...
}
```

This means when _not_ chaining you need to handle the generics:

`ConsoleAppender.Builder builder = ConsoleAppender.newBuilder();`

This is OK for the abstract Builders that are inherited, but a wee bit non-standard for concrete builder implementations.

Since the appender classes are final one might assume its builders can also be final and don't need the generics on the class itself.

I *think* it could be simplified::

For example ConsoleAppender:
```
public static final class Builder
extends AbstractOutputStreamAppender.Builder
implements org.apache.logging.log4j.core.util.Builder
```

`ConsoleAppender.Builder builder = ConsoleAppender.newBuilder();`

From a coding perspective a trivial change but more of a binary compatibility problem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.