From c8f263d3ccc6f70879177917c111d700c3e45259 Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Mon, 25 Nov 2024 17:25:01 +0200 Subject: [PATCH] 4.x: Remove unused code from SystemTagsManagerImpl --- .../metrics/api/SystemTagsManagerImpl.java | 84 +------------------ 1 file changed, 1 insertion(+), 83 deletions(-) diff --git a/metrics/api/src/main/java/io/helidon/metrics/api/SystemTagsManagerImpl.java b/metrics/api/src/main/java/io/helidon/metrics/api/SystemTagsManagerImpl.java index a74d4dd3ae2..92f0dc5554a 100644 --- a/metrics/api/src/main/java/io/helidon/metrics/api/SystemTagsManagerImpl.java +++ b/metrics/api/src/main/java/io/helidon/metrics/api/SystemTagsManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,23 +17,17 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.ServiceLoader; import java.util.Set; import java.util.TreeMap; -import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.StreamSupport; -import io.helidon.common.HelidonServiceLoader; -import io.helidon.common.LazyValue; import io.helidon.metrics.spi.MetricsProgrammaticConfig; /** @@ -49,11 +43,6 @@ */ class SystemTagsManagerImpl implements SystemTagsManager { - private static final LazyValue> METRICS_CONFIG_OVERRIDES = - LazyValue.create(() -> - HelidonServiceLoader.create(ServiceLoader.load(MetricsProgrammaticConfig.class)) - .asList()); - private static SystemTagsManagerImpl instance = new SystemTagsManagerImpl(); private static final Collection> ON_CHANGE_SUBSCRIBERS = new ArrayList<>(); @@ -124,22 +113,6 @@ static SystemTagsManagerImpl createWithoutSaving(MetricsConfig metricsConfig) { return new SystemTagsManagerImpl(metricsConfig); } - /** - * Returns an {@link java.lang.Iterable} of the implied type representing the provided scope if scope tagging - * is active: the scope tag name is non-null and non-blank. - * - * @param scopeTagName scope tag name - * @param scope scope value - * @param factory factory method to accept the scope tag and the scope and return an instance of the implied type - * @param type to which the scope tag and scope are converted - * @return iterable of the scope if the scope tag name is non-null and non-blank; an empty iterable otherwise - */ - static Iterable scopeIterable(String scopeTagName, String scope, BiFunction factory) { - return scopeTagName != null && !scopeTagName.isBlank() && scope != null - ? List.of(factory.apply(scopeTagName, scope)) - : List.of(); - } - @Override public Optional scopeTag(Optional candidateScope) { return scopeTagName == null @@ -252,59 +225,4 @@ private Optional scopeFromTags(Iterable tags) { : Optional.empty(); } - static class MultiIterable implements Iterable { - - private final Iterable[] iterables; - - private MultiIterable(Iterable... iterables) { - if (iterables.length == 0) { - throw new IllegalArgumentException("Must provide at least one Iterable"); - } - this.iterables = iterables; - } - - @Override - public Iterator iterator() { - return new Iterator() { - - private int nextIndex = 0; - private Iterator current = nextIterator(); - - @Override - public boolean hasNext() { - if (current.hasNext()) { - return true; - } - - current = nextIterator(); - return current.hasNext(); - } - - @Override - public T next() { - return current.next(); - } - - private Iterator nextIterator() { - while (nextIndex < iterables.length) { - Iterator candidateNextIterator = iterables[nextIndex].iterator(); - if (candidateNextIterator.hasNext()) { - nextIndex++; - return candidateNextIterator; - } - nextIndex++; - } - return Collections.emptyIterator(); - } - }; - } - - @Override - public void forEach(Consumer action) { - for (Iterable it : iterables) { - it.forEach(action); - } - } - } - }