Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-1290

Numeric values with more than 17 digits of precision cause error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • (Java) V4 4.5.0
    • None
    • None

    Description

      The IBM Cognos TM1 (OData compliant) REST API can return values such as this ...

      "@odata.context": "../$metadata#Cellsets('l8-ZO2wMAIABAAAg')/Cells(Value)",
      "value": [

      { "Value": 70 }

      ,

      { "Value": -0.043099999999995475 }

      ]

      This causes the following error ...

      2018-09-08 07:41:30,214 ERROR o.a.o.c.a.d.ClientEntitySetIterator [main] Error retrieving entities from EntitySet
      ...
      Caused by: org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException: The literal '-0.043099999999995475' has illegal content.
      at org.apache.olingo.commons.core.edm.primitivetype.EdmDouble.internalValueOfString(EdmDouble.java:80) ~[org.apache.olingo-odata-commons-core-4.5.0.jar:?]

      I investigated further and noted that the code uses a pattern ...

      private static final Pattern PATTERN = Pattern.compile(
      "(?:\\+|-)?
      p{Digit}

      {1,17}(?:\\.
      p{Digit}{1,17}

      )?(??:E|e)(?:\\+|-)?
      p{Digit}

      {1,3}

      )?");

      .. which is the cause of this error because we have 18 digits after the decimal point.

      The TM1 architect contacted RalfHandl who said ...

      "Olingo is too restrictive here, OData does not add any restrictions on representation of numbers on top of the JSON RFC."

      Attachments

        Activity

          People

            Unassigned Unassigned
            mikerobe Mike Roberts
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: