Browse Source

Fix delegation in ServerRequest decorators

Closes gh-31955
pull/32231/head
Arjen Poutsma 2 years ago
parent
commit
af44b3e6c0
  1. 80
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java
  2. 47
      spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java

80
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java

@ -19,6 +19,7 @@ package org.springframework.web.reactive.function.server; @@ -19,6 +19,7 @@ package org.springframework.web.reactive.function.server;
import java.net.InetSocketAddress;
import java.net.URI;
import java.security.Principal;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
@ -1086,6 +1087,22 @@ public abstract class RequestPredicates { @@ -1086,6 +1087,22 @@ public abstract class RequestPredicates {
return this.delegate.uriBuilder();
}
@Override
public String path() {
return this.delegate.path();
}
@Override
@Deprecated
public PathContainer pathContainer() {
return this.delegate.pathContainer();
}
@Override
public RequestPath requestPath() {
return this.delegate.requestPath();
}
@Override
public Headers headers() {
return this.delegate.headers();
@ -1141,21 +1158,41 @@ public abstract class RequestPredicates { @@ -1141,21 +1158,41 @@ public abstract class RequestPredicates {
return this.delegate.bodyToFlux(typeReference);
}
@Override
public <T> Mono<T> bind(Class<T> bindType) {
return this.delegate.bind(bindType);
}
@Override
public <T> Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) {
return this.delegate.bind(bindType, dataBinderCustomizer);
}
@Override
public Optional<Object> attribute(String name) {
return this.delegate.attribute(name);
}
@Override
public Map<String, Object> attributes() {
return this.delegate.attributes();
}
@Override
public Optional<String> queryParam(String name) {
return this.delegate.queryParam(name);
}
@Override
public MultiValueMap<String, String> queryParams() {
return this.delegate.queryParams();
}
@Override
public String pathVariable(String name) {
return this.delegate.pathVariable(name);
}
@Override
public Map<String, String> pathVariables() {
return this.delegate.pathVariables();
@ -1186,9 +1223,24 @@ public abstract class RequestPredicates { @@ -1186,9 +1223,24 @@ public abstract class RequestPredicates {
return this.delegate.exchange();
}
@Override
public Mono<ServerResponse> checkNotModified(Instant lastModified) {
return this.delegate.checkNotModified(lastModified);
}
@Override
public Mono<ServerResponse> checkNotModified(String etag) {
return this.delegate.checkNotModified(etag);
}
@Override
public Mono<ServerResponse> checkNotModified(Instant lastModified, String etag) {
return this.delegate.checkNotModified(lastModified, etag);
}
@Override
public String toString() {
return this.delegate.toString();
return String.format("HTTP %s %s", method(), path());
}
}
@ -1204,12 +1256,27 @@ public abstract class RequestPredicates { @@ -1204,12 +1256,27 @@ public abstract class RequestPredicates {
this.attributes = mergeMaps(delegate.attributes(), newAttributes);
}
@Override
public Optional<Object> attribute(String name) {
return Optional.ofNullable(this.attributes.get(name));
}
@Override
public Map<String, Object> attributes() {
return this.attributes;
}
@Override
public String pathVariable(String name) {
Map<String, String> pathVariables = pathVariables();
if (pathVariables.containsKey(name)) {
return pathVariables().get(name);
}
else {
throw new IllegalArgumentException("No path variable with name \"" + name + "\" available");
}
}
@Override
@SuppressWarnings("unchecked")
public Map<String, String> pathVariables() {
@ -1259,5 +1326,16 @@ public abstract class RequestPredicates { @@ -1259,5 +1326,16 @@ public abstract class RequestPredicates {
public RequestPath requestPath() {
return this.requestPath;
}
@Override
public String path() {
return this.requestPath.pathWithinApplication().value();
}
@Override
@Deprecated
public PathContainer pathContainer() {
return this.requestPath;
}
}
}

47
spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java

@ -1090,6 +1090,12 @@ public abstract class RequestPredicates { @@ -1090,6 +1090,12 @@ public abstract class RequestPredicates {
return this.delegate.path();
}
@Override
@Deprecated
public PathContainer pathContainer() {
return this.delegate.pathContainer();
}
@Override
public RequestPath requestPath() {
return this.delegate.requestPath();
@ -1135,11 +1141,21 @@ public abstract class RequestPredicates { @@ -1135,11 +1141,21 @@ public abstract class RequestPredicates {
return this.delegate.bind(bindType, dataBinderCustomizer);
}
@Override
public Optional<Object> attribute(String name) {
return this.delegate.attribute(name);
}
@Override
public Map<String, Object> attributes() {
return this.delegate.attributes();
}
@Override
public Optional<String> param(String name) {
return this.delegate.param(name);
}
@Override
public MultiValueMap<String, String> params() {
return this.delegate.params();
@ -1150,6 +1166,11 @@ public abstract class RequestPredicates { @@ -1150,6 +1166,11 @@ public abstract class RequestPredicates {
return this.delegate.multipartData();
}
@Override
public String pathVariable(String name) {
return this.delegate.pathVariable(name);
}
@Override
public Map<String, String> pathVariables() {
return this.delegate.pathVariables();
@ -1203,12 +1224,27 @@ public abstract class RequestPredicates { @@ -1203,12 +1224,27 @@ public abstract class RequestPredicates {
this.attributes = mergeMaps(delegate.attributes(), newAttributes);
}
@Override
public Optional<Object> attribute(String name) {
return Optional.ofNullable(this.attributes.get(name));
}
@Override
public Map<String, Object> attributes() {
return this.attributes;
}
@Override
public String pathVariable(String name) {
Map<String, String> pathVariables = pathVariables();
if (pathVariables.containsKey(name)) {
return pathVariables().get(name);
}
else {
throw new IllegalArgumentException("No path variable with name \"" + name + "\" available");
}
}
@Override
@SuppressWarnings("unchecked")
public Map<String, String> pathVariables() {
@ -1258,5 +1294,16 @@ public abstract class RequestPredicates { @@ -1258,5 +1294,16 @@ public abstract class RequestPredicates {
public RequestPath requestPath() {
return this.requestPath;
}
@Override
public String path() {
return this.requestPath.pathWithinApplication().value();
}
@Override
@Deprecated
public PathContainer pathContainer() {
return this.requestPath;
}
}
}

Loading…
Cancel
Save