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).

----------------------------------------------------------
--- Apache-Velocity-20010109/src/java/org/apache/velocity/runtime/Runtime.java  Tue 
Jan  2 03:42:29 2001
+++ Apache-Velocity/src/java/org/apache/velocity/runtime/Runtime.java   Fri Jan 12 
+18:17:10 2001
@@ -560,10 +560,16 @@
         
         if (parser != null)
         {
+            try
+            {
                 AST = parser.parse(inputStream, strTemplateName);
-                parserPool.put(parser);
                 return AST;
             }
+            finally
+            {
+                parserPool.put(parser);
+            }
+        }
         else
         {
             error("Runtime : ran out of parsers!");
----------------------------------------------------------

:) Christoph

Reply via email to