Skip to content

Commit 55f67c9

Browse files
committed
Fix potential null problem in actuator
1 parent 167c8ca commit 55f67c9

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -217,11 +217,18 @@ private ServerWebExchangeMatcher createDelegate(PathMappedEndpoints pathMappedEn
217217
if (this.includeLinks && StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
218218
delegateMatchers.add(new LinksServerWebExchangeMatcher());
219219
}
220+
if (delegateMatchers.isEmpty()) {
221+
return EMPTY_MATCHER;
222+
}
220223
return new OrServerWebExchangeMatcher(delegateMatchers);
221224
}
222225

223226
private Stream<String> streamPaths(List<Object> source, PathMappedEndpoints pathMappedEndpoints) {
224-
return source.stream().filter(Objects::nonNull).map(this::getEndpointId).map(pathMappedEndpoints::getPath);
227+
return source.stream()
228+
.filter(Objects::nonNull)
229+
.map(this::getEndpointId)
230+
.map(pathMappedEndpoints::getPath)
231+
.filter(Objects::nonNull);
225232
}
226233

227234
@Override
@@ -234,6 +241,7 @@ private List<ServerWebExchangeMatcher> getDelegateMatchers(Set<String> paths) {
234241
}
235242

236243
private PathPatternParserServerWebExchangeMatcher getDelegateMatcher(String path) {
244+
Assert.notNull(path, "'path' must not be null");
237245
return new PathPatternParserServerWebExchangeMatcher(path + "/**");
238246
}
239247

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -241,11 +241,18 @@ protected RequestMatcher createDelegate(WebApplicationContext context,
241241
if (this.includeLinks && StringUtils.hasText(basePath)) {
242242
delegateMatchers.addAll(getLinksMatchers(requestMatcherFactory, matcherProvider, basePath));
243243
}
244+
if (delegateMatchers.isEmpty()) {
245+
return EMPTY_MATCHER;
246+
}
244247
return new OrRequestMatcher(delegateMatchers);
245248
}
246249

247250
private Stream<String> streamPaths(List<Object> source, PathMappedEndpoints pathMappedEndpoints) {
248-
return source.stream().filter(Objects::nonNull).map(this::getEndpointId).map(pathMappedEndpoints::getPath);
251+
return source.stream()
252+
.filter(Objects::nonNull)
253+
.map(this::getEndpointId)
254+
.map(pathMappedEndpoints::getPath)
255+
.filter(Objects::nonNull);
249256
}
250257

251258
private List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory requestMatcherFactory,
@@ -316,6 +323,7 @@ private static final class RequestMatcherFactory {
316323
RequestMatcher antPath(RequestMatcherProvider matcherProvider, String... parts) {
317324
StringBuilder pattern = new StringBuilder();
318325
for (String part : parts) {
326+
Assert.notNull(part, "'part' must not be null");
319327
pattern.append(part);
320328
}
321329
return matcherProvider.getRequestMatcher(pattern.toString());

0 commit comments

Comments
 (0)