diff --git a/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/MetricList.java b/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/MetricList.java index c1570318..bda4482c 100644 --- a/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/MetricList.java +++ b/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/MetricList.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * List of metrics that should receive special treatment (used for blocking or allowing metric names). @@ -171,16 +172,16 @@ public void reload() private List> parseConfig(List lines) { + List> patternCounterPairs = new ArrayList<>(); // Create an empty list to hold pairs of Pattern and Counter - List> patternCounterPairs = lines.stream() - .map(String::trim) - .filter(line -> line.length() > 0 && !line.startsWith("#")) - .map(line -> { - Pattern pattern = Pattern.compile(line); - Counter counter = metricRegistry.counter( MetricRegistry.name( name, "blacklist" ) ); - return Pair.of(pattern, counter); // Create and return the Pair - }) - .collect(Collectors.toList()); + for (int i = 0; i < lines.size(); i++) { + String line = lines.get(i).trim(); + if (!line.isEmpty() && !line.startsWith("#")) { + Pattern pattern = Pattern.compile(line); + Counter counter = metricRegistry.counter( MetricRegistry.name( name, "blacklist-" + (i + 1) ) ); + patternCounterPairs.add(Pair.of(pattern, counter)); // Create and return the Pair + } + } // Reset the counters here if needed for (Pair pair : patternCounterPairs) {