[ https://issues.apache.org/jira/browse/MBUILDCACHE-56?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17717452#comment-17717452 ]
ASF GitHub Bot commented on MBUILDCACHE-56: ------------------------------------------- olamy commented on code in PR #73: URL: https://github.com/apache/maven-build-cache-extension/pull/73#discussion_r1179898215 ########## src/test/projects/mbuildcache-56-mojo-parameter-as-method/.mvn/maven-build-cache-config.xml: ########## @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<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"> + <configuration> + <enabled>true</enabled> + </configuration> + <input> + <global> + <glob>{*.java,*.xml,*.properties,*.mod,*.adoc}</glob> + </global> + <! > 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 > Labels: pull-request-available > 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)