You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2019/05/20 17:46:23 UTC
[maven-pmd-plugin] branch master updated: [MPMD-288] -
NullPointerException when File.list() returns null
This is an automated email from the ASF dual-hosted git repository.
adangel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 6c1f0a2 [MPMD-288] - NullPointerException when File.list() returns null
6c1f0a2 is described below
commit 6c1f0a25d5af6a403b4e851c18caf5d084c4a3d9
Author: Wil <wc...@users.noreply.github.com>
AuthorDate: Fri May 10 16:57:48 2019 +0200
[MPMD-288] - NullPointerException when File.list() returns null
Closes #11
Fixed NullPointerException
this line throws NPE when file.list is null
https://docs.oracle.com/javase/8/docs/api/java/io/File.html#list--
For me this occurs on jar files like `~/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar`
Contributed by: Wil Carmon
---
src/main/java/org/apache/maven/plugins/pmd/PmdReport.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index f88c89a..b3c5135 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -769,7 +769,9 @@ public class PmdReport
for ( String path : projectCompileClasspath )
{
File pathFile = new File( path );
- if ( !pathFile.exists() || pathFile.list().length == 0 )
+ String[] children = pathFile.list();
+
+ if ( !pathFile.exists() || ( children != null && children.length == 0 ) )
{
getLog().warn( "The project " + localProject.getArtifactId()
+ " does not seem to be compiled. PMD results might be inaccurate." );