In ContentResultMatchersDsl, the functions that accept a Matcher don't allow matchers for supertypes of the checked type. This causes code like

    mockMvc
        .get("/books/{bookId}/blurb", BOOK_ID)
        .andExpect { status { isOk() } }
        .andExpect { content { string(hasLength(145)) } }

to not compile, since hasLength is a Matcher<CharSequence> and string wants a Matcher<String>. The original method does accept a Matcher<? super String>; in this case, changing the string method to accept a Matcher<in String> would also solve this compilation error.

The other functions that accept a matcher (node and source) exhibit the same problem.

Comment From: dmitrysulman

I've opened a PR for fixing this: #34542.