You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Tom Eyckmans (JIRA)" <ji...@apache.org> on 2013/09/19 13:15:51 UTC
[jira] [Commented] (AXIS2-5342) Generated code for xsd:totalDigits
cause errors
[ https://issues.apache.org/jira/browse/AXIS2-5342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13771804#comment-13771804 ]
Tom Eyckmans commented on AXIS2-5342:
-------------------------------------
I've got a similar issue with the convertToStandardDecimalNotation and compare functions of the ConverterUtil class:
java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("18").toString();
if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal) > 0){
this.localEanIdType=param;
}
The toString() method results in "1.0E+18" and causes a:
Caused by: java.lang.NumberFormatException: For input string: "1.0E+18"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.parseLong(Long.java:483)
at org.apache.axis2.databinding.utils.ConverterUtil.compare(ConverterUtil.java:1277)
I've changed the code as a workaround to:
java.lang.String totalDigitsDecimal = "" + org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("18").longValue();
if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal) < 0) { ...
using default formatting here because in ConverterUtil compare Long.parseLong(value) also uses default formatting, changed if check from > to < because convertToStandardDecimalNotation generates the first 19 digit number (you'll run into a problem using this approach when you actually want to use Long.MAX_VALUE) and a smaller (valid) number generates a negative number. valid numbers don't generate a positive compare result.
> Generated code for xsd:totalDigits cause errors
> -----------------------------------------------
>
> Key: AXIS2-5342
> URL: https://issues.apache.org/jira/browse/AXIS2-5342
> Project: Axis2
> Issue Type: Bug
> Components: adb, codegen
> Affects Versions: 1.6.2
> Reporter: Conny Kreyßel
> Fix For: 1.7.0, 1.6.3
>
>
> If you have a element like
> <xsd:simpleType name="abc">
> <xsd:restriction base="xsd:integer">
> <xsd:totalDigits value="5" />
> </xsd:restriction>
> </xsd:simpleType>
> axis generates this as source code
> public void setAbc(java.math.BigInteger param){
> java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("5").toString();
> if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal) > 0){
> this.localHerkunftsschluessel=param;
> }
> else {
> throw new java.lang.RuntimeException();
> }
> }
> The problem is the toString() of the result from .convertToStandardDecimalNotation("5"). It converts the a BigDecimal into String and this results in "10000.0". Then ConverterUtil.compare() trys to convert this string into a Long. BANG.
> Please change convertToStandardDecimalNotation().toString() into convertToStandardDecimalNotation().toPlainString().
> The same functionality should be evaluated for xsd:int, xsd:float, xsd:decimal ...
> IMHO, this results from a bad implementation of AXIS2-4190. Please add testcases for this.
> Take a look at the following comment and below.
> https://issues.apache.org/jira/browse/AXIS2-4190?focusedCommentId=13285198&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13285198
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org