apache / apache/maven-checkstyle-plugin

[MCHECKSTYLE-333] Intermittent NPE on checkstyle:check

Open
#245 8 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
97
Forks
67
Avg merge
14h 50m
Merged PRs (30d)
6

Description

**[James Short](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=littlewing4b8)** opened **[MCHECKSTYLE-333](https://issues.apache.org/jira/browse/MCHECKSTYLE-333?redirect=false)** and commented

I generally run checkstyle:check manually but I wanted to integrate it into the validate phase of my root build.

After doing this, it will intermittent fail with an NPE:

```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (checkstyle) on project dropwizard-api: Execution checkstyle of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (checkstyle) on project dropwizard-api: Execution checkstyle of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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 checkstyle of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.NullPointerException
at java.util.zip.ZipFile.getZipEntry(ZipFile.java:566)
at java.util.zip.ZipFile.access$900(ZipFile.java:60)
at java.util.zip.ZipFile$ZipEntryIterator.next(ZipFile.java:524)
at java.util.zip.ZipFile$ZipEntryIterator.nextElement(ZipFile.java:499)
at java.util.zip.ZipFile$ZipEntryIterator.nextElement(ZipFile.java:480)
at java.util.jar.JarFile$JarEntryIterator.next(JarFile.java:257)
at java.util.jar.JarFile$JarEntryIterator.nextElement(JarFile.java:266)
at java.util.jar.JarFile$JarEntryIterator.nextElement(JarFile.java:247)
at org.codehaus.plexus.resource.loader.JarHolder.getEntries(JarHolder.java:132)
at org.codehaus.plexus.resource.loader.JarResourceLoader.loadJar(JarResourceLoader.java:100)
at org.codehaus.plexus.resource.loader.JarResourceLoader.initialize(JarResourceLoader.java:63)
at org.codehaus.plexus.resource.loader.JarResourceLoader.getResource(JarResourceLoader.java:141)
at org.apache.maven.plugin.checkstyle.resource.LicenseResourceManager.getResource(LicenseResourceManager.java:75)
at org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:91)
at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getOverridingProperties(DefaultCheckstyleExecutor.java:564)
at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getConfiguration(DefaultCheckstyleExecutor.java:379)
at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:217)
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:538)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
```

My pom config:

```

org.apache.maven.plugins
maven-checkstyle-plugin
2.17

build-tools/src/main/resources/checkstyle/checkstyle.xml
true
build-tools/src/main/resources/checkstyle/suppressions.xml
false



checkstyle
validate

check


true
UTF-8
true
true
false





org.coner
build-tools
1.0


com.puppycrawl.tools
checkstyle
6.19



```

---

**Affects:** 2.17

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the intermittent failure during the validate phase with the shown Maven plugin configuration. Trace the stack from DefaultCheckstyleExecutor.getOverridingProperties through LicenseResourceManager and JarResourceLoader, especially the JarHolder.getEntries call. Done means the configuration no longer intermittently fails with the reported NullPointerException and coverage is added for the failure case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.