maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adan...@apache.org
Subject [maven-pmd-plugin] 01/01: [MPMD-288] - NullPointerException fix
Date Mon, 20 May 2019 17:04:04 GMT
This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch MPMD-288
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 6b40dc747cd076d98c50fd7091a01b56c9651eea
Author: Wil <wcarmon@users.noreply.github.com>
AuthorDate: Fri May 10 16:57:48 2019 +0200

    [MPMD-288] - NullPointerException fix
    
    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." );


Mime
View raw message