[ https://issues.apache.org/jira/browse/AXIS2-5724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17061956#comment-17061956 ]
Adam Fordham commented on AXIS2-5724: ------------------------------------- The fix implemented in the referenced issue works when a restriction is a *Decimal* parameter. However, it fails with the *NumberFormatException* when the restriction is an *Integer*. This is because of the overloaded *org.apache.axis2.databinding.utils.ConverterUtil.compare(param,value)* method. When the `*param`* is an *Integer*, it calls the *compare(BigInteger binBigInteger, String value)* method that tries to convert the *StandardDecimalNotation* *String `value`* to a *Long*, which throws the *NumberFormat Exception*. A possbile fix would be to update the compare method to use something like this: {code:java} public static long compare(BigInteger binBigInteger, String value) { NumberFormat nf = NumberFormat.getInstance(); Long param = nf.parse(value).longValue(); return binBigInteger.longValue() - param; } {code} I'd be willing to contribute a patch. What is the best method to do this? > totalDigits Facet of XSD type int incorrectly treated in databinding > -------------------------------------------------------------------- > > Key: AXIS2-5724 > URL: https://issues.apache.org/jira/browse/AXIS2-5724 > Project: Axis2 > Issue Type: Bug > Components: adb > Affects Versions: 1.6.3, 1.7.3 > Environment: Windows 10, cygwin, java 1.8.0_60 > Reporter: Jeff Greif (work) > Priority: Major > > Note: I could not enter the release I'm using: 1.6.2. > The following XSD fragment > <xsd:complexType name="EMPL_RCDTypeShape"><xsd:simpleContent><xsd:extension > base="EMPL_RCDTypeDef"/></xsd:simpleContent></xsd:complexType> > <xsd:simpleType name="EMPL_RCDTypeDef"><xsd:restriction > base="xsd:int"><xsd:totalDigits value="3"/></xsd:restriction></xsd:simpleType> > produces, in a stub generated by wsdl2java > public void setEMPL_RCDTypeDef(int param){ > java.lang.String totalDigitsDecimal = > org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("3").toString(); > if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, > totalDigitsDecimal) > 0){ > this.localEMPL_RCDTypeDef=param; > } > else { > throw new java.lang.RuntimeException(); > } > } > The string value of totalDigitsDecimal is "1000.0", rather than "1000", or > some different method should have been called to convert totalDigits to a > string, causing the error seen in this stacktrace snippet: > Caused by: java.lang.NumberFormatException: For input string: "1000.0" > at > java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) > at java.lang.Integer.parseInt(Integer.java:580) > at java.lang.Integer.parseInt(Integer.java:615) > at > org.apache.axis2.databinding.utils.ConverterUtil.compare(ConverterUtil.java:1249) > at > com....SomeStub$EMPL_RCDTypeShape2.setEMPL_RCDTypeDef(CI_PRJ_ABSV_RQST_CIStub.java) -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@axis.apache.org For additional commands, e-mail: java-dev-h...@axis.apache.org