You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Victor Hu (Jira)" <ji...@apache.org> on 2022/05/05 23:15:00 UTC

[jira] [Commented] (OLINGO-1568) Error serializing BigDecimal when passed certain BigDecimal values

    [ https://issues.apache.org/jira/browse/OLINGO-1568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532555#comment-17532555 ] 

Victor Hu commented on OLINGO-1568:
-----------------------------------

I have created this patch to fix this bug: [^0001-OLINGO-1568-Add-handling-of-special-case-precision-s.patch]

The idea behind this code is to add handling to the special cases where precision does not match the OData format. If a BigDecimal sends a precision value less than scale, we set the precision to be equal to scale. If a BigDecimal sends an precision value of 0, we should treat it as null.

Included are unit tests covering these scenarios.

> Error serializing BigDecimal when passed certain BigDecimal values
> ------------------------------------------------------------------
>
>                 Key: OLINGO-1568
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1568
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata4-client
>    Affects Versions: (Java) V4 4.8.0, (Java) V4 4.9.0
>            Reporter: Victor Hu
>            Priority: Major
>         Attachments: 0001-OLINGO-1568-Add-handling-of-special-case-precision-s.patch
>
>
> This is a refiling OLINGO-1549 except categorized as a bug.
> This bug was introduced with the change made in OLINGO-1480 to allow for larger precision/scale values when passed in as a BigDecimal as they can exceed the default precision of 40 and scale of 25.
> However, this broke insertions for values ranging from ]0.0, 0.1[ as their BigDecimal representations have precision less than scale (which is not allowed according to the [OData CSDL|http://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html#sec_Scale]).
> This also breaks insertions for BigDecimal values that do not specify precision - an arbitrary precision in BigDecimal is represented as 0 versus the arbitrary precision representation of null in OData.
> The following throws an exception due to this bug
> {code:java}
> new ClientObjectFactoryImpl().newPrimitiveValueBuilder().buildDecimal(new BigDecimal("0.04")).toString();
> {code}
> {noformat}
> java.lang.IllegalArgumentException: org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException: The value '0.04' does not match the facets' constraints.{noformat}
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)