Skip to content

Commit

Permalink
fix spring-webflux cast to PathPattern throws ClassCastException
Browse files Browse the repository at this point in the history
  • Loading branch information
wang007 committed Oct 21, 2022
1 parent 7104290 commit 29ce07e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ public static Instrumenter<Object, Void> instrumenter() {

public static HttpRouteGetter<ServerWebExchange> httpRouteGetter() {
return (context, exchange) -> {
PathPattern bestPattern =
exchange.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
return bestPattern == null ? null : bestPattern.getPatternString();
Object bestPatternObj = exchange.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
if (bestPatternObj == null) {
return null;
}
if (bestPatternObj instanceof PathPattern) {
return ((PathPattern) bestPatternObj).getPatternString();
}
return bestPatternObj.toString();
};
}

Expand Down

0 comments on commit 29ce07e

Please sign in to comment.