Skip to content

Commit

Permalink
fix spring-webflux cast to PathPattern throws ClassCastException
Browse files Browse the repository at this point in the history
Signed-off-by: wangzhancheng <[email protected]>
  • Loading branch information
wang007 committed Oct 13, 2022
1 parent 7104290 commit 70e9d51
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ public static Instrumenter<Object, Void> instrumenter() {

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

Expand Down

0 comments on commit 70e9d51

Please sign in to comment.