Skip to content
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

Improve split cookie crumbs test in H2ToStH1UtilsTest #1748

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

We used ConstantHashCharSequence to make sure that two headers fall
into the same bucket in internal HttpHeaders data structure. However,
the hashCode() is taken only if CharSequence implements
AsciiBuffer or AsciiString. Otherwise, a static utility is used
to compute case-insensitive hashCode. As the result,
ConstantHashCharSequence does not provide what we expected.

Modifications:

  • Remove ConstantHashCharSequence and use caseInsensitiveHashCode /
    hashCodeAscii utilities to make sure that two header names result
    in the same bucket based on their hashCode value and ARRAY_SIZE_HINT

Result:

Test verifies the behavior it was created for.

This test was introduced in #1425.

Motivation:

We used `ConstantHashCharSequence` to make sure that two headers fall
into the same bucket in internal `HttpHeaders` data structure. However,
the `hashCode()` is taken only if `CharSequence` implements
`AsciiBuffer` or `AsciiString`. Otherwise, a static utility is used
to compute case-insensitive `hashCode`. As the result,
`ConstantHashCharSequence` does not provide what we expected.

Modifications:

- Remove `ConstantHashCharSequence` and use `caseInsensitiveHashCode` /
`hashCodeAscii` utilities to make sure that two header names result
in the same bucket based on their `hashCode` value and `ARRAY_SIZE_HINT`

Result:

Test verifies the behavior it was created for.
@idelpivnitskiy idelpivnitskiy merged commit dfd5900 into apple:main Aug 26, 2021
@idelpivnitskiy idelpivnitskiy deleted the H2ToStH1UtilsTest branch August 26, 2021 17:31
idelpivnitskiy added a commit that referenced this pull request Sep 24, 2021
Motivation:

We used `ConstantHashCharSequence` to make sure that two headers fall
into the same bucket in internal `HttpHeaders` data structure. However,
the `hashCode()` is taken only if `CharSequence` implements
`AsciiBuffer` or `AsciiString`. Otherwise, a static utility is used
to compute case-insensitive `hashCode`. As the result,
`ConstantHashCharSequence` does not provide what we expected.

Modifications:

- Remove `ConstantHashCharSequence` and use `caseInsensitiveHashCode` /
`hashCodeAscii` utilities to make sure that two header names result
in the same bucket based on their `hashCode` value and `ARRAY_SIZE_HINT`

Result:

Test verifies the behavior it was created for.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants