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

totalDigits Facet of XSD type short incorrectly treated in databinding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.2
    • 2.0.0
    • adb
    • None

    Description

      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)

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              robau Rob Audenaerde
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: