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

未关闭
#3,368 10 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

检查最终的 Appender Builder 声明(例如 ConsoleAppender.Builder),并将其与 AbstractOutputStreamAppender.Builder 以及 newBuilder() 的用法进行比较。在决定具体的 Appender 是否可以删除类级别的类型参数之前,检查二进制兼容性要求和现有测试;当 API 更改得到一致应用且没有兼容性回归时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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 <B> The type to build
     */
    public static class Builder<B extends Builder<B>> 
            extends AbstractOutputStreamAppender.Builder<B>
            implements org.apache.logging.log4j.core.util.Builder<ConsoleAppender> {
            ...
    }

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<Builder> 
      implements org.apache.logging.log4j.core.util.Builder<ConsoleAppender>

ConsoleAppender.Builder builder = ConsoleAppender.newBuilder();

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

主要语言
Java
星标
3.6k
派生
1.8k
平均合并
5 天 6 小时
30 天内合并 PR
24

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/logging-log4j2 的其他 Issue

查看 apache/logging-log4j2 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。