[Java] Match implicitHeadersRegex case insensitively
fix #25475
HTTP header names are case insensitive, but implicitHeadersRegex was matched with String.matches. A regex written as X-Request-Id did not skip a header declared as x-request-id in the spec.
The regex is now compiled once with Pattern.CASE_INSENSITIVE when the option is set, and shouldBeImplicitHeader reuses it. The field and its setter stay public API compatible. The option description now says the match is case insensitive, and the generator docs are regenerated.
Tests:
SpringCodegenTest.implicitHeadersRegexMatchesHeaderNamesCaseInsensitively_issue25475:API_KEYskips the petstoreapi_keyheader indeletePet. Fails without the fix.SpringCodegenTest.implicitHeadersRegexKeepsHeadersItDoesNotMatch: a regex that does not match keeps the header.SpringCodegenTest,JavaClientCodegenTest,AbstractJavaCodegenTestand the JAX-RS codegen tests pass (1065 tests).- Regenerated the 19 sample configs that set
implicitHeadersRegex. Their regexes are already lower case, so no sample changes.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Built the CLI, regenerated the samples whose configs use./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exitimplicitHeadersRegex(no changes) and exported the generator docs (committed). - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Java technical committee: @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg @KannaKim
cc @borsch, who added implicitHeadersRegex in #11819
Summary by cubic
Fixes #25475 so implicitHeadersRegex matches header names case insensitively, matching HTTP header semantics. A regex like X-Request-Id now skips a header declared as x-request-id.
- Compiles the regex once with
Pattern.CASE_INSENSITIVEwhen set, caching it and recompiling it when the field changes so subclasses that write the protected field directly are still honored; the setter stays public API compatible. - Updates the option description and regenerated generator docs.
- Adds tests covering case-insensitive matches and headers that don't match.