continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r563824 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
Date Wed, 08 Aug 2007 12:06:02 GMT
Author: evenisse
Date: Wed Aug  8 05:06:01 2007
New Revision: 563824

URL: http://svn.apache.org/viewvc?view=rev&rev=563824
Log:
[CONTINUUM-1374] Fix NPE when JAVA_HOME isn't defined
Submitted by: Olivier Lamy

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java?view=diff&rev=563824&r1=563823&r2=563824
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
Wed Aug  8 05:06:01 2007
@@ -59,10 +59,10 @@
      * @plexus.requirement role-hint="jdo"
      */
     private ContinuumStore store;
-    
+
     /**
      * @plexus.requirement role-hint="default"
-     */    
+     */
     private ProfileService profileService;
 
     private Map<String, ExecutorConfigurator> typesValues;
@@ -254,7 +254,13 @@
             Properties systemEnvVars = CommandLineUtils.getSystemEnvVars( false );
 
             String javaHome = (String) systemEnvVars.get( "JAVA_HOME" );
+            // olamy : JAVA_HOME can not exists with a mac user
+            if ( StringUtils.isEmpty( javaHome ) )
+            {
+                return getJavaHomeInformations( System.getProperty( "java.home" ) );
+            }
             return getJavaHomeInformations( javaHome );
+
         }
         catch ( IOException e )
         {
@@ -274,6 +280,10 @@
     public List<String> getJdkInformations( Installation installation )
         throws InstallationException
     {
+        if ( installation == null )
+        {
+            return getDefaultJdkInformations();
+        }
         if ( StringUtils.isEmpty( installation.getVarValue() ) )
         {
             return getDefaultJdkInformations();
@@ -299,16 +309,7 @@
         Commandline commandline = new Commandline();
 
         String executable = javaHome + File.separator + "bin" + File.separator + "java";
-        /*
-        if ( Os.isFamily( Os.FAMILY_DOS ) )
-        {
-            executable = "%JAVA_HOME%\\bin\\java";
-        }
-        else
-        {
-            executable = "$JAVA_HOME/bin/java";
-        }
-        */
+
         commandline.setExecutable( executable );
         commandline.addArguments( new String[]{"-version"} );
         final List<String> cliOutput = new ArrayList<String>();

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java?view=diff&rev=563824&r1=563823&r2=563824
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
Wed Aug  8 05:06:01 2007
@@ -1,13 +1,14 @@
 package org.apache.maven.continuum.installation;
 
-import java.util.List;
-
 import org.apache.maven.continuum.AbstractContinuumTest;
 import org.apache.maven.continuum.execution.ExecutorConfigurator;
 import org.apache.maven.continuum.model.system.Installation;
 import org.apache.maven.continuum.model.system.Profile;
 import org.apache.maven.continuum.profile.ProfileService;
 import org.apache.maven.continuum.store.ContinuumStore;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.List;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -149,7 +150,11 @@
         throws Exception
     {
         InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE,
"default" );
-        String javaHome = System.getProperty( "JAVA_HOME" );
+        String javaHome = System.getenv( "JAVA_HOME" );
+        if ( StringUtils.isEmpty( javaHome ) )
+        {
+            javaHome = System.getProperty( "java.home" );
+        }
         Installation installation = new Installation();
         installation.setName( "test" );
         installation.setType( InstallationService.JDK_TYPE );
@@ -164,7 +169,11 @@
     {
         InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE,
"default" );
         ExecutorConfigurator java = installationService.getExecutorConfigurator( InstallationService.JDK_TYPE
);
-        String javaHome = System.getProperty( "JAVA_HOME" );
+        String javaHome = System.getenv( "JAVA_HOME" );
+        if ( StringUtils.isEmpty( javaHome ) )
+        {
+            javaHome = System.getProperty( "java.home" );
+        }
         List<String> infos = installationService.getExecutorConfiguratorVersion( javaHome,
java );
         System.out.println( infos );
         assertNotNull( infos );
@@ -179,7 +188,7 @@
         List<String> infos = installationService.getExecutorConfiguratorVersion( javaHome,
java );
         assertNotNull( infos );
     }
-    
+
     public void testAddInstallationAutomaticProfile()
         throws Exception
     {



Mime
View raw message