Skip to content

ByteQuadsCanonicalizer.addName(String, int, int) has incorrect handling for case of q2 == null #687

@cowtowncoder

Description

@cowtowncoder

Up to Jackson 2.12.2, SymbolTable has:

    public String addName(String name, int q1, int q2) {
        _verifySharing();
        if (_intern) {
            name = InternCache.instance.intern(name);
        }
        int hash = (q2 == 0) ? calcHash(q1) : calcHash(q1, q2);
        ...
}

in which special handling is used if second "quad" is all zeroes. Presumable at some point calls were expected to be made with just q1 defined, q2 empty; and assumption probably being that this should for some reason also be supported just as an alias.

But it seems that doing this can be problematic if names (ids) with zero bytes are allowed: whether they are or not is debatable, but binary format like CBOR and Smile can technically encode such sequences. If so, there's a mismatch between "findName()" and "addName()" methods.

There also does not seem to be any good reason to have this check; plus removing it is a (small, granted) performance improvement.

So let's remove it from 2.13.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions