You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A matcher that implements only the abstract char[] overload is handed bufferStart == bufferEnd through the CharSequence path. StringSubstitutor searches a TextStringBuilder, so its matcher calls bind to that overload; with a caller-supplied prefix matcher that honours bufferStart, new StringSubstitutor(values).replace("a ${key} b") returns the input unsubstituted.
One argument changed. New StringMatcherTest fails on master with expected: <1> but was: <5> and expected: <a value b> but was: <a ${key} b>.
Verified with the default mvn goal (1894 tests, checkstyle, PMD, SpotBugs, japicmp).
Found by an automated review loop I run; the fix and test were reviewed and verified by me.
Hi @lenamonj
Nice find, thank you. There are two changes I'd like to see:
In testIsMatchOverloadsAgreeOnTheSameWindow(), the second case passes start = 1 with bufferStart = 2, outside the documented contract. The method tests the helper’s defensive behavior rather than required API behavior. A valid window that ends before the complete pattern would be a more useful negative case.
Add a direct call to the two-argument isMatch(CharSequence, int) using the custom matcher. This would explicitly cover the convenience overload that delegates through the corrected method. Explicit expected match lengths would also make the parity assertions easier to interpret.
The negative case is now a valid window that ends before the pattern completes: isMatch("xabz", 1, 0, 2) returns 0 through both overloads. The out-of-contract case is gone.
New testIsMatchCharSequenceStartDelegatesThroughTheCorrectedOverload calls isMatch("xabz", 1) and isMatch("xabz", 2) directly and expects 2 and 0. All parity assertions now state the expected length explicitly.
Against master's StringMatcher all four tests fail (the two-argument call returns 0 where 2 is expected); with the fix the default mvn goal is green, 1895 tests.
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
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.
StringMatcher.isMatch(CharSequence, int, int, int)forwardsbufferEndin thebufferStartslot:A matcher that implements only the abstract
char[]overload is handedbufferStart == bufferEndthrough theCharSequencepath.StringSubstitutorsearches aTextStringBuilder, so its matcher calls bind to that overload; with a caller-supplied prefix matcher that honoursbufferStart,new StringSubstitutor(values).replace("a ${key} b")returns the input unsubstituted.One argument changed. New
StringMatcherTestfails on master withexpected: <1> but was: <5>andexpected: <a value b> but was: <a ${key} b>.Verified with the default
mvngoal (1894 tests, checkstyle, PMD, SpotBugs, japicmp).Found by an automated review loop I run; the fix and test were reviewed and verified by me.