Skip to content

Fix null check in withStringMatcher - #3540

Open
kdomo wants to merge 1 commit into
spring-projects:mainfrom
kdomo:fix-withstringmatcher-null-check
Open

kdomo wants to merge 1 commit into
spring-projects:mainfrom
kdomo:fix-withstringmatcher-null-check

Conversation

@kdomo

@kdomo kdomo commented Sep 10, 2026

Copy link
Copy Markdown

TypedExampleMatcher.withStringMatcher(StringMatcher) asserted the ignoredPaths field instead of its defaultStringMatcher parameter:

public ExampleMatcher withStringMatcher(StringMatcher defaultStringMatcher) {
    Assert.notNull(ignoredPaths, "DefaultStringMatcher must not be empty");
    ...
}

ignoredPaths is always set, so the assertion always passed and a null defaultStringMatcher was accepted and stored, only to fail later. This asserts the parameter instead, matching the message and the sibling withIgnorePaths(String...) method, and adds a test covering the null argument.

Closes #3539

ExampleMatcher.withStringMatcher(StringMatcher) asserted the
ignoredPaths field rather than its defaultStringMatcher parameter.
The field is always set, so the assertion always passed and a null
defaultStringMatcher was not rejected, letting it be stored and fail
later. Assert the parameter instead, as the message already implies,
and add a test covering the null argument.

Closes spring-projects#3539

Signed-off-by: kdomo <dongho5088@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withStringMatcher asserts the wrong reference

2 participants