GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix AsciiString.contains(...) false negatives after a partial match by CCCLL · Pull Request #17975 · netty/netty

Conversation

@CCCLL

@CCCLL CCCLL commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Motivation:

AsciiString.contains(CharSequence, CharSequence) and containsIgnoreCase(CharSequence, CharSequence) compare b with a one character at a time. When a character does not match after a partial match, they continue with the next character of a and start over with the first character of b, so a match that begins inside the partial match is missed: contains("aab", "ab") and contains("ababc", "abc") return false, as does containsIgnoreCase("xxYz", "xyz").

Netty does not call these methods itself, but they are public API and have behaved like this since they were added in 4.1.0.Beta7.

Modification:

Check every start position in a with regionMatchesCharSequences(...) and the same CharEqualityComparator. Add these cases to testContains.

Result:

contains(...) and containsIgnoreCase(...) return true whenever b occurs in a.

Before:

AsciiString.contains("aab", "ab") = false (String.contains: true)
AsciiString.contains("ababc", "abc") = false (String.contains: true)
AsciiString.contains("Mississippi", "issip") = false (String.contains: true)
AsciiString.containsIgnoreCase("xxYz", "xyz") = false

After:

AsciiString.contains("aab", "ab") = true (String.contains: true)
AsciiString.contains("ababc", "abc") = true (String.contains: true)
AsciiString.contains("Mississippi", "issip") = true (String.contains: true)
AsciiString.containsIgnoreCase("xxYz", "xyz") = true

I also compared both methods with String.contains(...) (on ASCII lower-cased input for containsIgnoreCase) for 1,000,000 random pairs over {a, b, A, B}, with a as String, StringBuilder and AsciiString: 9076 and 43016 differences before the change, none after.

The new assertions fail before the change. common tests pass.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@CCCLL
Fix AsciiString.contains(...) false negatives after a partial match
08e1d94
Motivation:

AsciiString.contains(CharSequence, CharSequence) and
containsIgnoreCase(CharSequence, CharSequence) compare b with a one
character at a time. When a character does not match after a partial
match, they continue with the next character of a and start over with
the first character of b, so a match that begins inside the partial
match is missed: contains("aab", "ab") and contains("ababc", "abc")
return false, as does containsIgnoreCase("xxYz", "xyz").

Netty does not call these methods itself, but they are public API and
have behaved like this since they were added in 4.1.0.Beta7.

Modification:

Check every start position in a with regionMatchesCharSequences(...)
and the same CharEqualityComparator. Add these cases to testContains.

Result:

contains(...) and containsIgnoreCase(...) return true whenever b occurs
in a.
@normanmaurer normanmaurer added this to the 4.2.20.Final milestone Oct 21, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Oct 21, 2026
@testlens-app

testlens-app Bot commented Oct 21, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 08e1d94
▶️ Tests: 50518 executed
⚪️ Checks: 30/30 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer merged commit b7f1c9c into netty:4.2 Oct 21, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17985

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 21, 2026
This was referenced Oct 21, 2026
Auto-port 5.0: Fix AsciiString.contains(...) false negatives after a partial match #17985
Merged
Auto-port 4.1: Fix AsciiString.contains(...) false negatives after a partial match #17986
Merged
@netty-project-bot

netty-project-bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17986

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Oct 21, 2026
normanmaurer pushed a commit that referenced this pull request Oct 22, 2026
@netty-project-bot @CCCLL
Auto-port 5.0: Fix AsciiString.contains(...) false negatives after a …
296c3e5
…partial match (#17985)

Auto-port of #17975 to 5.0
Cherry-picked commit: b7f1c9c

---
Motivation:

`AsciiString.contains(CharSequence, CharSequence)` and
`containsIgnoreCase(CharSequence, CharSequence)` compare `b` with `a`
one character at a time. When a character does not match after a partial
match, they continue with the next character of `a` and start over with
the first character of `b`, so a match that begins inside the partial
match is missed: `contains("aab", "ab")` and `contains("ababc", "abc")`
return `false`, as does `containsIgnoreCase("xxYz", "xyz")`.

Netty does not call these methods itself, but they are public API and
have behaved like this since they were added in 4.1.0.Beta7.

Modification:

Check every start position in `a` with `regionMatchesCharSequences(...)`
and the same `CharEqualityComparator`. Add these cases to
`testContains`.

Result:

`contains(...)` and `containsIgnoreCase(...)` return `true` whenever `b`
occurs in `a`.

Co-authored-by: CCCLL <[email protected]>
normanmaurer pushed a commit that referenced this pull request Oct 22, 2026
@netty-project-bot @CCCLL
Auto-port 4.1: Fix AsciiString.contains(...) false negatives after a …
5b54565
…partial match (#17986)

Auto-port of #17975 to 4.1
Cherry-picked commit: b7f1c9c

---
Motivation:

`AsciiString.contains(CharSequence, CharSequence)` and
`containsIgnoreCase(CharSequence, CharSequence)` compare `b` with `a`
one character at a time. When a character does not match after a partial
match, they continue with the next character of `a` and start over with
the first character of `b`, so a match that begins inside the partial
match is missed: `contains("aab", "ab")` and `contains("ababc", "abc")`
return `false`, as does `containsIgnoreCase("xxYz", "xyz")`.

Netty does not call these methods itself, but they are public API and
have behaved like this since they were added in 4.1.0.Beta7.

Modification:

Check every start position in `a` with `regionMatchesCharSequences(...)`
and the same `CharEqualityComparator`. Add these cases to
`testContains`.

Result:

`contains(...)` and `containsIgnoreCase(...)` return `true` whenever `b`
occurs in `a`.


Co-authored-by: CCCLL <[email protected]>
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@netty-project-bot @CCCLL @lltopk
Auto-port 4.1: Fix AsciiString.contains(...) false negatives after a …
d4305a4
…partial match (netty#17986)

Auto-port of netty#17975 to 4.1
Cherry-picked commit: b7f1c9c

---
Motivation:

`AsciiString.contains(CharSequence, CharSequence)` and
`containsIgnoreCase(CharSequence, CharSequence)` compare `b` with `a`
one character at a time. When a character does not match after a partial
match, they continue with the next character of `a` and start over with
the first character of `b`, so a match that begins inside the partial
match is missed: `contains("aab", "ab")` and `contains("ababc", "abc")`
return `false`, as does `containsIgnoreCase("xxYz", "xyz")`.

Netty does not call these methods itself, but they are public API and
have behaved like this since they were added in 4.1.0.Beta7.

Modification:

Check every start position in `a` with `regionMatchesCharSequences(...)`
and the same `CharEqualityComparator`. Add these cases to
`testContains`.

Result:

`contains(...)` and `containsIgnoreCase(...)` return `true` whenever `b`
occurs in `a`.


Co-authored-by: CCCLL <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.20.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@CCCLL @netty-project-bot @normanmaurer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.