Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
3.9.7, 3.9.8
-
None
Description
MNG-5726 introduced a breaking change that makes "mvn site" fail when profiles based on OS activation are used.
From commit f860a8693d38292c8ce9ee3b6a883559e7a94796 maven-model-builder/src/main/java/org/apache/mavqen/model/profile/activation/OperatingSystemProfileActivator.java:
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);
context.getSystemProperties() may be empty (or not contain any of these three keys), which makes toLowerCase(Locale) fail with a NullPointerException.
Steps to reproduce:
git clone https://github.com/kohlschutter/junixsocket.git
git checkout 65602a9054eb232635678e1aa2f682969aaa059f
./scripts/build-site
Output:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M11:site (default-site) on project junixsocket: Failed to render reports: Error generating maven-project-info-reports-plugin:3.6.1:modules report: Unable to read local module POM: Some problems were encountered while processing the POMs: [ERROR] [ERROR] Failed to determine activation for profile arch-x86_64-MacOSX: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 243, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-aarch64-MacOSX: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 261, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-Linux: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 280, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-aarch64-Linux: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 299, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-NetBSD: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 318, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-OpenBSD: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 337, column 18: 6 problems were encountered while building the effective model for com.kohlschutter.junixsocket:junixsocket-native:2.10.1-SNAPSHOT [ERROR] [ERROR] Failed to determine activation for profile arch-x86_64-MacOSX: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 243, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-aarch64-MacOSX: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 261, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-Linux: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 280, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-aarch64-Linux: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 299, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-NetBSD: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 318, column 18 [ERROR] [ERROR] Failed to determine activation for profile arch-amd64-OpenBSD: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "java.util.Map.get(Object)" is null @ com.kohlschutter.junixsocket:junixsocket:2.10.1-SNAPSHOT, /Users/ck/Entwicklung/workspace/junixsocket/pom.xml, line 337, column 18 [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Suggested fix:
Fall back to using values from System.getProperty (or alternatively, Os.OS_NAME, Os.OS_ARCH, Os.OS_VERSION) if the system properties provided in the context is empty.