Skip to content

Commit acbf64a

Browse files
ziqinjzheaux
authored andcommitted
Improve And/Or-RequestMatcher/ServerWebExchangeMatcher API
Currently, the List-receiving constructors of AndRequestMatcher, OrRequestMatcher, AndServerWebExchangeMatcher, and OrServerWebExchangeMatcher don't support covariance, which adds obstacles to users of these APIs. For example, one cannot pass a List<PathPatternRequestMatcher> to OrRequestMatcher(List<RequestMatcher>). This commit resolves the aforementioned problem. It should not break existing code. Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
1 parent 46e27aa commit acbf64a

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

web/src/main/java/org/springframework/security/web/server/util/matcher/AndServerWebExchangeMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public class AndServerWebExchangeMatcher implements ServerWebExchangeMatcher {
4242

4343
private static final Log logger = LogFactory.getLog(AndServerWebExchangeMatcher.class);
4444

45-
private final List<ServerWebExchangeMatcher> matchers;
45+
private final List<? extends ServerWebExchangeMatcher> matchers;
4646

47-
public AndServerWebExchangeMatcher(List<ServerWebExchangeMatcher> matchers) {
47+
public AndServerWebExchangeMatcher(List<? extends ServerWebExchangeMatcher> matchers) {
4848
Assert.notEmpty(matchers, "matchers cannot be empty");
4949
this.matchers = matchers;
5050
}

web/src/main/java/org/springframework/security/web/server/util/matcher/OrServerWebExchangeMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public class OrServerWebExchangeMatcher implements ServerWebExchangeMatcher {
4040

4141
private static final Log logger = LogFactory.getLog(OrServerWebExchangeMatcher.class);
4242

43-
private final List<ServerWebExchangeMatcher> matchers;
43+
private final List<? extends ServerWebExchangeMatcher> matchers;
4444

45-
public OrServerWebExchangeMatcher(List<ServerWebExchangeMatcher> matchers) {
45+
public OrServerWebExchangeMatcher(List<? extends ServerWebExchangeMatcher> matchers) {
4646
Assert.notEmpty(matchers, "matchers cannot be empty");
4747
this.matchers = matchers;
4848
}

web/src/main/java/org/springframework/security/web/util/matcher/AndRequestMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
*/
3737
public final class AndRequestMatcher implements RequestMatcher {
3838

39-
private final List<RequestMatcher> requestMatchers;
39+
private final List<? extends RequestMatcher> requestMatchers;
4040

4141
/**
4242
* Creates a new instance
4343
* @param requestMatchers the {@link RequestMatcher} instances to try
4444
*/
45-
public AndRequestMatcher(List<RequestMatcher> requestMatchers) {
45+
public AndRequestMatcher(List<? extends RequestMatcher> requestMatchers) {
4646
Assert.notEmpty(requestMatchers, "requestMatchers must contain a value");
4747
Assert.noNullElements(requestMatchers, "requestMatchers cannot contain null values");
4848
this.requestMatchers = requestMatchers;

web/src/main/java/org/springframework/security/web/util/matcher/OrRequestMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
*/
3535
public final class OrRequestMatcher implements RequestMatcher {
3636

37-
private final List<RequestMatcher> requestMatchers;
37+
private final List<? extends RequestMatcher> requestMatchers;
3838

3939
/**
4040
* Creates a new instance
4141
* @param requestMatchers the {@link RequestMatcher} instances to try
4242
*/
43-
public OrRequestMatcher(List<RequestMatcher> requestMatchers) {
43+
public OrRequestMatcher(List<? extends RequestMatcher> requestMatchers) {
4444
Assert.notEmpty(requestMatchers, "requestMatchers must contain a value");
4545
Assert.noNullElements(requestMatchers, "requestMatchers cannot contain null values");
4646
this.requestMatchers = requestMatchers;

0 commit comments

Comments
 (0)