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)) {