commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java
Date Sun, 14 Nov 2004 18:29:02 GMT
oheger      2004/11/14 10:29:02

  Modified:    configuration/src/test/org/apache/commons/configuration
                        TestPropertiesConfiguration.java
               configuration/src/java/org/apache/commons/configuration
                        AbstractFileConfiguration.java
  Log:
  Bug 32236: Fixed NPE for file based configurations when constructed with invalid file name
  
  Revision  Changes    Path
  1.16      +14 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
  
  Index: TestPropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestPropertiesConfiguration.java	18 Oct 2004 21:38:45 -0000	1.15
  +++ TestPropertiesConfiguration.java	14 Nov 2004 18:29:02 -0000	1.16
  @@ -207,6 +207,19 @@
   
           assertEquals("true", conf.getString("configuration.loaded"));
       }
  +    
  +    public void testLoadUnexistingFile()
  +    {
  +        try
  +        {
  +            conf = new PropertiesConfiguration("Unexisting file");
  +            fail("Unexisting file was loaded.");
  +        }
  +        catch(ConfigurationException cex)
  +        {
  +            // fine
  +        }
  +    }
   
       public void testGetStringWithEscapedChars()
       {
  
  
  
  1.8       +5 -1      jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java
  
  Index: AbstractFileConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractFileConfiguration.java	19 Oct 2004 11:44:31 -0000	1.7
  +++ AbstractFileConfiguration.java	14 Nov 2004 18:29:02 -0000	1.8
  @@ -80,6 +80,10 @@
   
           // locate the file
           url = ConfigurationUtils.locate(fileName);
  +        if(url == null)
  +        {
  +            throw new ConfigurationException(fileName + " could not be found!");
  +        }
   
           // update the base path
           setBasePath(ConfigurationUtils.getBasePath(url));
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message