apache / apache/maven-artifact-plugin

JdkToolchainUtil: command built by string concat breaks on spaced java path; no timeout

Open Beginner friendly
#246 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
14
Forks
23
Avg merge
1h 27m
Merged PRs (30d)
8

Description

`JdkToolchainUtil.getJavaVersion(Toolchain)` (line 40) builds the command by string concatenation:

```java
Commandline cl = new Commandline(java + " -version");
```

`Commandline` tokenizes the string on whitespace, so a `java` binary path containing spaces (common on Windows and macOS, e.g. `/Applications/My Tools/jdk/bin/java`) is split into multiple arguments and the command fails.

Additionally, `CommandLineUtils.executeCommandLine` is invoked without a timeout, so a hung JVM blocks the build indefinitely.

Suggested fix: use `cl.createArg().setValue(java)` / `cl.addArgument` and bound the command execution with a timeout.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at JdkToolchainUtil.getJavaVersion(Toolchain), around line 40, and inspect how Commandline and CommandLineUtils.executeCommandLine are used. The change is done when Java paths containing spaces remain one argument and a hung JVM is bounded by a timeout; no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.