You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by he...@apache.org on 2005/10/01 15:11:42 UTC

svn commit: r292980 - /jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java

Author: henning
Date: Sat Oct  1 06:11:39 2005
New Revision: 292980

URL: http://svn.apache.org/viewcvs?rev=292980&view=rev
Log:
Remove String(String) C'tor.

Can anyone tell me whether this whole code segment is actually
correct? Because a method returning 'null' and not having a void
return type might cause this code to return 'null' to the
caller. According to the comment on top of this block, this might
actually be a bad idea. Maybe we can just remove the whole
method.getReturnType() check and return unconditionally "" when the
result is null?


Modified:
    jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java

Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=292980&r1=292979&r2=292980&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Sat Oct  1 06:11:39 2005
@@ -209,7 +209,9 @@
             if (obj == null)
             {
                 if( method.getReturnType() == Void.TYPE)
-                     return new String("");
+                {
+                    return "";
+                }
             }
             
             return obj;



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: svn commit: r292980 - /jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java

Posted by Will Glass-Husain <wg...@forio.com>.
This code block looks ok to me.  We can't remove this because that would be 
incompatible.  If we remove this check and always return "" for bad methods 
then

$validobject.nullMethod()

would echo "$validobject.nullMethod()" pre-update and empty string 
post-update.

WILL


----- Original Message ----- 
From: <he...@apache.org>
To: <ve...@jakarta.apache.org>
Sent: Saturday, October 01, 2005 6:11 AM
Subject: svn commit: r292980 - 
/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java


> Author: henning
> Date: Sat Oct  1 06:11:39 2005
> New Revision: 292980
>
> URL: http://svn.apache.org/viewcvs?rev=292980&view=rev
> Log:
> Remove String(String) C'tor.
>
> Can anyone tell me whether this whole code segment is actually
> correct? Because a method returning 'null' and not having a void
> return type might cause this code to return 'null' to the
> caller. According to the comment on top of this block, this might
> actually be a bad idea. Maybe we can just remove the whole
> method.getReturnType() check and return unconditionally "" when the
> result is null?
>
>
> Modified:
> 
> jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
>
> Modified: 
> jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
> URL: 
> http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=292980&r1=292979&r2=292980&view=diff
> ==============================================================================
> ---  
> jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java 
> (original)
> +++ 
> jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java 
> Sat Oct  1 06:11:39 2005
> @@ -209,7 +209,9 @@
>             if (obj == null)
>             {
>                 if( method.getReturnType() == Void.TYPE)
> -                     return new String("");
> +                {
> +                    return "";
> +                }
>             }
>
>             return obj;
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org