spring-projects / spring-projects/spring-data-commons

withStringMatcher asserts the wrong reference

Open Beginner friendly
#3,539 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.