Browse Source

Polish contribution

See gh-30971
pull/30980/head
Sam Brannen 3 years ago
parent
commit
f9f7a7cd78
  1. 6
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java
  2. 21
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java

6
spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -514,8 +514,8 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM @@ -514,8 +514,8 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
protected void addInterceptors(InterceptorRegistry registry) {
for (MappedInterceptor interceptor : mappedInterceptors) {
InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor());
if (interceptor.getPathPatterns() != null) {
registration.addPathPatterns(interceptor.getPathPatterns());
if (interceptor.getIncludePathPatterns() != null) {
registration.addPathPatterns(interceptor.getIncludePathPatterns());
}
}
}

21
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -137,18 +137,21 @@ public final class MappedInterceptor implements HandlerInterceptor { @@ -137,18 +137,21 @@ public final class MappedInterceptor implements HandlerInterceptor {
/**
* Return the patterns this interceptor is mapped to.
* Get the include path patterns this interceptor is mapped to.
* @see #getIncludePathPatterns()
* @see #getExcludePathPatterns()
* @deprecated since 6.1 in favor of {@link #getIncludePathPatterns()}
*/
@Nullable
@Deprecated
@Deprecated(since = "6.1", forRemoval = true)
public String[] getPathPatterns() {
return (!ObjectUtils.isEmpty(this.includePatterns) ?
Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
return getIncludePathPatterns();
}
/**
* Return the include path patterns this interceptor is mapped to.
* Get the include path patterns this interceptor is mapped to.
* @since 6.1
* @see #getExcludePathPatterns()
*/
@Nullable
public String[] getIncludePathPatterns() {
@ -158,7 +161,9 @@ public final class MappedInterceptor implements HandlerInterceptor { @@ -158,7 +161,9 @@ public final class MappedInterceptor implements HandlerInterceptor {
}
/**
* Return the exclude path patterns this interceptor is mapped to.
* Get the exclude path patterns this interceptor is mapped to.
* @since 6.1
* @see #getIncludePathPatterns()
*/
@Nullable
public String[] getExcludePathPatterns() {

Loading…
Cancel
Save