[JAVA-3749] JsonReader#visitUUIDConstructor has a condition that always true Created: 29/May/20  Updated: 28/Oct/23  Resolved: 02/Jun/20

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

Type: Bug Priority: Minor - P4
Reporter: Justin Chu Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux, Java


Issue Links:
Duplicate
is duplicated by JAVA-3799 visitUUIDConstructor always return Bs... Closed
Related
is related to JAVA-3799 visitUUIDConstructor always return Bs... Closed
Backwards Compatibility: Minor Change

 Description   

See https://github.com/mongodb/mongo-java-driver/blob/r4.0.3/bson/src/main/org/bson/json/JsonReader.java#L725

The condition

if (!"UUID".equals(uuidConstructorName) || !"GUID".equals(uuidConstructorName))

would always be true, such that it would always create a BsonBinary with the subtype:

BsonBinarySubType.UUID_LEGACY

when parsing a UUID.



 Comments   
Comment by Jeffrey Yemin [ 03/Jun/20 ]

Since the fix required a minor backwards breaking behavioral change, we don't plan to backport it to a patch release.

Comment by Justin Chu [ 03/Jun/20 ]

Thanks for the update.

May I know if this fix would also backport to the prior versions, such as 3.12?

3.12.5

Thank you.

Comment by Githook User [ 02/Jun/20 ]

Author:

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

Message: Fix JSON parsing of shell-mode UUID constructor

It's quite broken in a number of ways, actually:

  • It produced the wrong binary subtype for UUID/GUID (legacy instead of standard)
  • It partially supported alternate constructors for UUIDs that were proposed
    long ago for the shell but never implemented, but does not actually produced
    the correct byte ordering for CSUUID/CSGUID or JUUID/JGUID

This fix does two things:

  • It produces the correct subtype for the UUID constructor: standard, subtype 4
  • It removes the broken support for all the other constructors that were never
    actually implemented correctly.

JAVA-3749
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/01019c72e4114c735f3b8aff001469f63a93bac7

Comment by Jeffrey Yemin [ 29/May/20 ]

I think the intention was that the conditional be:

        if (!"UUID".equals(uuidConstructorName) && !"GUID".equals(uuidConstructorName)) {

I agree this is a bug.

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