mirror of https://github.com/apache/maven.git
[MNG-8178] Fall back to system properties for missing profile activation context properties (#1609)
A call to context.getSystemProperties() may yield an empty map, or one missing the desired key, which makes a subsequent call of toLowerCase fail with a NullPointerException. Fall-back to using system properties with the Os.OS_NAME and similar values instead. --------- Co-authored-by: Christian Kohlschütter <christian@kohlschutter.com>
This commit is contained in:
parent
d35864e348
commit
f2a0865c7a
|
@ -57,9 +57,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);
|
||||
|
|
Loading…
Reference in New Issue