You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/01/05 20:15:32 UTC

[maven-javadoc-plugin] branch master updated: [MJAVADOC-504] NullPointerException in JavadocUtil.getJavaHome() when JAVA_HOME isn't set

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

rfscholte 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 79a6b4b  [MJAVADOC-504] NullPointerException in JavadocUtil.getJavaHome() when JAVA_HOME isn't set
79a6b4b is described below

commit 79a6b4b69383d3bf5c342c12dc483bc3d4b82336
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Jan 5 21:15:22 2018 +0100

    [MJAVADOC-504] NullPointerException in JavadocUtil.getJavaHome() when JAVA_HOME isn't set
---
 .../apache/maven/plugins/javadoc/JavadocUtil.java  | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 4dc7631..f575455 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -1278,10 +1278,22 @@ public class JavadocUtil
     private static File getJavaHome( Log log )
     {
         File javaHome = null;
+        
+        String javaHomeValue = null;
+        try
+        {
+            javaHomeValue = CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" );
+        }
+        catch ( IOException e )
+        {
+            if ( log != null && log.isDebugEnabled() )
+            {
+                log.debug( "IOException: " + e.getMessage() );
+            }
+        }
 
         // if maven.home is set, we can assume JAVA_HOME must be used for testing
-        
-        if ( System.getProperty( "maven.home" ) == null )
+        if ( System.getProperty( "maven.home" ) == null || javaHomeValue == null )
         {
             // JEP220 (Java9) restructured the JRE/JDK runtime image
             if ( ( SystemUtils.IS_OS_MAC_OSX
@@ -1297,17 +1309,7 @@ public class JavadocUtil
 
         if ( javaHome == null || !javaHome.exists() )
         {
-            try
-            {
-                javaHome = new File( CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_HOME" ) );
-            }
-            catch ( IOException e )
-            {
-                if ( log != null && log.isDebugEnabled() )
-                {
-                    log.debug( "IOException: " + e.getMessage() );
-                }
-            }
+            javaHome = new File( javaHomeValue );
         }
 
         if ( javaHome == null || !javaHome.exists() )

-- 
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].