Fix compatibility issue with spring 5

This commit is contained in:
Spencer Gibb
2017-05-31 21:17:39 -06:00
parent c5f99b0bfd
commit f9a14e94be
2 changed files with 5 additions and 5 deletions

View File

@@ -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;

View File

@@ -48,9 +48,9 @@ public class RemoteAddrRoutePredicateFactory implements RoutePredicateFactory {
}
return exchange -> {
Optional<InetSocketAddress> 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)) {