You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org> on 2007/03/08 01:04:42 UTC

[jira] Closed: (VELOCITY-404) Uberspect - info is created wrong / premature blocking of invalid methods

     [ https://issues.apache.org/jira/browse/VELOCITY-404?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-404.
-------------------------------------------


> Uberspect - info is created wrong / premature blocking of invalid methods
> -------------------------------------------------------------------------
>
>                 Key: VELOCITY-404
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-404
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.4
>            Reporter: Will Glass-Husain
>         Assigned To: Will Glass-Husain
>            Priority: Minor
>             Fix For: 1.5
>
>         Attachments: InfoOnExceptionTest.java, InfoOnExceptionUberspect.java, InfoOnExceptionUberspect.java, patch1.txt, StringResourceLoader.java
>
>
> Reported and patch submitted by Llwellyn Falco & Dan Powell.  Email below:
> Sorry,
>     apparently i am being a bit confusing.
>     the patch was rather large (six lines of code) so i can understand why i 
> should have explained it more clearly,
>     The patch is against 3 issues, 1 of them i submitted when the old 
> bugzilla, the other 2 don't exist. but there is a unit test per each issue 
> submitted with the patch.
>     don't quite understand why i would create an issue merely to close it. i 
> mean if i needed to show my boss i was working the busy work would make 
> sense, but as we are all doing this
>     in our free time.... if you feel you need notes that better explain the 
> patch than the unit tests, by all means fell free, but i personally can't 
> think what i would write that is more precise than actual code.
>     issue 1 (this is Velocity-381)
> [ see Velocity-381 ]
>   issue 2 (no jira issue)
>  the info is created wrong.
>  code change
> ----
> -                method = rsvc.getUberspect().getMethod(o, methodName, 
> params, new Info("",1,1));
> +                method = rsvc.getUberspect().getMethod(o, methodName, 
> params, new Info(context.getCurrentTemplateName(), getLine(), getColumn()));
> -----
>  the test checks against an uberspect that throws exceptions with it can't 
> find stuff.
> (this is also useful for development, but i am trying to start with small 
> changes as to keep things simple, so kept it to testing)
> ---
>     public Info getInfoFor(String velocity) throws Exception {
>         try {
>             parseString(velocity, this);
>             fail("Uberspect Should have thrown an exception");
>             throw new Error("Shouldn't be able to reach this point");
>         } catch (VelocityParsingError t) {
>             return t.getInfo();
>         }
>     }
>     public void testInfoForField() throws Exception {
>         Info i = getInfoFor("$main.unknownField");
>         assertInfoEqual(i, "$main.unknownField", 1, 7);
>     }
>     public void testInfoForMethod() throws Exception {
>         Info i = getInfoFor("$main.unknownMethod()");
>         assertInfoEqual(i, "$main.unknownMethod()", 1, 7);
>     }
>     private void assertInfoEqual(Info i, String name, int line, int column) 
> {
>         assertEquals("Template Name", name, i.getTemplateName());
>         assertEquals("Template Line", line, i.getLine());
>         assertEquals("Template Column", column, i.getColumn());
>     }
> ---
> The third test also deals with the uberspect. design indicates that the 
> uberspect should be asked to find the method, and therefore if you wanted a 
> to write an uberspect to check when you are calling methods on null's you 
> could write one. but the parser blocked it.
> the test is
> ---
>     public void testNullPointer() {
>         assertErrorThrown("$main.getNull().callMethod()");
>     }
>     private void assertErrorThrown(String string) {
>         try {
>             String result = parseString(string, this);
>         Assert.fail("parsing '" + string + "' did not fail but returned '" + 
> result + "'");
>         } catch (Throwable t) {
>             return;
>         }
>     }
> ---- 
>   the code change is the removal of premature exit
> -                if (result == null)
> -                {
> -                    return null;
> -                }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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