Prevent NPE when using pathExtension predicate

This commit ensures pathExtension predicate is skipped when the value
is null, in order to provide a more predictable behavior, and allow
a better compatibility with collections not supporting null elements
like the ones created by List#of.

Closes gh-32404
This commit is contained in:
Sébastien Deleuze
2024-03-11 18:24:04 +01:00
parent 6767f7010c
commit b1bf8c5242
4 changed files with 44 additions and 2 deletions

View File

@@ -843,7 +843,7 @@ public abstract class RequestPredicates {
@Override
public boolean test(ServerRequest request) {
String pathExtension = UriUtils.extractFileExtension(request.path());
return this.extensionPredicate.test(pathExtension);
return (pathExtension != null && this.extensionPredicate.test(pathExtension));
}
@Override