jon 01/06/12 16:48:55
Modified: src/java/org/apache/velocity/texen Generator.java
Log:
added patch by "Russell Edens" <[EMAIL PROTECTED]> to clear out the
fileWriters cache
JSS: also made sure to close other java.io stuff down in finally
statements.
ran the test suite and things passed
Revision Changes Path
1.16 +24 -7
jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java
Index: Generator.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Generator.java 2001/04/02 01:15:18 1.15
+++ Generator.java 2001/06/12 23:48:54 1.16
@@ -76,7 +76,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leon Messerschmidt</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Generator.java,v 1.15 2001/04/02 01:15:18 geirm Exp $
+ * @version $Id: Generator.java,v 1.16 2001/06/12 23:48:54 jon Exp $
*/
public class Generator
{
@@ -154,15 +154,18 @@
{
try
{
- FileInputStream fi = new FileInputStream (propFile);
- BufferedInputStream bi = new BufferedInputStream (fi);
+ BufferedInputStream bi = null;
try
{
+ bi = new BufferedInputStream (new FileInputStream (propFile));
props.load (bi);
}
finally
{
- bi.close();
+ if (bi != null)
+ {
+ bi.close();
+ }
}
}
catch (Exception e)
@@ -193,10 +196,21 @@
ClassLoader classLoader = Runtime.class.getClassLoader();
try
{
- InputStream inputStream = classLoader.getResourceAsStream(
- DEFAULT_TEXEN_PROPERTIES);
+ InputStream inputStream = null;
+ try
+ {
+ inputStream = classLoader.getResourceAsStream(
+ DEFAULT_TEXEN_PROPERTIES);
- props.load( inputStream );
+ props.load( inputStream );
+ }
+ finally
+ {
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+ }
}
catch (Exception ioe)
{
@@ -319,6 +333,7 @@
VelocityContext vc = new VelocityContext( controlContext );
template.merge (vc,fileWriter);
+ // commented because it is closed in shutdown();
//fw.close();
return "";
@@ -448,5 +463,7 @@
/* do nothing */
}
}
+ // clear the file writers cache
+ fileWriters.clear();
}
}