Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2296

Parts of the legacy BSON API do not handle documents containing Decimal128 values

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON

      This is using 3.4.0-SNAPSHOT as of today, when decoding a mgo encoded object with decimal128 values.

      org.bson.BSONException: Unexpected BSON type: DECIMAL128
      	at org.bson.BsonBinaryReader.doSkipValue(BsonBinaryReader.java:357) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at org.bson.AbstractBsonReader.skipValue(AbstractBsonReader.java:492) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at org.bson.LazyBSONObject.keySet(LazyBSONObject.java:151) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at com.mongodb.LazyDBCallback.createObject(LazyDBCallback.java:41) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at org.bson.LazyBSONCallback.gotBinary(LazyBSONCallback.java:41) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at org.bson.LazyBSONDecoder.decode(LazyBSONDecoder.java:63) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      	at com.mongodb.LazyDBDecoder.readObject(LazyDBDecoder.java:39) ~[mongo-java-driver-3.4.0-SNAPSHOT.jar:na]
      

      On the encoding side, the following test case will complain about Can't serialize class org.bson.types.Decimal128.

              BSONObject obj = new BasicBSONObject();
              obj.put("i", Decimal128.parse("1"));
      
              OutputBuffer ob = new BasicOutputBuffer(); 
              DBEncoder encoder = DefaultDBEncoder.FACTORY.create();
              encoder.writeObject(ob, obj);
      

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            chunming.li@mongodb.com Chunming Li (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: