Skip to content

OrRequestMatcher and AndRequestMatcher should accept List<? extends RequestMatcher> #12751

@chschu

Description

@chschu

Expected Behavior

By allowing construction of an OrRequestMatcher/AndRequestMatcher from a List<? extends RequestMatcher>, the following expressions would compile:

new OrRequestMatcher(Stream.of(new AntPathRequestMatcher("foo")).toList());

Current Behavior

The expression doesn't compile, because Java infers the type List<AntPathRequestMatcher> for the parameter value, and there is no constructor accepting that type.

Context

With complex generic expressions (which are common when using the Java Streams API), explicit type parameters must be used to use the two matchers:

new OrRequestMatcher(Stream.<RequestMatcher>of(new AntPathRequestMatcher("foo")).toList());

This is hard to write and even harder to read in more complex cases.

Metadata

Metadata

Assignees

Labels

in: webAn issue in web modules (web, webmvc)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions