You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2010/03/30 07:40:27 UTC

[jira] Resolved: (VELOCITY-753) IntrospectionUtils.isMethodInvocationConvertible() returns true for NumberFormat.format(double) method with a Float.class argument

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

Nathan Bubna resolved VELOCITY-753.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0
                   1.7

> IntrospectionUtils.isMethodInvocationConvertible() returns true for NumberFormat.format(double) method with a Float.class argument
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-753
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-753
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Tim Kuntz
>             Fix For: 1.7, 2.0
>
>
> NumberFormat has both a format(double) and format(Object) method. When evaluated against a Float, IntrospectionUtils is returning true. This causes Method.getBestMatch() to throw an AmbigouusException.
> I have included a failing test case below to show this issue.
> Thanks,
> Tim
> import java.io.StringReader;
> import java.io.StringWriter;
> import java.text.NumberFormat;
> import junit.framework.TestCase;
> import org.apache.velocity.VelocityContext;
> import org.apache.velocity.app.Velocity;
> public class VelocityFormatTest extends TestCase {
> 	public void test_format_of_float() throws Exception {
> 		// verify format() outside of Velocity
> 		NumberFormat numberFormat = NumberFormat.getInstance();
> 		Float aFloat = new Float(5.23);
> 		assertEquals("5.23", numberFormat.format(aFloat));
> 		Velocity.init();
> 		VelocityContext context = new VelocityContext();
> 		context.put("numberFormatter", numberFormat);
> 		context.put("aFloat", aFloat);
> 		StringWriter sw = new StringWriter();
> 		StringReader sr = new StringReader(
> 				"float value is ${numberFormatter.format($aFloat)}");
> 		Velocity.evaluate(context, sw, "name", sr);
> 		String expectedValue = "float value is 5.23";
> 		assertEquals(expectedValue, sw.toString());
> 	}
> }

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