[JAVA-2500] org.bson.json.JsonParseException: JSON reader was expecting a value but found '}'. Created: 20/Apr/17  Updated: 29/Oct/23  Resolved: 20/Apr/17

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: 3.5.0
Fix Version/s: 3.5.0

Type: Bug Priority: Major - P3
Reporter: Michael Weber Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The following code works prior to version 3.4. but does not in 3.5.0-Snapshot

    @Test
    public void testDecode() {
        StringWriter stringWriter = new StringWriter();
        JsonWriter writer = new JsonWriter(stringWriter, new JsonWriterSettings(true));
        CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry());
        Codec<Document> documentCodec = codecRegistry.get(Document.class);
 
        Document document = new Document("dateList", Arrays.asList(new Date(), new Date()));
        documentCodec.encode(writer, document, EncoderContext.builder().build());
 
        Document decoded = documentCodec.decode(new JsonReader(stringWriter.toString()), DecoderContext.builder().build());
    }

While decoding, it throws an exception after the first date is read.

org.bson.json.JsonParseException: JSON reader was expecting a value but found '}'.



 Comments   
Comment by Githook User [ 20/Apr/17 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2500: Ensure that JsonReader.visitDateTimeExtendedJson always consumes the END_OBJECT token
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/678591b0ee9f1d62bac60b3048ab79e41cf4ebfa

Comment by Jeffrey Yemin [ 20/Apr/17 ]

Hi Michael,

Thanks for testing out the snapshot. We have a fix in internal review now and will get it published as soon as it's approved.

Generated at Thu Feb 08 08:57:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.