Skip to content

Commit a8467be

Browse files
committed
fix: add null check
Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
1 parent 36935fb commit a8467be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-cloud-gateway-server-webmvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/XForwardedRequestHeadersFilter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ private String toHostHeader(ServerRequest request) {
234234
}
235235

236236
private String stripTrailingSlash(URI uri) {
237-
if (uri.getPath().endsWith("/")) {
238-
return uri.getPath().substring(0, uri.getPath().length() - 1);
237+
String path = uri.getPath();
238+
if (path == null) {
239+
return null;
240+
}
241+
if (path.endsWith("/")) {
242+
return path.substring(0, path.length() - 1);
239243
}
240244
else {
241245
return uri.getPath();

0 commit comments

Comments
 (0)