Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5789

Generated code for xsd:totalDigits throws NumberFormatException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.7.3
    • Fix Version/s: None
    • Component/s: adb, codegen
    • Labels:
      None

      Description

      In relation to issue https://issues.apache.org/jira/browse/AXIS2-5342,
      generated code for type:

          <simpleType name="INTERO3_TYPE">
              <restriction base="integer">
                  <totalDigits value="3"/>
              </restriction>
          </simpleType>
      

      produces a class with setter:

       public void setINTERO3_TYPE(java.math.BigInteger param) {
              java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("3").toPlainString();
      
              if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal) < 0) {
                  this.localINTERO3_TYPE = param;
              } else {
                  throw new java.lang.RuntimeException(
                      "Input values do not follow defined XSD restrictions");
              }
          }
      

      ConverterUtil.convertToStandardDecimalNotation produces a BigDecimal with a toPlainString() value "1000.0", but ConverterUtil.compare(BigInteger, String) contains code:

      ConverterUtil.java:1344
      public static long compare(BigInteger binBigInteger, String value) {
              return binBigInteger.longValue() - Long.parseLong(value);
          }
      
      

      which parses second string parameter as a Long, throwing a NumberFormatException

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                filjander Stefano Rodi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: