Axis2
  1. Axis2
  2. AXIS2-4200

ConverterUtil.compare fails for BigInteger values

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5.5, 1.6.0
    • Component/s: adb
    • Labels:
      None
    • Environment:
      Axis2 1.4.1, JBoss 4.2, jdk6u10

      Description

      A range is defined as:

      <xs:restriction base="xs:integer">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="999999999999999"/>
      </xs:restriction>

      The generated databinding calls:

      public void setPhoneNumberType(java.math.BigInteger param){
      if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "999999999999999") <= 0)

      { this.localPhoneNumberType=param; }

      else

      { throw new java.lang.RuntimeException(); }

      The ConverterUtil code is:

      public static int compare(BigInteger binBigInteger, String value)

      { return binBigInteger.intValue() - Integer.parseInt(value); }

      This will always fail for values that exceed the capacity of a java.lang.Integer with:

      Caused by: java.lang.NumberFormatException: For input string: "999999999999999"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Integer.parseInt(Integer.java:459)
      at java.lang.Integer.parseInt(Integer.java:497)
      at org.apache.axis2.databinding.utils.ConverterUtil.compare(ConverterUtil.java:1281)
      [...]

        Issue Links

          Activity

          Hide
          David Übelacker added a comment -

          Have the same problem with version 1.5.1

          solved it by replacing

          public static int compare(BigInteger binBigInteger, String value)

          { return binBigInteger.intValue() - Integer.parseInt(value); }

          with

          public static long compare(BigInteger binBigInteger, String value)

          { return binBigInteger.longValue() - Long.parseLong(value); }

          in org.apache.axis2.databinding.utils.ConverterUtil

          Show
          David Übelacker added a comment - Have the same problem with version 1.5.1 solved it by replacing public static int compare(BigInteger binBigInteger, String value) { return binBigInteger.intValue() - Integer.parseInt(value); } with public static long compare(BigInteger binBigInteger, String value) { return binBigInteger.longValue() - Long.parseLong(value); } in org.apache.axis2.databinding.utils.ConverterUtil
          Hide
          Amila Chinthaka Suriarachchi added a comment -

          fixed the issue with revision 896320

          Show
          Amila Chinthaka Suriarachchi added a comment - fixed the issue with revision 896320
          Hide
          Hudson added a comment -

          Integrated in axis2-1.5 #124 (See https://hudson.apache.org/hudson/job/axis2-1.5/124/)
          AXIS2-4200: Merged r896320 to the 1.5 branch.

          Show
          Hudson added a comment - Integrated in axis2-1.5 #124 (See https://hudson.apache.org/hudson/job/axis2-1.5/124/ ) AXIS2-4200 : Merged r896320 to the 1.5 branch.

            People

            • Assignee:
              Unassigned
              Reporter:
              Roman HEINZ
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development