[JAVA-4837] NullPointerException using Document#getList where the BSON array contains null elements Created: 09/Jan/23  Updated: 28/Oct/23  Resolved: 12/Jan/23

Status: Closed
Project: Java Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 4.8.2

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

Attachments: PNG File image-2023-01-09-14-37-20-985.png    
Backwards Compatibility: Minor Change
Documentation Changes: Not Needed

 Description   

Please add Null check while in the values while using constructValuesList method

Caused by: java.lang.NullPointerException: null
    at org.bson.Document.constructValuesList(Document.java:381)
    at org.bson.Document.getList(Document.java:349)
 

null check for item. PFA 

 

 

Sample input which causes the exception  

  "skills" : [ 
        "SQL"
        "null"
        "null"
        "null"
        "null"
        null
        null
        null
        null
        null
    ]



 Comments   
Comment by Githook User [ 12/Jan/23 ]

Author:

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

Message: Allow null elements in Document#getList (#1066)

JAVA-4837
Branch: 4.8.x
https://github.com/mongodb/mongo-java-driver/commit/0079ef182b52b32106599b21c46c9e32d5ccc658

Comment by Githook User [ 12/Jan/23 ]

Author:

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

Message: Allow null elements in Document#getList (#1066)

JAVA-4837
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/4de305e4e1120aa7fbed87505ea3b36cb37dde05

Generated at Thu Feb 08 09:03:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.