Skip to content

Commit

Permalink
Return null immediately when sla is null in convertSla()
Browse files Browse the repository at this point in the history
Closes gh-13991
  • Loading branch information
izeye authored and snicoll committed Aug 3, 2018
1 parent 16aff4c commit 7b6b91a
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -39,8 +39,6 @@
*/
public class PropertiesMeterFilter implements MeterFilter {

private static final ServiceLevelAgreementBoundary[] EMPTY_SLA = {};

private MetricsProperties properties;

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

private long[] convertSla(Meter.Type meterType, ServiceLevelAgreementBoundary[] sla) {
long[] converted = Arrays.stream((sla != null) ? sla : EMPTY_SLA)
if (sla == null) {
return null;
}
long[] converted = Arrays.stream(sla)
.map((candidate) -> candidate.getValue(meterType))
.filter(Objects::nonNull).mapToLong(Long::longValue).toArray();
return (converted.length != 0) ? converted : null;
Expand Down

0 comments on commit 7b6b91a

Please sign in to comment.