[
https://issues.apache.org/struts/browse/WW-2971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45673#action_45673
]
Travis Newby commented on WW-2971:
----------------------------------
I'm not sure. The semantics get a bit strange when talking about min and max
values for floating point numbers. Unlike integers that - when you fill up
your allotted number of bits - you've reached a min or a max, with floating
points you can fill up your bits by representing lots of numbers that are
nowhere near the min or max. However, a pedantic discussion about those
semantics doesn't help Mr. Lee.
As a temporary patch, you can modify the first two if's in the isInRange method
to something like...
<pre>
<code>
if (double.class == toType || Double.class == toType)
{
bigValue = new BigDecimal(stringValue);
lowerBound = BigDecimal.valueOf(-Double.MAX_VALUE);
upperBound = BigDecimal.valueOf(Double.MAX_VALUE);
}
else if (float.class == toType || Float.class == toType)
{
bigValue = new BigDecimal(stringValue);
lowerBound = BigDecimal.valueOf(-Float.MAX_VALUE);
upperBound = BigDecimal.valueOf(Float.MAX_VALUE);
}
</code>
</pre>
That may or may not be a good long term solution; I must admit that I didn't go
looking through the IEEE spec to see what the true "most negative" legal double
is. Additionally - and in the long run - the class needs to be refactored
because it's a bit sloppy. Perhaps having converters for all the basic types
and using the chain of responsibility pattern would clean things up a bit?
> type conversion cannot convert negative numbers to Double
> ----------------------------------------------------------
>
> Key: WW-2971
> URL: https://issues.apache.org/struts/browse/WW-2971
> Project: Struts 2
> Issue Type: Bug
> Components: Expression Language
> Affects Versions: 2.1.6
> Environment: Struts 2.1.6, 2.1.6 Conventions plugin
> Reporter: Allen Lee
> Attachments: tdartest.tar.bz2
>
>
> Replicate via the following:
> 1. create an action with a Double property
> 2. post to the action with a negative number for that property
> 3. exception stack trace similar to the following will appear, where
> LongitudeLatitudeBox has a Double maximumLongitude property :
> expr: longitudeLatitudeBox.maximumLongitude val: [Ljava.lang.String;@bf2f7c
> context: ognl.ognlcont...@39042078
> root:[org.tdar.struts.action.datasetcontrol...@13072d,
> com.opensymphony.xwork2.defaulttextprovi...@17fd168] value:
> [Ljava.lang.String;@bf2f7c
> ognl.MethodFailedException: Method "setMinimumLongitude" failed for object
> org.tdar.core.bean.coverage.longitudelatitude...@299813
> [java.lang.NoSuchMethodException: setMinimumLongitude([Ljava.lang.String;)]
> at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823)
> at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964)
> at
> ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75)
> at
> ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131)
> at
> com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
> at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656)
> at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.ASTChain.setValueBody(ASTChain.java:172)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.Ognl.setValue(Ognl.java:476)
> at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
> at
> com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:155)
> at
> com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:143)
> at
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
> at
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
> at
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
> at
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
> at
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
> at
> com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.