You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/10/02 10:33:46 UTC

[maven-javadoc-plugin] branch master updated: (doc) fix potential NPE

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 24d2533  (doc) fix potential NPE
24d2533 is described below

commit 24d2533e848043d09e0a0cd9d627d1d22e4b7c0e
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Oct 2 12:33:38 2021 +0200

    (doc) fix potential NPE
---
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 88 +++++++++++-----------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 2168e5e..b1b5a57 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1453,21 +1453,21 @@ public abstract class AbstractJavadocMojo
      * stylesheetfile</a>.
      */
     @Parameter( property = "stylesheetfile" )
-    private String stylesheetfile;
-    
-    /**
-     * Specifies the path of an additional HTML stylesheet file relative to the {@link #javadocDirectory}
-     * Example:
-     * <pre>
-     *     &lt;addStylesheets&gt;
-     *         &lt;resources/addstylesheet.css&lt;/addStylesheet&gt;
-     *     &lt;/addStylesheets&gt;
-     * </pre>
+    private String stylesheetfile;
+    
+    /**
+     * Specifies the path of an additional HTML stylesheet file relative to the {@link #javadocDirectory}
+     * Example:
+     * <pre>
+     *     &lt;addStylesheets&gt;
+     *         &lt;resources/addstylesheet.css&lt;/addStylesheet&gt;
+     *     &lt;/addStylesheets&gt;
+     * </pre>
      * @since 3.3.0
-     */
-    @Parameter
-    private String[] addStylesheets;
-    
+     */
+    @Parameter
+    private String[] addStylesheets;
+    
     /**
      * Specifies the class file that starts the taglet used in generating the documentation for that tag.
      * <br/>
@@ -3152,34 +3152,34 @@ public abstract class AbstractJavadocMojo
         }
     }
     
-    
-    private Optional<File> getAddStylesheet( final File javadocOutputDirectory, final String stylesheet )
-            throws MavenReportException
-    {
-        if ( StringUtils.isEmpty( stylesheet ) )
-        {
-            return Optional.empty();
-        }
-        
-        File addstylesheetfile = new File( getJavadocDirectory(), stylesheet );
-        if ( addstylesheetfile.exists() )
-        {
-            Optional<File> stylesheetfile = getStylesheetFile( javadocOutputDirectory );
-            if ( stylesheetfile.isPresent() )
-            {
-                if ( stylesheetfile.get().getName().equals( addstylesheetfile.getName() ) )
-                {
-                    throw new MavenReportException( "additional stylesheet must have a different name "
-                                                        + "than stylesheetfile: " + stylesheetfile.get().getName() );
-                }
-            }
-            
-            return Optional.of( addstylesheetfile );
-        }
-
-        throw new MavenReportException( "additional stylesheet file does not exist: " 
-                                            + addstylesheetfile.getAbsolutePath() );
-    }
+    
+    private Optional<File> getAddStylesheet( final File javadocOutputDirectory, final String stylesheet )
+            throws MavenReportException
+    {
+        if ( StringUtils.isEmpty( stylesheet ) )
+        {
+            return Optional.empty();
+        }
+        
+        File addstylesheetfile = new File( getJavadocDirectory(), stylesheet );
+        if ( addstylesheetfile.exists() )
+        {
+            Optional<File> stylesheetfile = getStylesheetFile( javadocOutputDirectory );
+            if ( stylesheetfile.isPresent() )
+            {
+                if ( stylesheetfile.get().getName().equals( addstylesheetfile.getName() ) )
+                {
+                    throw new MavenReportException( "additional stylesheet must have a different name "
+                                                        + "than stylesheetfile: " + stylesheetfile.get().getName() );
+                }
+            }
+            
+            return Optional.of( addstylesheetfile );
+        }
+
+        throw new MavenReportException( "additional stylesheet file does not exist: " 
+                                            + addstylesheetfile.getAbsolutePath() );
+    }
 
     /**
      * Method to get the help file to be used by the Javadoc Tool.
@@ -5685,7 +5685,7 @@ public abstract class AbstractJavadocMojo
                               JavadocUtil.quotedPathArgument( stylesheetfile.get().getAbsolutePath() ) );
         }
         
-        addAddStyleSheets( arguments ); 
+        addAddStyleSheets( arguments ); 
 
         if ( StringUtils.isNotEmpty( sourcepath ) && !isJavaDocVersionAtLeast( SINCE_JAVADOC_1_5 ) )
         {
@@ -6542,7 +6542,7 @@ public abstract class AbstractJavadocMojo
                 }
             }
             
-            if ( isValidJavadocLink( url, detected ) )
+            if ( url != null && isValidJavadocLink( url, detected ) )
             {
                 getLog().debug( "Added Javadoc link: " + url + " for " + artifact.getId() );