Skip to content

Commit 7b6b91a

Browse files
izeyesnicoll
authored andcommitted
Return null immediately when sla is null in convertSla()
Closes gh-13991
1 parent 16aff4c commit 7b6b91a

File tree

1 file changed

+4
-3
lines changed
  • spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics

1 file changed

+4
-3
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
*/
4040
public class PropertiesMeterFilter implements MeterFilter {
4141

42-
private static final ServiceLevelAgreementBoundary[] EMPTY_SLA = {};
43-
4442
private MetricsProperties properties;
4543

4644
public PropertiesMeterFilter(MetricsProperties properties) {
@@ -67,7 +65,10 @@ public DistributionStatisticConfig configure(Meter.Id id,
6765
}
6866

6967
private long[] convertSla(Meter.Type meterType, ServiceLevelAgreementBoundary[] sla) {
70-
long[] converted = Arrays.stream((sla != null) ? sla : EMPTY_SLA)
68+
if (sla == null) {
69+
return null;
70+
}
71+
long[] converted = Arrays.stream(sla)
7172
.map((candidate) -> candidate.getValue(meterType))
7273
.filter(Objects::nonNull).mapToLong(Long::longValue).toArray();
7374
return (converted.length != 0) ? converted : null;

0 commit comments

Comments
 (0)