Removes deprecations.
Fixes gh-698
This commit is contained in:
@@ -37,7 +37,6 @@ import reactor.netty.resources.ConnectionProvider;
|
||||
import reactor.netty.tcp.SslProvider;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
import org.springframework.boot.web.server.WebServerException;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
@@ -539,42 +538,6 @@ public class HttpClientProperties {
|
||||
this.closeNotifyReadTimeout = closeNotifyReadTimeout;
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.handshake-timeout")
|
||||
@Deprecated
|
||||
public long getHandshakeTimeoutMillis() {
|
||||
return getHandshakeTimeout().toMillis();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHandshakeTimeoutMillis(long handshakeTimeoutMillis) {
|
||||
setHandshakeTimeout(Duration.ofMillis(handshakeTimeoutMillis));
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout")
|
||||
@Deprecated
|
||||
public long getCloseNotifyFlushTimeoutMillis() {
|
||||
return getCloseNotifyFlushTimeout().toMillis();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCloseNotifyFlushTimeoutMillis(long closeNotifyFlushTimeoutMillis) {
|
||||
setCloseNotifyFlushTimeout(Duration.ofMillis(closeNotifyFlushTimeoutMillis));
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout")
|
||||
@Deprecated
|
||||
public long getCloseNotifyReadTimeoutMillis() {
|
||||
return getCloseNotifyReadTimeout().toMillis();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCloseNotifyReadTimeoutMillis(long closeNotifyReadTimeoutMillis) {
|
||||
setCloseNotifyFlushTimeout(Duration.ofMillis(closeNotifyReadTimeoutMillis));
|
||||
}
|
||||
|
||||
public SslProvider.DefaultConfigurationType getDefaultConfigurationType() {
|
||||
return defaultConfigurationType;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,8 @@ import java.util.function.Predicate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
|
||||
import org.springframework.cloud.gateway.filter.FilterDefinition;
|
||||
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||
@@ -60,22 +58,6 @@ public class DiscoveryClientRouteDefinitionLocator implements RouteDefinitionLoc
|
||||
|
||||
private Flux<List<ServiceInstance>> serviceInstances;
|
||||
|
||||
/**
|
||||
* Kept for backwards compatibility. You should use the reactive discovery client.
|
||||
* @param discoveryClient the blocking discovery client
|
||||
* @param properties the configuration properties
|
||||
* @deprecated kept for backwards compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public DiscoveryClientRouteDefinitionLocator(DiscoveryClient discoveryClient,
|
||||
DiscoveryLocatorProperties properties) {
|
||||
this(discoveryClient.getClass().getSimpleName(), properties);
|
||||
serviceInstances = Flux
|
||||
.defer(() -> Flux.fromIterable(discoveryClient.getServices()))
|
||||
.map(discoveryClient::getInstances)
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
}
|
||||
|
||||
public DiscoveryClientRouteDefinitionLocator(ReactiveDiscoveryClient discoveryClient,
|
||||
DiscoveryLocatorProperties properties) {
|
||||
this(discoveryClient.getClass().getSimpleName(), properties);
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientAutoConfiguration;
|
||||
import org.springframework.cloud.gateway.config.GatewayAutoConfiguration;
|
||||
@@ -103,22 +102,4 @@ public class GatewayDiscoveryClientAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated In favor of the native reactive service discovery capability.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Deprecated
|
||||
@ConditionalOnProperty(value = "spring.cloud.discovery.reactive.enabled",
|
||||
havingValue = "false")
|
||||
public static class BlockingDiscoveryClientRouteDefinitionLocatorConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.discovery.locator.enabled")
|
||||
public DiscoveryClientRouteDefinitionLocator discoveryClientRouteDefinitionLocator(
|
||||
DiscoveryClient discoveryClient, DiscoveryLocatorProperties properties) {
|
||||
return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,12 +39,6 @@ public class AdaptCachedBodyGlobalFilter
|
||||
|
||||
private ConcurrentMap<String, Boolean> routesToCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Cached request body key.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String CACHED_REQUEST_BODY_KEY = CACHED_REQUEST_BODY_ATTR;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EnableBodyCachingEvent event) {
|
||||
this.routesToCache.putIfAbsent(event.getRouteId(), true);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
@@ -27,8 +26,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.gateway.support.tagsprovider.GatewayHttpTagsProvider;
|
||||
import org.springframework.cloud.gateway.support.tagsprovider.GatewayRouteTagsProvider;
|
||||
import org.springframework.cloud.gateway.support.tagsprovider.GatewayTagsProvider;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
@@ -53,12 +50,6 @@ public class GatewayMetricsFilter implements GlobalFilter, Ordered {
|
||||
.reduce(exchange -> Tags.empty(), GatewayTagsProvider::and);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GatewayMetricsFilter(MeterRegistry meterRegistry) {
|
||||
this(meterRegistry, Arrays.asList(new GatewayHttpTagsProvider(),
|
||||
new GatewayRouteTagsProvider()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
// start the timer as soon as possible and report the metric event before we write
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.event.SmartApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
@@ -70,24 +69,6 @@ public class WeightCalculatorWebFilter
|
||||
|
||||
private Map<String, GroupWeightConfig> groupWeights = new ConcurrentHashMap<>();
|
||||
|
||||
/* for testing */ WeightCalculatorWebFilter() {
|
||||
this.routeLocator = null;
|
||||
this.configurationService = new ConfigurationService();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public WeightCalculatorWebFilter(Validator validator) {
|
||||
this(validator, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public WeightCalculatorWebFilter(Validator validator,
|
||||
ObjectProvider<RouteLocator> routeLocator) {
|
||||
this.routeLocator = routeLocator;
|
||||
this.configurationService = new ConfigurationService();
|
||||
this.configurationService.setValidator(validator);
|
||||
}
|
||||
|
||||
public WeightCalculatorWebFilter(ObjectProvider<RouteLocator> routeLocator,
|
||||
ConfigurationService configurationService) {
|
||||
this.routeLocator = routeLocator;
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.cloud.gateway.support.Configurable;
|
||||
import org.springframework.cloud.gateway.support.HasRouteId;
|
||||
import org.springframework.cloud.gateway.support.NameUtils;
|
||||
import org.springframework.cloud.gateway.support.ShortcutConfigurable;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -78,9 +77,4 @@ public interface GatewayFilterFactory<C> extends ShortcutConfigurable, Configura
|
||||
return NameUtils.normalizeFilterFactoryName(getClass());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default ServerHttpRequest.Builder mutate(ServerHttpRequest request) {
|
||||
return request.mutate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,12 +105,6 @@ public class RequestSizeGatewayFilterFactory extends
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestSizeGatewayFilterFactory.RequestSizeConfig setMaxSize(
|
||||
Long maxSize) {
|
||||
return this.setMaxSize(DataSize.ofBytes(maxSize));
|
||||
}
|
||||
|
||||
public RequestSizeGatewayFilterFactory.RequestSizeConfig setMaxSize(
|
||||
DataSize maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
|
||||
@@ -220,12 +220,6 @@ public class RetryGatewayFilterFactory
|
||||
removeAlreadyRouted(exchange);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GatewayFilter apply(Repeat<ServerWebExchange> repeat,
|
||||
Retry<ServerWebExchange> retry) {
|
||||
return apply(null, repeat, retry);
|
||||
}
|
||||
|
||||
public GatewayFilter apply(String routeId, Repeat<ServerWebExchange> repeat,
|
||||
Retry<ServerWebExchange> retry) {
|
||||
if (routeId != null && getPublisher() != null) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory.rewrite;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
@@ -75,11 +74,6 @@ public class CachedBodyOutputMessage implements ReactiveHttpOutputMessage {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWriteHandler(Function<Flux<DataBuffer>, Mono<Void>> writeHandler) {
|
||||
|
||||
}
|
||||
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
this.body = Flux.from(body);
|
||||
return Mono.empty();
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory.rewrite;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* This class is BETA and may be subject to change in a future release. Response who's job
|
||||
* it is to gather the Publisher<DataBuffer> from the writeWith message during a
|
||||
* call to HttpMessageWriter.write. Also gathers any headers set there.
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpMessageWriterResponse implements ServerHttpResponse {
|
||||
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
private final DataBufferFactory dataBufferFactory;
|
||||
|
||||
private Publisher<? extends DataBuffer> body;
|
||||
|
||||
public HttpMessageWriterResponse(DataBufferFactory dataBufferFactory) {
|
||||
this.dataBufferFactory = dataBufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
this.body = body;
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeAndFlushWith(
|
||||
Publisher<? extends Publisher<? extends DataBuffer>> body) {
|
||||
// TODO: is this kosher?
|
||||
return writeWith(Flux.from(body).flatMapSequential(p -> p));
|
||||
}
|
||||
|
||||
public Publisher<? extends DataBuffer> getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setStatusCode(HttpStatus status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, ResponseCookie> getCookies() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCookie(ResponseCookie cookie) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBufferFactory bufferFactory() {
|
||||
return this.dataBufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(Supplier<? extends Mono<Void>> action) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> setComplete() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.gateway.filter.factory.rewrite;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -29,7 +28,6 @@ import org.springframework.cloud.gateway.support.BodyInserterContext;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
||||
import org.springframework.web.reactive.function.BodyInserter;
|
||||
@@ -59,11 +57,6 @@ public class ModifyRequestBodyGatewayFilterFactory extends
|
||||
this.messageReaders = messageReaders;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ModifyRequestBodyGatewayFilterFactory(ServerCodecConfigurer codecConfigurer) {
|
||||
this(codecConfigurer.getReaders());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public GatewayFilter apply(Config config) {
|
||||
@@ -152,12 +145,6 @@ public class ModifyRequestBodyGatewayFilterFactory extends
|
||||
|
||||
private String contentType;
|
||||
|
||||
@Deprecated
|
||||
private Map<String, Object> inHints;
|
||||
|
||||
@Deprecated
|
||||
private Map<String, Object> outHints;
|
||||
|
||||
private RewriteFunction rewriteFunction;
|
||||
|
||||
public Class getInClass() {
|
||||
@@ -178,28 +165,6 @@ public class ModifyRequestBodyGatewayFilterFactory extends
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<String, Object> getInHints() {
|
||||
return inHints;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Config setInHints(Map<String, Object> inHints) {
|
||||
this.inHints = inHints;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<String, Object> getOutHints() {
|
||||
return outHints;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Config setOutHints(Map<String, Object> outHints) {
|
||||
this.outHints = outHints;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RewriteFunction getRewriteFunction() {
|
||||
return rewriteFunction;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.gateway.filter.factory.rewrite;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -38,19 +37,12 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.client.reactive.ClientHttpResponse;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyInserter;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.server.HandlerStrategies;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static java.util.function.Function.identity;
|
||||
@@ -69,22 +61,6 @@ public class ModifyResponseBodyGatewayFilterFactory extends
|
||||
|
||||
private final List<HttpMessageReader<?>> messageReaders;
|
||||
|
||||
@Deprecated
|
||||
public ModifyResponseBodyGatewayFilterFactory() {
|
||||
super(Config.class);
|
||||
messageReaders = HandlerStrategies.withDefaults().messageReaders();
|
||||
messageBodyDecoders = Collections.emptyMap();
|
||||
messageBodyEncoders = Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ModifyResponseBodyGatewayFilterFactory(ServerCodecConfigurer codecConfigurer) {
|
||||
super(Config.class);
|
||||
this.messageReaders = codecConfigurer.getReaders();
|
||||
messageBodyDecoders = Collections.emptyMap();
|
||||
messageBodyEncoders = Collections.emptyMap();
|
||||
}
|
||||
|
||||
public ModifyResponseBodyGatewayFilterFactory(
|
||||
List<HttpMessageReader<?>> messageReaders,
|
||||
Set<MessageBodyDecoder> messageBodyDecoders,
|
||||
@@ -190,12 +166,6 @@ public class ModifyResponseBodyGatewayFilterFactory extends
|
||||
private GatewayFilterFactory<Config> gatewayFilterFactory;
|
||||
|
||||
public ModifyResponseGatewayFilter(Config config) {
|
||||
this(config, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ModifyResponseGatewayFilter(Config config,
|
||||
@Nullable ServerCodecConfigurer codecConfigurer) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@@ -205,12 +175,6 @@ public class ModifyResponseBodyGatewayFilterFactory extends
|
||||
.response(new ModifiedServerHttpResponse(exchange, config)).build());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
ServerHttpResponse decorate(ServerWebExchange exchange) {
|
||||
return new ModifiedServerHttpResponse(exchange, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return NettyWriteResponseFilter.WRITE_RESPONSE_FILTER_ORDER - 1;
|
||||
@@ -353,50 +317,4 @@ public class ModifyResponseBodyGatewayFilterFactory extends
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ResponseAdapter implements ClientHttpResponse {
|
||||
|
||||
private final Flux<DataBuffer> flux;
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
public ResponseAdapter(Publisher<? extends DataBuffer> body,
|
||||
HttpHeaders headers) {
|
||||
this.headers = headers;
|
||||
if (body instanceof Flux) {
|
||||
flux = (Flux) body;
|
||||
}
|
||||
else {
|
||||
flux = ((Mono) body).flux();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<DataBuffer> getBody() {
|
||||
return flux;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawStatusCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, ResponseCookie> getCookies() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.cloud.gateway.support.AbstractStatefulConfigurable;
|
||||
import org.springframework.cloud.gateway.support.ConfigurationService;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
public abstract class AbstractRateLimiter<C> extends AbstractStatefulConfigurable<C>
|
||||
implements RateLimiter<C>, ApplicationListener<FilterArgsEvent> {
|
||||
@@ -32,15 +31,6 @@ public abstract class AbstractRateLimiter<C> extends AbstractStatefulConfigurabl
|
||||
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Deprecated
|
||||
protected AbstractRateLimiter(Class<C> configClass, String configurationPropertyName,
|
||||
Validator validator) {
|
||||
super(configClass);
|
||||
this.configurationPropertyName = configurationPropertyName;
|
||||
this.configurationService = new ConfigurationService();
|
||||
this.configurationService.setValidator(validator);
|
||||
}
|
||||
|
||||
protected AbstractRateLimiter(Class<C> configClass, String configurationPropertyName,
|
||||
ConfigurationService configurationService) {
|
||||
super(configClass);
|
||||
@@ -52,21 +42,6 @@ public abstract class AbstractRateLimiter<C> extends AbstractStatefulConfigurabl
|
||||
return configurationPropertyName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected Validator getValidator() {
|
||||
if (this.configurationService != null) {
|
||||
return this.configurationService.getValidator();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setValidator(Validator validator) {
|
||||
if (this.configurationService != null) {
|
||||
this.configurationService.setValidator(validator);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setConfigurationService(ConfigurationService configurationService) {
|
||||
this.configurationService = configurationService;
|
||||
}
|
||||
|
||||
@@ -46,22 +46,10 @@ public interface RateLimiter<C> extends StatefulConfigurable<C> {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Response(boolean allowed, long tokensRemaining) {
|
||||
this.allowed = allowed;
|
||||
this.tokensRemaining = tokensRemaining;
|
||||
this.headers = Collections.emptyMap();
|
||||
}
|
||||
|
||||
public boolean isAllowed() {
|
||||
return allowed;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public long getTokensRemaining() {
|
||||
return tokensRemaining;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return Collections.unmodifiableMap(headers);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
|
||||
import org.springframework.data.redis.core.script.RedisScript;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
@@ -56,18 +55,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
public class RedisRateLimiter extends AbstractRateLimiter<RedisRateLimiter.Config>
|
||||
implements ApplicationContextAware {
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Config#replenishRate}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String REPLENISH_RATE_KEY = "replenishRate";
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Config#burstCapacity}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String BURST_CAPACITY_KEY = "burstCapacity";
|
||||
|
||||
/**
|
||||
* Redis Rate Limiter property name.
|
||||
*/
|
||||
@@ -138,15 +125,6 @@ public class RedisRateLimiter extends AbstractRateLimiter<RedisRateLimiter.Confi
|
||||
this.initialized.compareAndSet(false, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RedisRateLimiter(ReactiveStringRedisTemplate redisTemplate,
|
||||
RedisScript<List<Long>> script, Validator validator) {
|
||||
super(Config.class, CONFIGURATION_PROPERTY_NAME, validator);
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.script = script;
|
||||
this.initialized.compareAndSet(false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates an instance with default static configuration, useful in Java DSL.
|
||||
* @param defaultReplenishRate how many tokens per second in token-bucket algorithm.
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.function.Predicate;
|
||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -88,21 +87,6 @@ public class HostRoutePredicateFactory
|
||||
|
||||
private List<String> patterns = new ArrayList<>();
|
||||
|
||||
@Deprecated
|
||||
public String getPattern() {
|
||||
if (!CollectionUtils.isEmpty(this.patterns)) {
|
||||
return patterns.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Config setPattern(String pattern) {
|
||||
this.patterns = new ArrayList<>();
|
||||
this.patterns.add(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,6 @@ import static java.util.Arrays.stream;
|
||||
public class MethodRoutePredicateFactory
|
||||
extends AbstractRoutePredicateFactory<MethodRoutePredicateFactory.Config> {
|
||||
|
||||
/**
|
||||
* Method key.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String METHOD_KEY = "method";
|
||||
|
||||
/**
|
||||
* Methods key.
|
||||
*/
|
||||
@@ -80,19 +74,6 @@ public class MethodRoutePredicateFactory
|
||||
|
||||
private HttpMethod[] methods;
|
||||
|
||||
@Deprecated
|
||||
public HttpMethod getMethod() {
|
||||
if (methods != null && methods.length > 0) {
|
||||
return methods[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMethod(HttpMethod method) {
|
||||
this.methods = new HttpMethod[] { method };
|
||||
}
|
||||
|
||||
public HttpMethod[] getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
@@ -124,21 +123,6 @@ public class PathRoutePredicateFactory
|
||||
|
||||
private boolean matchOptionalTrailingSeparator = true;
|
||||
|
||||
@Deprecated
|
||||
public String getPattern() {
|
||||
if (!CollectionUtils.isEmpty(this.patterns)) {
|
||||
return patterns.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Config setPattern(String pattern) {
|
||||
this.patterns = new ArrayList<>();
|
||||
this.patterns.add(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
@@ -71,9 +71,4 @@ public class CachingRouteDefinitionLocator
|
||||
.doOnNext(routes -> cache.put(CACHE_KEY, routes)).subscribe();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/* for testing */ void handleRefresh() {
|
||||
refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,11 +73,6 @@ public class CachingRouteLocator
|
||||
.doOnNext(routes -> cache.put(CACHE_KEY, routes)).subscribe();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/* for testing */ void handleRefresh() {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
|
||||
@@ -54,13 +54,6 @@ public class Route implements Ordered {
|
||||
|
||||
private final Map<String, Object> metadata;
|
||||
|
||||
@Deprecated
|
||||
private Route(String id, URI uri, int order,
|
||||
AsyncPredicate<ServerWebExchange> predicate,
|
||||
List<GatewayFilter> gatewayFilters) {
|
||||
this(id, uri, order, predicate, gatewayFilters, new HashMap<>());
|
||||
}
|
||||
|
||||
private Route(String id, URI uri, int order,
|
||||
AsyncPredicate<ServerWebExchange> predicate,
|
||||
List<GatewayFilter> gatewayFilters, Map<String, Object> metadata) {
|
||||
|
||||
@@ -26,10 +26,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.config.GatewayProperties;
|
||||
import org.springframework.cloud.gateway.event.FilterArgsEvent;
|
||||
import org.springframework.cloud.gateway.event.PredicateArgsEvent;
|
||||
@@ -42,12 +38,8 @@ import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||
import org.springframework.cloud.gateway.handler.predicate.RoutePredicateFactory;
|
||||
import org.springframework.cloud.gateway.support.ConfigurationService;
|
||||
import org.springframework.cloud.gateway.support.HasRouteId;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
/**
|
||||
@@ -55,8 +47,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class RouteDefinitionRouteLocator
|
||||
implements RouteLocator, BeanFactoryAware, ApplicationEventPublisherAware {
|
||||
public class RouteDefinitionRouteLocator implements RouteLocator {
|
||||
|
||||
/**
|
||||
* Default filters name.
|
||||
@@ -75,20 +66,6 @@ public class RouteDefinitionRouteLocator
|
||||
|
||||
private final GatewayProperties gatewayProperties;
|
||||
|
||||
@Deprecated
|
||||
public RouteDefinitionRouteLocator(RouteDefinitionLocator routeDefinitionLocator,
|
||||
List<RoutePredicateFactory> predicates,
|
||||
List<GatewayFilterFactory> gatewayFilterFactories,
|
||||
GatewayProperties gatewayProperties, ConversionService conversionService) {
|
||||
this.routeDefinitionLocator = routeDefinitionLocator;
|
||||
this.configurationService = new ConfigurationService();
|
||||
this.configurationService.setConversionService(conversionService);
|
||||
initFactories(predicates);
|
||||
gatewayFilterFactories.forEach(
|
||||
factory -> this.gatewayFilterFactories.put(factory.name(), factory));
|
||||
this.gatewayProperties = gatewayProperties;
|
||||
}
|
||||
|
||||
public RouteDefinitionRouteLocator(RouteDefinitionLocator routeDefinitionLocator,
|
||||
List<RoutePredicateFactory> predicates,
|
||||
List<GatewayFilterFactory> gatewayFilterFactories,
|
||||
@@ -102,30 +79,6 @@ public class RouteDefinitionRouteLocator
|
||||
this.gatewayProperties = gatewayProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (this.configurationService.getBeanFactory() == null) {
|
||||
this.configurationService.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Deprecated
|
||||
public void setValidator(Validator validator) {
|
||||
if (this.configurationService.getValidator() == null) {
|
||||
this.configurationService.setValidator(validator);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
|
||||
if (this.configurationService.getPublisher() == null) {
|
||||
this.configurationService.setApplicationEventPublisher(publisher);
|
||||
}
|
||||
}
|
||||
|
||||
private void initFactories(List<RoutePredicateFactory> predicates) {
|
||||
predicates.forEach(factory -> {
|
||||
String key = factory.name();
|
||||
|
||||
@@ -181,21 +181,6 @@ public class PredicateSpec extends UriSpec {
|
||||
.applyAsync(c -> c.setPatterns(Arrays.asList(patterns))));
|
||||
}
|
||||
|
||||
/**
|
||||
* A predicate that checks if the path of the request matches the given pattern
|
||||
* @param pattern the pattern to check the path against. The pattern is a
|
||||
* {@link org.springframework.util.PathMatcher} pattern
|
||||
* @param matchOptionalTrailingSeparator set to false if you do not want this path to
|
||||
* match when there is a trailing <code>/</code>
|
||||
* @return a {@link BooleanSpec} to be used to add logical operators
|
||||
*/
|
||||
@Deprecated
|
||||
public BooleanSpec path(String pattern, boolean matchOptionalTrailingSeparator) {
|
||||
return asyncPredicate(getBean(PathRoutePredicateFactory.class).applyAsync(c -> c
|
||||
.setPatterns(Collections.singletonList(pattern))
|
||||
.setMatchOptionalTrailingSeparator(matchOptionalTrailingSeparator)));
|
||||
}
|
||||
|
||||
/**
|
||||
* A predicate that checks if the path of the request matches the given pattern
|
||||
* @param patterns the pattern to check the path against. The pattern is a
|
||||
|
||||
@@ -54,20 +54,6 @@ public class ConfigurationService implements ApplicationEventPublisherAware {
|
||||
|
||||
private Supplier<Validator> validator;
|
||||
|
||||
@Deprecated
|
||||
public ConfigurationService() {
|
||||
this.conversionService = () -> null;
|
||||
this.validator = () -> null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ConfigurationService(BeanFactory beanFactory,
|
||||
ConversionService conversionService, Validator validator) {
|
||||
this.beanFactory = beanFactory;
|
||||
this.conversionService = () -> conversionService;
|
||||
this.validator = () -> validator;
|
||||
}
|
||||
|
||||
public ConfigurationService(BeanFactory beanFactory,
|
||||
ObjectProvider<ConversionService> conversionService,
|
||||
ObjectProvider<Validator> validator) {
|
||||
@@ -76,6 +62,14 @@ public class ConfigurationService implements ApplicationEventPublisherAware {
|
||||
this.validator = validator::getIfAvailable;
|
||||
}
|
||||
|
||||
public ConfigurationService(BeanFactory beanFactory,
|
||||
Supplier<ConversionService> conversionService,
|
||||
Supplier<Validator> validator) {
|
||||
this.beanFactory = beanFactory;
|
||||
this.conversionService = conversionService;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
public ApplicationEventPublisher getPublisher() {
|
||||
return this.publisher;
|
||||
}
|
||||
@@ -85,33 +79,6 @@ public class ConfigurationService implements ApplicationEventPublisherAware {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public BeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setConversionService(ConversionService conversionService) {
|
||||
this.conversionService = () -> conversionService;
|
||||
}
|
||||
|
||||
public void setParser(SpelExpressionParser parser) {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
public Validator getValidator() {
|
||||
return this.validator.get();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setValidator(Validator validator) {
|
||||
this.validator = () -> validator;
|
||||
}
|
||||
|
||||
public <T, C extends Configurable<T> & ShortcutConfigurable> ConfigurableBuilder<T, C> with(
|
||||
C configurable) {
|
||||
return new ConfigurableBuilder<T, C>(this, configurable);
|
||||
@@ -121,10 +88,9 @@ public class ConfigurationService implements ApplicationEventPublisherAware {
|
||||
return new InstanceBuilder<T>(this, instance);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static <T> T bindOrCreate(Bindable<T> bindable, Map<String, Object> properties,
|
||||
String configurationPropertyName, Validator validator,
|
||||
ConversionService conversionService) {
|
||||
/* for testing */ static <T> T bindOrCreate(Bindable<T> bindable,
|
||||
Map<String, Object> properties, String configurationPropertyName,
|
||||
Validator validator, ConversionService conversionService) {
|
||||
// see ConfigurationPropertiesBinder from spring boot for this definition.
|
||||
BindHandler handler = new IgnoreTopLevelConverterNotFoundBindHandler();
|
||||
|
||||
@@ -139,9 +105,8 @@ public class ConfigurationService implements ApplicationEventPublisherAware {
|
||||
.bindOrCreate(configurationPropertyName, bindable, handler);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getTargetObject(Object candidate) {
|
||||
/* for testing */ static <T> T getTargetObject(Object candidate) {
|
||||
try {
|
||||
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) {
|
||||
return (T) ((Advised) candidate).getTargetSource().getTarget();
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.discovery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.runners.Enclosed;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.config.LoadBalancerProperties;
|
||||
import org.springframework.cloud.gateway.route.RouteDefinition;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(Enclosed.class)
|
||||
public class BlockingGatewayDiscoveryClientAutoConfigurationTests {
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Config.class, properties = {
|
||||
"spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.discovery.reactive.enabled=false",
|
||||
"spring.cloud.gateway.loadbalancer.use404=true",
|
||||
"spring.cloud.discovery.client.simple.instances.service[0].uri=https://service1:443" })
|
||||
public static class EnabledByProperty {
|
||||
|
||||
@Autowired(required = false)
|
||||
private DiscoveryClientRouteDefinitionLocator locator;
|
||||
|
||||
@Autowired(required = false)
|
||||
private LoadBalancerProperties properties;
|
||||
|
||||
@Test
|
||||
public void routeLocatorBeanExists() {
|
||||
assertThat(locator).as("DiscoveryClientRouteDefinitionLocator was null")
|
||||
.isNotNull();
|
||||
List<RouteDefinition> definitions = locator.getRouteDefinitions()
|
||||
.collectList().block();
|
||||
assertThat(definitions).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void use404() {
|
||||
assertThat(properties.isUse404()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Config.class)
|
||||
public static class DisabledByDefault {
|
||||
|
||||
@Autowired(required = false)
|
||||
private DiscoveryClientRouteDefinitionLocator locator;
|
||||
|
||||
@Test
|
||||
public void routeLocatorBeanMissing() {
|
||||
assertThat(locator).as("DiscoveryClientRouteDefinitionLocator exists")
|
||||
.isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration
|
||||
protected static class Config {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.gateway.event.PredicateArgsEvent;
|
||||
import org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.GroupWeightConfig;
|
||||
import org.springframework.cloud.gateway.support.ConfigurationService;
|
||||
import org.springframework.cloud.gateway.support.WeightConfig;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||
@@ -40,7 +41,7 @@ public class WeightCalculatorWebFilterTests {
|
||||
|
||||
@Test
|
||||
public void testWeightCalculation() {
|
||||
WeightCalculatorWebFilter filter = new WeightCalculatorWebFilter();
|
||||
WeightCalculatorWebFilter filter = createFilter();
|
||||
|
||||
String grp1 = "group1";
|
||||
String grp2 = "group2";
|
||||
@@ -59,6 +60,11 @@ public class WeightCalculatorWebFilterTests {
|
||||
asList(0.125, 0.125, 0.25, 0.5), 0.125, 0.25, 0.5);
|
||||
}
|
||||
|
||||
private WeightCalculatorWebFilter createFilter() {
|
||||
return new WeightCalculatorWebFilter(null,
|
||||
new ConfigurationService(null, () -> null, () -> null));
|
||||
}
|
||||
|
||||
private void assertWeightCalculation(WeightCalculatorWebFilter filter, String group,
|
||||
int item, int weight, List<Double> normalized, Double... middleRanges) {
|
||||
String routeId = route(item);
|
||||
@@ -96,7 +102,7 @@ public class WeightCalculatorWebFilterTests {
|
||||
|
||||
@Test
|
||||
public void testChooseRouteWithRandom() {
|
||||
WeightCalculatorWebFilter filter = new WeightCalculatorWebFilter();
|
||||
WeightCalculatorWebFilter filter = createFilter();
|
||||
filter.addWeightConfig(new WeightConfig("groupa", "route1", 1));
|
||||
filter.addWeightConfig(new WeightConfig("groupa", "route2", 3));
|
||||
filter.addWeightConfig(new WeightConfig("groupa", "route3", 6));
|
||||
@@ -144,6 +150,10 @@ public class WeightCalculatorWebFilterTests {
|
||||
|
||||
private WeightConfig weightConfig;
|
||||
|
||||
TestWeightCalculatorWebFilter() {
|
||||
super(null, new ConfigurationService(null, () -> null, () -> null));
|
||||
}
|
||||
|
||||
@Override
|
||||
void addWeightConfig(WeightConfig weightConfig) {
|
||||
this.weightConfig = weightConfig;
|
||||
|
||||
@@ -102,8 +102,8 @@ public class ModifyResponseBodyGatewayFilterFactoryTests extends BaseWebClientTe
|
||||
return Mono.just(modifiedResponse);
|
||||
}))
|
||||
.uri(uri))
|
||||
.route("modify_response_java_test_to_large",
|
||||
r -> r.path("/").and().host("www.modifyresponsebodyjavatoolarge.org")
|
||||
.route("modify_response_java_test_to_large", r -> r.path("/").and()
|
||||
.host("www.modifyresponsebodyjavatoolarge.org")
|
||||
.filters(f -> f.prefixPath("/httpbin").modifyResponseBody(
|
||||
String.class, String.class,
|
||||
(webExchange, originalResponse) -> {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BetweenRoutePredicateFactoryTests {
|
||||
ApplicationConversionService conversionService = new ApplicationConversionService();
|
||||
conversionService.addConverter(new StringToZonedDateTimeConverter());
|
||||
// @formatter:off
|
||||
T config = new ConfigurationService(null, conversionService, null)
|
||||
T config = new ConfigurationService(null, () -> conversionService, () -> null)
|
||||
.with(factory)
|
||||
.name("myname")
|
||||
.normalizedProperties(properties)
|
||||
|
||||
@@ -88,7 +88,7 @@ public class MethodRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void toStringFormatSingleMethod() {
|
||||
Config config = new Config();
|
||||
config.setMethod(HttpMethod.GET);
|
||||
config.setMethods(HttpMethod.GET);
|
||||
Predicate predicate = new MethodRoutePredicateFactory().apply(config);
|
||||
assertThat(predicate.toString()).contains("Methods: [GET]");
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RouteDefinitionRouteLocatorTests {
|
||||
RouteDefinitionRouteLocator routeDefinitionRouteLocator = new RouteDefinitionRouteLocator(
|
||||
new CompositeRouteDefinitionLocator(Flux.just(routeDefinitionLocator)),
|
||||
predicates, gatewayFilterFactories, gatewayProperties,
|
||||
new ConfigurationService());
|
||||
new ConfigurationService(null, () -> null, () -> null));
|
||||
|
||||
StepVerifier.create(routeDefinitionRouteLocator.getRoutes()).assertNext(route -> {
|
||||
List<GatewayFilter> filters = route.getFilters();
|
||||
@@ -105,7 +105,7 @@ public class RouteDefinitionRouteLocatorTests {
|
||||
RouteDefinitionRouteLocator routeDefinitionRouteLocator = new RouteDefinitionRouteLocator(
|
||||
new CompositeRouteDefinitionLocator(Flux.just(routeDefinitionLocator)),
|
||||
predicates, gatewayFilterFactories, gatewayProperties,
|
||||
new ConfigurationService());
|
||||
new ConfigurationService(null, () -> null, () -> null));
|
||||
|
||||
StepVerifier.create(routeDefinitionRouteLocator.getRoutes()).assertNext(route -> {
|
||||
List<GatewayFilter> filters = route.getFilters();
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.gateway.route.builder;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -28,6 +30,7 @@ import org.springframework.cloud.gateway.route.Route;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.server.HandlerStrategies;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -93,7 +96,9 @@ public class GatewayFilterSpecTests {
|
||||
.predicate(exchange -> true);
|
||||
|
||||
when(context.getBean(ModifyResponseBodyGatewayFilterFactory.class))
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory());
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory(
|
||||
HandlerStrategies.withDefaults().messageReaders(),
|
||||
Collections.emptySet(), Collections.emptySet()));
|
||||
|
||||
RouteLocatorBuilder.Builder routes = new RouteLocatorBuilder(context).routes();
|
||||
GatewayFilterSpec spec = new GatewayFilterSpec(routeBuilder, routes);
|
||||
@@ -116,7 +121,9 @@ public class GatewayFilterSpecTests {
|
||||
.predicate(exchange -> true);
|
||||
|
||||
when(context.getBean(ModifyResponseBodyGatewayFilterFactory.class))
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory());
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory(
|
||||
HandlerStrategies.withDefaults().messageReaders(),
|
||||
Collections.emptySet(), Collections.emptySet()));
|
||||
|
||||
RouteLocatorBuilder.Builder routes = new RouteLocatorBuilder(context).routes();
|
||||
GatewayFilterSpec spec = new GatewayFilterSpec(routeBuilder, routes);
|
||||
@@ -139,7 +146,9 @@ public class GatewayFilterSpecTests {
|
||||
.predicate(exchange -> true);
|
||||
|
||||
when(context.getBean(ModifyResponseBodyGatewayFilterFactory.class))
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory());
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory(
|
||||
HandlerStrategies.withDefaults().messageReaders(),
|
||||
Collections.emptySet(), Collections.emptySet()));
|
||||
|
||||
RouteLocatorBuilder.Builder routes = new RouteLocatorBuilder(context).routes();
|
||||
GatewayFilterSpec spec = new GatewayFilterSpec(routeBuilder, routes);
|
||||
@@ -162,7 +171,9 @@ public class GatewayFilterSpecTests {
|
||||
.predicate(exchange -> true);
|
||||
|
||||
when(context.getBean(ModifyResponseBodyGatewayFilterFactory.class))
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory());
|
||||
.thenReturn(new ModifyResponseBodyGatewayFilterFactory(
|
||||
HandlerStrategies.withDefaults().messageReaders(),
|
||||
Collections.emptySet(), Collections.emptySet()));
|
||||
|
||||
RouteLocatorBuilder.Builder routes = new RouteLocatorBuilder(context).routes();
|
||||
GatewayFilterSpec spec = new GatewayFilterSpec(routeBuilder, routes);
|
||||
|
||||
@@ -109,7 +109,6 @@ import static org.junit.Assume.assumeThat;
|
||||
org.springframework.cloud.gateway.actuate.GatewayControllerEndpointTests.class,
|
||||
org.springframework.cloud.gateway.config.GatewayAutoConfigurationTests.class,
|
||||
org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocatorTests.class,
|
||||
org.springframework.cloud.gateway.discovery.BlockingGatewayDiscoveryClientAutoConfigurationTests.class,
|
||||
org.springframework.cloud.gateway.discovery.ReactiveGatewayDiscoveryClientAutoConfigurationTests.class,
|
||||
org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocatorIntegrationTests.class,
|
||||
org.springframework.cloud.gateway.support.ShortcutConfigurableTests.class,
|
||||
@@ -119,7 +118,6 @@ import static org.junit.Assume.assumeThat;
|
||||
org.springframework.cloud.gateway.test.ForwardTests.class,
|
||||
org.springframework.cloud.gateway.test.PostTests.class,
|
||||
org.springframework.cloud.gateway.test.ssl.SingleCertSSLTests.class,
|
||||
org.springframework.cloud.gateway.test.ssl.SSLHandshakeTimeoutDeprecatedTests.class,
|
||||
org.springframework.cloud.gateway.test.ssl.MultiCertSSLTests.class,
|
||||
org.springframework.cloud.gateway.test.ssl.SSLHandshakeTimeoutTests.class,
|
||||
org.springframework.cloud.gateway.test.websocket.WebSocketIntegrationTests.class,
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.gateway.test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
|
||||
import org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocator;
|
||||
import org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -49,7 +49,8 @@ public class GatewayTestApplication {
|
||||
|
||||
@Bean
|
||||
public DiscoveryClientRouteDefinitionLocator discoveryClientRouteLocator(
|
||||
DiscoveryClient discoveryClient, DiscoveryLocatorProperties properties) {
|
||||
ReactiveDiscoveryClient discoveryClient,
|
||||
DiscoveryLocatorProperties properties) {
|
||||
return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.gateway.test;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -29,14 +28,12 @@ import org.springframework.context.annotation.Bean;
|
||||
|
||||
public class RouteConstructionIntegrationTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void routesWithVerificationShouldFail() {
|
||||
exception.expect(Throwable.class);
|
||||
new SpringApplicationBuilder(TestConfig.class).profiles("verification-route")
|
||||
.run();
|
||||
Assert.assertThrows(Throwable.class, () -> {
|
||||
new SpringApplicationBuilder(TestConfig.class).profiles("verification-route")
|
||||
.run();
|
||||
});
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.test.ssl;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.JsonPathAssertions;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
// this test works because it assumes TLS hand shake cannot be done in 1ms. It takes
|
||||
// closer to 80ms
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = { "spring.cloud.gateway.httpclient.ssl.handshake-timeout-millis=1" })
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("ssl")
|
||||
// this is testing that the deprecated handshake-timeout-millis property still works
|
||||
@Deprecated
|
||||
public class SSLHandshakeTimeoutDeprecatedTests extends SingleCertSSLTests {
|
||||
|
||||
@Test
|
||||
@Override // here we validate that it the handshake times out
|
||||
public void testSslTrust() {
|
||||
ResponseSpec responseSpec = testClient.get().uri("/ssltrust").exchange();
|
||||
responseSpec.expectStatus().is5xxServerError();
|
||||
JsonPathAssertions jsonPath = responseSpec.expectBody().jsonPath("message");
|
||||
jsonPath.isEqualTo("handshake timed out");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user