mojohaus / servicedocgen-maven-plugin

ServicedocGen Maven Plugin
Apache License 2.0
2 stars 4 forks source link

NPE for non java projects (e.g. pom/module projects) #17

Closed hohwille closed 8 years ago

hohwille commented 8 years ago
Caused by: java.lang.NullPointerException
        at org.codehaus.mojo.servicedocgen.GenerateMojo.scanJavaFilesRecursive(GenerateMojo.java:191)
        at org.codehaus.mojo.servicedocgen.GenerateMojo.scanServices(GenerateMojo.java:173)
        at org.codehaus.mojo.servicedocgen.GenerateMojo.execute(GenerateMojo.java:133)
        ... 21 more
hohwille commented 8 years ago

Line 191 is:

for ( File file : sourceDir.listFiles() )

This would mean that sourceDir is null. How can this happen? It is the argument sourceFolder from this code:

            File sourceFolder = new File( sourceDir );
            builder.addSourceFolder( sourceFolder );
            if ( this.serviceClassName == null )
            {
                scanJavaFilesRecursive( sourceFolder, builder, serviceClasses );
            }
hohwille commented 8 years ago

Can File.listFiles() return null or a File[] with a null entry?

hohwille commented 8 years ago

OK. File.listFiles() indeed returns null if the path does not exist. Stupid one.

hohwille commented 8 years ago

fixed with this commit (typo in issue number, sorry): https://github.com/mojohaus/servicedocgen-maven-plugin/commit/bfe86535eb5b02eab94f10fefca46fdffab435af