Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

EmbeddedMavenExecutor restores a constructor-time System snapshot after every run

未关闭 适合新手
#46 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
build-system

调研方向

从 maven-executor/src/main/java/org/apache/maven/executor/embedded/EmbeddedMavenExecutor.java 的第 128-129 行和第 159-162 行开始,然后跟踪 execute(),以了解 System 状态何时被捕获和恢复。当在同一个长期存在的 executor 上重复执行时,能够保留两次运行之间设置的系统属性,即表示完成;如果周围的测试提供了合适的位置,请为该行为添加或更新覆盖测试。

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

描述

bug
Affected version

1.0.0

Bug description

EmbeddedMavenExecutor copies System.getProperties() once, in its constructor (EmbeddedMavenExecutor.java:128-129), together with System.out and System.err, and restores that same snapshot in the finally block of every execute() (:159-162). Any change a caller makes to system properties between two executions on one long-lived executor is silently reverted after the next run. maven-verifier's Embedded3xLauncher snapshotted per run.

The pattern that triggers it is the natural one for a test fixture: one ExecutorHelper per JVM, reused across hundreds of integration tests, some of which set a system property to drive the next build. Found while porting maven-surefire's IT fixture (apache/maven-surefire#3484); the fixture now creates one executor per Verifier instance to avoid it.

Proposal: take the snapshot at the start of each execute() rather than in the constructor. This is distinct from the thread-safety window in #16 item 8, which is about System.setProperties(null) during a run.

The same JVM-lifetime pattern is in apache/maven itself: its/core-it-support/maven-it-helper/.../Verifier.java holds static final EmbeddedMavenExecutor and ForkedMavenExecutor instances, so the core ITs on master and on the 3.x branches (apache/maven-integration-testing#445) are exposed as well; fixing the snapshot point in the executor covers all of them.

The obvious workaround, one EmbeddedMavenExecutor per execution closed afterwards, does not work at scale: on apache/maven-surefire#3484 (run 35594937350) the IT JVM runs out of heap after roughly a hundred builds (java.lang.OutOfMemoryError: Java heap space inside the embedded Maven), because close() does not release the Maven ClassWorld the constructor built. So callers are pushed back to a JVM-lifetime executor and inherit the snapshot behaviour; moving the snapshot into execute() is the fix that avoids both.

主要语言
Java
星标
5
派生
2
平均合并
4 小时 22 分钟
30 天内合并 PR
2

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

apache/maven-executor 的其他 Issue

查看 apache/maven-executor 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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