This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new d8f02a06b8 Bugfix: fix CLI graceful death (#11239) (#11246)
d8f02a06b8 is described below
commit d8f02a06b833403c54ebaa1374534aeae79ea234
Author: Tamas Cservenak <[email protected]>
AuthorDate: Fri Oct 10 10:59:07 2025 +0200
Bugfix: fix CLI graceful death (#11239) (#11246)
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
$
```
Backport of 7baf2a8921923bb4782490e0adb5d4b0381ae4fc
---
.../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 20247749e2..4c9b6528ac 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);
//
----------------------------------------------------------------------