Skip to content

Bug in ParameterBindingJsonReader - visitUUIDConstructor - UUID subtype 04 #3750

Closed
@arn-cpu

Description

@arn-cpu

Hi,
there is a bug in private method BsonBinary visitUUIDConstructor(String uuidConstructorName) in ParameterBindingJsonReader class:

private BsonBinary visitUUIDConstructor(String uuidConstructorName) {
        this.verifyToken(JsonTokenType.LEFT_PAREN);
        String hexString = this.readStringFromExtendedJson().replaceAll("\\{", "").replaceAll("}", "").replaceAll("-", "");
        this.verifyToken(JsonTokenType.RIGHT_PAREN);
        byte[] bytes = decodeHex(hexString);
        BsonBinarySubType subType = BsonBinarySubType.UUID_STANDARD;
        if (!"UUID".equals(uuidConstructorName) || !"GUID".equals(uuidConstructorName)) {
            subType = BsonBinarySubType.UUID_LEGACY;
        }

        return new BsonBinary(subType, bytes);
    }

It should be following, because if not UUID and not GUID then use legacy UUID:

if (!"UUID".equals(uuidConstructorName) && !"GUID".equals(uuidConstructorName)) {
            subType = BsonBinarySubType.UUID_LEGACY;
        }

Now when I use UUID I get subtype 03 instead of 04 which I use on database so I can't perform my query correctly.
I am trying to use @query annotation with UUID('id') and I can't get any records, because query is wrongly encoded. I have to make some workaround with mongoTemplate or something else.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions