[JAVA-2577] GridFSFileCodec throws exception when metadata field is null Created: 06/Aug/17 Updated: 27/Oct/23 Resolved: 06/Sep/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | GridFS |
| Affects Version/s: | 3.5.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mihály Gyöngyösi | Assignee: | Ross Lawley |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
macOS Sierra (10.12.6) |
||
| Description |
|
GridFSFileCodec throws an exception when the file's "metadata" field is null. GridFSFileCodec.java#73 Underlying problem in the BsonDocument class (containsKey("metadata") return true when the value is BsonNull.
Full stacktrace:
|
| Comments |
| Comment by Ross Lawley [ 07/Aug/17 ] |
|
Hi, Correct, you should not include the field at all. Ross |
| Comment by Mihály Gyöngyösi [ 07/Aug/17 ] |
|
Hi ross.lawley, Thank you for your answer. So it means when I don't want to add metadata to the GridFS file then I have to skip it and I should not add the field with null value? This GridFS file/document generated by an other project and with "metadata" : null (Type: Null) Mihály |
| Comment by Ross Lawley [ 07/Aug/17 ] |
|
Hi mgyongyosi, Thanks for the ticket, as you mention the GridFSCodec is expecting a document BSON type for the metadata field and not a NULL type. This follows the specification and expected format for the GridFS convention. I'd be interested to learn, how you have come to have an alternative BSON type (null) in the metadata field? Ross |