Skip to content

Deserializing BigDecimal throws exception #75

Closed

Description

@CluEleSsUK

Inside CustomClassMapper in method deserializeToClass(Object obj, Class<T> clazz), the conditional statement wrongly assumes the value is of primitive type if Number.class.isAssignableFrom(clazz).
BigDecimal returns true but is not primitive, and throws an IllegalArgumentException in deserializeToPrimitive(Object obj, Class<T> clazz)

Activity

  1. hiranya911 commented on Sep 20, 2017

    @hiranya911
    Contributor

    Thanks for pointing this out @CluEleSsUK. If you can please provide us a pull request to fix this. Otherwise I will take a look in a couple of days.

  2. CluEleSsUK commented on Sep 20, 2017

    @CluEleSsUK
    Author
  3. ghajba commented on Oct 7, 2017

    @ghajba

    A question to this topic: how should a BigDecimal/BigInteger be serialized?

    I am currently facing the same issue, and I want to fix it, but I don't just want to hack something together.

  4. schmidt-sebastian commented on Mar 6, 2019

    @schmidt-sebastian
    Contributor

    We are taking a look at this internally as this affects Android as well.

  5. schmidt-sebastian commented on Mar 14, 2019

    @schmidt-sebastian
    Contributor

    I have pushed PRs to provide better error messages. Unfortunately, this will only marginally improve your experience with BigDecimal/BigInteger. Our backend does not support integer precision for numbers that exceed the 64bit signed range. If you do need to store larger numbers, please use "double" instead.

  6. hiranya911 commented on Mar 14, 2019

    @hiranya911
    Contributor

    @schmidt-sebastian are you going to implement any changes in the Admin SDK code?

  7. schmidt-sebastian commented on Mar 15, 2019

    @schmidt-sebastian
    Contributor

    We are only updating our error messages: googleapis/google-cloud-java#4675.

    For now, the best work around is using double or Strings, both of which round-trip well between other clients and the backend.

  8. hiranya911 commented on Oct 8, 2019

    @hiranya911
    Contributor

    As of now we don't plan to support serialization of these types in RTDB. But we can revisit this issue if there's more interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions