spring-projects / spring-projects/spring-data-commons
withStringMatcher asserts the wrong reference
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
TypedExampleMatcher.withStringMatcher(StringMatcher) validates the wrong reference:
public ExampleMatcher withStringMatcher(StringMatcher defaultStringMatcher) {
Assert.notNull(ignoredPaths, "DefaultStringMatcher must not be empty");
return new TypedExampleMatcher(nullHandler, defaultStringMatcher, propertySpecifiers, ignoredPaths,
defaultIgnoreCase, mode);
}
It asserts the ignoredPaths field instead of the defaultStringMatcher parameter. ignoredPaths is always set, so the assertion always passes, and a null defaultStringMatcher is accepted and stored, only to fail later. The assertion should guard the parameter, as its message already indicates. The sibling method withIgnorePaths(String...) correctly asserts its own parameter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the TypedExampleMatcher.withStringMatcher(StringMatcher) entry point and compare its validation with the sibling withIgnorePaths(String...) method. Verify that the string matcher parameter, rather than ignoredPaths, is validated, and confirm that null is rejected while valid matchers retain the existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100