geirm 00/11/26 20:28:55
Modified: src/java/org/apache/velocity/runtime Runtime.java
Log:
Added check to see if we are passed a null or empty properties file for init( string
).
Revision Changes Path
1.54 +30 -27
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
Index: Runtime.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Runtime.java 2000/11/27 03:37:50 1.53
+++ Runtime.java 2000/11/27 04:28:54 1.54
@@ -160,7 +160,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Bowden</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magusson Jr.</a>
- * @version $Id: Runtime.java,v 1.53 2000/11/27 03:37:50 geirm Exp $
+ * @version $Id: Runtime.java,v 1.54 2000/11/27 04:28:54 geirm Exp $
*/
public class Runtime implements RuntimeConstants
{
@@ -282,39 +282,42 @@
setDefaultProperties();
/*
- * Try loading propertiesFile as a straight file first,
+ * if we were passed propertis, try loading propertiesFile as a straight
file first,
* if that fails, then try and use the classpath
*/
-
- File file = new File(propertiesFileName);
-
- try
+
+ if (propertiesFileName != null && !propertiesFileName.equals(""))
{
- if( file.exists() )
+ File file = new File(propertiesFileName);
+
+ try
{
- FileInputStream is = new FileInputStream( file );
- addPropertiesFromStream( is, propertiesFileName );
+ if( file.exists() )
+ {
+ FileInputStream is = new FileInputStream( file );
+ addPropertiesFromStream( is, propertiesFileName );
+ }
+ else
+ {
+ info ("Override Properties : " + file.getPath() + " not found.
Looking in classpath.");
+
+ /*
+ * lets try the classpath
+ */
+
+ ClassLoader classLoader = Runtime.class.getClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream(
propertiesFileName );
+
+ if (inputStream!= null)
+ addPropertiesFromStream( inputStream, propertiesFileName );
+ else
+ info ("Override Properties : " + propertiesFileName + " not
found in classpath.");
+ }
}
- else
+ catch (Exception ex)
{
- info ("Override Properties : " + file.getPath() + " not found.
Looking in classpath.");
-
- /*
- * lets try the classpath
- */
-
- ClassLoader classLoader = Runtime.class.getClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream(
propertiesFileName );
-
- if (inputStream!= null)
- addPropertiesFromStream( inputStream, propertiesFileName );
- else
- info ("Override Properties : " + propertiesFileName + " not
found in classpath.");
+ error("Exception finding properties " + propertiesFileName + " : "
+ ex);
}
- }
- catch (Exception ex)
- {
- error("Exception finding properties " + propertiesFileName + " : " +
ex);
}
/*