geirm       01/06/28 12:17:17

  Modified:    src/java/org/apache/velocity/runtime/directive Tag:
                        VEL_1_1_BRANCH Include.java
  Log:
  Fix to bug reported by Dan Finkelstein <[EMAIL PROTECTED]>
  - when using Velocity.evaluate() with a #include() in the eval string
  you get an NPE.  This fix solves the problem in a crude way - I didn't
  want to change the API in Velocity class until 1.2
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.20.2.1  +15 -2     
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java
  
  Index: Include.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java,v
  retrieving revision 1.20
  retrieving revision 1.20.2.1
  diff -u -r1.20 -r1.20.2.1
  --- Include.java      2001/04/28 18:58:40     1.20
  +++ Include.java      2001/06/28 19:17:15     1.20.2.1
  @@ -99,7 +99,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kasper Nielsen</a>
  - * @version $Id: Include.java,v 1.20 2001/04/28 18:58:40 geirm Exp $
  + * @version $Id: Include.java,v 1.20.2.1 2001/06/28 19:17:15 geirm Exp $
    */
   public class Include extends Directive
   {
  @@ -227,8 +227,21 @@
           {
               /*
                *  get the resource, and assume that we use the encoding of the 
current template
  +             *  the 'current resource' can be null if we are processing a stream....
                */
  -            resource = Runtime.getContent(arg, current.getEncoding());
  +
  +            String encoding = null;
  +
  +            if ( current != null)
  +            {
  +                encoding = current.getEncoding();
  +            }
  +            else
  +            {
  +                encoding = (String) Runtime.getProperty( Runtime.INPUT_ENCODING);
  +            }
  +
  +            resource = Runtime.getContent(arg, encoding);
           }
           catch (Exception e)
           {
  
  
  

Reply via email to