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 10:49:00 UTC

[jira] [Comment Edited] (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=17715435#comment-17715435 ] 

Olivier Lamy edited comment on MBUILDCACHE-56 at 4/23/23 10:48 AM:
-------------------------------------------------------------------

[~sjaranowski] I know BUT this is not the problem :) 
here we try to read a value (Mojo parameter) and not to set value.
So when there is a field it works fine but it's broken when there is no field because it is using this method which is expecting a field see https://github.com/codehaus-plexus/plexus-utils/blob/21bf1654318ac4814c9f9c97418a0be69cd8d215/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java#L175


was (Author: olamy):
[~sjaranowski] I know BUT this is not the problem :) 
here we try to read values and not to set value.
So when there is a field it works fine but it's broken when there is no field because it is using this method which is expecting a field see https://github.com/codehaus-plexus/plexus-utils/blob/21bf1654318ac4814c9f9c97418a0be69cd8d215/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java#L175

> 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)