jon         01/01/12 11:42:37

  Modified:    src/java/org/apache/velocity/runtime Runtime.java
  Log:
  When an exception occurs in Runtime.parse it is not catched
  and the parser is not returned to the pool in a finally
  block. Therefore after N errors it runs out of parsers.
  
  The Template.process which calls it has a try/finally block
  just to close the input stream.
  
  The trivial fix is below. Maybe it should add something to
  the log (catching the exception).
  Christoph Reck <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.81      +10 -4     
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.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- Runtime.java      2001/01/02 02:42:29     1.80
  +++ Runtime.java      2001/01/12 19:42:36     1.81
  @@ -169,7 +169,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.80 2001/01/02 02:42:29 jvanzyl Exp $
  + * @version $Id: Runtime.java,v 1.81 2001/01/12 19:42:36 jon Exp $
    */
   public class Runtime implements RuntimeConstants
   {    
  @@ -560,9 +560,15 @@
           
           if (parser != null)
           {
  -            AST = parser.parse(inputStream, strTemplateName);
  -            parserPool.put(parser);
  -            return AST;
  +            try
  +            {
  +                AST = parser.parse(inputStream, strTemplateName);
  +                return AST;
  +            }
  +            finally
  +            {
  +                parserPool.put(parser);
  +            }
           }
           else
           {
  
  
  

Reply via email to