From f9a14e94be3f146b9fcfe2e6b9812771e0535e79 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Wed, 31 May 2017 21:17:39 -0600 Subject: [PATCH] Fix compatibility issue with spring 5 --- .../handler/predicate/PathRoutePredicateFactory.java | 4 ++-- .../handler/predicate/RemoteAddrRoutePredicateFactory.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactory.java index cc22378f..be0e45e1 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactory.java @@ -24,8 +24,8 @@ import java.util.function.Predicate; import org.springframework.tuple.Tuple; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.patterns.PathPattern; -import org.springframework.web.util.patterns.PathPatternParser; +import org.springframework.web.util.pattern.PathPattern; +import org.springframework.web.util.pattern.PathPatternParser; import static org.springframework.cloud.gateway.handler.support.RoutePredicateFactoryUtils.traceMatch; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE; diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/RemoteAddrRoutePredicateFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/RemoteAddrRoutePredicateFactory.java index aaefed1f..591f8288 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/RemoteAddrRoutePredicateFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/predicate/RemoteAddrRoutePredicateFactory.java @@ -48,9 +48,9 @@ public class RemoteAddrRoutePredicateFactory implements RoutePredicateFactory { } return exchange -> { - Optional remoteAddress = exchange.getRequest().getRemoteAddress(); - if (remoteAddress.isPresent()) { - String hostAddress = remoteAddress.get().getAddress().getHostAddress(); + InetSocketAddress remoteAddress = exchange.getRequest().getRemoteAddress(); + if (remoteAddress != null) { + String hostAddress = remoteAddress.getAddress().getHostAddress(); String host = exchange.getRequest().getURI().getHost(); if (!hostAddress.equals(host)) {