maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lennart Jörelid (JIRA) <j...@apache.org>
Subject [jira] [Commented] (MCHECKSTYLE-287) checkstyle report throws NPE
Date Tue, 05 Jul 2016 19:23:11 GMT

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

Lennart Jörelid commented on MCHECKSTYLE-287:
---------------------------------------------

However, the problem stems from another method which attempts to gather all Artifacts which
could potentially contain a License.
The call is 

{code:java}
final Artifact artifact = (Artifact) plugin.getArtifactMap().get( depKey );
{code}

... and this returns null for artifacts injected as dependencies to the plugin. When logged
using the version pushed in by PR #88, something like the following occurs:

{code}
[DEBUG] Generating /Users/lj/Development/Projects/Skolverket/Repos/framework/persistence/persistence-spi-jpa/target/site/checkstyle.html
[INFO] Generating "Checkstyle" report           --- maven-checkstyle-plugin:2.18-SNAPSHOT:checkstyle
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key [se.foo:foo-codestyle]. Not
including null Artifact. 
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key [se.jguru.nazgul.tools.codestyle:nazgul-codestyle].
Not including null Artifact. 
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key [se.foo:foo-codestyle]. Not
including null Artifact. 
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key [se.jguru.nazgul.tools.codestyle:nazgul-codestyle].
Not including null Artifact. 
[DEBUG] executeCheckstyle start headerLocation : LICENSE.txt
[DEBUG] Adding licenceArtifact [com.puppycrawl.tools:checkstyle:6.11.2] to resourceManager.
[DEBUG] Adding licenceArtifact [org.slf4j:jcl-over-slf4j:1.5.6] to resourceManager.
[DEBUG] Adding licenceArtifact [org.slf4j:slf4j-jdk14:1.5.6] to resourceManager.
{code}

This corresponds to the following configuration of the maven-checkstyle-plugin:

{code:xml}
<plugin>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.18-SNAPSHOT</version>
          <executions>
            <execution>
              <id>verify</id>
              <phase>package</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <encoding>UTF-8</encoding>
                <skip>false</skip>
                <configLocation>/codestyle/foo-checkstyle.xml</configLocation>
                <suppressionsLocation>/codestyle/foo-checkstyle-suppressions.xml</suppressionsLocation>
                <failOnViolation>false</failOnViolation>
                <violationSeverity>error</violationSeverity>
                <suppressionsFile>/codestyle/foo-checkstyle-suppressions.xml</suppressionsFile>
              </configuration>
            </execution>
            <execution>
              <id>report</id>
              <goals>
                <goal>checkstyle</goal>
              </goals>
              <configuration>
                <encoding>UTF-8</encoding>
                <skip>false</skip>
                <configLocation>/codestyle/foo-checkstyle.xml</configLocation>
                <suppressionsLocation>/codestyle/foo-checkstyle-suppressions.xml</suppressionsLocation>
                <failOnViolation>false</failOnViolation>
                <violationSeverity>error</violationSeverity>
                <suppressionsFile>/codestyle/foo-checkstyle-suppressions.xml</suppressionsFile>
              </configuration>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>6.19</version>
            </dependency>
            <dependency>
              <groupId>se.foo</groupId>
              <artifactId>foo-codestyle</artifactId>
              <version>1.9.3-SNAPSHOT</version>
            </dependency>
            <dependency>
              <groupId>se.jguru.nazgul.tools.codestyle</groupId>
              <artifactId>nazgul-codestyle</artifactId>
              <version>5.0.1</version>
            </dependency>
            <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>jcl-over-slf4j</artifactId>
              <version>1.7.20</version>
            </dependency>
            <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-jdk14</artifactId>
              <version>1.7.20</version>
            </dependency>
          </dependencies>
{code}
 

> checkstyle report throws NPE
> ----------------------------
>
>                 Key: MCHECKSTYLE-287
>                 URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-287
>             Project: Maven Checkstyle Plugin
>          Issue Type: Bug
>    Affects Versions: 2.13, 2.14
>            Reporter: Thomas Scheffler
>         Attachments: patch1.diff, projects.tar.gz
>
>
> I don't know what triggers this bug. Somehow org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.collectArtifacts(String)
produces a List which contains the null object. And therefor an exception is thrown here (2.14):
> {noformat}
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site)
on project oaipmh: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site
failed. NullPointerException -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site
(default-site) on project oaipmh: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site
failed.
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
> 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
> 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
> 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
> 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
> 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
> 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
> 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-site of
goal org.apache.maven.plugins:maven-site-plugin:3.3:site failed.
> 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
> 	... 19 more
> Caused by: java.lang.NullPointerException
> 	at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.configureResourceLocator(DefaultCheckstyleExecutor.java:852)
> 	at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:102)
> 	at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:474)
> 	at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:156)
> 	at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
> 	at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:219)
> 	at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:319)
> 	at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:135)
> 	at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:175)
> 	at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:138)
> 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
> 	... 20 more
> {noformat}
> Looking at the code, you see a null check is done for the list, bit not for elements
of that list:
> {noformat}
>         // MCHECKSTYLE-225: load licenses from additional artifacts, not from classpath
>         if ( additionalArtifacts != null )
>         {
>             for ( Artifact licenseArtifact : additionalArtifacts )
>             {
>                 try
>                 {
>                     resourceManager.addSearchPath( "jar", "jar:" + licenseArtifact.getFile().toURI().toURL()
);
>                 }
>                 catch ( MalformedURLException e )
>                 {
>                     // noop
>                 }
>             }
>         }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message