[
https://issues.apache.org/jira/browse/AXIS2-6041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17895876#comment-17895876
]
Christian Ortlepp commented on AXIS2-6041:
------------------------------------------
I had a look at the
[PR|https://github.com/apache/axis-axis2-java-core/pull/642]. I think it looks
good in general, but:
* it does not adapt comparison for bytes, floats and doubles. I think at least
we would have to also adapt comparisons for bytes, I am not sure if it is
necessary for float & double (is there anything that NumberFormat can parse
that double/float can't?
* We now create a new NumberFormat instance for every comparison. This is
[inefficient|https://docs.oracle.com/javase/8/docs/api/java/text/NumberFormat.html]
and may lead to performance problems. Since NumberFormat is not Thread-Safe,
we could alternatively put it into a ThreadLocal (This has it's downsides too
of course, but they may be worth it.)
If nobody has any other suggestions/objections I will create a new PR based on
the one by sndurkin.
> totalDigits Facet of XSD type short incorrectly treated in databinding
> ----------------------------------------------------------------------
>
> Key: AXIS2-6041
> URL: https://issues.apache.org/jira/browse/AXIS2-6041
> Project: Axis2
> Issue Type: Bug
> Components: adb
> Affects Versions: 1.8.2
> Reporter: Rob Audenaerde
> Priority: Major
> Fix For: 2.0.0
>
>
> I think this is the same problem as AXIS2-5724, but then for `short`
> {{<xsd:simpleType name="Volgnummer">}}
> {{<xsd:annotation>}}
> {{<xsd:documentation>}}
> {{Een getal tussen de 1 en 20.}}
> {{</xsd:documentation>}}
> {{</xsd:annotation>}}
> {{<xsd:restriction base="xsd:short">}}
> {{<xsd:minInclusive value="1" />}}
> {{<xsd:maxInclusive value="20" />}}
> {{<xsd:totalDigits value="2" />}}
> {{</xsd:restriction>}}
> {{</xsd:simpleType>}}
> {{Results in:}}
>
> {{public void setVolgnummer(short param) {}}
> {{java.lang.String totalDigitsDecimal =}}
> {{org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("2")}}
> {{.toPlainString();}}
> {{if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
> totalDigitsDecimal) < 0) {}}
> {{this.localVolgnummer = param;}}
> {{} else {}}
> {{throw new java.lang.RuntimeException("Input values do not follow defined
> XSD restrictions");}}
> {{}}}
> {{}}}
> But the {{totalDigitsDecimal will be filled with 100.0, which cannot be
> converted to short.}}
>
> {{@Test}}
> {{public void testVolgnummer() {}}
> {{final ServiceStub.Volgnummer volgnummer = new ServiceStub.Volgnummer();}}
> {{volgnummer.setVolgnummer((short) 1);}}
> {{}}}
> Fails with:
>
> {{java.lang.NumberFormatException: For input string: "100.0"}}{{ at
> java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)}}
> {{ at java.base/java.lang.Integer.parseInt(Integer.java:668)}}
> {{ at java.base/java.lang.Short.parseShort(Short.java:137)}}
> {{ at java.base/java.lang.Short.parseShort(Short.java:163)}}
> {{ at
> org.apache.axis2.databinding.utils.ConverterUtil.compare(ConverterUtil.java:1330)}}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]