[ https://issues.apache.org/jira/browse/MBUILDCACHE-56?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715405#comment-17715405 ]
Slawomir Jaranowski commented on MBUILDCACHE-56: ------------------------------------------------ Even when we have @Parameter on the field - plugin configurator will use setter method at first, so setting only a filed can break something. Like in https://github.com/apache/maven-dependency-plugin/blob/master/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java#L73 {code:java} @SuppressWarnings("unused") // marker-field, setArtifact(String) does the magic @Parameter(property = "artifact") private String artifact; {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)