[JAVA-3212] Inconsistent output between java driver and mongo shell Created: 22/Feb/19  Updated: 27/Oct/23  Resolved: 25/Feb/19

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

Type: Bug Priority: Major - P3
Reporter: Varun Agrawal Assignee: Jeffrey Yemin
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-39827 Remove \x02 Binary (Old) support from... Closed

 Description   

Mongo Shell version: 4.x

https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/BsonBinaryReader.java#L139-L145

 

I have noticed this code is causing conflicts with binData from mongoshell.

 

To test the issue, just create a simple document

{"A":  "bin2" : BinData(2, "aGVsbG8="),}

//hello

Java driver fails to process it.



 Comments   
Comment by Danny Hatcher (Inactive) [ 25/Feb/19 ]

I created SERVER-39827 for the above question.

Comment by Varun Agrawal [ 25/Feb/19 ]

@Jeff Thank you. Please do let me know if you hear something from server team

Comment by Jeffrey Yemin [ 25/Feb/19 ]

Hi varun@varunagw.com,

 

The driver is following the BSON specification, which states this about BSON binary subtype 2:

\x02 Binary (Old) - This used to be the default subtype, but was deprecated in favor of \x00. Drivers and tools should be sure to handle \x02 appropriately. The structure of the binary data (the byte* array in the binary non-terminal) must be an int32 followed by a (byte*). The int32 is the number of bytes in the repetition.

All drivers treat it as a decoding error if the data does not conform to that specification. See the drivers specification tests here.

As a workaround, please avoid using BSON binary subtype 2.

I will ask the server team follow up on this to see if this should be treated as a shell issue, or whether this is expected behavior.

 

 

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