geirm       01/06/16 09:05:17

  Modified:    src/java/org/apache/velocity/texen Tag: VEL_1_1_BRANCH
                        Generator.java
  Log:
  Synching up with HEAD before release - this was committed by Jon
  with the following message :
  
  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
  No                   revision
  
  
  No                   revision
  
  
  1.15.4.1  +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.15.4.1
  diff -u -r1.15 -r1.15.4.1
  --- Generator.java    2001/04/02 01:15:18     1.15
  +++ Generator.java    2001/06/16 16:05:17     1.15.4.1
  @@ -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.15.4.1 2001/06/16 16:05:17 geirm 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();
       }
   }
  
  
  

Reply via email to