Skip to content

Timeout Java process during JDK discovery - #201

Open
efegokdemir wants to merge 7 commits into
apache:masterfrom
efegokdemir:codex/issue-170-process-timeout
Open

efegokdemir wants to merge 7 commits into
apache:masterfrom
efegokdemir:codex/issue-170-process-timeout

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

JDK discovery could wait indefinitely for a discovered java executable to finish.

Changes

  • Bound the Java metadata process to 30 seconds.
  • Forcefully terminate timed-out processes and retain the existing ignore behavior.
  • Preserve the interrupt flag when discovery is interrupted.

Testing

  • mvn -Dspotless.skip=true -Dtest=ToolchainDiscovererTest test — passed
  • Checkstyle — passed
  • git diff --check — passed

Fixes #170


To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following:

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A timed-out candidate triggers an unchecked null dereference that discards healthy toolchain results.

1 open issue
What changed in this PR

Bounds Java metadata discovery to address indefinite Maven hangs described in #170.

Changes:

  • Limits Java processes to 30 seconds and forcibly terminates timed-out processes.
  • Restores the thread’s interrupt flag when discovery is interrupted.
File Description
src/​main/​java/​org/​apache/​maven/​plugins/​toolchain/​jdk/​ToolchainDiscoverer.java Adds process timeout, termination, and interrupt handling.

Review effort: Balanced

@slachiewicz slachiewicz added the bug Something isn't working label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No timeout for external java process in doGetToolchainModel

4 participants