Skip to content

Commit 78fbd12

Browse files
committed
Merge branch '3.5.x' into 4.0.x
Closes gh-48987
2 parents 6a433fd + fcc327c commit 78fbd12

File tree

1 file changed

+10
-15
lines changed
  • module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure

1 file changed

+10
-15
lines changed

module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Map;
2121
import java.util.Map.Entry;
2222
import java.util.Objects;
23-
import java.util.function.Supplier;
2423

2524
import io.micrometer.core.instrument.Meter;
2625
import io.micrometer.core.instrument.Meter.Id;
@@ -88,12 +87,9 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
8887
return DistributionStatisticConfig.builder()
8988
.percentilesHistogram(lookupWithFallbackToAll(distribution.getPercentilesHistogram(), id, null))
9089
.percentiles(lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
91-
.serviceLevelObjectives(
92-
convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id, null)))
93-
.minimumExpectedValue(
94-
convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id, null)))
95-
.maximumExpectedValue(
96-
convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null)))
90+
.serviceLevelObjectives(convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id)))
91+
.minimumExpectedValue(convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id)))
92+
.maximumExpectedValue(convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id)))
9793
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
9894
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null))
9995
.build()
@@ -117,24 +113,23 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
117113
return (value != null) ? MeterValue.valueOf(value).getValue(meterType) : null;
118114
}
119115

120-
private <T> @Nullable T lookup(Map<String, T> values, Id id, @Nullable T defaultValue) {
116+
private <T> @Nullable T lookup(Map<String, T> values, Id id) {
121117
if (values.isEmpty()) {
122-
return defaultValue;
118+
return null;
123119
}
124-
Supplier<@Nullable T> getDefaultValue = () -> defaultValue;
125-
return doLookup(values, id, getDefaultValue);
120+
return doLookup(values, id);
126121
}
127122

128123
@Contract("_, _, !null -> !null")
129124
private <T> @Nullable T lookupWithFallbackToAll(Map<String, T> values, Id id, @Nullable T defaultValue) {
130125
if (values.isEmpty()) {
131126
return defaultValue;
132127
}
133-
Supplier<@Nullable T> getAllOrDefaultValue = () -> values.getOrDefault("all", defaultValue);
134-
return doLookup(values, id, getAllOrDefaultValue);
128+
@Nullable T result = doLookup(values, id);
129+
return (result != null) ? result : values.getOrDefault("all", defaultValue);
135130
}
136131

137-
private <T> @Nullable T doLookup(Map<String, T> values, Id id, Supplier<@Nullable T> defaultValue) {
132+
private <T> @Nullable T doLookup(Map<String, T> values, Id id) {
138133
String name = id.getName();
139134
while (StringUtils.hasLength(name)) {
140135
T result = values.get(name);
@@ -145,7 +140,7 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
145140
name = (lastDot != -1) ? name.substring(0, lastDot) : "";
146141
}
147142

148-
return defaultValue.get();
143+
return null;
149144
}
150145

151146
}

0 commit comments

Comments
 (0)