You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Olivier Lamy (Jira)" <ji...@apache.org> on 2023/04/23 01:01:00 UTC

[jira] [Commented] (MBUILDCACHE-56) NPE with mojo parameters not declared as fields (prevent any saving of cache)

    [ https://issues.apache.org/jira/browse/MBUILDCACHE-56?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715327#comment-17715327 ] 

Olivier Lamy commented on MBUILDCACHE-56:
-----------------------------------------

current workaround is to ignore the property:
{code}
<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd">
  <executionControl>
    <reconcile>
      <plugins>
        <!-- workaround for https://issues.apache.org/jira/browse/MBUILDCACHE-56 -->
        <plugin artifactId="maven-enforcer-plugin" goal="enforce">
          <nologs>
            <nolog propertyName="commandLineRules"/>
          </nologs>
        </plugin>
      </plugins>
    </reconcile>
  </executionControl>
</cache>
{code}

> NPE with mojo parameters not declared as fields (prevent any saving of cache)
> -----------------------------------------------------------------------------
>
>                 Key: MBUILDCACHE-56
>                 URL: https://issues.apache.org/jira/browse/MBUILDCACHE-56
>             Project: Maven Build Cache Extension
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Olivier Lamy
>            Assignee: Olivier Lamy
>            Priority: Blocker
>             Fix For: 1.0.1
>
>
> such field from m-enforcer-p https://github.com/apache/maven-enforcer/blame/master/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java#L192 is creating an NPE when trying saving the cache content because there is no field but a method!
> This makes the cache extension totally not usable.
> {code}
> java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Field.setAccessible(boolean)" because "field" is null
>     at org.codehaus.plexus.util.ReflectionUtils.getValueIncludingSuperclasses (ReflectionUtils.java:177)
>     at org.apache.maven.buildcache.CacheControllerImpl.recordMojoProperties (CacheControllerImpl.java:612)
>     at org.apache.maven.buildcache.CacheControllerImpl.buildExecutionInfo (CacheControllerImpl.java:579)
>     at org.apache.maven.buildcache.CacheControllerImpl.save (CacheControllerImpl.java:440)
>     at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:134)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
>     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:260)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
> {code}
> Ideally we should check if there is a field and throw IAE in this case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)