[
https://issues.apache.org/jira/browse/MNG-8178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17864330#comment-17864330
]
ASF GitHub Bot commented on MNG-8178:
-------------------------------------
kohlschuetter commented on PR #1603:
URL: https://github.com/apache/maven/pull/1603#issuecomment-2218378762
@slawekjaranowski DefaultProfileActivationContext.setSystemProperties allows
empty/null system properties (the default value if setSystemProperties isn't
called is an empty map, too). Moreover, I don't think we can make any
assumptions on "os.name", etc., to be available.
As to where this from: I've added an exception to
`DefaultProfileActivationContext` that checks for empty property maps, and this
is what I get
```
at
org.apache.maven.model.profile.DefaultProfileActivationContext.setSystemProperties
(DefaultProfileActivationContext.java:108)
at
org.apache.maven.model.building.DefaultModelBuilder.getProfileActivationContext
(DefaultModelBuilder.java:661)
at org.apache.maven.model.building.DefaultModelBuilder.build
(DefaultModelBuilder.java:265)
at org.apache.maven.model.building.DefaultModelBuilder.build
(DefaultModelBuilder.java:247)
at org.apache.maven.project.DefaultProjectBuilder.build
(DefaultProjectBuilder.java:176)
at org.apache.maven.project.DefaultProjectBuilder.build
(DefaultProjectBuilder.java:123)
at
org.apache.maven.report.projectinfo.ModulesReport$ModulesRenderer.renderBody
(ModulesReport.java:174)
at org.apache.maven.reporting.AbstractMavenReportRenderer.render
(AbstractMavenReportRenderer.java:82)
at org.apache.maven.report.projectinfo.ModulesReport.executeReport
(ModulesReport.java:75)
at org.apache.maven.reporting.AbstractMavenReport.generate
(AbstractMavenReport.java:289)
at
org.apache.maven.plugins.site.render.ReportDocumentRenderer.renderDocument
(ReportDocumentRenderer.java:198)
at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render
(DefaultSiteRenderer.java:298)
at org.apache.maven.plugins.site.render.SiteMojo.renderNonDoxiaDocuments
(SiteMojo.java:280)
at org.apache.maven.plugins.site.render.SiteMojo.renderLocale
(SiteMojo.java:162)
at org.apache.maven.plugins.site.render.SiteMojo.execute
(SiteMojo.java:115)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
(DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
(MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
(MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000
(MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run
(MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute
(DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:159)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:105)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:73)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
(LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:903)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:280)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:203)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke
(DirectMethodHandleAccessor.java:103)
at java.lang.reflect.Method.invoke (Method.java:580)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch
(Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main
(Launcher.java:314)
```
> Profile activation based on OS properties is broken for "mvn site"
> ------------------------------------------------------------------
>
> Key: MNG-8178
> URL: https://issues.apache.org/jira/browse/MNG-8178
> Project: Maven
> Issue Type: Bug
> Affects Versions: 3.9.7, 3.9.8
> Reporter: Christian Kohlschütter
> Priority: Blocker
>
> 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:
>
> {code: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);{code}
> context.getSystemProperties() may be empty (or not contain any of these three
> keys), which makes toLowerCase(Locale) fail with a NullPointerException.
> Steps to reproduce:
>
> {code:java}
> git clone https://github.com/kohlschutter/junixsocket.git
> git checkout 65602a9054eb232635678e1aa2f682969aaa059f
> ./scripts/build-site
> {code}
> Output:
> {code:java}
> [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{code}
> 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.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)