Skip to content

Cannot retrieve map that contains BigInteger using SDC. #1611

Closed
@mmonti

Description

@mmonti

Hi!

I am running into an issue when i try to retrieve a document that contains a key with a BigInteger type value.
The error I am getting is a bit missleading since the document is stored correctly but fail to retrieve:

java.lang.IllegalArgumentException: Attribute of type java.math.BigInteger cannot be stored and must be converted.

This seems to be a limitation only on the SDC sdk since I tried to store and retrieve the document with the Couchbase Driver class (Cluster) and I was able to do it without any issues.

I did some debugging in the code and it looks like there is check in the CouchbaseDocument.java class (line 126) that uses CouchbaseSimpleTypes to test if the type of the value that is beign loaded matches certain types: CouchbaseDocument.class, CouchbaseList.class.

 private void verifyValueType(final Object value) {
        if (value != null) {
            Class<?> clazz = value.getClass();
            if (!CouchbaseSimpleTypes.DOCUMENT_TYPES.isSimpleType(clazz)) {
                throw new IllegalArgumentException("Attribute of type " + clazz.getCanonicalName() + " cannot be stored and must be converted.");
            }
        }
    }

I created a repository with a couple test to repro the issue: https://github.com/mmonti/sdc-biginteger-issue/blob/master/src/test/java/com/example/biginteger/BigIntegerIssue.java

I am using spring-data-couchbase 4.4.5 in the repro project, but i can confirm that the issue is also present in spring-data-couchbase 3.1.18.

I just wanted to know if this is a known issue and if there is any possible workaround for it.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions