The JDK 21 compiler linter flags potential `this-escape` violations in DGS generated code

未关闭
#651 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

  • #1001 来自 @Mohith26 —— 已关闭,未合并

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java, kotlin
领域
compilers, tooling

调研方向

从生成的 Mutation 构造函数和 Projection 初始化器开始,使用链接的最小案例在 JDK 21 和 -Xlint:all 下重现该警告。通过 dgs-codegen 追溯两份输出;当生成的代码在两个示例中都不再触发报告的 this-escape 警告时,即可完成。

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

描述

When compiling code generated by dgs-codegen using JDK 21 and having all linters enabled using the -Xlint:all compiler argument, then the compiler will raise a warning of a potential this-escape in some generated code.

I've created a minimal reproduction case for a violation in the constructor of a Mutation query, see: https://github.com/Badbond/dgs-codegen-reproduction-case-this-escape. We have also seen the issue being raised for a similar case in a Projection using a static initializer:

public class StateMachineFragmentProjection<PARENT extends BaseSubProjectionNode<?, ?>, ROOT extends BaseSubProjectionNode<?, ?>> extends BaseSubProjectionNode<PARENT, ROOT> {
  {
    getFields().put("__typename", null);
  }

  public StateMachineFragmentProjection(PARENT parent, ROOT root) {
    super(parent, root, java.util.Optional.of("StateMachine"));
  }

See also JDK-8299995.

Environment:

  • Maven 3.9.5.
  • JDK 21.0.2-tem.
  • DGS codegen 6.1.3.
主要语言
Kotlin
星标
220
派生
123
平均合并
1 天 6 小时
30 天内合并 PR
23

环境准备

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

从这里开始

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

Netflix/dgs-codegen 的其他 Issue

查看 Netflix/dgs-codegen 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

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