This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 7baf2a8921 Bugfix: fix CLI graceful death (#11239)
7baf2a8921 is described below
commit 7baf2a8921923bb4782490e0adb5d4b0381ae4fc
Author: Tamas Cservenak <[email protected]>
AuthorDate: Fri Oct 10 09:39:11 2025 +0200
Bugfix: fix CLI graceful death (#11239)
When CLI contains unsupported parameters, the `context.options` may be
null, that is violated by `populateUserProperties` method.
Before (master):
```
$ mvn --encrypt-master-password xxxxx
[ERROR] Error executing Maven.
[ERROR] Error parsing program arguments
[ERROR] Caused by: Failed to parse CLI arguments: Unrecognized option:
--encrypt-master-password
[ERROR] Error populating user properties
[ERROR] Caused by: Cannot invoke
"org.apache.maven.api.cli.Options.userProperties()" because "context.options"
is null
[ERROR] Error reading core extensions descriptor
[ERROR] Caused by: null
$
```
With PR:
```
$ mvn --encrypt-master-password
[ERROR] Error executing Maven.
[ERROR] Error parsing program arguments
[ERROR] Caused by: Failed to parse CLI arguments: Unrecognized option:
--encrypt-master-password
$
```
---
.../src/main/java/org/apache/maven/cling/invoker/BaseParser.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
index b44377b7f3..bd8a6e6693 100644
---
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
+++
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
@@ -435,8 +435,9 @@ protected Map<String, String>
populateUserProperties(LocalContext context) {
// are most dominant.
//
----------------------------------------------------------------------
- Map<String, String> userSpecifiedProperties =
- new HashMap<>(context.options.userProperties().orElse(new
HashMap<>()));
+ Map<String, String> userSpecifiedProperties = context.options != null
+ ? new HashMap<>(context.options.userProperties().orElse(new
HashMap<>()))
+ : new HashMap<>();
createInterpolator().interpolate(userSpecifiedProperties, paths::get);
//
----------------------------------------------------------------------