Repository navigation
OPENNLP-1955: Reject surrogate separators in StringUtil.split and check it against String.split - #1305
Merged
Conversation
….split in the test, single scan in the report listener A surrogate char as separator would let the character scan split a supplementary code point between its two chars, where String.split with the same one-char pattern matches code points and keeps the pair intact. Both overloads now throw IllegalArgumentException for a surrogate separator, with the Javadoc stating the rule, and four pinning tests cover the high and low surrogate bounds. StringUtilSplitTest adds a seeded differential test: 20,000 random inputs built from separators, ASCII and supplementary code points, 12 separators including the metacharacters hash, dollar, dot and pipe, and limits 0, 1, 2, 3, 5, 7 and -1, each compared with String.split on the quoted separator for both overloads. FineGrainedReportListener finds the category dash with one indexOf per label instead of contains followed by indexOf, at the six sites the earlier commit changed. opennlp-api: 426 tests, opennlp-cli: 38 tests, checkstyle clean. (cherry picked from commit bececbfd9aae87cc1fb3a5d47efa45da3cc57348)
krickert
force-pushed
the
OPENNLP-1955-split-followup
branch
from
September 16, 2026 06:09
219750b to
39c1c07
Compare
rzo1
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #1302, based on main. The review of that PR landed after the merge, so its one commit is here.
StringUtil.split: a surrogate char as separator let the char scan split a supplementary code point between its two chars, whileString.splitwith the same one-char pattern matches code points and keeps the pair intact. Both overloads now throwIllegalArgumentExceptionfor a surrogate separator. Javadoc and@throwssay so, and four tests cover the high and low surrogate bounds.StringUtilSplitTest: a seeded differential test compares both overloads withString.spliton the quoted separator over 20,000 random inputs built from 12 separators (including# $ . |), ASCII and supplementary code points, and the limits 0, 1, 2, 3, 5, 7 and -1. The equivalence claim of OPENNLP-1955: Replace literal String.split calls with a regex-free StringUtil.split #1302 is now checked in CI rather than in a commit message.FineGrainedReportListener: the six category sites didcontains("-")and thenindexOf('-'), two scans per label inside comparators. OneindexOfeach now.opennlp-api 426 and opennlp-cli 38 tests with checkstyle and forbiddenapis,
-Dopennlp.forkCount=1. No manual change and no eval build: the parsers produce the same fields.OPENNLP-1955