Skip to content

Bug in ParameterBindingJsonReader - visitUUIDConstructor - UUID subtype 04 #3750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arn-cpu opened this issue Jul 26, 2021 · 1 comment
Closed
Assignees
Labels
type: task A general task

Comments

@arn-cpu
Copy link

arn-cpu commented Jul 26, 2021

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 26, 2021
@christophstrobl christophstrobl self-assigned this Dec 13, 2021
@christophstrobl christophstrobl added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 13, 2021
mp911de pushed a commit that referenced this issue Apr 13, 2023
See: #3750
Original pull request: #4334
@mp911de mp911de added this to the 4.1 RC1 (2023.0.0) milestone Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants