Skip to content

Commit c7b06a8

Browse files
committed
Include the environment's default profiles in the env endpoint's response
Closes spring-projects#39245
1 parent c3b710a commit c7b06a8

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ private EnvironmentDescriptor getEnvironmentDescriptor(Predicate<String> propert
101101
propertyNamePredicate, showUnsanitized));
102102
}
103103
});
104-
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), propertySources);
104+
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()),
105+
Arrays.asList(this.environment.getDefaultProfiles()), propertySources);
105106
}
106107

107108
@ReadOperation
@@ -114,7 +115,7 @@ EnvironmentEntryDescriptor getEnvironmentEntryDescriptor(String propertyName, bo
114115
Map<String, PropertyValueDescriptor> descriptors = getPropertySourceDescriptors(propertyName, showUnsanitized);
115116
PropertySummaryDescriptor summary = getPropertySummaryDescriptor(descriptors);
116117
return new EnvironmentEntryDescriptor(summary, Arrays.asList(this.environment.getActiveProfiles()),
117-
toPropertySourceDescriptors(descriptors));
118+
Arrays.asList(this.environment.getDefaultProfiles()), toPropertySourceDescriptors(descriptors));
118119
}
119120

120121
private List<PropertySourceEntryDescriptor> toPropertySourceDescriptors(
@@ -209,17 +210,25 @@ public static final class EnvironmentDescriptor implements OperationResponseBody
209210

210211
private final List<String> activeProfiles;
211212

213+
private final List<String> defaultProfiles;
214+
212215
private final List<PropertySourceDescriptor> propertySources;
213216

214-
private EnvironmentDescriptor(List<String> activeProfiles, List<PropertySourceDescriptor> propertySources) {
217+
private EnvironmentDescriptor(List<String> activeProfiles, List<String> defaultProfiles,
218+
List<PropertySourceDescriptor> propertySources) {
215219
this.activeProfiles = activeProfiles;
220+
this.defaultProfiles = defaultProfiles;
216221
this.propertySources = propertySources;
217222
}
218223

219224
public List<String> getActiveProfiles() {
220225
return this.activeProfiles;
221226
}
222227

228+
public List<String> getDefaultProfiles() {
229+
return this.defaultProfiles;
230+
}
231+
223232
public List<PropertySourceDescriptor> getPropertySources() {
224233
return this.propertySources;
225234
}
@@ -236,12 +245,15 @@ public static final class EnvironmentEntryDescriptor {
236245

237246
private final List<String> activeProfiles;
238247

248+
private final List<String> defaultProfiles;
249+
239250
private final List<PropertySourceEntryDescriptor> propertySources;
240251

241252
EnvironmentEntryDescriptor(PropertySummaryDescriptor property, List<String> activeProfiles,
242-
List<PropertySourceEntryDescriptor> propertySources) {
253+
List<String> defaultProfiles, List<PropertySourceEntryDescriptor> propertySources) {
243254
this.property = property;
244255
this.activeProfiles = activeProfiles;
256+
this.defaultProfiles = defaultProfiles;
245257
this.propertySources = propertySources;
246258
}
247259

@@ -253,6 +265,10 @@ public List<String> getActiveProfiles() {
253265
return this.activeProfiles;
254266
}
255267

268+
public List<String> getDefaultProfiles() {
269+
return this.defaultProfiles;
270+
}
271+
256272
public List<PropertySourceEntryDescriptor> getPropertySources() {
257273
return this.propertySources;
258274
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointWebExtensionTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ void whenShowValuesIsWhenAuthorizedAndSecurityContextIsNotAuthorized() {
8686

8787
private void verifyPrefixed(SecurityContext securityContext, boolean showUnsanitized) {
8888
given(this.delegate.getEnvironmentEntryDescriptor("test", showUnsanitized))
89-
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList()));
89+
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList(),
90+
Collections.emptyList()));
9091
this.webExtension.environmentEntry(securityContext, "test");
9192
then(this.delegate).should().getEnvironmentEntryDescriptor("test", showUnsanitized);
9293
}

0 commit comments

Comments
 (0)