Polish "Add ServerWebExchange a new attribute for PathContainer to avoid repeating parsePath in PathRoutePredicateFactory."
See gh-2884
This commit is contained in:
@@ -174,12 +174,13 @@
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>1.20</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>1.20</version>
|
||||
<scope>provided</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -90,12 +90,9 @@ public class PathRoutePredicateFactory extends AbstractRoutePredicateFactory<Pat
|
||||
return new GatewayPredicate() {
|
||||
@Override
|
||||
public boolean test(ServerWebExchange exchange) {
|
||||
PathContainer path = (PathContainer) exchange.getAttributes()
|
||||
.get(GATEWAY_PREDICATE_PATH_CONTAINER_ATTR);
|
||||
if (path == null) {
|
||||
path = parsePath(exchange.getRequest().getURI().getRawPath());
|
||||
exchange.getAttributes().put(GATEWAY_PREDICATE_PATH_CONTAINER_ATTR, path);
|
||||
}
|
||||
PathContainer path = (PathContainer) exchange.getAttributes().computeIfAbsent(
|
||||
GATEWAY_PREDICATE_PATH_CONTAINER_ATTR,
|
||||
s -> parsePath(exchange.getRequest().getURI().getRawPath()));
|
||||
|
||||
PathPattern match = null;
|
||||
for (int i = 0; i < pathPatterns.size(); i++) {
|
||||
|
||||
@@ -75,4 +75,8 @@ public class PathRoutePredicatePathContainerAttrBenchMarkTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
org.openjdk.jmh.Main.main(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user