You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2024/07/10 20:02:42 UTC
(maven) branch maven-3.9.x updated: [MNG-8178] Fall back to system properties for missing profile activation context properties (#1603)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.9.x by this push:
new 5223ff68a6 [MNG-8178] Fall back to system properties for missing profile activation context properties (#1603)
5223ff68a6 is described below
commit 5223ff68a675b017112b2d2a86b04f0b2361aba4
Author: Dr. Christian Kohlschütter <ch...@kohlschutter.com>
AuthorDate: Wed Jul 10 22:02:36 2024 +0200
[MNG-8178] Fall back to system properties for missing profile activation context properties (#1603)
A call to context.getSystemProperties() may yield empty an empty map, or
one missing the desired key, which makes a subsequent call of
toLowerCase fail with a NullPointerException.
Fall-back to using Os.OS_NAME and similar properties.
---------
Co-authored-by: Guillaume Nodet <gn...@gmail.com>
---
.../profile/activation/OperatingSystemProfileActivator.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
index 63931b7f20..11dbd69ace 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
@@ -58,9 +58,15 @@ public class OperatingSystemProfileActivator implements ProfileActivator {
boolean active = ensureAtLeastOneNonNull(os);
- String actualOsName = context.getSystemProperties().get("os.name").toLowerCase(Locale.ENGLISH);
- String actualOsArch = context.getSystemProperties().get("os.arch").toLowerCase(Locale.ENGLISH);
- String actualOsVersion = context.getSystemProperties().get("os.version").toLowerCase(Locale.ENGLISH);
+ String actualOsName = context.getSystemProperties()
+ .getOrDefault("os.name", Os.OS_NAME)
+ .toLowerCase(Locale.ENGLISH);
+ String actualOsArch = context.getSystemProperties()
+ .getOrDefault("os.arch", Os.OS_ARCH)
+ .toLowerCase(Locale.ENGLISH);
+ String actualOsVersion = context.getSystemProperties()
+ .getOrDefault("os.version", Os.OS_VERSION)
+ .toLowerCase(Locale.ENGLISH);
if (active && os.getFamily() != null) {
active = determineFamilyMatch(os.getFamily(), actualOsName);