Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c839ebb

Browse files
committed
Merge branch '2.6.x' into 2.7.x
Closes spring-projectsgh-29261
2 parents 3e6c8bc + 8e583f6 commit c839ebb

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

‎spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -41,10 +41,7 @@ class IncludeExcludeGroupMemberPredicate implements Predicate<String> {
4141

4242
@Override
4343
public boolean test(String name) {
44-
return testCleanName(clean(name));
45-
}
46-
47-
private boolean testCleanName(String name) {
44+
name = clean(name);
4845
return isIncluded(name) && !isExcluded(name);
4946
}
5047

@@ -64,7 +61,18 @@ private boolean isIncludedName(String name) {
6461
}
6562

6663
private boolean isExcluded(String name) {
67-
return this.exclude.contains("*") || this.exclude.contains(name);
64+
return this.exclude.contains("*") || isExcludedName(name);
65+
}
66+
67+
private boolean isExcludedName(String name) {
68+
if (this.exclude.contains(name)) {
69+
return true;
70+
}
71+
if (name.contains("/")) {
72+
String parent = name.substring(0, name.lastIndexOf("/"));
73+
return isExcludedName(parent);
74+
}
75+
return false;
6876
}
6977

7078
private Set<String> clean(Set<String> names) {

‎spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -112,6 +112,12 @@ void specifiedIncludeShouldNotIncludeExcludedNested() {
112112
assertThat(predicate).accepts("test/a").rejects("test/b").rejects("foo");
113113
}
114114

115+
@Test // gh-29251
116+
void specifiedExcludeShouldExcludeNestedChildren() {
117+
Predicate<String> predicate = include("*").exclude("test");
118+
assertThat(predicate).rejects("test").rejects("test/a").rejects("test/a").accepts("other");
119+
}
120+
115121
private Builder include(String... include) {
116122
return new Builder(include);
117123
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /