Fix bugs in previous commit

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@570889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Carlos Sanchez Gonzalez 2007-08-29 18:24:22 +00:00
parent 4ea3730eb8
commit 3c0f795c34
4 changed files with 15 additions and 7 deletions

View File

@ -32,13 +32,13 @@ public interface ConfigurationValidationResult
boolean isValid();
/**
* Parsed user settings, or null if there's any parse error, that can be retrieved through
* Parsed user settings. If there's any parse error, it can be retrieved through
* {@link #getUserSettingsException()}
*/
Settings getUserSettings();
/**
* Parsed global settings, or null if there's any parse error, that can be retrieved through
* Parsed global settings. If there's any parse error, it can be retrieved through
* {@link #getGlobalSettingsException()}
*/
Settings getGlobalSettings();

View File

@ -37,7 +37,7 @@ public class DefaultConfigurationValidationResult
public boolean isValid()
{
return ( getUserSettings() != null ) && ( getGlobalSettings() != null );
return ( getUserSettingsException() == null ) && ( getGlobalSettingsException() == null );
}
public Throwable getUserSettingsException()
@ -87,7 +87,7 @@ public class DefaultConfigurationValidationResult
public boolean isGlobalSettingsFilePresent()
{
return getGlobalSettingsException() instanceof FileNotFoundException;
return isSettingsFilePresent( getGlobalSettings(), getGlobalSettingsException() );
}
public boolean isUserSettingsFileParses()
@ -97,7 +97,7 @@ public class DefaultConfigurationValidationResult
public boolean isUserSettingsFilePresent()
{
return getUserSettingsException() instanceof FileNotFoundException;
return isSettingsFilePresent( getUserSettings(), getUserSettingsException() );
}
public void setGlobalSettingsFileParses( boolean globalSettingsFileParses )
@ -124,4 +124,9 @@ public class DefaultConfigurationValidationResult
{
// ignored
}
private boolean isSettingsFilePresent( Settings settings, Throwable e )
{
return ( settings != null ) || ( ( e != null ) && !( e instanceof FileNotFoundException ) );
}
}

View File

@ -754,7 +754,10 @@ public class MavenEmbedder
{
try
{
fileReader.close();
if ( fileReader != null )
{
fileReader.close();
}
}
catch ( IOException e )
{

View File

@ -60,7 +60,7 @@ public class ValidateConfigurationTest
File global = new File( getBasedir(), "src/test/resources/settings/valid-settings.xml" );
Configuration configuration = new DefaultConfiguration()
.setUserSettingsFile( global );
.setGlobalSettingsFile( global );
ConfigurationValidationResult result = MavenEmbedder.validateConfiguration( configuration );